Skip to content

Commit

Permalink
Add genrules to testdata/testvectors that copy Wycheproof test vectors
Browse files Browse the repository at this point in the history
Bazel Modules use different repository names (https://bazel.build/versions/6.0.0/build/bzlmod#repository-names), so file paths are different when using Bzlmod vs WORKSPACE-based projects. This will allow to load test vectors in a uniform manner when using Bzlmod.

PiperOrigin-RevId: 597556206
Change-Id: I0c22f77c86651427bf6025751ce686051052ca3a
  • Loading branch information
morambro authored and copybara-github committed Jan 11, 2024
1 parent d91ff93 commit 6967087
Showing 1 changed file with 195 additions and 0 deletions.
195 changes: 195 additions & 0 deletions testdata/testvectors/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,198 @@ filegroup(
testonly = 1,
srcs = ["hpke_boringssl.json"],
)

# Below we define a set of genrules to copy test vectors from Wycheproof.
# This is needed to assist the transition to using Bazel Modules, in that Bazel
# Modules packages use a different folder naming for dependencies compared to
# WORKSPACE-based packages.

genrule(
name = "aes_cmac",
testonly = 1,
srcs = ["@wycheproof//testvectors:aes_cmac"],
outs = ["aes_cmac_test.json"],
cmd = "cp $(SRCS) $(@D)/",
)

genrule(
name = "aes_gcm",
testonly = 1,
srcs = ["@wycheproof//testvectors:aes_gcm"],
outs = ["aes_gcm_test.json"],
cmd = "cp $(SRCS) $(@D)/",
)

genrule(
name = "aes_gcm_siv",
testonly = 1,
srcs = ["@wycheproof//testvectors:aes_gcm_siv"],
outs = ["aes_gcm_siv_test.json"],
cmd = "cp $(SRCS) $(@D)/",
)

genrule(
name = "aes_eax",
testonly = 1,
srcs = ["@wycheproof//testvectors:aes_eax"],
outs = ["aes_eax_test.json"],
cmd = "cp $(SRCS) $(@D)/",
)

genrule(
name = "aes_siv_cmac",
testonly = 1,
srcs = ["@wycheproof//testvectors:aes_siv_cmac"],
outs = [
"aead_aes_siv_cmac_test.json",
"aes_siv_cmac_test.json",
],
cmd = "cp $(SRCS) $(@D)/",
)

genrule(
name = "chacha20_poly1305",
testonly = 1,
srcs = ["@wycheproof//testvectors:chacha20_poly1305"],
outs = [
"chacha20_poly1305_test.json",
"xchacha20_poly1305_test.json",
],
cmd = "cp $(SRCS) $(@D)/",
)

genrule(
name = "hmac",
testonly = 1,
srcs = ["@wycheproof//testvectors:hmac"],
outs = [
"hmac_sha1_test.json",
"hmac_sha224_test.json",
"hmac_sha256_test.json",
"hmac_sha384_test.json",
"hmac_sha3_224_test.json",
"hmac_sha3_256_test.json",
"hmac_sha3_384_test.json",
"hmac_sha3_512_test.json",
"hmac_sha512_test.json",
],
cmd = "cp $(SRCS) $(@D)/",
)

genrule(
name = "rsa_pss",
testonly = 1,
srcs = ["@wycheproof//testvectors:rsa_pss"],
outs = [
"rsa_pss_2048_sha1_mgf1_20_test.json",
"rsa_pss_2048_sha256_mgf1_0_test.json",
"rsa_pss_2048_sha256_mgf1_32_test.json",
"rsa_pss_3072_sha256_mgf1_32_test.json",
"rsa_pss_4096_sha256_mgf1_32_test.json",
"rsa_pss_4096_sha512_mgf1_32_test.json",
"rsa_pss_misc_test.json",
],
cmd = "cp $(SRCS) $(@D)/",
)

genrule(
name = "rsa_signature",
testonly = 1,
srcs = ["@wycheproof//testvectors:rsa_signature"],
outs = [
# Signature verification
"rsa_signature_2048_sha224_test.json",
"rsa_signature_2048_sha256_test.json",
"rsa_signature_2048_sha512_test.json",
"rsa_signature_3072_sha256_test.json",
"rsa_signature_3072_sha384_test.json",
"rsa_signature_3072_sha512_test.json",
"rsa_signature_4096_sha384_test.json",
"rsa_signature_4096_sha512_test.json",
"rsa_signature_2048_sha3_224_test.json",
"rsa_signature_2048_sha3_256_test.json",
"rsa_signature_2048_sha3_384_test.json",
"rsa_signature_2048_sha3_512_test.json",
"rsa_signature_3072_sha3_256_test.json",
"rsa_signature_3072_sha3_384_test.json",
"rsa_signature_3072_sha3_512_test.json",
"rsa_signature_test.json",
# Signature generation
"rsa_sig_gen_misc_test.json",
],
cmd = "cp $(SRCS) $(@D)/",
)

genrule(
name = "ecdsa_webcrypto",
testonly = 1,
srcs = ["@wycheproof//testvectors:ecdsa_webcrypto"],
outs = ["ecdsa_webcrypto_test.json"],
cmd = "cp $(SRCS) $(@D)/",
)

genrule(
name = "ecdsa",
testonly = 1,
srcs = ["@wycheproof//testvectors:ecdsa"],
outs = [
"ecdsa_brainpoolP224r1_sha224_test.json",
"ecdsa_brainpoolP256r1_sha256_test.json",
"ecdsa_brainpoolP320r1_sha384_test.json",
"ecdsa_brainpoolP384r1_sha384_test.json",
"ecdsa_brainpoolP512r1_sha512_test.json",
"ecdsa_secp224r1_sha224_test.json",
"ecdsa_secp224r1_sha256_test.json",
"ecdsa_secp224r1_sha3_224_test.json",
"ecdsa_secp224r1_sha3_256_test.json",
"ecdsa_secp224r1_sha3_512_test.json",
"ecdsa_secp224r1_sha512_test.json",
"ecdsa_secp256k1_sha256_test.json",
"ecdsa_secp256k1_sha3_256_test.json",
"ecdsa_secp256k1_sha3_512_test.json",
"ecdsa_secp256k1_sha512_test.json",
"ecdsa_secp256r1_sha256_test.json",
"ecdsa_secp256r1_sha3_256_test.json",
"ecdsa_secp256r1_sha3_512_test.json",
"ecdsa_secp256r1_sha512_test.json",
"ecdsa_secp384r1_sha384_test.json",
"ecdsa_secp384r1_sha3_384_test.json",
"ecdsa_secp384r1_sha3_512_test.json",
"ecdsa_secp384r1_sha512_test.json",
"ecdsa_secp521r1_sha3_512_test.json",
"ecdsa_secp521r1_sha512_test.json",
"ecdsa_test.json", # deprecated: use the files above
],
cmd = "cp $(SRCS) $(@D)/",
)

genrule(
name = "eddsa",
testonly = 1,
srcs = ["@wycheproof//testvectors:eddsa"],
outs = [
"ed448_test.json",
"eddsa_test.json",
],
cmd = "cp $(SRCS) $(@D)/",
)

genrule(
name = "ecdh",
testonly = 1,
srcs = ["@wycheproof//testvectors:ecdh"],
outs = [
"ecdh_brainpoolP224r1_test.json",
"ecdh_brainpoolP256r1_test.json",
"ecdh_brainpoolP320r1_test.json",
"ecdh_brainpoolP384r1_test.json",
"ecdh_brainpoolP512r1_test.json",
"ecdh_secp224r1_test.json",
"ecdh_secp256k1_test.json",
"ecdh_secp256r1_test.json",
"ecdh_secp384r1_test.json",
"ecdh_secp521r1_test.json",
"ecdh_test.json", # deprecated use the files above
],
cmd = "cp $(SRCS) $(@D)/",
)

0 comments on commit 6967087

Please sign in to comment.