Reputation: 85
I am currently using iTextSharp 5 to apply digital signatures to PDFs. I am applying signatures in the detached mode by using the support of BouncyCastle, like this:
public void Sign(PDFDocument doc, SigningKey key)
{
using (PdfReader reader = new PdfReader(doc.Content))
using (MemoryStream memStream = new MemoryStream())
using (PdfStamper stamper = PdfStamper.CreateSignature(reader, memStream, '\0'))
{
PdfSignatureAppearance signature = stamper.SignatureAppearance;
IExternalSignature pks = new PrivateKeySignature(key.ToParameters(), DigestAlgorithms.SHA256);
MakeSignature.SignDetached(signature, pks, key.CertChain, null, null, null, 0, CryptoStandard.CADES);
doc.Content = memStream.ToArray();
}
}
I found out that CryptoStandard
allows me to choose the standard for my digital signature, but the only ones I see are CADES
and CMS
, and I also require support for PADES. Is it possible to do it in iTextSharp?
Upvotes: 0
Views: 2096
Reputation: 95918
First off, you say you require support for PADES but you don't mention which PAdES profile you need.
PAdES originally (in 2009/2010) was specified as an ETSI technical specification (ETSI TS 102 778 parts 1-6) with profiles
Meanwhile (2016) it has been updates as an European Standard (ETSI EN 319 142 parts 1-2) with profiles
(the latter three being re-christianed versions of the old profiles but the baseline profiles being in focus now).
As you found out the iText enumeration CryptoStandard
knows two options CMS
and CADES
.
First of all, CADES
is not for generating arbitrary CAdES signatures but for generating specially profiled CAdES signature containers and embedding them in PDFs as is required for non-CMS-profile PAdES signatures.
Concerning your question, therefore
I also require support for PADES. Is it possible to do it in iTextSharp?
Yes, iText 5.5.x does support simple PAdES profiles. In particular you'll use the CryptoStandard
values for following profiles:
CryptoStandard.CMS
for the profile for CMS digital signatures in PDF;CryptoStandard.CADES
for baseline signatures at level B-B and B-T and for extended ones at levels PAdES-E-BES and PAdES-E-EPES.Upvotes: 1