void ICanonicalWriterEndRootElementCallback.OnEndOfRootElement(XmlDictionaryWriter dictionaryWriter)
        {
            byte[] digest = this.hashStream.FlushHashAndGetValue();
            PreDigestedSignedInfo signedInfo = new PreDigestedSignedInfo(this.dictionaryManager)
            {
                AddEnvelopedSignatureTransform = true,
                CanonicalizationMethod         = "http://www.w3.org/2001/10/xml-exc-c14n#",
                SignatureMethod = this.signingCredentials.SignatureAlgorithm,
                DigestMethod    = this.signingCredentials.DigestAlgorithm
            };

            signedInfo.AddReference(this.assertionId, digest);
            SignedXml xml = new SignedXml(signedInfo, this.dictionaryManager, this.keyInfoSerializer);

            xml.ComputeSignature(this.signingCredentials.SigningKey);
            xml.Signature.KeyIdentifier = this.signingCredentials.SigningKeyIdentifier;
            xml.WriteTo(dictionaryWriter);
        }
Ejemplo n.º 2
0
        void ICanonicalWriterEndRootElementCallback.OnEndOfRootElement(XmlDictionaryWriter dictionaryWriter)
        {
            byte[] hashValue = this.hashStream.FlushHashAndGetValue();

            PreDigestedSignedInfo signedInfo = new PreDigestedSignedInfo(this.dictionaryManager);

            signedInfo.AddEnvelopedSignatureTransform = true;
            signedInfo.CanonicalizationMethod         = SecurityAlgorithms.ExclusiveC14n;
            signedInfo.SignatureMethod = this.signingCredentials.SignatureAlgorithm;
            signedInfo.DigestMethod    = this.signingCredentials.DigestAlgorithm;
            signedInfo.AddReference(this.assertionId, hashValue);

            SignedXml signedXml = new SignedXml(signedInfo, this.dictionaryManager, this.keyInfoSerializer);

            signedXml.ComputeSignature(this.signingCredentials.SigningKey);
            signedXml.Signature.KeyIdentifier = this.signingCredentials.SigningKeyIdentifier;
            signedXml.WriteTo(dictionaryWriter);
        }