Esempio n. 1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         HMACCommon hMacCommon = _hMacCommon;
         _hMacCommon = null;
         if (hMacCommon != null)
         {
             hMacCommon.Dispose(disposing);
         }
     }
     base.Dispose(disposing);
 }
        public HMACSHA512(byte[] key)
        {
            if (key is null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            this.HashName = HashAlgorithmNames.SHA512;
            _hMacCommon   = new HMACCommon(HashAlgorithmNames.SHA512, key, BlockSize);
            base.Key      = _hMacCommon.ActualKey !;
            // change the default value of BlockSizeValue to 128 instead of 64
            BlockSizeValue = BlockSize;
            HashSizeValue  = _hMacCommon.HashSizeInBits;
        }
Esempio n. 3
0
        public HMACSHA256(byte[] key)
        {
            if (key is null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            this.HashName = HashAlgorithmNames.SHA256;
            _hMacCommon   = new HMACCommon(HashAlgorithmNames.SHA256, key, BlockSize);
            base.Key      = _hMacCommon.ActualKey !;
            // this not really needed as it'll initialize BlockSizeValue with same value it has which is 64.
            // we just want to be explicit in all HMAC extended classes
            BlockSizeValue = BlockSize;
            HashSizeValue  = _hMacCommon.HashSizeInBits;
        }
Esempio n. 4
0
        /// <summary>
        /// Release all resources used by the current instance of the
        /// <see cref="IncrementalHash"/> class.
        /// </summary>
        public void Dispose()
        {
            _disposed = true;

            if (_hash != null)
            {
                _hash.Dispose();
                _hash = null;
            }

            if (_hmac != null)
            {
                _hmac.Dispose(true);
                _hmac = null;
            }
        }
Esempio n. 5
0
 public HMACSHA512(byte[] key)
 {
     this.HashName = HashAlgorithmNames.SHA512;
     _hMacCommon   = new HMACCommon(HashAlgorithmNames.SHA512, key, BlockSize);
     base.Key      = _hMacCommon.ActualKey;
 }
Esempio n. 6
0
 public HMACSHA512(byte[] key)
 {
     this.HashName = HashAlgorithmNames.SHA512;
     _hMacCommon   = new HMACCommon(HashAlgorithmNames.SHA512, key);
     base.Key      = key;
 }
Esempio n. 7
0
 public HMACMD5(byte[] key)
 {
     this.HashName = HashAlgorithmNames.MD5;
     _hMacCommon   = new HMACCommon(HashAlgorithmNames.MD5, key);
     base.Key      = key;
 }