/// <summary> /// Routes data written to the object into the <see cref="MD4"/> hash algorithm for computing the hash. /// </summary> /// <param name="array">The array of data bytes.</param> /// <param name="ibStart">The offset into the byte array from which to begin using data.</param> /// <param name="cbSize">The number of bytes in the array to use as data.</param> /// <exception cref="ObjectDisposedException">The MD4CryptoServiceProvider instance has been disposed.</exception> /// <exception cref="CryptographicException">The data could not be hashed.</exception> protected override void HashCore(byte[] array, int ibStart, int cbSize) { if (m_Disposed) { throw new ObjectDisposedException(this.GetType().FullName); } byte[] copy = new byte[cbSize]; Array.Copy(array, ibStart, copy, 0, cbSize); if (SspiProvider.CryptHashData(m_Hash, copy, copy.Length, 0) == 0) { throw new CryptographicException("The data could not be hashed."); } }
protected override void HashCore(byte[] array, int ibStart, int cbSize) { if (ibStart > 0) { GCHandle handle = GCHandle.Alloc(array, GCHandleType.Pinned); try { IntPtr address = handle.AddrOfPinnedObject(); if (SspiProvider.CryptHashData(m_Hash, new IntPtr(address.ToInt64() + ibStart), cbSize, 0) == 0) { throw new CryptographicException("The data could not be hashed."); } } finally { handle.Free(); } } else { if (SspiProvider.CryptHashData(m_Hash, array, cbSize, 0) == 0) { throw new CryptographicException("The data could not be hashed."); } } }