コード例 #1
0
ファイル: SignatureValidator.cs プロジェクト: xgalv/Cryptool2
        public void CanonicalizeSignedInfo(XmlElement SignedInfo)
        {
            Canonicalizator canonicalizator           = new Canonicalizator(this._inputDocument);
            Stream          stream                    = canonicalizator.CanonicalizeNode(SignedInfo);
            StreamReader    canonicalizedStreamReader = new StreamReader(stream);
            string          canonicalizedString       = canonicalizedStreamReader.ReadToEnd();

            this._canonicalizedSignedInfo = canonicalizedString;
            this.ValidateSignature(this._signedXml.Signature, this._signedXml.SignatureValue);
        }
コード例 #2
0
ファイル: SignatureValidator.cs プロジェクト: xgalv/Cryptool2
        public byte[] DigestElement(XmlElement element, string hashAlgorithm, string canonicalizationAlgorithm)
        {
            Canonicalizator canonicalizator = new Canonicalizator(this._inputDocument);
            Stream          canonicalStream = canonicalizator.CanonicalizeNode(element);

            canonicalStream.Position = 0;
            StreamReader canonicalStreamReader = new StreamReader(canonicalStream);
            string       canonString           = canonicalStreamReader.ReadToEnd();
            SHA1CryptoServiceProvider sha1CryptoServiceProvider = new SHA1CryptoServiceProvider();

            canonicalStream.Position = 0;
            byte[] hash = sha1CryptoServiceProvider.ComputeHash(canonicalStream);
            string base64ConvertedHashValue = Convert.ToBase64String(hash);

            return(hash);
        }