Skip to content

Commit 0fc0aaf

Browse files
committed
deduplicate functions
1 parent 7266341 commit 0fc0aaf

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

cng/sha3.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,9 @@ func SumSHAKE256(data []byte, length int) []byte {
5858
return out
5959
}
6060

61-
// SupportsSHAKE returns true if the SHAKE extendable output function with the
62-
// given securityBits is supported.
61+
// SupportsSHAKE returns true if the SHAKE and CSHAKE extendable output functions
62+
// with the given securityBits are supported.
6363
func SupportsSHAKE(securityBits int) bool {
64-
// CNG implements SHAKE using CSHAKE with empty N and S.
65-
return SupportsCSHAKE(securityBits)
66-
}
67-
68-
// SupportsCSHAKE returns true if the CSHAKE extendable output function with the
69-
// given securityBits is supported.
70-
func SupportsCSHAKE(securityBits int) bool {
7164
var id string
7265
switch securityBits {
7366
case 128:

cng/sha3_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,10 @@ var testShakes = map[string]struct {
3434
func skipCSHAKEIfNotSupported(t *testing.T, algo string) {
3535
var supported bool
3636
switch algo {
37-
case "SHAKE128":
37+
case "SHAKE128", "CSHAKE128":
3838
supported = cng.SupportsSHAKE(128)
39-
case "SHAKE256":
39+
case "SHAKE256", "CSHAKE256":
4040
supported = cng.SupportsSHAKE(256)
41-
case "CSHAKE128":
42-
supported = cng.SupportsCSHAKE(128)
43-
case "CSHAKE256":
44-
supported = cng.SupportsCSHAKE(256)
4541
}
4642
if !supported {
4743
t.Skip("skipping: not supported")

0 commit comments

Comments
 (0)