From 81b9d733b04b635e6c6e78396c4bde0d344da06c Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 28 Aug 2017 14:27:03 -0400 Subject: [PATCH] [dev.boringcrypto] crypto/hmac: test empty key This happens in the scrypt and pbkdf unit tests. Change-Id: I1eda944d7c01d28c7a6dd9f428f5fdd1cbd58939 Reviewed-on: https://go-review.googlesource.com/59771 Reviewed-by: Adam Langley --- src/crypto/hmac/hmac_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/crypto/hmac/hmac_test.go b/src/crypto/hmac/hmac_test.go index aac9aa96a8..444978001c 100644 --- a/src/crypto/hmac/hmac_test.go +++ b/src/crypto/hmac/hmac_test.go @@ -518,6 +518,31 @@ var hmacTests = []hmacTest{ sha512.Size, sha512.BlockSize, }, + // HMAC without key is dumb but should probably not fail. + { + sha1.New, + []byte{}, + []byte("message"), + "d5d1ed05121417247616cfc8378f360a39da7cfa", + sha1.Size, + sha1.BlockSize, + }, + { + sha256.New, + []byte{}, + []byte("message"), + "eb08c1f56d5ddee07f7bdf80468083da06b64cf4fac64fe3a90883df5feacae4", + sha256.Size, + sha256.BlockSize, + }, + { + sha512.New, + []byte{}, + []byte("message"), + "08fce52f6395d59c2a3fb8abb281d74ad6f112b9a9c787bcea290d94dadbc82b2ca3e5e12bf2277c7fedbb0154d5493e41bb7459f63c8e39554ea3651b812492", + sha512.Size, + sha512.BlockSize, + }, } func TestHMAC(t *testing.T) { -- 2.50.0