]> 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 a6ba71c27560d7b2569de8b500c931d096ea25ec..2c4fc2db91786893296ce559418d8adf39fc5b92 100644 (file)
@@ -26,6 +26,8 @@ import (
        "hash"
 )
 
+import "crypto/internal/boring"
+
 // FIPS 198-1:
 // https://csrc.nist.gov/publications/fips/fips198-1/FIPS-198-1_final.pdf
 
@@ -124,6 +126,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()