Exemplo n.º 1
0
 internal SignedXml(SignedInfo signedInfo, DictionaryManager dictionaryManager, SecurityTokenSerializer tokenSerializer)
 {
     if (signedInfo == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("signedInfo"));
     }
     if (dictionaryManager == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dictionaryManager");
     }
     if (tokenSerializer == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("tokenSerializer");
     }
     this.transformFactory = StandardTransformFactory.Instance;
     this.tokenSerializer = tokenSerializer;
     this.signature = new Signature(this, signedInfo);
     this.dictionaryManager = dictionaryManager;
 }
Exemplo n.º 2
0
 void ComputeSignature(HashAlgorithm hash, AsymmetricSignatureFormatter formatter, string signatureMethod)
 {
     this.Signature.SignedInfo.ComputeReferenceDigests();
     this.Signature.SignedInfo.ComputeHash(hash);
     byte[] signature;
     if (SecurityUtils.RequiresFipsCompliance && signatureMethod == SecurityAlgorithms.RsaSha256Signature)
     {
         // This is to avoid the RSAPKCS1SignatureFormatter.CreateSignature from using SHA256Managed (non-FIPS-Compliant).
         // Hence we precompute the hash using SHA256CSP (FIPS compliant) and pass it to method.
         // NOTE: RSAPKCS1SignatureFormatter does not understand SHA256CSP inherently and hence this workaround. 
         formatter.SetHashAlgorithm("SHA256");
         signature = formatter.CreateSignature(hash.Hash);
     }
     else
     {
         signature = formatter.CreateSignature(hash);
     }
     this.Signature.SetSignatureValue(signature);
 }