]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.boringcrypto] crypto/internal/boring: fix NewHMAC with empty key
authorRuss Cox <rsc@golang.org>
Mon, 28 Aug 2017 18:26:31 +0000 (14:26 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 30 Aug 2017 19:23:44 +0000 (19:23 +0000)
Test is in a separate CL for easier cherry-picking to master branch.

Change-Id: Ia4a9032892d2896332010fe18a3216f8c4a58d1c
Reviewed-on: https://go-review.googlesource.com/59770
Reviewed-by: Adam Langley <agl@golang.org>
src/crypto/internal/boring/hmac.go

index a5474382227705990167a1955b5da0f75bd872c9..3757da6805f71ad204ffbba97178cc75a9f7f51e 100644 (file)
@@ -100,7 +100,7 @@ func (h *boringHMAC) Reset() {
        }
        C._goboringcrypto_HMAC_CTX_init(&h.ctx)
 
-       if C._goboringcrypto_HMAC_Init(&h.ctx, unsafe.Pointer(&h.key[0]), C.int(len(h.key)), h.md) == 0 {
+       if C._goboringcrypto_HMAC_Init(&h.ctx, unsafe.Pointer(base(h.key)), C.int(len(h.key)), h.md) == 0 {
                panic("boringcrypto: HMAC_Init failed")
        }
        if int(C._goboringcrypto_HMAC_size(&h.ctx)) != h.size {