moritzgloeckl / origami

Origami External Signature Fork - allows signing of PDFs with external providers
GNU Lesser General Public License v3.0
1 stars 2 forks source link

External Signature Discussion #1

Open moritzgloeckl opened 6 years ago

moritzgloeckl commented 6 years ago

Discussion Thread

moritzgloeckl commented 6 years ago

Regarding PAdES, I'm not entirely sure, but I think it's more or less the same as the PKCS#7 signature, except that the /SubFilter is ETSI.CAdES.detached instead of adbe.pkcs7.detached.

The other type of detached signatures (ETSI.CAdES.detached) are constructed similarly to the adbe.pkcs7.detached containers. The differences between them mostly are the profiling of additional attributes of the container. (https://stackoverflow.com/questions/26468316/itext-detached-signature-means)

ekzobrain commented 6 years ago

Yes, generally it is the same PKCS#7 container with additional attributes inside. But there are several subtypes with different attributes, so it can't be implemented with just one line of code. First of all we should find which subtypes are supported (recommended) by PDF, I think it may be inside PDF specs. If you want to see an example of such signature in PDF - you can try to create it with this software: https://www.kryptokoder.com/home.html and then analyze PCCS#7 container and see which additional attributes are inside.

ekzobrain commented 6 years ago

The list of PAdES profiles (subtypes) is listed here: https://en.wikipedia.org/wiki/PAdES

moritzgloeckl commented 6 years ago

I've created a PAdES signed document with an external provider, this is how it looks (relevant parts):

/FT /Sig
/F 132
/T (PrimeSign Signatur1)
/Type /Annot
/Subtype /Widget
/V 15 0 R
/P 1 0 R
/Rect [0.0 0.0 0.0 0.0]
/AP <<
/N 16 0 R
>>
/TU (PrimeSign Signatur1)
>>
endobj
15 0 obj
<<
/Type /Sig
/Filter /Adobe.PPKLite
/SubFilter /ETSI.CAdES.detached
/Name <Test Person>
/M (D:20180203142718+01'00')
/Reason (Signaturpruefung unter: https://www.signaturpruefung.gv.at)
/Contents <signature here>
/ByteRange [0 8238 16432 490]

So really the only difference I can see is ETSI.CAdES.detached. Maybe you can check as well? I don't understand why they released their own format when it's more or less the same as PKCS#7... I've also checked the specification 1 to 6 that is linked at your Wikipedia link, but I can't see the difference.

ekzobrain commented 6 years ago

May you send that signed document to me to analyze? Or is it private?

The main idea of AdES (Advanced Electronic signature) is that it contains additional validation attributes and (in LT profile) the whole certificate chain, so that a signature may be correctly validated even many years later, after signature certificate expiration, or even after CA that issued a certificate has already closed.

As I see here http://www.etsi.org/deliver/etsi_ts%5C102700_102799%5C10277804%5C01.01.02_60%5Cts_10277804v010102p.pdf it is not enough to just insert some externally created signature content into the document for PaDES, it requires adding some additional TimeStamp structures to the document, so it may not be so easy to implement signing and especially validation of this signature type.

moritzgloeckl commented 6 years ago

Hey, I've added two new PDFs with my last commit ecfa75a01a2d23e9dd423ff7962e6007e7baeda0. There are two PDFs one is PAdES signed and the other one is the unsigned. Please note however that the signed one includes a visible signature as well (a table).

You can check the Signature here, it checks for S (Signature) and C (Certificate). The Signature should be green, but the Certificate is Red because it's a self-signed testing certificate. I've signed the PDF with an external provider and they show up as PAdES (not saying that the external provider implemented PAdES correctly).

ekzobrain commented 5 years ago

Hi, @moritzgloeckl. Do you still work on this? I currently returned back to this topic and need an implementation of multiple PKCS7 signatures at least, and may be multiple PAdES signatures...

moritzgloeckl commented 5 years ago

Hi @netcitylife, I still work on this more or less, but I'm pretty happy with how it is now. I never tried multiple signatures before, so I can probably only give you limited advice on that. But the PDF specification is a good start and should teach you would you need to know. I think it's pretty similar to what we already have. I never followed up on the PAdES maybe there is more info available on that now? I never really understood the difference...