예제 #1
0
        /// <summary><inheritDoc></inheritDoc></summary>
        /// <exception cref="System.IO.IOException"></exception>
        protected override Document SignDocumentInternal(Document document, SignatureParameters parameters,
                                                         DigestSigner signer)
        {
            if (parameters.SignaturePackaging != SignaturePackaging.ENVELOPING &&
                parameters.SignaturePackaging != SignaturePackaging.DETACHED)
            {
                throw new ArgumentException("Unsupported signature packaging " + parameters.SignaturePackaging);
            }

            ExternalDigestSigner   factory   = new ExternalDigestSigner(signer, parameters);
            CmsSignedDataGenerator generator = CreateCMSSignedDataGenerator(
                factory, parameters, GetSigningProfile(parameters), true, null);

            byte[]                  toBeSigned     = Streams.ReadAll(document.OpenStream());
            var                     content        = new CmsProcessableByteArray(toBeSigned);
            CmsSignedData           data           = generator.Generate(content, parameters.SignaturePackaging != SignaturePackaging.DETACHED);
            Document                signedDocument = new CMSSignedDocument(data);
            CAdESSignatureExtension extension      = GetExtensionProfile(parameters);

            if (extension != null)
            {
                signedDocument = extension.ExtendSignatures(
                    new CMSSignedDocument(data), document, parameters);
            }
            return(signedDocument);
        }
예제 #2
0
 public Document SignDocument(Document document, SignatureParameters parameters, DigestSigner signer)
 {
     return(SignDocumentInternal(document, parameters, signer));
 }
예제 #3
0
 protected abstract Document SignDocumentInternal(Document document, SignatureParameters parameters, DigestSigner signer);
예제 #4
0
 public ExternalDigestSigner(DigestSigner signer, SignatureParameters parameters)
 {
     m_stream          = new MemoryStream();
     this.signer       = signer;
     m_digestAlgorithm = parameters.DigestAlgorithm;
 }