/// <summary> /// Computes an attribute containing a time-stamp token of the provided data, from the provided TSA using the /// provided. /// </summary> /// <remarks> /// Computes an attribute containing a time-stamp token of the provided data, from the provided TSA using the /// provided. The hashing is performed by the method using the specified algorithm and a BouncyCastle provider. /// </remarks> /// <param name="signedData"></param> /// <exception cref="System.Exception">System.Exception</exception> protected internal virtual BcCms.Attribute GetTimeStampAttribute(DerObjectIdentifier oid , ITspSource tsa, AlgorithmIdentifier digestAlgorithm, byte[] messageImprint) { try { //jbonilla Hack para obtener el digest del TSA IDigest digest = null; string algorithmName = null; digest = DigestUtilities.GetDigest(DigestAlgorithm.SHA1.GetName()); algorithmName = DigestAlgorithm.SHA1.GetName(); digest.BlockUpdate(messageImprint, 0, messageImprint.Length); byte[] r = new byte[digest.GetDigestSize()]; digest.DoFinal(r, 0); byte[] toTimeStamp = r; TimeStampResponse tsresp = tsa.GetTimeStampResponse(DigestAlgorithm.GetByName(algorithmName) , toTimeStamp); TimeStampToken tstoken = tsresp.TimeStampToken; if (tstoken == null) { throw new ArgumentNullException("The TimeStampToken returned for the signature time stamp was empty." ); } BcCms.Attribute signatureTimeStamp = new BcCms.Attribute(oid, new DerSet(Asn1Object.FromByteArray (tstoken.GetEncoded()))); return(signatureTimeStamp); } catch (IOException e) { throw new RuntimeException(e); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } }
/// <summary> /// Computes an attribute containing a time-stamp token of the provided data, from the provided TSA using the /// provided. /// </summary> /// <remarks> /// Computes an attribute containing a time-stamp token of the provided data, from the provided TSA using the /// provided. The hashing is performed by the method using the specified algorithm and a BouncyCastle provider. /// </remarks> /// <param name="signedData"></param> /// <exception cref="System.Exception">System.Exception</exception> protected internal virtual BcCms.Attribute GetTimeStampAttribute(DerObjectIdentifier oid , ITspSource tsa, AlgorithmIdentifier digestAlgorithm, byte[] messageImprint) { try { //jbonilla Hack para obtener el digest del TSA IDigest digest = null; string algorithmName = null; if (tsa is ITSAClient) { //TODO jbonilla - ¿AlgorithmIdentifier? digest = ((ITSAClient)tsa).GetMessageDigest(); algorithmName = digest.AlgorithmName; } else { digest = DigestUtilities.GetDigest(DigestAlgorithm.SHA1.GetName()); algorithmName = DigestAlgorithm.SHA1.GetName(); } byte[] toTimeStamp = DigestAlgorithms.Digest(digest, messageImprint); TimeStampResponse tsresp = tsa.GetTimeStampResponse(DigestAlgorithm.GetByName(algorithmName) , toTimeStamp); TimeStampToken tstoken = tsresp.TimeStampToken; if (tstoken == null) { throw new ArgumentNullException("The TimeStampToken returned for the signature time stamp was empty." ); } BcCms.Attribute signatureTimeStamp = new BcCms.Attribute(oid, new DerSet(Asn1Object.FromByteArray (tstoken.GetEncoded()))); return(signatureTimeStamp); } catch (IOException e) { throw new RuntimeException(e); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } }
///// <param> ///// the tspSource to set ///// </param> //public ITspSource TspSource { get; set; } ///// <param> ///// the verifier to set ///// </param> //public ICertificateVerifier Verifier { get; set; } //public ISignedDocumentValidator Validator { get; } public CAdESService(ITspSource tspSource, ICertificateVerifier verifier, ISignedDocumentValidator validator) { this.tspSource = tspSource; this.verifier = verifier; this.validator = validator; }
/// <param name="tspSource">the tspSource to set</param> public virtual void SetTspSource(ITspSource tspSource) { this.tspSource = tspSource; }
/// <param name="signatureTsa">the TSA used for the signature-time-stamp attribute</param> public override void SetSignatureTsa(ITspSource signatureTsa) { this.signatureTsa = signatureTsa; }
/// <param name="tspSource">the tspSource to set</param> public virtual void SetTspSource(ITspSource tspSource) { this.tspSource = tspSource; }
/// <param name="signatureTsa">the signatureTsa to set</param> public virtual void SetSignatureTsa(ITspSource signatureTsa) { this.signatureTsa = signatureTsa; }
/// <summary> /// Computes an attribute containing a time-stamp token of the provided data, from the provided TSA using the /// provided. /// </summary> /// <remarks> /// Computes an attribute containing a time-stamp token of the provided data, from the provided TSA using the /// provided. The hashing is performed by the method using the specified algorithm and a BouncyCastle provider. /// </remarks> /// <param name="signedData"></param> /// <exception cref="System.Exception">System.Exception</exception> protected internal virtual BcCms.Attribute GetTimeStampAttribute(DerObjectIdentifier oid , ITspSource tsa, AlgorithmIdentifier digestAlgorithm, byte[] messageImprint) { try { //jbonilla Hack para obtener el digest del TSA IDigest digest = null; string algorithmName = null; if (tsa is ITSAClient) { //TODO jbonilla - ¿AlgorithmIdentifier? digest = ((ITSAClient)tsa).GetMessageDigest(); algorithmName = digest.AlgorithmName; } else { digest = DigestUtilities.GetDigest(DigestAlgorithm.SHA1.GetName()); algorithmName = DigestAlgorithm.SHA1.GetName(); } byte[] toTimeStamp = DigestAlgorithms.Digest(digest, messageImprint); TimeStampResponse tsresp = tsa.GetTimeStampResponse(DigestAlgorithm.GetByName(algorithmName) , toTimeStamp); TimeStampToken tstoken = tsresp.TimeStampToken; if (tstoken == null) { throw new ArgumentNullException("The TimeStampToken returned for the signature time stamp was empty." ); } BcCms.Attribute signatureTimeStamp = new BcCms.Attribute(oid, new DerSet(Asn1Object.FromByteArray (tstoken.GetEncoded()))); return signatureTimeStamp; } catch (IOException e) { throw new RuntimeException(e); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } }
/// <param name="signatureTsa">the TSA used for the signature-time-stamp attribute</param> public override void SetSignatureTsa(ITspSource signatureTsa) { this.signatureTsa = signatureTsa; }
/// <param name="signatureTsa">the signatureTsa to set</param> public virtual void SetSignatureTsa(ITspSource signatureTsa) { this.signatureTsa = signatureTsa; }