Skip to content

Commit a332689

Browse files
FiloSottilegopherbot
authored andcommitted
crypto/internal/hpke: replace x/crypto/hkdf with crypto/internal/fips/hkdf
Change-Id: Id69e8e3a7dd61ca33489140eb76771b176a9ea4a Reviewed-on: https://go-review.googlesource.com/c/go/+/629057 Reviewed-by: Russ Cox <[email protected]> Auto-Submit: Filippo Valsorda <[email protected]> TryBot-Bypass: Filippo Valsorda <[email protected]> Commit-Queue: Filippo Valsorda <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent ad072b3 commit a332689

File tree

4 files changed

+2
-104
lines changed

4 files changed

+2
-104
lines changed

src/crypto/internal/hpke/hpke.go

+2-7
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import (
99
"crypto/aes"
1010
"crypto/cipher"
1111
"crypto/ecdh"
12+
"crypto/internal/fips/hkdf"
1213
"crypto/rand"
1314
"errors"
1415
"internal/byteorder"
1516
"math/bits"
1617

1718
"golang.org/x/crypto/chacha20poly1305"
18-
"golang.org/x/crypto/hkdf"
1919
)
2020

2121
// testingOnlyGenerateKey is only used during testing, to provide
@@ -42,12 +42,7 @@ func (kdf *hkdfKDF) LabeledExpand(suiteID []byte, randomKey []byte, label string
4242
labeledInfo = append(labeledInfo, suiteID...)
4343
labeledInfo = append(labeledInfo, label...)
4444
labeledInfo = append(labeledInfo, info...)
45-
out := make([]byte, length)
46-
n, err := hkdf.Expand(kdf.hash.New, randomKey, labeledInfo).Read(out)
47-
if err != nil || n != int(length) {
48-
panic("hpke: LabeledExpand failed unexpectedly")
49-
}
50-
return out
45+
return hkdf.Expand(kdf.hash.New, randomKey, labeledInfo, int(length))
5146
}
5247

5348
// dhKEM implements the KEM specified in RFC 9180, Section 4.1.

src/go/build/deps_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,6 @@ var depsRules = `
551551
< golang.org/x/crypto/chacha20
552552
< golang.org/x/crypto/internal/poly1305
553553
< golang.org/x/crypto/chacha20poly1305
554-
< golang.org/x/crypto/hkdf
555554
< crypto/internal/hpke
556555
< crypto/x509/internal/macos
557556
< crypto/x509/pkix;

src/vendor/golang.org/x/crypto/hkdf/hkdf.go

-95
This file was deleted.

src/vendor/modules.txt

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ golang.org/x/crypto/chacha20
44
golang.org/x/crypto/chacha20poly1305
55
golang.org/x/crypto/cryptobyte
66
golang.org/x/crypto/cryptobyte/asn1
7-
golang.org/x/crypto/hkdf
87
golang.org/x/crypto/internal/alias
98
golang.org/x/crypto/internal/poly1305
109
# golang.org/x/net v0.27.1-0.20240722181819-765c7e89b3bd

0 commit comments

Comments
 (0)