3

I need to sign some binary content (scanned documents) with a digital signature compliant with European norms, CAdES - XAdES. One option would be to use this library to do a XAdES signature. Is there a standard way of packaging binary content for inclusion in a XAdES enveloping signature? A developer in a hurry might Base64 encode the whole thing and put it in a pair of tags? Seems a bit savage. Is there an accepted way? What about canonicalization? Can I just turn it off?

3 Answers 3

1

Base64 will add huge overhead so I would suggest one of the following solutions:

  • Sign the PDF but keep the XAdES signature in a separate XML file ("external signature"). The advantage is that the original document is instantly available even without the signature verification software. Which is also a security disadvantage, as people can open the file without verifying its authenticity. YMMV.
  • Rather than embedding PDF inside XAdES, embed XAdES inside PDF, as the format is very well prepared already for digital signatures since ISO 32000 and there's even a dedicated PDF profile for that called PAdES. It's the best solution by all factors as the signature will be validated automatically on document opening and you don't need dedicated software. And usability was always a huge problem in EU electronic signature, as documented in this article.
1
  • 1
    Having been chained in a dark room to implement QES, your article was thrilling reading !
    – bbsimonbb
    Commented May 16, 2017 at 13:59
1

There are three valid signature methods concerning european norms:

  • CAdES
  • PAdES
  • XAdES

PAdES and XAdES refer specifically to a document format, PDF and XML.
PDF files signed with PAdES will remain PDF, and XML signed with XAdES will remain valid XML.

For every other file type, including binary content with no specific format, you should use CAdES. This will wrap your content in a P7M file that you will be able to inspect with P7M signature readers, and you will also be able to extract the original file if needed.

Encoding your content with Base64 and placing into an XML for XAdES signature is jumping through loops to reach your objective (having a signed file), and once you give that signed file to someone they will have no idea on how to interpret it, unless you also add instruction about how you encoded it, defeating the purpose of having a signature standard (as you manipulated your data in a non-standard way).

3
  • Are you aware of any implementations of CAdES, or is this left to the user?
    – bbsimonbb
    Commented May 16, 2017 at 10:13
  • There are multiple libraries, depending on what language you're using. A quick google search should turn up multiple results, with varying degrees of complexity. I personally used BouncyCastle (a free java and c# cryptography library), there are many examples around on how to create a valid CAdES file.
    – BgrWorker
    Commented May 16, 2017 at 12:44
  • 1
    This answer is somehow confusing regarding the XAdES signature. XAdES can also be applied to any kind of data, similar to CAdES. Have a look at blogs.adobe.com/security/91014620_eusig_wp_ue.pdf. Only PAdES is restricted to PDF documents. Correct me if I am wrong. Commented Apr 20, 2018 at 7:16
0

Base64 encoding the binary content was the way to go. The MS-XAdES package is the best, perhaps only, implementation of the European signature norms for dot net. Even with canonicalization, I had to serialize the XML on one line to get the signature to validate. XML, you have to love it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .