Esempio n. 1
0
        protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm)
        {
            // we're sealed and the base should have checked this already
            Contract.Assert(data != null);
            Contract.Assert(!String.IsNullOrEmpty(hashAlgorithm.Name));

#if MONO
            var hash = HashAlgorithm.Create(hashAlgorithm.Name);
            return(hash.ComputeHash(data));
#else
            using (SafeHashHandle hashHandle = Utils.CreateHash(Utils.StaticProvHandle, GetAlgorithmId(hashAlgorithm))) {
                // Read the data 4KB at a time, providing similar read characteristics to a standard HashAlgorithm
                byte[] buffer    = new byte[4096];
                int    bytesRead = 0;
                do
                {
                    bytesRead = data.Read(buffer, 0, buffer.Length);
                    if (bytesRead > 0)
                    {
                        Utils.HashData(hashHandle, buffer, 0, bytesRead);
                    }
                } while (bytesRead > 0);

                return(Utils.EndHash(hashHandle));
            }
#endif
        }
 [System.Security.SecuritySafeCritical]  // auto-generated
 public override void Initialize() {
     if (_safeHashHandle != null && !_safeHashHandle.IsClosed)
         _safeHashHandle.Dispose();
     
     // _CreateHash will check for failures and throw the appropriate exception
     _safeHashHandle = Utils.CreateHash(Utils.StaticProvHandle, Constants.CALG_MD5);
 }
 protected override byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm)
 {
     using (SafeHashHandle hash = Utils.CreateHash(Utils.StaticProvHandle, RSACryptoServiceProvider.GetAlgorithmId(hashAlgorithm)))
     {
         Utils.HashData(hash, data, offset, count);
         return(Utils.EndHash(hash));
     }
 }
 public override void Initialize()
 {
     if ((this._safeHashHandle != null) && !this._safeHashHandle.IsClosed)
     {
         this._safeHashHandle.Dispose();
     }
     this._safeHashHandle = Utils.CreateHash(Utils.StaticProvHandle, 0x8003);
 }
 public MD5CryptoServiceProvider()
 {
     if (CryptoConfig.AllowOnlyFipsAlgorithms)
     {
         throw new InvalidOperationException(Environment.GetResourceString("Cryptography_NonCompliantFIPSAlgorithm"));
     }
     this._safeHashHandle = Utils.CreateHash(Utils.StaticProvHandle, 0x8003);
 }
 public override void Initialize()
 {
     if ((this._safeHashHandle != null) && !this._safeHashHandle.IsClosed)
     {
         this._safeHashHandle.Dispose();
     }
     this._safeHashHandle = Utils.CreateHash(Utils.StaticProvHandle, 0x8004);
 }
        [System.Security.SecuritySafeCritical]  // auto-generated
        public MD5CryptoServiceProvider() {
            if (CryptoConfig.AllowOnlyFipsAlgorithms)
                throw new InvalidOperationException(Environment.GetResourceString("Cryptography_NonCompliantFIPSAlgorithm"));
            Contract.EndContractBlock();

            // _CreateHash will check for failures and throw the appropriate exception
            _safeHashHandle = Utils.CreateHash(Utils.StaticProvHandle, Constants.CALG_MD5);
        }
 public MD5CryptoServiceProvider()
 {
     if (CryptoConfig.AllowOnlyFipsAlgorithms)
     {
         throw new InvalidOperationException(Environment.GetResourceString("Cryptography_NonCompliantFIPSAlgorithm"));
     }
     this._safeHashHandle = Utils.CreateHash(Utils.StaticProvHandle, 0x8003);
 }
        [System.Security.SecuritySafeCritical]  // auto-generated
        public override void Initialize()
        {
            if (_safeHashHandle != null && !_safeHashHandle.IsClosed)
            {
                _safeHashHandle.Dispose();
            }

            // _CreateHash will check for failures and throw the appropriate exception
            _safeHashHandle = Utils.CreateHash(Utils.StaticProvHandle, Constants.CALG_MD5);
        }
Esempio n. 10
0
        internal static void HashData(SafeHashHandle hHash, byte[] data, int ibStart, int cbSize)
        {
            SafeHashHandle hHash1 = hHash;

            byte[] data1    = data;
            int    length   = data1.Length;
            int    ibStart1 = ibStart;
            int    cbSize1  = cbSize;

            Utils.HashData(hHash1, data1, length, ibStart1, cbSize1);
        }
Esempio n. 11
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        public MD5CryptoServiceProvider()
        {
            if (CryptoConfig.AllowOnlyFipsAlgorithms)
            {
                throw new InvalidOperationException(Environment.GetResourceString("Cryptography_NonCompliantFIPSAlgorithm"));
            }
            Contract.EndContractBlock();

            // _CreateHash will check for failures and throw the appropriate exception
            _safeHashHandle = Utils.CreateHash(Utils.StaticProvHandle, Constants.CALG_MD5);
        }
