]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/crypto/hmac/hmac.go
[dev.boringcrypto] all: merge master into dev.boringcrypto
[gostls13.git] / src / crypto / hmac / hmac.go
index c8c0617c47f7880f3571f43f0040cbca1a793109..1f70abbb68d0ab849c2f13d5c6890fdf666b3d77 100644 (file)
@@ -22,6 +22,7 @@ timing side-channels:
 package hmac
 
 import (
+       "crypto/internal/boring"
        "crypto/subtle"
        "hash"
 )
@@ -68,6 +69,13 @@ func (h *hmac) Reset() {
 // the returned Hash does not implement encoding.BinaryMarshaler
 // or encoding.BinaryUnmarshaler.
 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()