aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/hmac/hmac.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto/hmac/hmac.go')
-rw-r--r--src/crypto/hmac/hmac.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/crypto/hmac/hmac.go b/src/crypto/hmac/hmac.go
index 9ef9c448ee..6996963660 100644
--- a/src/crypto/hmac/hmac.go
+++ b/src/crypto/hmac/hmac.go
@@ -22,6 +22,7 @@ timing side-channels:
package hmac
import (
+ "crypto/internal/boring"
"crypto/subtle"
"hash"
)
@@ -65,6 +66,13 @@ func (h *hmac) Reset() {
// New returns a new HMAC hash using the given hash.Hash type and key.
func New(h func() hash.Hash, key []byte) hash.Hash {
+ if boring.Enabled {
+ hm := boring.NewHMAC(h, key)
+ if hm != nil {
+ return hm
+ }
+ // BoringCrypto did not recognize h, so fall through to standard Go code.
+ }
hm := new(hmac)
hm.outer = h()
hm.inner = h()