Skip to content

Commit fb5719c

Browse files
committed
crypto/internal/fips140/ecdsa: make TestingOnlyNewDRBG generic
We are re-sealing the .zip file anyway for another reason, might as well take the opportunity to remove the fips140.Hash type indirection. Change-Id: I6a6a6964fdb312cc2c64e327f845c398c0f6279b Reviewed-on: https://go-review.googlesource.com/c/go/+/701519 Reviewed-by: Michael Pratt <[email protected]> Reviewed-by: Daniel McCarney <[email protected]> Reviewed-by: Mark Freeman <[email protected]> TryBot-Bypass: Filippo Valsorda <[email protected]>
1 parent 56067e3 commit fb5719c

File tree

3 files changed

+2
-9
lines changed

3 files changed

+2
-9
lines changed

src/crypto/internal/fips140/ecdsa/hmacdrbg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func newDRBG[H hash.Hash](hash func() H, entropy, nonce []byte, s personalizatio
122122
//
123123
// This should only be used for ACVP testing. hmacDRBG is not intended to be
124124
// used directly.
125-
func TestingOnlyNewDRBG(hash func() hash.Hash, entropy, nonce []byte, s []byte) *hmacDRBG {
125+
func TestingOnlyNewDRBG[H hash.Hash](hash func() H, entropy, nonce []byte, s []byte) *hmacDRBG {
126126
return newDRBG(hash, entropy, nonce, plainPersonalizationString(s))
127127
}
128128

src/crypto/internal/fips140/fips140.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package fips140
77
import (
88
"crypto/internal/fips140deps/godebug"
99
"errors"
10-
"hash"
1110
"runtime"
1211
)
1312

@@ -75,9 +74,3 @@ func Version() string {
7574
// moved to a different file.
7675
return "latest" //mkzip:version
7776
}
78-
79-
// Hash is a legacy compatibility alias for hash.Hash.
80-
//
81-
// It's only here because [crypto/internal/fips140/ecdsa.TestingOnlyNewDRBG]
82-
// takes a "func() fips140.Hash" in v1.0.0, instead of being generic.
83-
type Hash = hash.Hash

src/crypto/internal/fips140test/acvp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1624,7 +1624,7 @@ func cmdHmacDrbgAft(h func() hash.Hash) command {
16241624
// * Uninstantiate
16251625
// See Table 7 in draft-vassilev-acvp-drbg
16261626
out := make([]byte, outLen)
1627-
drbg := ecdsa.TestingOnlyNewDRBG(func() fips140.Hash { return h() }, entropy, nonce, personalization)
1627+
drbg := ecdsa.TestingOnlyNewDRBG(h, entropy, nonce, personalization)
16281628
drbg.Generate(out)
16291629
drbg.Generate(out)
16301630

0 commit comments

Comments
 (0)