Exemple #1
0
        public static void HashWithWrongKey()
        {
            var a = new Blake2bMac();

            using (var k = new Key(new Ed25519()))
            {
                Assert.Throws <ArgumentException>("key", () => a.Mac(k, ReadOnlySpan <byte> .Empty));
            }
        }
Exemple #2
0
        public static void HashWithMaxSpanSuccess()
        {
            var a = new Blake2bMac();

            using (var k = new Key(a))
            {
                a.Mac(k, ReadOnlySpan <byte> .Empty, new byte[a.MaxMacSize]);
            }
        }
Exemple #3
0
        public static void HashWithSpanTooLarge()
        {
            var a = new Blake2bMac();

            using (var k = new Key(a))
            {
                Assert.Throws <ArgumentException>("mac", () => a.Mac(k, ReadOnlySpan <byte> .Empty, new byte[a.MaxMacSize + 1]));
            }
        }
Exemple #4
0
        public static void HashWithSizeTooSmall()
        {
            var a = new Blake2bMac();

            using (var k = new Key(a))
            {
                Assert.Throws <ArgumentOutOfRangeException>("macSize", () => a.Mac(k, ReadOnlySpan <byte> .Empty, a.MinMacSize - 1));
            }
        }
Exemple #5
0
        public static void HashWithKeySuccess()
        {
            var a = new Blake2bMac();

            using (var k = new Key(a))
            {
                var b = a.Mac(k, ReadOnlySpan <byte> .Empty);

                Assert.NotNull(b);
                Assert.Equal(a.DefaultMacSize, b.Length);
            }
        }
Exemple #6
0
        public static void HashWithNullKey()
        {
            var a = new Blake2bMac();

            Assert.Throws <ArgumentNullException>("key", () => a.Mac(null, ReadOnlySpan <byte> .Empty));
        }