/** * Sets the crypto information to sign. * @param privKey the private key * @param certChain the certificate chain * @param crlList the certificate revocation list. It can be <CODE>null</CODE> */ public void SetSignInfo(ICipherParameters privKey, X509Certificate[] certChain, object[] crlList) { pkcs = new PdfPKCS7(privKey, certChain, crlList, hashAlgorithm, PdfName.ADBE_PKCS7_SHA1.Equals(Get(PdfName.SUBFILTER))); pkcs.SetExternalDigest(externalDigest, externalRSAdata, digestEncryptionAlgorithm); if (PdfName.ADBE_X509_RSA_SHA1.Equals(Get(PdfName.SUBFILTER))) { MemoryStream bout = new MemoryStream(); for (int k = 0; k < certChain.Length; ++k) { byte[] tmp = certChain[k].GetEncoded(); bout.Write(tmp, 0, tmp.Length); } bout.Close(); Cert = bout.ToArray(); Contents = pkcs.GetEncodedPKCS1(); } else { Contents = pkcs.GetEncodedPKCS7(); } name = PdfPKCS7.GetSubjectFields(pkcs.SigningCertificate).GetField("CN"); if (name != null) { Put(PdfName.NAME, new PdfString(name, PdfObject.TEXT_UNICODE)); } pkcs = new PdfPKCS7(privKey, certChain, crlList, hashAlgorithm, PdfName.ADBE_PKCS7_SHA1.Equals(Get(PdfName.SUBFILTER))); pkcs.SetExternalDigest(externalDigest, externalRSAdata, digestEncryptionAlgorithm); }