Ejemplo n.º 1
0
        protected void VerifyHmac_Empty(string digest)
        {
            // using ReadOnlySpan<byte>.Empty may throw NRE if length not validated correctly
            var hmac = Create(ReadOnlySpan <byte> .Empty);

            byte[] digestBytes    = ByteUtils.HexToByteArray(digest);
            byte[] computedDigest = new byte[hmac.HashSize];
            hmac.ComputeHash(ByteUtils.AsciiBytes("Empty key"), computedDigest);

            Assert.Equal(digestBytes, computedDigest);

            hmac = Create(Array.Empty <byte>());
            hmac.ComputeHash(ByteUtils.AsciiBytes("Empty key"), computedDigest);

            Assert.Equal(digestBytes, computedDigest);
        }
Ejemplo n.º 2
0
 protected void Verify(string input, string prepend, string output)
 {
     Verify(ByteUtils.AsciiBytes(input), ByteUtils.AsciiBytes(prepend), output);
 }