private bool CheckSignedInfo(IMac macAlg) { if (macAlg == null) { throw new ArgumentNullException(nameof(macAlg)); } SignedXmlDebugLog.LogBeginCheckSignedInfo(this, m_signature.SignedInfo); int signatureLength; if (m_signature.SignedInfo.SignatureLength == null) { signatureLength = macAlg.GetMacSize() * 8; } else { signatureLength = Convert.ToInt32(m_signature.SignedInfo.SignatureLength, null); } // signatureLength should be less than hash size if (signatureLength < 0 || signatureLength > macAlg.GetMacSize() * 8) { throw new System.Security.Cryptography.CryptographicException(SR.Cryptography_Xml_InvalidSignatureLength); } if (signatureLength % 8 != 0) { throw new System.Security.Cryptography.CryptographicException(SR.Cryptography_Xml_InvalidSignatureLength2); } if (m_signature.SignatureValue == null) { throw new System.Security.Cryptography.CryptographicException(SR.Cryptography_Xml_SignatureValueRequired); } if (m_signature.SignatureValue.Length != signatureLength / 8) { throw new System.Security.Cryptography.CryptographicException(SR.Cryptography_Xml_InvalidSignatureLength); } // Calculate the hash GetC14NDigest(new MacHashWrapper(macAlg)); byte[] hashValue = new byte[macAlg.GetMacSize()]; macAlg.DoFinal(hashValue, 0); SignedXmlDebugLog.LogVerifySignedInfo(this, macAlg, hashValue, m_signature.SignatureValue); for (int i = 0; i < m_signature.SignatureValue.Length; i++) { if (m_signature.SignatureValue[i] != hashValue[i]) { return(false); } } return(true); }