diff options
author | tb <> | 2025-09-04 16:40:12 +0000 |
---|---|---|
committer | tb <> | 2025-09-04 16:40:12 +0000 |
commit | 5bb84009cdbe7f61b86ba976964b1abca35909ad (patch) | |
tree | 228a84069053f62c8f1185787711e2a6afe85803 /src | |
parent | bb812db6e0414f9cfb2b1f7ea0af5111584a080c (diff) | |
download | openbsd-5bb84009cdbe7f61b86ba976964b1abca35909ad.tar.gz openbsd-5bb84009cdbe7f61b86ba976964b1abca35909ad.tar.bz2 openbsd-5bb84009cdbe7f61b86ba976964b1abca35909ad.zip |
wycheproof: use local variables for testGroups and algorithm
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/wycheproof/wycheproof.go | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go index 7ecb344b5c..930ba4624c 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.162 2025/09/04 16:38:40 tb Exp $ */ | 1 | /* $OpenBSD: wycheproof.go,v 1.163 2025/09/04 16:40:12 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> |
@@ -2645,6 +2645,8 @@ func testGroupFromAlgorithm(algorithm string, variant testVariant) wycheproofTes | |||
2645 | } | 2645 | } |
2646 | 2646 | ||
2647 | func runTestVectors(path string, variant testVariant) bool { | 2647 | func runTestVectors(path string, variant testVariant) bool { |
2648 | var algorithm string | ||
2649 | var testGroups []json.RawMessage | ||
2648 | b, err := ioutil.ReadFile(path) | 2650 | b, err := ioutil.ReadFile(path) |
2649 | if err != nil { | 2651 | if err != nil { |
2650 | log.Fatalf("Failed to read test vectors: %v", err) | 2652 | log.Fatalf("Failed to read test vectors: %v", err) |
@@ -2653,23 +2655,25 @@ func runTestVectors(path string, variant testVariant) bool { | |||
2653 | if err := json.Unmarshal(b, wtv); err != nil { | 2655 | if err := json.Unmarshal(b, wtv); err != nil { |
2654 | log.Fatalf("Failed to unmarshal JSON: %v", err) | 2656 | log.Fatalf("Failed to unmarshal JSON: %v", err) |
2655 | } | 2657 | } |
2656 | fmt.Printf("Loaded Wycheproof test vectors for %v with %d tests from %q\n", wtv.Algorithm, wtv.NumberOfTests, filepath.Base(path)) | 2658 | algorithm = wtv.Algorithm |
2659 | testGroups = wtv.TestGroups | ||
2660 | fmt.Printf("Loaded Wycheproof test vectors for %v with %d tests from %q\n", algorithm, wtv.NumberOfTests, filepath.Base(path)) | ||
2657 | 2661 | ||
2658 | success := true | 2662 | success := true |
2659 | for _, tg := range wtv.TestGroups { | 2663 | for _, tg := range testGroups { |
2660 | wtg := testGroupFromAlgorithm(wtv.Algorithm, variant) | 2664 | wtg := testGroupFromAlgorithm(algorithm, variant) |
2661 | if wtg == nil { | 2665 | if wtg == nil { |
2662 | log.Printf("INFO: Unknown test vector algorithm %q", wtv.Algorithm) | 2666 | log.Printf("INFO: Unknown test vector algorithm %q", algorithm) |
2663 | return false | 2667 | return false |
2664 | } | 2668 | } |
2665 | if err := json.Unmarshal(tg, wtg); err != nil { | 2669 | if err := json.Unmarshal(tg, wtg); err != nil { |
2666 | log.Fatalf("Failed to unmarshal test groups JSON: %v", err) | 2670 | log.Fatalf("Failed to unmarshal test groups JSON: %v", err) |
2667 | } | 2671 | } |
2668 | testc.runTest(func() bool { | 2672 | testc.runTest(func() bool { |
2669 | return wtg.run(wtv.Algorithm, variant) | 2673 | return wtg.run(algorithm, variant) |
2670 | }) | 2674 | }) |
2671 | } | 2675 | } |
2672 | for _ = range wtv.TestGroups { | 2676 | for _ = range testGroups { |
2673 | result := <-testc.resultCh | 2677 | result := <-testc.resultCh |
2674 | if !result { | 2678 | if !result { |
2675 | success = false | 2679 | success = false |