Esempio n. 12
0
        protected override byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm)
        {
            // we're sealed and the base should have checked this already
            Contract.Assert(data != null);
            Contract.Assert(offset >= 0 && offset <= data.Length);
            Contract.Assert(count >= 0 && count <= data.Length);
            Contract.Assert(!String.IsNullOrEmpty(hashAlgorithm.Name));

            using (SafeHashHandle hashHandle = Utils.CreateHash(Utils.StaticProvHandle, GetAlgorithmId(hashAlgorithm))) {
                Utils.HashData(hashHandle, data, offset, count);
                return(Utils.EndHash(hashHandle));
            }
        }
        [System.Security.SecuritySafeCritical]  // auto-generated
        public MD5CryptoServiceProvider()
        {
            // .NET Framework 2.0 - 4.7.2 rejected MD5 when in FIPS mode because it was not
            // an approved algorithm.  Since this caused problems for legitimate applications
            // this is no longer done, an application or library needs to determine on its own
            // if MD5 is prohibited in context.
            if (CryptoConfig.AllowOnlyFipsAlgorithms && AppContextSwitches.UseLegacyFipsThrow)
            {
                throw new InvalidOperationException(Environment.GetResourceString("Cryptography_NonCompliantFIPSAlgorithm"));
            }
            Contract.EndContractBlock();

            // _CreateHash will check for failures and throw the appropriate exception
            _safeHashHandle = Utils.CreateHash(Utils.StaticProvHandle, Constants.CALG_MD5);
        }
 protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm)
 {
     using (SafeHashHandle hash = Utils.CreateHash(Utils.StaticProvHandle, RSACryptoServiceProvider.GetAlgorithmId(hashAlgorithm)))
     {
         byte[] numArray = new byte[4096];
         int    cbSize;
         do
         {
             cbSize = data.Read(numArray, 0, numArray.Length);
             if (cbSize > 0)
             {
                 Utils.HashData(hash, numArray, 0, cbSize);
             }
         }while (cbSize > 0);
         return(Utils.EndHash(hash));
     }
 }
 protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm)
 {
     byte[] result;
     using (SafeHashHandle safeHashHandle = Utils.CreateHash(Utils.StaticProvHandle, RSACryptoServiceProvider.GetAlgorithmId(hashAlgorithm)))
     {
         byte[] array = new byte[4096];
         int    num;
         do
         {
             num = data.Read(array, 0, array.Length);
             if (num > 0)
             {
                 Utils.HashData(safeHashHandle, array, 0, num);
             }
         }while (num > 0);
         result = Utils.EndHash(safeHashHandle);
     }
     return(result);
 }
Esempio n. 16
0
 [System.Security.SecuritySafeCritical]  // auto-generated
 public SHA1Managed()
 {
     // _CreateHash will check for failures and throw the appropriate exception
     _safeHashHandle = Utils.CreateHash(Utils.StaticProvHandle, Constants.CALG_SHA1);
 }
Esempio n. 17
0
 internal static void HashData(SafeHashHandle hHash, byte[] data, int ibStart, int cbSize)
 {
     HashData(hHash, data, data.Length, ibStart, cbSize);
 }
Esempio n. 18
0
 [System.Security.SecuritySafeCritical]  // auto-generated
 public SHA1Managed()
 {
     // _CreateHash will check for failures and throw the appropriate exception
     _safeHashHandle = Utils.CreateHash(Utils.StaticProvHandle, Constants.CALG_SHA1);
 }
Esempio n. 19
0
 public SHA1CryptoServiceProvider()
 {
     this._safeHashHandle = Utils.CreateHash(Utils.StaticProvHandle, 32772);
 }
Esempio n. 20
0
 internal static byte[] EndHash(SafeHashHandle hHash)
 {
     byte[] o = (byte[])null;
     Utils.EndHash(hHash, JitHelpers.GetObjectHandleOnStack <byte[]>(ref o));
     return(o);
 }
Esempio n. 21
0
 [System.Security.SecurityCritical]  // auto-generated
 internal static void HashData(SafeHashHandle hHash, byte[] data, int ibStart, int cbSize)
 {
     HashData(hHash, data, data.Length, ibStart, cbSize);
 }
Esempio n. 22
0
 private static extern void HashData(SafeHashHandle hHash, byte[] data, int cbData, int ibStart, int cbSize);
 internal static byte[] EndHash(SafeHashHandle hHash)
 {
     byte[] o = null;
     EndHash(hHash, JitHelpers.GetObjectHandleOnStack<byte[]>(ref o));
     return o;
 }
Esempio n. 24
0
 private static extern void EndHash(SafeHashHandle hHash, ObjectHandleOnStack retHash);
Esempio n. 25
0
 internal static byte[] EndHash(SafeHashHandle hHash)
 {
     byte[] result = null;
     Utils.EndHash(hHash, JitHelpers.GetObjectHandleOnStack <byte[]>(ref result));
     return(result);
 }
Esempio n. 26
0
 private static extern void HashData(SafeHashHandle hHash, byte[] data, int cbData, int ibStart, int cbSize);
Esempio n. 27
0
 private static extern void EndHash(SafeHashHandle hHash, ObjectHandleOnStack retHash);
Esempio n. 28
0
 protected override bool ReleaseHandle()
 {
     SafeHashHandle.FreeHash(this.handle);
     return(true);
 }
Esempio n. 29
0
 [System.Security.SecurityCritical]  // auto-generated
 internal static byte[] EndHash(SafeHashHandle hHash)
 {
     byte[] hash = null;
     EndHash(hHash, JitHelpers.GetObjectHandleOnStack(ref hash));
     return hash;
 }