@@ -23,6 +23,7 @@ Subject: [PATCH] Add crypto backend foundation
23
23
src/crypto/ed25519/boring.go | 71 ++++++
24
24
src/crypto/ed25519/ed25519.go | 73 ++++++
25
25
src/crypto/ed25519/notboring.go | 16 ++
26
+ src/crypto/hkdf/hkdf.go | 14 ++
26
27
src/crypto/hkdf/hkdf_test.go | 2 +-
27
28
src/crypto/hmac/hmac.go | 2 +-
28
29
src/crypto/hmac/hmac_test.go | 2 +-
@@ -74,7 +75,7 @@ Subject: [PATCH] Add crypto backend foundation
74
75
src/hash/notboring_test.go | 9 +
75
76
src/net/smtp/smtp_test.go | 72 ++++--
76
77
src/runtime/runtime_boring.go | 5 +
77
- 70 files changed, 1145 insertions(+), 80 deletions(-)
78
+ 71 files changed, 1159 insertions(+), 80 deletions(-)
78
79
create mode 100644 src/crypto/dsa/boring.go
79
80
create mode 100644 src/crypto/dsa/notboring.go
80
81
create mode 100644 src/crypto/ed25519/boring.go
@@ -811,6 +812,52 @@ index 00000000000000..b0cdd44d81c753
811
812
+ func boringPrivateKey(PrivateKey) (*boring.PrivateKeyEd25519, error) {
812
813
+ panic("boringcrypto: not available")
813
814
+ }
815
+ diff --git a/src/crypto/hkdf/hkdf.go b/src/crypto/hkdf/hkdf.go
816
+ index 7cfbe2c60de356..78139ed6170da5 100644
817
+ --- a/src/crypto/hkdf/hkdf.go
818
+ +++ b/src/crypto/hkdf/hkdf.go
819
+ @@ -11,6 +11,7 @@
820
+ package hkdf
821
+
822
+ import (
823
+ + boring "crypto/internal/backend"
824
+ "crypto/internal/fips140/hkdf"
825
+ "crypto/internal/fips140only"
826
+ "errors"
827
+ @@ -27,6 +28,9 @@ func Extract[H hash.Hash](h func() H, secret, salt []byte) ([]byte, error) {
828
+ if err := checkFIPS140Only(h, secret); err != nil {
829
+ return nil, err
830
+ }
831
+ + if boring.Enabled && boring.SupportsHKDF() {
832
+ + return boring.ExtractHKDF(func() hash.Hash { return h() }, secret, salt)
833
+ + }
834
+ return hkdf.Extract(h, secret, salt), nil
835
+ }
836
+
837
+ @@ -47,6 +51,9 @@ func Expand[H hash.Hash](h func() H, pseudorandomKey []byte, info string, keyLen
838
+ return nil, errors.New("hkdf: requested key length too large")
839
+ }
840
+
841
+ + if boring.Enabled && boring.SupportsHKDF() {
842
+ + return boring.ExpandHKDF(func() hash.Hash { return h() }, pseudorandomKey, []byte(info), keyLength)
843
+ + }
844
+ return hkdf.Expand(h, pseudorandomKey, info, keyLength), nil
845
+ }
846
+
847
+ @@ -63,6 +70,13 @@ func Key[Hash hash.Hash](h func() Hash, secret, salt []byte, info string, keyLen
848
+ return nil, errors.New("hkdf: requested key length too large")
849
+ }
850
+
851
+ + if boring.Enabled && boring.SupportsHKDF() {
852
+ + pseudorandomKey, err := boring.ExtractHKDF(func() hash.Hash { return h() }, secret, salt)
853
+ + if err != nil {
854
+ + return nil, err
855
+ + }
856
+ + return boring.ExpandHKDF(func() hash.Hash { return h() }, pseudorandomKey, []byte(info), keyLength)
857
+ + }
858
+ return hkdf.Key(h, secret, salt, info, keyLength), nil
859
+ }
860
+
814
861
diff --git a/src/crypto/hkdf/hkdf_test.go b/src/crypto/hkdf/hkdf_test.go
815
862
index 201b440289bb2d..4ed4960ff35b66 100644
816
863
--- a/src/crypto/hkdf/hkdf_test.go
0 commit comments