Ejemplo n.º 1
0
        private bool CheckDigestedReferences()
        {
            ArrayList references = m_signature.SignedInfo.References;

            for (int i = 0; i < references.Count; ++i)
            {
                Reference digestedReference = (Reference)references[i];

                if (!ReferenceUsesSafeTransformMethods(digestedReference))
                {
                    return(false);
                }

                SignedXmlDebugLog.LogVerifyReference(this, digestedReference);
                byte[] calculatedHash = null;
                try
                {
                    calculatedHash = digestedReference.CalculateHashValue(_containingDocument, m_signature.ReferencedItems);
                }
                catch (CryptoSignedXmlRecursionException)
                {
                    SignedXmlDebugLog.LogSignedXmlRecursionLimit(this, digestedReference);
                    return(false);
                }
                // Compare both hashes
                SignedXmlDebugLog.LogVerifyReferenceHash(this, digestedReference, calculatedHash, digestedReference.DigestValue);

                if (!CryptographicEquals(calculatedHash, digestedReference.DigestValue))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        private bool CheckDigestedReferences()
        {
            ArrayList references = m_signature.SignedInfo.References;

            for (int i = 0; i < references.Count; ++i)
            {
                Reference digestedReference = (Reference)references[i];

                SignedXmlDebugLog.LogVerifyReference(this, digestedReference);
                byte[] calculatedHash = null;
                try {
                    calculatedHash = digestedReference.CalculateHashValue(m_containingDocument, m_signature.ReferencedItems);
                }
                catch (CryptoSignedXmlRecursionException) {
                    SignedXmlDebugLog.LogSignedXmlRecursionLimit(this, digestedReference);
                    return(false);
                }
                // Compare both hashes
                SignedXmlDebugLog.LogVerifyReferenceHash(this, digestedReference, calculatedHash, digestedReference.DigestValue);
                if (calculatedHash.Length != digestedReference.DigestValue.Length)
                {
                    return(false);
                }

                byte[] rgb1 = calculatedHash;
                byte[] rgb2 = digestedReference.DigestValue;
                for (int j = 0; j < rgb1.Length; ++j)
                {
                    if (rgb1[j] != rgb2[j])
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }