]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/crypto/hmac/hmac.go
[dev.boringcrypto] crypto/hmac: merge up to 2a206c7 and skip test
[gostls13.git] / src / crypto / hmac / hmac.go
index cdda33c2cbac2dc55c63e71858e01bffda5a8a82..34805765d550c17234bafc0fc7e8215bbb70b81b 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
 
@@ -126,6 +128,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()