public void Reset() { SecurityAssert.SAssert(state != HMACState.Uninitialised); var iPadKey = XorKey(key, 0x36); digest.Reset(); digest.Update(iPadKey, 0, iPadKey.Length); state = HMACState.InnerHashing; }
public void Reset() { SecurityAssert.Assert(_state != HMACState.Uninitialised); var iPadKey = XorKey(_key, 0x36); _digest.Reset(); _digest.Update(iPadKey); _state = HMACState.InnerHashing; }
public HMAC(IDigest digest, byte[] key) { SecurityAssert.NotNull(digest); SecurityAssert.NotNull(key); _digest = digest; _key = new byte[digest.BlockSize / 8]; _state = HMACState.Uninitialised; ProcessInputKey(key); _state = HMACState.ProcessedKey; Reset(); }
public HMAC(IDigest digest, byte[] key) { SecurityAssert.NotNull(digest); SecurityAssert.NotNull(key); this.digest = digest; this.key = new byte[digest.BlockSize / 8]; ProcessInputKey(key); state = HMACState.ProcessedKey; Reset(); }
public byte[] Digest() { SecurityAssert.SAssert(state == HMACState.InnerHashing); state = HMACState.HashingDone; var innerHash = digest.Digest(); var oPadKey = XorKey(key, 0x5c); digest.Reset(); digest.Update(oPadKey, 0, oPadKey.Length); digest.Update(innerHash, 0, innerHash.Length); return digest.Digest(); }
public void Digest(Span <byte> output) { SecurityAssert.Assert(_state == HMACState.InnerHashing); _state = HMACState.HashingDone; var innerHash = _digest.DigestBuffer(); var oPadKey = XorKey(_key, 0x5c); _digest.Reset(); _digest.Update(oPadKey); _digest.Update(innerHash); _digest.Digest(output); }
private void ProcessInputKey(byte[] bytes) { var blockLength = _digest.BlockSize / 8; if (bytes.Length > blockLength) { _state = HMACState.Uninitialised; _digest.Reset(); _digest.Update(bytes); _digest.Digest(_key.AsSpan()); } else { Array.Copy(bytes, _key, bytes.Length); } }
private void ProcessInputKey(byte[] bytes) { var blockLength = digest.BlockSize / 8; if (bytes.Length > blockLength) { state = HMACState.Uninitialised; digest.Reset(); digest.Update(bytes, 0, bytes.Length); var keyHash = digest.Digest(); Array.Copy(keyHash, key, keyHash.Length); } else { Array.Copy(bytes, key, bytes.Length); } }