private SHA1CryptoServiceProvider(CspParameters parameters) { _paramCSP = parameters; _hHash = IntPtr.Zero; if (SharedStatics.Crypto_SHA1CryptoServiceProviderContext == _zeroPointer) { IntPtr hCSP = IntPtr.Zero; int hr = _AcquireCSP(_paramCSP, ref hCSP); if (hCSP == IntPtr.Zero) { throw new CryptographicException(Environment.GetResourceString("Cryptography_CSP_CouldNotAcquire")); } SharedStatics.Crypto_SHA1CryptoServiceProviderContext = hCSP; // next bit is in case we do two acquires... if (SharedStatics.Crypto_SHA1CryptoServiceProviderContext != hCSP) { _FreeCSP(hCSP); } } _hHash = _CreateHash(SharedStatics.Crypto_SHA1CryptoServiceProviderContext, CALG_SHA1); if (_hHash == IntPtr.Zero) { throw new CryptographicException(Environment.GetResourceString("Cryptography_CSP_CreateHash")); } _HashHandleProtector = new __HashHandleProtector(_hHash); }
/************************* PUBLIC METHODS ************************/ /// <include file='doc\SHA1CryptoServiceProvider.uex' path='docs/doc[@for="SHA1CryptoServiceProvider.Initialize"]/*' /> public override void Initialize() { if (_HashHandleProtector != null && !_HashHandleProtector.IsClosed) { _HashHandleProtector.Close(); } _hHash = _CreateHash(SharedStatics.Crypto_SHA1CryptoServiceProviderContext, CALG_SHA1); if (_hHash == IntPtr.Zero) { throw new CryptographicException(Environment.GetResourceString("Cryptography_CSP_CreateHash")); } _HashHandleProtector = new __HashHandleProtector(_hHash); }