/// <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); }
public Document SignDocument(Document document, SignatureParameters parameters, DigestSigner signer) { return(SignDocumentInternal(document, parameters, signer)); }
protected abstract Document SignDocumentInternal(Document document, SignatureParameters parameters, DigestSigner signer);
public ExternalDigestSigner(DigestSigner signer, SignatureParameters parameters) { m_stream = new MemoryStream(); this.signer = signer; m_digestAlgorithm = parameters.DigestAlgorithm; }