SetExternalDigest() public method

public SetExternalDigest ( byte digest, byte RSAdata, String digestEncryptionAlgorithm ) : void
digest byte
RSAdata byte
digestEncryptionAlgorithm String
return void
示例#1
0
 /**
  * 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(CipherParameters 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);
 }
示例#2
0
 /**
 * 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))) {
         if (certChain.Length > 1) {
             PdfArray arr = new PdfArray();
             for (int ii = 0; ii < certChain.Length; ii++) {
                 arr.Add(new PdfString(certChain[ii].GetEncoded()));
             }
             Put(PdfName.CERT, arr);
         }
         else {
             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);
 }