Beispiel #1
0
 public override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _hHash?.Dispose();
         _hProv?.Dispose();
     }
 }
Beispiel #2
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                SafeKeyHandle hKey = _hKey;
                _hKey = null;
                if (hKey != null)
                {
                    hKey.Dispose();
                }

                SafeProvHandle hProvider = _hProvider;
                _hProvider = null;
                if (hProvider != null)
                {
                    hProvider.Dispose();
                }
            }

            base.Dispose(disposing);
        }
Beispiel #3
0
            public override bool TryFinalizeHashAndReset(Span <byte> destination, out int bytesWritten)
            {
                if (destination.Length < HashSizeInBytes)
                {
                    bytesWritten = 0;
                    return(false);
                }

                int hashSize = HashSizeInBytes;

                if (!Interop.Advapi32.CryptGetHashParam(_hHash, Interop.Advapi32.CryptHashProperty.HP_HASHVAL, destination, ref hashSize, 0))
                {
                    int hr = Interop.CPError.GetHRForLastWin32Error();
                    throw new CryptographicException(hr);
                }
                bytesWritten = hashSize;

                //reinitialize
                _hHash.Dispose();
                _hKey.Dispose();
                _hProv.Dispose();
                SetKey();
                return(true);
            }