Skip to content

Commit

Permalink
Use test vectors from the internal //testdata/testvector:* targets
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 597764947
Change-Id: I56aefab42979ed61137522af8d4f7cdc4cd4008b
  • Loading branch information
morambro authored and copybara-github committed Jan 12, 2024
1 parent 8d0456d commit bcbdc04
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 15 deletions.
6 changes: 5 additions & 1 deletion aead/subtle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ go_test(
"xchacha20poly1305_test.go",
"xchacha20poly1305_vectors_test.go",
],
data = ["@wycheproof//testvectors:all"],
data = [
"//testdata/testvectors:aes_gcm",
"//testdata/testvectors:aes_gcm_siv",
"//testdata/testvectors:chacha20_poly1305",
],
deps = [
":subtle",
"//mac/subtle",
Expand Down
2 changes: 1 addition & 1 deletion daead/subtle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ go_library(
go_test(
name = "subtle_test",
srcs = ["aes_siv_test.go"],
data = ["@wycheproof//testvectors:all"],
data = ["//testdata/testvectors:aes_siv_cmac"],
deps = [
":subtle",
"//subtle/random",
Expand Down
5 changes: 4 additions & 1 deletion hybrid/subtle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ go_test(
"public_key_test.go",
"subtle_test.go",
],
data = ["@wycheproof//testvectors:all"],
data = [
"//testdata/testvectors:ecdh",
"//testdata/testvectors:ecdh_ecpoint",
],
deps = [
":subtle",
"//hybrid",
Expand Down
5 changes: 4 additions & 1 deletion internal/aead/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ go_test(
"chacha20poly1305_insecure_nonce_test.go",
"chacha20poly1305_insecure_nonce_vectors_test.go",
],
data = ["@wycheproof//testvectors:all"],
data = [
"//testdata/testvectors:aes_gcm",
"//testdata/testvectors:chacha20_poly1305",
],
deps = [
":aead",
"//subtle/random",
Expand Down
3 changes: 2 additions & 1 deletion internal/signature/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ go_test(
"rsassapss_signer_verifier_test.go",
],
data = [
"@wycheproof//testvectors:all",
"//testdata/testvectors:rsa_pss",
"//testdata/testvectors:rsa_signature",
],
deps = [
":signature",
Expand Down
2 changes: 1 addition & 1 deletion keyderivation/internal/streamingprf/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ go_test(
"streaming_prf_factory_test.go",
"streaming_prf_test.go",
],
data = ["@wycheproof//testvectors:all"],
data = ["//testdata/testvectors:kdf"],
embed = [":streamingprf"],
deps = [
"//aead",
Expand Down
2 changes: 1 addition & 1 deletion kwp/subtle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ go_library(
go_test(
name = "subtle_test",
srcs = ["kwp_test.go"],
data = ["@wycheproof//testvectors:all"],
data = ["//testdata/testvectors:keywrap"],
deps = [
":subtle",
"//subtle/random",
Expand Down
2 changes: 1 addition & 1 deletion mac/subtle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ go_test(
"cmac_test.go",
"hmac_test.go",
],
data = ["@wycheproof//testvectors:all"],
data = ["//testdata/testvectors:aes_cmac"],
deps = [
":subtle",
"//subtle/random",
Expand Down
6 changes: 5 additions & 1 deletion prf/subtle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ go_test(
"hmac_test.go",
"subtle_test.go",
],
data = ["@wycheproof//testvectors:all"],
data = [
"//testdata/testvectors:aes_cmac",
"//testdata/testvectors:hmac",
"//testdata/testvectors:kdf",
],
deps = [
":subtle",
"//testutil",
Expand Down
3 changes: 2 additions & 1 deletion signature/subtle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ go_test(
"subtle_test.go",
],
data = [
"@wycheproof//testvectors:all",
"//testdata/testvectors:ecdsa",
"//testdata/testvectors:eddsa",
],
deps = [
":subtle",
Expand Down
2 changes: 1 addition & 1 deletion subtle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ go_test(
"subtle_test.go",
"x25519_test.go",
],
data = ["@wycheproof//testvectors:xdh"],
data = ["//testdata/testvectors:xdh"],
deps = [
":subtle",
"//testutil",
Expand Down
2 changes: 1 addition & 1 deletion testutil/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ go_test(
"wycheproofutil_test.go",
],
data = [
"@wycheproof//testvectors:all",
"//testdata/testvectors:aes_gcm",
],
deps = [
":testutil",
Expand Down
10 changes: 7 additions & 3 deletions testutil/wycheproofutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

const (
wycheproofDir = "wycheproof/testvectors"
testvectorsDir = "testdata/testvectors"
)

// SkipTestIfTestSrcDirIsNotSet skips the test if TEST_SRCDIR is not set.
Expand Down Expand Up @@ -89,12 +89,16 @@ func (a *HexBytes) UnmarshalText(text []byte) error {
//
// When using this in a test function, the function should start with
// SkipTestIfTestSrcDirIsNotSet(), to expediently skip the test.
func PopulateSuite(suite interface{}, filename string) error {
func PopulateSuite(suite any, filename string) error {
srcDir, ok := os.LookupEnv("TEST_SRCDIR")
if !ok {
return errors.New("TEST_SRCDIR not found")
}
f, err := os.Open(filepath.Join(srcDir, wycheproofDir, filename))
workspaceDir, ok := os.LookupEnv("TEST_WORKSPACE")
if !ok {
return errors.New("TEST_WORKSPACE not found")
}
f, err := os.Open(filepath.Join(srcDir, workspaceDir, testvectorsDir, filename))
if err != nil {
return err
}
Expand Down

0 comments on commit bcbdc04

Please sign in to comment.