summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2023-11-07 16:27:56 +0000
committertb <>2023-11-07 16:27:56 +0000
commitf2d57e310e7629d8c071efe406019979f64c137a (patch)
treeeece479e6e86e72a06a3b76e1de266775db19d82 /src
parent2a1d4f20a5c9b27e3a2febf2f431454eaab6d805 (diff)
downloadopenbsd-f2d57e310e7629d8c071efe406019979f64c137a.tar.gz
openbsd-f2d57e310e7629d8c071efe406019979f64c137a.tar.bz2
openbsd-f2d57e310e7629d8c071efe406019979f64c137a.zip
Add stringer interfaces to the test groups
This simplifies and unifies a lot of error messages.
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/wycheproof/wycheproof.go228
1 files changed, 126 insertions, 102 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go
index 39f1456b67..fa5a55b93a 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.151 2023/11/06 15:21:44 tb Exp $ */ 1/* $OpenBSD: wycheproof.go,v 1.152 2023/11/07 16:27:56 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2018 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2018 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2018,2019,2022 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2018,2019,2022 Theo Buehler <tb@openbsd.org>
@@ -119,6 +119,10 @@ func (variant testVariant) String() string {
119 return variants[variant] 119 return variants[variant]
120} 120}
121 121
122func wycheproofFormatTestCase(tcid int, comment string, flags []string, result string) string {
123 return fmt.Sprintf("Test case %d (%q) %v %v", tcid, comment, flags, result)
124}
125
122var testc *testCoordinator 126var testc *testCoordinator
123 127
124type wycheproofJWKPublic struct { 128type wycheproofJWKPublic struct {
@@ -156,6 +160,10 @@ type wycheproofTestAesCbcPkcs5 struct {
156 Flags []string `json:"flags"` 160 Flags []string `json:"flags"`
157} 161}
158 162
163func (wt *wycheproofTestAesCbcPkcs5) String() string {
164 return wycheproofFormatTestCase(wt.TCID, wt.Comment, wt.Flags, wt.Result)
165}
166
159type wycheproofTestGroupAead struct { 167type wycheproofTestGroupAead struct {
160 IVSize int `json:"ivSize"` 168 IVSize int `json:"ivSize"`
161 KeySize int `json:"keySize"` 169 KeySize int `json:"keySize"`
@@ -180,6 +188,10 @@ type wycheproofTestAead struct {
180 Flags []string `json:"flags"` 188 Flags []string `json:"flags"`
181} 189}
182 190
191func (wt *wycheproofTestAead) String() string {
192 return wycheproofFormatTestCase(wt.TCID, wt.Comment, wt.Flags, wt.Result)
193}
194
183type wycheproofTestGroupAesCmac struct { 195type wycheproofTestGroupAesCmac struct {
184 KeySize int `json:"keySize"` 196 KeySize int `json:"keySize"`
185 TagSize int `json:"tagSize"` 197 TagSize int `json:"tagSize"`
@@ -197,6 +209,10 @@ type wycheproofTestAesCmac struct {
197 Flags []string `json:"flags"` 209 Flags []string `json:"flags"`
198} 210}
199 211
212func (wt *wycheproofTestAesCmac) String() string {
213 return wycheproofFormatTestCase(wt.TCID, wt.Comment, wt.Flags, wt.Result)
214}
215
200type wycheproofDSAKey struct { 216type wycheproofDSAKey struct {
201 G string `json:"g"` 217 G string `json:"g"`
202 KeySize int `json:"keySize"` 218 KeySize int `json:"keySize"`
@@ -215,6 +231,10 @@ type wycheproofTestDSA struct {
215 Flags []string `json:"flags"` 231 Flags []string `json:"flags"`
216} 232}
217 233
234func (wt *wycheproofTestDSA) String() string {
235 return wycheproofFormatTestCase(wt.TCID, wt.Comment, wt.Flags, wt.Result)
236}
237
218type wycheproofTestGroupDSA struct { 238type wycheproofTestGroupDSA struct {
219 Key *wycheproofDSAKey `json:"key"` 239 Key *wycheproofDSAKey `json:"key"`
220 KeyDER string `json:"keyDer"` 240 KeyDER string `json:"keyDer"`
@@ -234,6 +254,10 @@ type wycheproofTestECDH struct {
234 Flags []string `json:"flags"` 254 Flags []string `json:"flags"`
235} 255}
236 256
257func (wt *wycheproofTestECDH) String() string {
258 return wycheproofFormatTestCase(wt.TCID, wt.Comment, wt.Flags, wt.Result)
259}
260
237type wycheproofTestGroupECDH struct { 261type wycheproofTestGroupECDH struct {
238 Curve string `json:"curve"` 262 Curve string `json:"curve"`
239 Encoding string `json:"encoding"` 263 Encoding string `json:"encoding"`
@@ -251,6 +275,10 @@ type wycheproofTestECDHWebCrypto struct {
251 Flags []string `json:"flags"` 275 Flags []string `json:"flags"`
252} 276}
253 277
278func (wt *wycheproofTestECDHWebCrypto) String() string {
279 return wycheproofFormatTestCase(wt.TCID, wt.Comment, wt.Flags, wt.Result)
280}
281
254type wycheproofTestGroupECDHWebCrypto struct { 282type wycheproofTestGroupECDHWebCrypto struct {
255 Curve string `json:"curve"` 283 Curve string `json:"curve"`
256 Encoding string `json:"encoding"` 284 Encoding string `json:"encoding"`
@@ -276,6 +304,10 @@ type wycheproofTestECDSA struct {
276 Flags []string `json:"flags"` 304 Flags []string `json:"flags"`
277} 305}
278 306
307func (wt *wycheproofTestECDSA) String() string {
308 return wycheproofFormatTestCase(wt.TCID, wt.Comment, wt.Flags, wt.Result)
309}
310
279type wycheproofTestGroupECDSA struct { 311type wycheproofTestGroupECDSA struct {
280 Key *wycheproofECDSAKey `json:"key"` 312 Key *wycheproofECDSAKey `json:"key"`
281 KeyDER string `json:"keyDer"` 313 KeyDER string `json:"keyDer"`
@@ -320,6 +352,10 @@ type wycheproofTestEdDSA struct {
320 Flags []string `json:"flags"` 352 Flags []string `json:"flags"`
321} 353}
322 354
355func (wt *wycheproofTestEdDSA) String() string {
356 return wycheproofFormatTestCase(wt.TCID, wt.Comment, wt.Flags, wt.Result)
357}
358
323type wycheproofTestGroupEdDSA struct { 359type wycheproofTestGroupEdDSA struct {
324 JWK *wycheproofJWKEdDSA `json:"jwk"` 360 JWK *wycheproofJWKEdDSA `json:"jwk"`
325 Key *wycheproofEdDSAKey `json:"key"` 361 Key *wycheproofEdDSAKey `json:"key"`
@@ -341,6 +377,10 @@ type wycheproofTestHkdf struct {
341 Flags []string `json:"flags"` 377 Flags []string `json:"flags"`
342} 378}
343 379
380func (wt *wycheproofTestHkdf) String() string {
381 return wycheproofFormatTestCase(wt.TCID, wt.Comment, wt.Flags, wt.Result)
382}
383
344type wycheproofTestGroupHkdf struct { 384type wycheproofTestGroupHkdf struct {
345 Type string `json:"type"` 385 Type string `json:"type"`
346 KeySize int `json:"keySize"` 386 KeySize int `json:"keySize"`
@@ -357,6 +397,10 @@ type wycheproofTestHmac struct {
357 Flags []string `json:"flags"` 397 Flags []string `json:"flags"`
358} 398}
359 399
400func (wt *wycheproofTestHmac) String() string {
401 return wycheproofFormatTestCase(wt.TCID, wt.Comment, wt.Flags, wt.Result)
402}
403
360type wycheproofTestGroupHmac struct { 404type wycheproofTestGroupHmac struct {
361 KeySize int `json:"keySize"` 405 KeySize int `json:"keySize"`
362 TagSize int `json:"tagSize"` 406 TagSize int `json:"tagSize"`
@@ -374,6 +418,10 @@ type wycheproofTestKW struct {
374 Flags []string `json:"flags"` 418 Flags []string `json:"flags"`
375} 419}
376 420
421func (wt *wycheproofTestKW) String() string {
422 return wycheproofFormatTestCase(wt.TCID, wt.Comment, wt.Flags, wt.Result)
423}
424
377type wycheproofTestGroupKW struct { 425type wycheproofTestGroupKW struct {
378 KeySize int `json:"keySize"` 426 KeySize int `json:"keySize"`
379 Type string `json:"type"` 427 Type string `json:"type"`
@@ -388,6 +436,10 @@ type wycheproofTestPrimality struct {
388 Flags []string `json:"flags"` 436 Flags []string `json:"flags"`
389} 437}
390 438
439func (wt *wycheproofTestPrimality) String() string {
440 return wycheproofFormatTestCase(wt.TCID, wt.Comment, wt.Flags, wt.Result)
441}
442
391type wycheproofTestGroupPrimality struct { 443type wycheproofTestGroupPrimality struct {
392 Type string `json:"type"` 444 Type string `json:"type"`
393 Tests []*wycheproofTestPrimality `json:"tests"` 445 Tests []*wycheproofTestPrimality `json:"tests"`
@@ -403,6 +455,10 @@ type wycheproofTestRSA struct {
403 Flags []string `json:"flags"` 455 Flags []string `json:"flags"`
404} 456}
405 457
458func (wt *wycheproofTestRSA) String() string {
459 return wycheproofFormatTestCase(wt.TCID, wt.Comment, wt.Flags, wt.Result)
460}
461
406type wycheproofTestGroupRSA struct { 462type wycheproofTestGroupRSA struct {
407 E string `json:"e"` 463 E string `json:"e"`
408 KeyASN string `json:"keyAsn"` 464 KeyASN string `json:"keyAsn"`
@@ -439,6 +495,10 @@ type wycheproofTestRsaes struct {
439 Flags []string `json:"flags"` 495 Flags []string `json:"flags"`
440} 496}
441 497
498func (wt *wycheproofTestRsaes) String() string {
499 return wycheproofFormatTestCase(wt.TCID, wt.Comment, wt.Flags, wt.Result)
500}
501
442type wycheproofTestGroupRsaesOaep struct { 502type wycheproofTestGroupRsaesOaep struct {
443 D string `json:"d"` 503 D string `json:"d"`
444 E string `json:"e"` 504 E string `json:"e"`
@@ -475,6 +535,10 @@ type wycheproofTestRsassa struct {
475 Flags []string `json:"flags"` 535 Flags []string `json:"flags"`
476} 536}
477 537
538func (wt *wycheproofTestRsassa) String() string {
539 return wycheproofFormatTestCase(wt.TCID, wt.Comment, wt.Flags, wt.Result)
540}
541
478type wycheproofTestGroupRsassa struct { 542type wycheproofTestGroupRsassa struct {
479 E string `json:"e"` 543 E string `json:"e"`
480 KeyASN string `json:"keyAsn"` 544 KeyASN string `json:"keyAsn"`
@@ -501,6 +565,10 @@ type wycheproofTestX25519 struct {
501 Flags []string `json:"flags"` 565 Flags []string `json:"flags"`
502} 566}
503 567
568func (wt *wycheproofTestX25519) String() string {
569 return wycheproofFormatTestCase(wt.TCID, wt.Comment, wt.Flags, wt.Result)
570}
571
504type wycheproofTestGroupX25519 struct { 572type wycheproofTestGroupX25519 struct {
505 Curve string `json:"curve"` 573 Curve string `json:"curve"`
506 Tests []*wycheproofTestX25519 `json:"tests"` 574 Tests []*wycheproofTestX25519 `json:"tests"`
@@ -645,12 +713,10 @@ func checkAesCbcPkcs5(ctx *C.EVP_CIPHER_CTX, doEncrypt int, key []byte, keyLen i
645 (*C.uchar)(unsafe.Pointer(&in[0])), C.int(inLen)) 713 (*C.uchar)(unsafe.Pointer(&in[0])), C.int(inLen))
646 if ret != 1 { 714 if ret != 1 {
647 if wt.Result == "invalid" { 715 if wt.Result == "invalid" {
648 fmt.Printf("INFO: Test case %d (%q) [%v] %v - EVP_CipherUpdate() = %d, want %v\n", 716 fmt.Printf("INFO: %s [%v] - EVP_CipherUpdate() = %d\n", wt, action, ret)
649 wt.TCID, wt.Comment, action, wt.Flags, ret, wt.Result)
650 return true 717 return true
651 } 718 }
652 fmt.Printf("FAIL: Test case %d (%q) [%v] %v - EVP_CipherUpdate() = %d, want %v\n", 719 fmt.Printf("FAIL: %s [%v] - EVP_CipherUpdate() = %d\n", wt, action, ret)
653 wt.TCID, wt.Comment, action, wt.Flags, ret, wt.Result)
654 return false 720 return false
655 } 721 }
656 722
@@ -660,15 +726,13 @@ func checkAesCbcPkcs5(ctx *C.EVP_CIPHER_CTX, doEncrypt int, key []byte, keyLen i
660 if wt.Result == "invalid" { 726 if wt.Result == "invalid" {
661 return true 727 return true
662 } 728 }
663 fmt.Printf("FAIL: Test case %d (%q) [%v] %v - EVP_CipherFinal_ex() = %d, want %v\n", 729 fmt.Printf("FAIL: %s [%v] - EVP_CipherFinal_ex() = %d\n", wt, action, ret)
664 wt.TCID, wt.Comment, action, wt.Flags, ret, wt.Result)
665 return false 730 return false
666 } 731 }
667 732
668 cipherOutLen += finallen 733 cipherOutLen += finallen
669 if cipherOutLen != C.int(outLen) && wt.Result != "invalid" { 734 if cipherOutLen != C.int(outLen) && wt.Result != "invalid" {
670 fmt.Printf("FAIL: Test case %d (%q) [%v] %v - open length mismatch: got %d, want %d\n", 735 fmt.Printf("FAIL: %s [%v] - open length mismatch: got %d, want %d\n", wt, action, cipherOutLen, outLen)
671 wt.TCID, wt.Comment, action, wt.Flags, cipherOutLen, outLen)
672 return false 736 return false
673 } 737 }
674 738
@@ -681,8 +745,7 @@ func checkAesCbcPkcs5(ctx *C.EVP_CIPHER_CTX, doEncrypt int, key []byte, keyLen i
681 if bytes.Equal(openedMsg, out) == (wt.Result != "invalid") { 745 if bytes.Equal(openedMsg, out) == (wt.Result != "invalid") {
682 success = true 746 success = true
683 } else { 747 } else {
684 fmt.Printf("FAIL: Test case %d (%q) [%v] %v - msg match: %t; want %v\n", 748 fmt.Printf("FAIL: %s [%v] - msg match: %t\n", wt, action, bytes.Equal(openedMsg, out))
685 wt.TCID, wt.Comment, action, wt.Flags, bytes.Equal(openedMsg, out), wt.Result)
686 } 749 }
687 return success 750 return success
688} 751}
@@ -804,8 +867,7 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int,
804 wt.Comment == "0 size IV is not valid" || wt.Comment == "Very long nonce" { 867 wt.Comment == "0 size IV is not valid" || wt.Comment == "Very long nonce" {
805 return true 868 return true
806 } 869 }
807 fmt.Printf("FAIL: Test case %d (%q) [%v] %v - setting IV len to %d failed. got %d, want %v\n", 870 fmt.Printf("FAIL: %s [%v] - setting IV len to %d failed: %d.\n", wt, action, ivLen, ret)
808 wt.TCID, wt.Comment, action, wt.Flags, ivLen, ret, wt.Result)
809 return false 871 return false
810 } 872 }
811 873
@@ -815,8 +877,7 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int,
815 if wt.Comment == "Invalid tag size" { 877 if wt.Comment == "Invalid tag size" {
816 return true 878 return true
817 } 879 }
818 fmt.Printf("FAIL: Test case %d (%q) [%v] %v - setting tag length to %d failed. got %d, want %v\n", 880 fmt.Printf("FAIL: %s [%v] - setting tag length to %d failed: %d.\n", wt, action, tagLen, ret)
819 wt.TCID, wt.Comment, action, wt.Flags, tagLen, ret, wt.Result)
820 return false 881 return false
821 } 882 }
822 } 883 }
@@ -824,8 +885,7 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int,
824 ret = C.EVP_CipherInit_ex(ctx, nil, nil, (*C.uchar)(unsafe.Pointer(&key[0])), 885 ret = C.EVP_CipherInit_ex(ctx, nil, nil, (*C.uchar)(unsafe.Pointer(&key[0])),
825 (*C.uchar)(unsafe.Pointer(&iv[0])), C.int(doEncrypt)) 886 (*C.uchar)(unsafe.Pointer(&iv[0])), C.int(doEncrypt))
826 if ret != 1 { 887 if ret != 1 {
827 fmt.Printf("FAIL: Test case %d (%q) [%v] %v - setting key and IV failed. got %d, want %v\n", 888 fmt.Printf("FAIL: %s [%v] - setting key and IV failed: %d.\n", wt, action, ret)
828 wt.TCID, wt.Comment, action, wt.Flags, ret, wt.Result)
829 return false 889 return false
830 } 890 }
831 891
@@ -833,16 +893,14 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int,
833 if doCCM { 893 if doCCM {
834 ret = C.EVP_CipherUpdate(ctx, nil, &cipherOutLen, nil, C.int(inLen)) 894 ret = C.EVP_CipherUpdate(ctx, nil, &cipherOutLen, nil, C.int(inLen))
835 if ret != 1 { 895 if ret != 1 {
836 fmt.Printf("FAIL: Test case %d (%q) [%v] %v - setting input length to %d failed. got %d, want %v\n", 896 fmt.Printf("FAIL: %s [%v] - setting input length to %d failed: %d.\n", wt, action, inLen, ret)
837 wt.TCID, wt.Comment, action, wt.Flags, inLen, ret, wt.Result)
838 return false 897 return false
839 } 898 }
840 } 899 }
841 900
842 ret = C.EVP_CipherUpdate(ctx, nil, &cipherOutLen, (*C.uchar)(unsafe.Pointer(&aad[0])), C.int(aadLen)) 901 ret = C.EVP_CipherUpdate(ctx, nil, &cipherOutLen, (*C.uchar)(unsafe.Pointer(&aad[0])), C.int(aadLen))
843 if ret != 1 { 902 if ret != 1 {
844 fmt.Printf("FAIL: Test case %d (%q) [%v] %v - processing AAD failed. got %d, want %v\n", 903 fmt.Printf("FAIL: %s [%v] - processing AAD failed: %d.\n", wt, action, ret)
845 wt.TCID, wt.Comment, action, wt.Flags, ret, wt.Result)
846 return false 904 return false
847 } 905 }
848 906
@@ -858,8 +916,7 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int,
858 if wt.Result == "invalid" { 916 if wt.Result == "invalid" {
859 return true 917 return true
860 } 918 }
861 fmt.Printf("FAIL: Test case %d (%q) [%v] %v - EVP_CipherUpdate() = %d, want %v\n", 919 fmt.Printf("FAIL: %s [%v] - EVP_CipherUpdate() = %d.\n", wt, action, ret)
862 wt.TCID, wt.Comment, action, wt.Flags, ret, wt.Result)
863 return false 920 return false
864 } 921 }
865 922
@@ -869,31 +926,27 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int,
869 926
870 ret = C.EVP_CipherFinal_ex(ctx, (*C.uchar)(unsafe.Pointer(&dummyOut[0])), &tmpLen) 927 ret = C.EVP_CipherFinal_ex(ctx, (*C.uchar)(unsafe.Pointer(&dummyOut[0])), &tmpLen)
871 if ret != 1 { 928 if ret != 1 {
872 fmt.Printf("FAIL: Test case %d (%q) [%v] %v - EVP_CipherFinal_ex() = %d, want %v\n", 929 fmt.Printf("FAIL: %s [%v] - EVP_CipherFinal_ex() = %d.\n", wt, action, ret)
873 wt.TCID, wt.Comment, action, wt.Flags, ret, wt.Result)
874 return false 930 return false
875 } 931 }
876 cipherOutLen += tmpLen 932 cipherOutLen += tmpLen
877 } 933 }
878 934
879 if cipherOutLen != C.int(outLen) { 935 if cipherOutLen != C.int(outLen) {
880 fmt.Printf("FAIL: Test case %d (%q) [%v] %v - cipherOutLen %d != outLen %d. Result %v\n", 936 fmt.Printf("FAIL: %s [%v] - cipherOutLen %d != outLen %d.\n", wt, action, cipherOutLen, outLen)
881 wt.TCID, wt.Comment, action, wt.Flags, cipherOutLen, outLen, wt.Result)
882 return false 937 return false
883 } 938 }
884 939
885 success := true 940 success := true
886 if !bytes.Equal(cipherOut, out) { 941 if !bytes.Equal(cipherOut, out) {
887 fmt.Printf("FAIL: Test case %d (%q) [%v] %v - expected and computed output do not match. Result: %v\n", 942 fmt.Printf("FAIL: %s [%v] - expected and computed output do not match.\n", wt, action)
888 wt.TCID, wt.Comment, action, wt.Flags, wt.Result)
889 success = false 943 success = false
890 } 944 }
891 if doEncrypt == 1 { 945 if doEncrypt == 1 {
892 tagOut := make([]byte, tagLen) 946 tagOut := make([]byte, tagLen)
893 ret = C.EVP_CIPHER_CTX_ctrl(ctx, ctrlGetTag, C.int(tagLen), unsafe.Pointer(&tagOut[0])) 947 ret = C.EVP_CIPHER_CTX_ctrl(ctx, ctrlGetTag, C.int(tagLen), unsafe.Pointer(&tagOut[0]))
894 if ret != 1 { 948 if ret != 1 {
895 fmt.Printf("FAIL: Test case %d (%q) [%v] %v - EVP_CIPHER_CTX_ctrl() = %d, want %v\n", 949 fmt.Printf("FAIL: %s [%v] - EVP_CIPHER_CTX_ctrl() = %d.\n", wt, action, ret)
896 wt.TCID, wt.Comment, action, wt.Flags, ret, wt.Result)
897 return false 950 return false
898 } 951 }
899 952
@@ -904,8 +957,7 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int,
904 // support to the length of 96 bits, to promote 957 // support to the length of 96 bits, to promote
905 // interoperability, efficiency and simplicity of design." 958 // interoperability, efficiency and simplicity of design."
906 if bytes.Equal(tagOut, tag) != (wt.Result == "valid" || wt.Result == "acceptable") { 959 if bytes.Equal(tagOut, tag) != (wt.Result == "valid" || wt.Result == "acceptable") {
907 fmt.Printf("FAIL: Test case %d (%q) [%v] %v - expected and computed tag do not match - ret: %d, Result: %v\n", 960 fmt.Printf("FAIL: %s [%v] - expected and computed tag do not match: %d.\n", wt, action, ret)
908 wt.TCID, wt.Comment, action, wt.Flags, ret, wt.Result)
909 success = false 961 success = false
910 } 962 }
911 } 963 }
@@ -1087,8 +1139,7 @@ func runAesCmacTest(cipher *C.EVP_CIPHER, wt *wycheproofTestAesCmac) bool {
1087 1139
1088 ret := C.EVP_DigestSignInit(mdctx, nil, nil, nil, pkey) 1140 ret := C.EVP_DigestSignInit(mdctx, nil, nil, nil, pkey)
1089 if ret != 1 { 1141 if ret != 1 {
1090 fmt.Printf("FAIL: Test case %d (%q) %v - EVP_DigestSignInit() = %d, want %v\n", 1142 fmt.Printf("FAIL: %s - EVP_DigestSignInit() = %d.\n", wt, ret)
1091 wt.TCID, wt.Comment, wt.Flags, ret, wt.Result)
1092 return false 1143 return false
1093 } 1144 }
1094 1145
@@ -1097,8 +1148,7 @@ func runAesCmacTest(cipher *C.EVP_CIPHER, wt *wycheproofTestAesCmac) bool {
1097 1148
1098 ret = C.EVP_DigestSign(mdctx, (*C.uchar)(unsafe.Pointer(&outTag[0])), &outLen, (*C.uchar)(unsafe.Pointer(&msg[0])), C.size_t(msgLen)) 1149 ret = C.EVP_DigestSign(mdctx, (*C.uchar)(unsafe.Pointer(&outTag[0])), &outLen, (*C.uchar)(unsafe.Pointer(&msg[0])), C.size_t(msgLen))
1099 if ret != 1 { 1150 if ret != 1 {
1100 fmt.Printf("FAIL: Test case %d (%q) %v - EVP_DigestSign() = %d, want %v\n", 1151 fmt.Printf("FAIL: %s - EVP_DigestSign() = %d.\n", wt, ret)
1101 wt.TCID, wt.Comment, wt.Flags, ret, wt.Result)
1102 return false 1152 return false
1103 } 1153 }
1104 1154
@@ -1106,8 +1156,7 @@ func runAesCmacTest(cipher *C.EVP_CIPHER, wt *wycheproofTestAesCmac) bool {
1106 1156
1107 success := true 1157 success := true
1108 if bytes.Equal(tag, outTag) != (wt.Result == "valid") { 1158 if bytes.Equal(tag, outTag) != (wt.Result == "valid") {
1109 fmt.Printf("FAIL: Test case %d (%q) %v - want %v\n", 1159 fmt.Printf("FAIL: %s.\n", wt)
1110 wt.TCID, wt.Comment, wt.Flags, wt.Result)
1111 success = false 1160 success = false
1112 } 1161 }
1113 return success 1162 return success
@@ -1164,14 +1213,12 @@ func checkAeadOpen(ctx *C.EVP_AEAD_CTX, iv []byte, ivLen int, aad []byte, aadLen
1164 if wt.Result == "invalid" { 1213 if wt.Result == "invalid" {
1165 return true 1214 return true
1166 } 1215 }
1167 fmt.Printf("FAIL: Test case %d (%q) %v - EVP_AEAD_CTX_open() = %d, want %v\n", 1216 fmt.Printf("FAIL: %s - EVP_AEAD_CTX_open() = %d.\n", wt, int(openRet))
1168 wt.TCID, wt.Comment, wt.Flags, int(openRet), wt.Result)
1169 return false 1217 return false
1170 } 1218 }
1171 1219
1172 if openedMsgLen != C.size_t(msgLen) { 1220 if openedMsgLen != C.size_t(msgLen) {
1173 fmt.Printf("FAIL: Test case %d (%q) %v - open length mismatch: got %d, want %d\n", 1221 fmt.Printf("FAIL: %s - open length mismatch: got %d, want %d.\n", wt, openedMsgLen, msgLen)
1174 wt.TCID, wt.Comment, wt.Flags, openedMsgLen, msgLen)
1175 return false 1222 return false
1176 } 1223 }
1177 1224
@@ -1184,8 +1231,7 @@ func checkAeadOpen(ctx *C.EVP_AEAD_CTX, iv []byte, ivLen int, aad []byte, aadLen
1184 if bytes.Equal(openedMsg, msg) == (wt.Result != "invalid") { 1231 if bytes.Equal(openedMsg, msg) == (wt.Result != "invalid") {
1185 success = true 1232 success = true
1186 } else { 1233 } else {
1187 fmt.Printf("FAIL: Test case %d (%q) %v - msg match: %t; want %v\n", 1234 fmt.Printf("FAIL: %s - msg match: %t.\n", wt, bytes.Equal(openedMsg, msg))
1188 wt.TCID, wt.Comment, wt.Flags, bytes.Equal(openedMsg, msg), wt.Result)
1189 } 1235 }
1190 return success 1236 return success
1191} 1237}
@@ -1209,14 +1255,13 @@ func checkAeadSeal(ctx *C.EVP_AEAD_CTX, iv []byte, ivLen int, aad []byte, aadLen
1209 if sealRet != 1 { 1255 if sealRet != 1 {
1210 success := (wt.Result == "invalid") 1256 success := (wt.Result == "invalid")
1211 if !success { 1257 if !success {
1212 fmt.Printf("FAIL: Test case %d (%q) %v - EVP_AEAD_CTX_seal() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, int(sealRet), wt.Result) 1258 fmt.Printf("FAIL: %s - EVP_AEAD_CTX_seal() = %d.\n", wt, int(sealRet))
1213 } 1259 }
1214 return success 1260 return success
1215 } 1261 }
1216 1262
1217 if sealedLen != C.size_t(maxOutLen) { 1263 if sealedLen != C.size_t(maxOutLen) {
1218 fmt.Printf("FAIL: Test case %d (%q) %v - seal length mismatch: got %d, want %d\n", 1264 fmt.Printf("FAIL: %s - seal length mismatch: got %d, want %d.\n", wt, sealedLen, maxOutLen)
1219 wt.TCID, wt.Comment, wt.Flags, sealedLen, maxOutLen)
1220 return false 1265 return false
1221 } 1266 }
1222 1267
@@ -1227,9 +1272,7 @@ func checkAeadSeal(ctx *C.EVP_AEAD_CTX, iv []byte, ivLen int, aad []byte, aadLen
1227 if (bytes.Equal(sealedCt, ct) && bytes.Equal(sealedTag, tag)) == (wt.Result != "invalid") { 1272 if (bytes.Equal(sealedCt, ct) && bytes.Equal(sealedTag, tag)) == (wt.Result != "invalid") {
1228 success = true 1273 success = true
1229 } else { 1274 } else {
1230 fmt.Printf("FAIL: Test case %d (%q) %v - EVP_AEAD_CTX_seal() = %d, ct match: %t, tag match: %t; want %v\n", 1275 fmt.Printf("FAIL: %s - EVP_AEAD_CTX_seal() = %d, ct match: %t, tag match: %t.\n", wt, int(sealRet), bytes.Equal(sealedCt, ct), bytes.Equal(sealedTag, tag))
1231 wt.TCID, wt.Comment, wt.Flags, int(sealRet),
1232 bytes.Equal(sealedCt, ct), bytes.Equal(sealedTag, tag), wt.Result)
1233 } 1276 }
1234 return success 1277 return success
1235} 1278}
@@ -1398,8 +1441,7 @@ func runDSATest(dsa *C.DSA, md *C.EVP_MD, variant testVariant, wt *wycheproofTes
1398 1441
1399 success := true 1442 success := true
1400 if ret == 1 != (wt.Result == "valid") { 1443 if ret == 1 != (wt.Result == "valid") {
1401 fmt.Printf("FAIL: Test case %d (%q) %v - DSA_verify() = %d, want %v\n", 1444 fmt.Printf("FAIL: %s - DSA_verify() = %d.\n", wt, wt.Result)
1402 wt.TCID, wt.Comment, wt.Flags, ret, wt.Result)
1403 success = false 1445 success = false
1404 } 1446 }
1405 return success 1447 return success
@@ -1525,8 +1567,7 @@ func runECDHTest(nid int, variant testVariant, wt *wycheproofTestECDH) bool {
1525 1567
1526 ret := C.EC_KEY_set_private_key(privKey, bnPriv) 1568 ret := C.EC_KEY_set_private_key(privKey, bnPriv)
1527 if ret != 1 { 1569 if ret != 1 {
1528 fmt.Printf("FAIL: Test case %d (%q) %v - EC_KEY_set_private_key() = %d, want %v\n", 1570 fmt.Printf("FAIL: %s - EC_KEY_set_private_key() = %d.\n", wt, ret)
1529 wt.TCID, wt.Comment, wt.Flags, ret, wt.Result)
1530 return false 1571 return false
1531 } 1572 }
1532 1573
@@ -1564,8 +1605,7 @@ func runECDHTest(nid int, variant testVariant, wt *wycheproofTestECDH) bool {
1564 if wt.Result == "invalid" || wt.Result == "acceptable" { 1605 if wt.Result == "invalid" || wt.Result == "acceptable" {
1565 return true 1606 return true
1566 } 1607 }
1567 fmt.Printf("FAIL: Test case %d (%q) %v - ASN decoding failed: want %v\n", 1608 fmt.Printf("FAIL: %s - ASN decoding failed.\n", wt)
1568 wt.TCID, wt.Comment, wt.Flags, wt.Result)
1569 return false 1609 return false
1570 } 1610 }
1571 1611
@@ -1585,8 +1625,7 @@ func runECDHTest(nid int, variant testVariant, wt *wycheproofTestECDH) bool {
1585 if wt.Result == "invalid" { 1625 if wt.Result == "invalid" {
1586 return true 1626 return true
1587 } 1627 }
1588 fmt.Printf("FAIL: Test case %d (%q) %v - ECDH_compute_key() = %d, want %d, result: %v\n", 1628 fmt.Printf("FAIL: %s - ECDH_compute_key() = %d, want %d.\n", wt, ret, int(secLen))
1589 wt.TCID, wt.Comment, wt.Flags, ret, int(secLen), wt.Result)
1590 return false 1629 return false
1591 } 1630 }
1592 1631
@@ -1597,7 +1636,7 @@ func runECDHTest(nid int, variant testVariant, wt *wycheproofTestECDH) bool {
1597 1636
1598 // XXX The shared fields of the secp224k1 test cases have a 0 byte preprended. 1637 // XXX The shared fields of the secp224k1 test cases have a 0 byte preprended.
1599 if len(shared) == int(secLen)+1 && shared[0] == 0 { 1638 if len(shared) == int(secLen)+1 && shared[0] == 0 {
1600 fmt.Printf("INFO: Test case %d (%q) %v - prepending 0 byte\n", wt.TCID, wt.Comment, wt.Flags) 1639 fmt.Printf("INFO: %s - prepending 0 byte.\n", wt)
1601 // shared = shared[1:]; 1640 // shared = shared[1:];
1602 zero := make([]byte, 1, secLen+1) 1641 zero := make([]byte, 1, secLen+1)
1603 secret = append(zero, secret...) 1642 secret = append(zero, secret...)
@@ -1605,8 +1644,7 @@ func runECDHTest(nid int, variant testVariant, wt *wycheproofTestECDH) bool {
1605 1644
1606 success := true 1645 success := true
1607 if !bytes.Equal(shared, secret) { 1646 if !bytes.Equal(shared, secret) {
1608 fmt.Printf("FAIL: Test case %d (%q) %v - expected and computed shared secret do not match, want %v\n", 1647 fmt.Printf("FAIL: %s - expected and computed shared secret do not match.\n", wt)
1609 wt.TCID, wt.Comment, wt.Flags, wt.Result)
1610 success = false 1648 success = false
1611 } 1649 }
1612 return success 1650 return success
@@ -1649,8 +1687,7 @@ func runECDHWebCryptoTest(nid int, wt *wycheproofTestECDHWebCrypto) bool {
1649 1687
1650 ret := C.EC_KEY_set_private_key(privKey, bnD) 1688 ret := C.EC_KEY_set_private_key(privKey, bnD)
1651 if ret != 1 { 1689 if ret != 1 {
1652 fmt.Printf("FAIL: Test case %d (%q) %v - EC_KEY_set_private_key() = %d, want %v\n", 1690 fmt.Printf("FAIL: %s - EC_KEY_set_private_key() = %d.\n", wt, ret)
1653 wt.TCID, wt.Comment, wt.Flags, ret, wt.Result)
1654 return false 1691 return false
1655 } 1692 }
1656 1693
@@ -1685,8 +1722,7 @@ func runECDHWebCryptoTest(nid int, wt *wycheproofTestECDHWebCrypto) bool {
1685 if wt.Result == "invalid" { 1722 if wt.Result == "invalid" {
1686 return true 1723 return true
1687 } 1724 }
1688 fmt.Printf("FAIL: Test case %d (%q) %v - EC_KEY_set_public_key_affine_coordinates() = %d, want %v\n", 1725 fmt.Printf("FAIL: %s - EC_KEY_set_public_key_affine_coordinates() = %d.\n", wt, ret)
1689 wt.TCID, wt.Comment, wt.Flags, ret, wt.Result)
1690 return false 1726 return false
1691 } 1727 }
1692 pubPoint := C.EC_KEY_get0_public_key(pubKey) 1728 pubPoint := C.EC_KEY_get0_public_key(pubKey)
@@ -1705,8 +1741,7 @@ func runECDHWebCryptoTest(nid int, wt *wycheproofTestECDHWebCrypto) bool {
1705 if wt.Result == "invalid" { 1741 if wt.Result == "invalid" {
1706 return true 1742 return true
1707 } 1743 }
1708 fmt.Printf("FAIL: Test case %d (%q) %v - ECDH_compute_key() = %d, want %d, result: %v\n", 1744 fmt.Printf("FAIL: %s - ECDH_compute_key() = %d, want %d.\n", wt, ret, int(secLen))
1709 wt.TCID, wt.Comment, wt.Flags, ret, int(secLen), wt.Result)
1710 return false 1745 return false
1711 } 1746 }
1712 1747
@@ -1717,8 +1752,7 @@ func runECDHWebCryptoTest(nid int, wt *wycheproofTestECDHWebCrypto) bool {
1717 1752
1718 success := true 1753 success := true
1719 if !bytes.Equal(shared, secret) { 1754 if !bytes.Equal(shared, secret) {
1720 fmt.Printf("FAIL: Test case %d (%q) %v - expected and computed shared secret do not match, want %v\n", 1755 fmt.Printf("FAIL: %s - expected and computed shared secret do not match.\n", wt)
1721 wt.TCID, wt.Comment, wt.Flags, wt.Result)
1722 success = false 1756 success = false
1723 } 1757 }
1724 return success 1758 return success
@@ -1781,8 +1815,7 @@ func runECDSATest(ecKey *C.EC_KEY, md *C.EVP_MD, nid int, variant testVariant, w
1781 // XXX audit acceptable cases... 1815 // XXX audit acceptable cases...
1782 success := true 1816 success := true
1783 if ret == 1 != (wt.Result == "valid") && wt.Result != "acceptable" { 1817 if ret == 1 != (wt.Result == "valid") && wt.Result != "acceptable" {
1784 fmt.Printf("FAIL: Test case %d (%q) %v - ECDSA_verify() = %d, want %v\n", 1818 fmt.Printf("FAIL: %s - ECDSA_verify() = %d.\n", wt, int(ret))
1785 wt.TCID, wt.Comment, wt.Flags, int(ret), wt.Result)
1786 success = false 1819 success = false
1787 } 1820 }
1788 return success 1821 return success
@@ -1977,8 +2010,7 @@ func runEdDSATest(pkey *C.EVP_PKEY, wt *wycheproofTestEdDSA) bool {
1977 2010
1978 success := true 2011 success := true
1979 if (ret == 1) != (wt.Result == "valid") { 2012 if (ret == 1) != (wt.Result == "valid") {
1980 fmt.Printf("FAIL: Test case %d (%q) %v - EVP_DigestVerify() = %d, want %v\n", 2013 fmt.Printf("FAIL: %s - EVP_DigestVerify() = %d.\n", wt, int(ret))
1981 wt.TCID, wt.Comment, wt.Flags, int(ret), wt.Result)
1982 success = false 2014 success = false
1983 } 2015 }
1984 return success 2016 return success
@@ -2078,7 +2110,7 @@ func runHkdfTest(md *C.EVP_MD, wt *wycheproofTestHkdf) bool {
2078 if ret <= 0 { 2110 if ret <= 0 {
2079 success := wt.Result == "invalid" 2111 success := wt.Result == "invalid"
2080 if !success { 2112 if !success {
2081 fmt.Printf("FAIL: Test case %d (%q) %v - got %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, ret, wt.Result) 2113 fmt.Printf("FAIL: %s - got %d.\n", wt, ret)
2082 } 2114 }
2083 return success 2115 return success
2084 } 2116 }
@@ -2088,7 +2120,7 @@ func runHkdfTest(md *C.EVP_MD, wt *wycheproofTestHkdf) bool {
2088 log.Fatalf("Failed to decode okm %q: %v", wt.Okm, err) 2120 log.Fatalf("Failed to decode okm %q: %v", wt.Okm, err)
2089 } 2121 }
2090 if !bytes.Equal(out[:outLen], okm) { 2122 if !bytes.Equal(out[:outLen], okm) {
2091 fmt.Printf("FAIL: Test case %d (%q) %v - expected and computed output don't match: %v\n", wt.TCID, wt.Comment, wt.Flags, wt.Result) 2123 fmt.Printf("FAIL: %s - expected and computed output don't match.\n", wt)
2092 } 2124 }
2093 2125
2094 return wt.Result == "valid" 2126 return wt.Result == "valid"
@@ -2140,13 +2172,13 @@ func runHmacTest(md *C.EVP_MD, tagBytes int, wt *wycheproofTestHmac) bool {
2140 if ret == nil { 2172 if ret == nil {
2141 if wt.Result != "invalid" { 2173 if wt.Result != "invalid" {
2142 success = false 2174 success = false
2143 fmt.Printf("FAIL: Test case %d (%q) %v - HMAC: got nil, want %v\n", wt.TCID, wt.Comment, wt.Flags, wt.Result) 2175 fmt.Printf("FAIL: Test case %s - HMAC: got nil.\n", wt)
2144 } 2176 }
2145 return success 2177 return success
2146 } 2178 }
2147 2179
2148 if int(gotLen) < tagBytes { 2180 if int(gotLen) < tagBytes {
2149 fmt.Printf("FAIL: Test case %d (%q) %v - HMAC length: got %d, want %d, expected %v\n", wt.TCID, wt.Comment, wt.Flags, gotLen, tagBytes, wt.Result) 2181 fmt.Printf("FAIL: %s - HMAC length: got %d, want %d.\n", wt, gotLen, tagBytes)
2150 return false 2182 return false
2151 } 2183 }
2152 2184
@@ -2158,7 +2190,7 @@ func runHmacTest(md *C.EVP_MD, tagBytes int, wt *wycheproofTestHmac) bool {
2158 success = bytes.Equal(got[:tagBytes], tag) == (wt.Result == "valid") 2190 success = bytes.Equal(got[:tagBytes], tag) == (wt.Result == "valid")
2159 2191
2160 if !success { 2192 if !success {
2161 fmt.Printf("FAIL: Test case %d (%q) %v - got %v want %v\n", wt.TCID, wt.Comment, wt.Flags, success, wt.Result) 2193 fmt.Printf("FAIL: %s - got %t.\n", wt, success)
2162 } 2194 }
2163 2195
2164 return success 2196 return success
@@ -2189,8 +2221,7 @@ func runKWTestWrap(keySize int, key []byte, keyLen int, msg []byte, msgLen int,
2189 2221
2190 ret := C.AES_set_encrypt_key((*C.uchar)(unsafe.Pointer(&key[0])), (C.int)(keySize), (*C.AES_KEY)(unsafe.Pointer(&aesKey))) 2222 ret := C.AES_set_encrypt_key((*C.uchar)(unsafe.Pointer(&key[0])), (C.int)(keySize), (*C.AES_KEY)(unsafe.Pointer(&aesKey)))
2191 if ret != 0 { 2223 if ret != 0 {
2192 fmt.Printf("FAIL: Test case %d (%q) %v - AES_set_encrypt_key() = %d, want %v\n", 2224 fmt.Printf("FAIL: %s - AES_set_encrypt_key() = %d.\n", wt, int(ret))
2193 wt.TCID, wt.Comment, wt.Flags, int(ret), wt.Result)
2194 return false 2225 return false
2195 } 2226 }
2196 2227
@@ -2208,8 +2239,7 @@ func runKWTestWrap(keySize int, key []byte, keyLen int, msg []byte, msgLen int,
2208 success = true 2239 success = true
2209 } 2240 }
2210 if !success { 2241 if !success {
2211 fmt.Printf("FAIL: Test case %d (%q) %v - msgLen = %d, AES_wrap_key() = %d, want %v\n", 2242 fmt.Printf("FAIL: %s - msgLen = %d, AES_wrap_key() = %d.\n", wt, msgLen, int(ret))
2212 wt.TCID, wt.Comment, wt.Flags, msgLen, int(ret), wt.Result)
2213 } 2243 }
2214 return success 2244 return success
2215} 2245}
@@ -2219,8 +2249,7 @@ func runKWTestUnWrap(keySize int, key []byte, keyLen int, msg []byte, msgLen int
2219 2249
2220 ret := C.AES_set_decrypt_key((*C.uchar)(unsafe.Pointer(&key[0])), (C.int)(keySize), (*C.AES_KEY)(unsafe.Pointer(&aesKey))) 2250 ret := C.AES_set_decrypt_key((*C.uchar)(unsafe.Pointer(&key[0])), (C.int)(keySize), (*C.AES_KEY)(unsafe.Pointer(&aesKey)))
2221 if ret != 0 { 2251 if ret != 0 {
2222 fmt.Printf("FAIL: Test case %d (%q) %v - AES_set_encrypt_key() = %d, want %v\n", 2252 fmt.Printf("FAIL: %s - AES_set_encrypt_key() = %d.\n", wt, int(ret))
2223 wt.TCID, wt.Comment, wt.Flags, int(ret), wt.Result)
2224 return false 2253 return false
2225 } 2254 }
2226 2255
@@ -2239,8 +2268,7 @@ func runKWTestUnWrap(keySize int, key []byte, keyLen int, msg []byte, msgLen int
2239 success = true 2268 success = true
2240 } 2269 }
2241 if !success { 2270 if !success {
2242 fmt.Printf("FAIL: Test case %d (%q) %v - keyLen = %d, AES_unwrap_key() = %d, want %v\n", 2271 fmt.Printf("FAIL: %s - keyLen = %d, AES_unwrap_key() = %d.\n", wt, keyLen, int(ret))
2243 wt.TCID, wt.Comment, wt.Flags, keyLen, int(ret), wt.Result)
2244 } 2272 }
2245 return success 2273 return success
2246} 2274}
@@ -2302,7 +2330,7 @@ func runPrimalityTest(wt *wycheproofTestPrimality) bool {
2302 ret := C.BN_is_prime_ex(bnValue, C.BN_prime_checks, (*C.BN_CTX)(unsafe.Pointer(nil)), (*C.BN_GENCB)(unsafe.Pointer(nil))) 2330 ret := C.BN_is_prime_ex(bnValue, C.BN_prime_checks, (*C.BN_CTX)(unsafe.Pointer(nil)), (*C.BN_GENCB)(unsafe.Pointer(nil)))
2303 success := wt.Result == "acceptable" || (ret == 0 && wt.Result == "invalid") || (ret == 1 && wt.Result == "valid") 2331 success := wt.Result == "acceptable" || (ret == 0 && wt.Result == "invalid") || (ret == 1 && wt.Result == "valid")
2304 if !success { 2332 if !success {
2305 fmt.Printf("FAIL: Test case %d (%q) %v failed - got %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, ret, wt.Result) 2333 fmt.Printf("FAIL: %s - got %d.\n", wt, ret)
2306 } 2334 }
2307 return success 2335 return success
2308} 2336}
@@ -2340,7 +2368,7 @@ func runRsaesOaepTest(rsa *C.RSA, sha *C.EVP_MD, mgfSha *C.EVP_MD, wt *wycheproo
2340 success = (wt.Result == "invalid") 2368 success = (wt.Result == "invalid")
2341 2369
2342 if !success { 2370 if !success {
2343 fmt.Printf("FAIL: Test case %d (%q) %v - got %d, want %d. Expected: %v\n", wt.TCID, wt.Comment, wt.Flags, ret, rsaSize, wt.Result) 2371 fmt.Printf("FAIL: %s - RSA size got %d, want %d.\n", wt, ret, rsaSize)
2344 } 2372 }
2345 return success 2373 return success
2346 } 2374 }
@@ -2368,7 +2396,7 @@ func runRsaesOaepTest(rsa *C.RSA, sha *C.EVP_MD, mgfSha *C.EVP_MD, wt *wycheproo
2368 success = (wt.Result == "invalid") 2396 success = (wt.Result == "invalid")
2369 2397
2370 if !success { 2398 if !success {
2371 fmt.Printf("FAIL: Test case %d (%q) %v - got %d, want %d. Expected: %v\n", wt.TCID, wt.Comment, wt.Flags, ret, rsaSize, wt.Result) 2399 fmt.Printf("FAIL: %s - got %d, want %d.\n", wt, ret, msgLen)
2372 } 2400 }
2373 return success 2401 return success
2374 } 2402 }
@@ -2376,7 +2404,7 @@ func runRsaesOaepTest(rsa *C.RSA, sha *C.EVP_MD, mgfSha *C.EVP_MD, wt *wycheproo
2376 to = to[:msgLen] 2404 to = to[:msgLen]
2377 if !bytes.Equal(msg, to) { 2405 if !bytes.Equal(msg, to) {
2378 success = false 2406 success = false
2379 fmt.Printf("FAIL: Test case %d (%q) %v - expected and calculated message differ. Expected: %v", wt.TCID, wt.Comment, wt.Flags, wt.Result) 2407 fmt.Printf("FAIL: %s - expected and calculated message differ.\n", wt)
2380 } 2408 }
2381 2409
2382 return success 2410 return success
@@ -2463,7 +2491,7 @@ func runRsaesPkcs1Test(rsa *C.RSA, wt *wycheproofTestRsaes) bool {
2463 success = (wt.Result == "invalid") 2491 success = (wt.Result == "invalid")
2464 2492
2465 if !success { 2493 if !success {
2466 fmt.Printf("FAIL: Test case %d (%q) %v - got %d, want %d. Expected: %v\n", wt.TCID, wt.Comment, wt.Flags, ret, len(wt.Msg)/2, wt.Result) 2494 fmt.Printf("FAIL: %s - got %d, want %d.\n", wt, ret, len(wt.Msg)/2)
2467 } 2495 }
2468 return success 2496 return success
2469 } 2497 }
@@ -2475,10 +2503,10 @@ func runRsaesPkcs1Test(rsa *C.RSA, wt *wycheproofTestRsaes) bool {
2475 2503
2476 if int(ret) != len(msg) { 2504 if int(ret) != len(msg) {
2477 success = false 2505 success = false
2478 fmt.Printf("FAIL: Test case %d (%q) %v - got %d, want %d. Expected: %v\n", wt.TCID, wt.Comment, wt.Flags, ret, len(msg), wt.Result) 2506 fmt.Printf("FAIL: %s - got %d, want %d.\n", wt, ret, len(msg))
2479 } else if !bytes.Equal(msg, decrypted[:len(msg)]) { 2507 } else if !bytes.Equal(msg, decrypted[:len(msg)]) {
2480 success = false 2508 success = false
2481 fmt.Printf("FAIL: Test case %d (%q) %v - expected and calculated message differ. Expected: %v", wt.TCID, wt.Comment, wt.Flags, wt.Result) 2509 fmt.Printf("FAIL: %s - expected and calculated message differ.\n", wt)
2482 } 2510 }
2483 2511
2484 return success 2512 return success
@@ -2564,8 +2592,7 @@ func runRsassaTest(rsa *C.RSA, sha *C.EVP_MD, mgfSha *C.EVP_MD, sLen int, wt *wy
2564 if wt.Result == "invalid" { 2592 if wt.Result == "invalid" {
2565 return true 2593 return true
2566 } 2594 }
2567 fmt.Printf("FAIL: Test case %d (%q) %v - RSA_public_decrypt() = %d, want %v\n", 2595 fmt.Printf("FAIL: %s - RSA_public_decrypt() = %d.\n", wt, int(ret))
2568 wt.TCID, wt.Comment, wt.Flags, int(ret), wt.Result)
2569 return false 2596 return false
2570 } 2597 }
2571 2598
@@ -2580,8 +2607,7 @@ func runRsassaTest(rsa *C.RSA, sha *C.EVP_MD, mgfSha *C.EVP_MD, sLen int, wt *wy
2580 } else if ret == 0 && (wt.Result == "invalid" || wt.Result == "acceptable") { 2607 } else if ret == 0 && (wt.Result == "invalid" || wt.Result == "acceptable") {
2581 success = true 2608 success = true
2582 } else { 2609 } else {
2583 fmt.Printf("FAIL: Test case %d (%q) %v - RSA_verify_PKCS1_PSS_mgf1() = %d, want %v\n", 2610 fmt.Printf("FAIL: %s - RSA_verify_PKCS1_PSS_mgf1() = %d.\n", wt, int(ret))
2584 wt.TCID, wt.Comment, wt.Flags, int(ret), wt.Result)
2585 } 2611 }
2586 return success 2612 return success
2587} 2613}
@@ -2663,8 +2689,7 @@ func runRSATest(rsa *C.RSA, md *C.EVP_MD, nid int, wt *wycheproofTestRSA) bool {
2663 // XXX audit acceptable cases... 2689 // XXX audit acceptable cases...
2664 success := true 2690 success := true
2665 if ret == 1 != (wt.Result == "valid") && wt.Result != "acceptable" { 2691 if ret == 1 != (wt.Result == "valid") && wt.Result != "acceptable" {
2666 fmt.Printf("FAIL: Test case %d (%q) %v - RSA_verify() = %d, want %v\n", 2692 fmt.Printf("FAIL: %s - RSA_verify() = %d.\n", wt, int(ret))
2667 wt.TCID, wt.Comment, wt.Flags, int(ret), wt.Result)
2668 success = false 2693 success = false
2669 } 2694 }
2670 return success 2695 return success
@@ -2746,8 +2771,7 @@ func runX25519Test(wt *wycheproofTestX25519) bool {
2746 // XXX audit acceptable cases... 2771 // XXX audit acceptable cases...
2747 success := true 2772 success := true
2748 if result != (wt.Result == "valid") && wt.Result != "acceptable" { 2773 if result != (wt.Result == "valid") && wt.Result != "acceptable" {
2749 fmt.Printf("FAIL: Test case %d (%q) %v - X25519(), want %v\n", 2774 fmt.Printf("FAIL: %s - X25519().\n", wt)
2750 wt.TCID, wt.Comment, wt.Flags, wt.Result)
2751 success = false 2775 success = false
2752 } 2776 }
2753 return success 2777 return success