diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/wycheproof/wycheproof.go | 71 |
1 files changed, 41 insertions, 30 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go index 930ba4624c..41ad449b96 100644 --- a/src/regress/lib/libcrypto/wycheproof/wycheproof.go +++ b/src/regress/lib/libcrypto/wycheproof/wycheproof.go | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: wycheproof.go,v 1.163 2025/09/04 16:40:12 tb Exp $ */ | 1 | /* $OpenBSD: wycheproof.go,v 1.164 2025/09/04 16:44:14 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018,2023 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2018,2023 Joel Sing <jsing@openbsd.org> |
4 | * Copyright (c) 2018,2019,2022-2024 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2018,2019,2022-2024 Theo Buehler <tb@openbsd.org> |
@@ -578,6 +578,13 @@ type wycheproofTestGroupRunner interface { | |||
578 | run(string, testVariant) bool | 578 | run(string, testVariant) bool |
579 | } | 579 | } |
580 | 580 | ||
581 | type wycheproofVersion int | ||
582 | |||
583 | const ( | ||
584 | v0 wycheproofVersion = iota | ||
585 | v1 | ||
586 | ) | ||
587 | |||
581 | type wycheproofTestVectors struct { | 588 | type wycheproofTestVectors struct { |
582 | Algorithm string `json:"algorithm"` | 589 | Algorithm string `json:"algorithm"` |
583 | GeneratorVersion string `json:"generatorVersion"` | 590 | GeneratorVersion string `json:"generatorVersion"` |
@@ -2644,7 +2651,7 @@ func testGroupFromAlgorithm(algorithm string, variant testVariant) wycheproofTes | |||
2644 | } | 2651 | } |
2645 | } | 2652 | } |
2646 | 2653 | ||
2647 | func runTestVectors(path string, variant testVariant) bool { | 2654 | func runTestVectors(path string, variant testVariant, version wycheproofVersion) bool { |
2648 | var algorithm string | 2655 | var algorithm string |
2649 | var testGroups []json.RawMessage | 2656 | var testGroups []json.RawMessage |
2650 | b, err := ioutil.ReadFile(path) | 2657 | b, err := ioutil.ReadFile(path) |
@@ -2725,35 +2732,36 @@ func main() { | |||
2725 | } | 2732 | } |
2726 | 2733 | ||
2727 | tests := []struct { | 2734 | tests := []struct { |
2735 | version wycheproofVersion | ||
2728 | name string | 2736 | name string |
2729 | pattern string | 2737 | pattern string |
2730 | variant testVariant | 2738 | variant testVariant |
2731 | }{ | 2739 | }{ |
2732 | {"AES", "aes_[cg]*[^xv]_test.json", Normal}, // Skip AES-EAX, AES-GCM-SIV and AES-SIV-CMAC. | 2740 | {v0, "AES", "aes_[cg]*[^xv]_test.json", Normal}, // Skip AES-EAX, AES-GCM-SIV and AES-SIV-CMAC. |
2733 | {"ChaCha20-Poly1305", "chacha20_poly1305_test.json", Normal}, | 2741 | {v0, "ChaCha20-Poly1305", "chacha20_poly1305_test.json", Normal}, |
2734 | {"DSA", "dsa_*test.json", Normal}, | 2742 | {v0, "DSA", "dsa_*test.json", Normal}, |
2735 | {"DSA", "dsa_*_p1363_test.json", P1363}, | 2743 | {v0, "DSA", "dsa_*_p1363_test.json", P1363}, |
2736 | {"ECDH", "ecdh_test.json", Normal}, | 2744 | {v0, "ECDH", "ecdh_test.json", Normal}, |
2737 | {"ECDH", "ecdh_[^w_]*_test.json", Normal}, | 2745 | {v0, "ECDH", "ecdh_[^w_]*_test.json", Normal}, |
2738 | {"ECDH EcPoint", "ecdh_*_ecpoint_test.json", EcPoint}, | 2746 | {v0, "ECDH EcPoint", "ecdh_*_ecpoint_test.json", EcPoint}, |
2739 | {"ECDH webcrypto", "ecdh_webcrypto_test.json", Webcrypto}, | 2747 | {v0, "ECDH webcrypto", "ecdh_webcrypto_test.json", Webcrypto}, |
2740 | {"ECDSA", "ecdsa_test.json", Normal}, | 2748 | {v0, "ECDSA", "ecdsa_test.json", Normal}, |
2741 | {"ECDSA", "ecdsa_[^w]*test.json", Normal}, | 2749 | {v0, "ECDSA", "ecdsa_[^w]*test.json", Normal}, |
2742 | {"ECDSA P1363", "ecdsa_*_p1363_test.json", P1363}, | 2750 | {v0, "ECDSA P1363", "ecdsa_*_p1363_test.json", P1363}, |
2743 | {"ECDSA webcrypto", "ecdsa_webcrypto_test.json", Webcrypto}, | 2751 | {v0, "ECDSA webcrypto", "ecdsa_webcrypto_test.json", Webcrypto}, |
2744 | {"EDDSA", "eddsa_test.json", Normal}, | 2752 | {v0, "EDDSA", "eddsa_test.json", Normal}, |
2745 | {"ED448", "ed448_test.json", Skip}, | 2753 | {v0, "ED448", "ed448_test.json", Skip}, |
2746 | {"HKDF", "hkdf_sha*_test.json", Normal}, | 2754 | {v0, "HKDF", "hkdf_sha*_test.json", Normal}, |
2747 | {"HMAC", "hmac_sha*_test.json", Normal}, | 2755 | {v0, "HMAC", "hmac_sha*_test.json", Normal}, |
2748 | {"JSON webcrypto", "json_web_*_test.json", Skip}, | 2756 | {v0, "JSON webcrypto", "json_web_*_test.json", Skip}, |
2749 | {"KW", "kw_test.json", Normal}, | 2757 | {v0, "KW", "kw_test.json", Normal}, |
2750 | {"Primality test", "primality_test.json", Normal}, | 2758 | {v0, "Primality test", "primality_test.json", Normal}, |
2751 | {"RSA", "rsa_*test.json", Normal}, | 2759 | {v0, "RSA", "rsa_*test.json", Normal}, |
2752 | {"X25519", "x25519_test.json", Normal}, | 2760 | {v0, "X25519", "x25519_test.json", Normal}, |
2753 | {"X25519 ASN", "x25519_asn_test.json", Skip}, | 2761 | {v0, "X25519 ASN", "x25519_asn_test.json", Skip}, |
2754 | {"X25519 JWK", "x25519_jwk_test.json", Skip}, | 2762 | {v0, "X25519 JWK", "x25519_jwk_test.json", Skip}, |
2755 | {"X25519 PEM", "x25519_pem_test.json", Skip}, | 2763 | {v0, "X25519 PEM", "x25519_pem_test.json", Skip}, |
2756 | {"XCHACHA20-POLY1305", "xchacha20_poly1305_test.json", Normal}, | 2764 | {v0, "XCHACHA20-POLY1305", "xchacha20_poly1305_test.json", Normal}, |
2757 | } | 2765 | } |
2758 | 2766 | ||
2759 | success := true | 2767 | success := true |
@@ -2772,6 +2780,9 @@ func main() { | |||
2772 | 2780 | ||
2773 | for _, test := range tests { | 2781 | for _, test := range tests { |
2774 | path := testVectorPath | 2782 | path := testVectorPath |
2783 | if test.version == v1 { | ||
2784 | path = path + "_v1" | ||
2785 | } | ||
2775 | tvs, err := filepath.Glob(filepath.Join(path, test.pattern)) | 2786 | tvs, err := filepath.Glob(filepath.Join(path, test.pattern)) |
2776 | if err != nil { | 2787 | if err != nil { |
2777 | log.Fatalf("Failed to glob %v test vectors: %v", test.name, err) | 2788 | log.Fatalf("Failed to glob %v test vectors: %v", test.name, err) |
@@ -2786,15 +2797,15 @@ func main() { | |||
2786 | } | 2797 | } |
2787 | wg.Add(1) | 2798 | wg.Add(1) |
2788 | <-vectorsRateLimitCh | 2799 | <-vectorsRateLimitCh |
2789 | go func(tv string, variant testVariant) { | 2800 | go func(tv string, variant testVariant, version wycheproofVersion) { |
2790 | select { | 2801 | select { |
2791 | case resultCh <- runTestVectors(tv, variant): | 2802 | case resultCh <- runTestVectors(tv, variant, version): |
2792 | default: | 2803 | default: |
2793 | log.Fatal("result channel is full") | 2804 | log.Fatal("result channel is full") |
2794 | } | 2805 | } |
2795 | vectorsRateLimitCh <- true | 2806 | vectorsRateLimitCh <- true |
2796 | wg.Done() | 2807 | wg.Done() |
2797 | }(tv, test.variant) | 2808 | }(tv, test.variant, test.version) |
2798 | } | 2809 | } |
2799 | } | 2810 | } |
2800 | 2811 | ||