diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/wycheproof/wycheproof.go | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go index 41ad449b96..0463a9b3be 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.164 2025/09/04 16:44:14 tb Exp $ */ | 1 | /* $OpenBSD: wycheproof.go,v 1.165 2025/09/04 16:48:42 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> |
@@ -594,6 +594,15 @@ type wycheproofTestVectors struct { | |||
594 | TestGroups []json.RawMessage `json:"testGroups"` | 594 | TestGroups []json.RawMessage `json:"testGroups"` |
595 | } | 595 | } |
596 | 596 | ||
597 | type wycheproofTestVectorsV1 struct { | ||
598 | Algorithm string `json:"algorithm"` | ||
599 | Schema string `json:"schema"` | ||
600 | NumberOfTests int `json:"numberOfTests"` | ||
601 | Header []string `json:"header"` | ||
602 | Notes json.RawMessage `json:"notes"` | ||
603 | TestGroups []json.RawMessage `json:"testGroups"` | ||
604 | } | ||
605 | |||
597 | var nids = map[string]int{ | 606 | var nids = map[string]int{ |
598 | "brainpoolP224r1": C.NID_brainpoolP224r1, | 607 | "brainpoolP224r1": C.NID_brainpoolP224r1, |
599 | "brainpoolP256r1": C.NID_brainpoolP256r1, | 608 | "brainpoolP256r1": C.NID_brainpoolP256r1, |
@@ -2658,13 +2667,23 @@ func runTestVectors(path string, variant testVariant, version wycheproofVersion) | |||
2658 | if err != nil { | 2667 | if err != nil { |
2659 | log.Fatalf("Failed to read test vectors: %v", err) | 2668 | log.Fatalf("Failed to read test vectors: %v", err) |
2660 | } | 2669 | } |
2661 | wtv := &wycheproofTestVectors{} | 2670 | if version == v0 { |
2662 | if err := json.Unmarshal(b, wtv); err != nil { | 2671 | wtv := &wycheproofTestVectors{} |
2663 | log.Fatalf("Failed to unmarshal JSON: %v", err) | 2672 | if err := json.Unmarshal(b, wtv); err != nil { |
2673 | log.Fatalf("Failed to unmarshal JSON: %v", err) | ||
2674 | } | ||
2675 | algorithm = wtv.Algorithm | ||
2676 | testGroups = wtv.TestGroups | ||
2677 | fmt.Printf("Loaded Wycheproof test vectors for %v with %d tests from %q\n", wtv.Algorithm, wtv.NumberOfTests, filepath.Base(path)) | ||
2678 | } else { | ||
2679 | wtv := &wycheproofTestVectorsV1{} | ||
2680 | if err := json.Unmarshal(b, wtv); err != nil { | ||
2681 | log.Fatalf("Failed to unmarshal JSON: %v", err) | ||
2682 | } | ||
2683 | algorithm = wtv.Algorithm | ||
2684 | testGroups = wtv.TestGroups | ||
2685 | fmt.Printf("Loaded Wycheproof v1 test vectors for %v with %d tests from %q\n", wtv.Algorithm, wtv.NumberOfTests, filepath.Base(path)) | ||
2664 | } | 2686 | } |
2665 | algorithm = wtv.Algorithm | ||
2666 | testGroups = wtv.TestGroups | ||
2667 | fmt.Printf("Loaded Wycheproof test vectors for %v with %d tests from %q\n", algorithm, wtv.NumberOfTests, filepath.Base(path)) | ||
2668 | 2687 | ||
2669 | success := true | 2688 | success := true |
2670 | for _, tg := range testGroups { | 2689 | for _, tg := range testGroups { |