/// <summary>Note: This can only be called after the message has been read.</summary> /// <returns>True, if the message verifies, false otherwise</returns> public bool Verify() { if (!IsIntegrityProtected()) { throw new PgpException("data not integrity protected."); } DigestStream dIn = (DigestStream)encStream; // // make sure we are at the end. // while (encStream.ReadByte() >= 0) { // do nothing } // // process the MDC packet // byte[] lookAhead = truncStream.GetLookAhead(); IDigest hash = dIn.ReadDigest(); hash.BlockUpdate(lookAhead, 0, 2); byte[] digest = DigestUtilities.DoFinal(hash); byte[] streamDigest = new byte[digest.Length]; Array.Copy(lookAhead, 2, streamDigest, 0, streamDigest.Length); return(Arrays.AreEqual(digest, streamDigest)); }
public bool Verify() { if (!IsIntegrityProtected()) { throw new PgpException("data not integrity protected."); } DigestStream digestStream = (DigestStream)encStream; while (encStream.ReadByte() >= 0) { } byte[] lookAhead = truncStream.GetLookAhead(); IDigest digest = digestStream.ReadDigest(); digest.BlockUpdate(lookAhead, 0, 2); byte[] array = DigestUtilities.DoFinal(digest); byte[] array2 = new byte[array.Length]; Array.Copy(lookAhead, 2, array2, 0, array2.Length); return(Arrays.ConstantTimeAreEqual(array, array2)); }