diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/wycheproof/wycheproof.go | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go index 0aaaf6a9b8..3e21227ef6 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.61 2018/09/22 00:29:13 tb Exp $ */ | 1 | /* $OpenBSD: wycheproof.go,v 1.62 2018/09/22 06:06:36 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 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> |
@@ -754,13 +754,13 @@ func runAesCmacTest(cipher *C.EVP_CIPHER, wt *wycheproofTestAesCmac) bool { | |||
754 | 754 | ||
755 | ret := C.CMAC_Init(ctx, unsafe.Pointer(&key[0]), C.size_t(keyLen), cipher, nil) | 755 | ret := C.CMAC_Init(ctx, unsafe.Pointer(&key[0]), C.size_t(keyLen), cipher, nil) |
756 | if ret != 1 { | 756 | if ret != 1 { |
757 | fmt.Printf("FAIL: Test case %d (%q) - CMAC_Init() = %d, want %v\n", wt.TCID, wt.Comment, ret, wt.Result) | 757 | fmt.Printf("FAIL: Test case %d (%q) %v - CMAC_Init() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, ret, wt.Result) |
758 | return false | 758 | return false |
759 | } | 759 | } |
760 | 760 | ||
761 | ret = C.CMAC_Update(ctx, unsafe.Pointer(&msg[0]), C.size_t(msgLen)) | 761 | ret = C.CMAC_Update(ctx, unsafe.Pointer(&msg[0]), C.size_t(msgLen)) |
762 | if ret != 1 { | 762 | if ret != 1 { |
763 | fmt.Printf("FAIL: Test case %d (%q) - CMAC_Update() = %d, want %v\n", wt.TCID, wt.Comment, ret, wt.Result) | 763 | fmt.Printf("FAIL: Test case %d (%q) %v - CMAC_Update() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, ret, wt.Result) |
764 | return false | 764 | return false |
765 | } | 765 | } |
766 | 766 | ||
@@ -769,7 +769,7 @@ func runAesCmacTest(cipher *C.EVP_CIPHER, wt *wycheproofTestAesCmac) bool { | |||
769 | 769 | ||
770 | ret = C.CMAC_Final(ctx, (*C.uchar)(unsafe.Pointer(&outTag[0])), &outLen) | 770 | ret = C.CMAC_Final(ctx, (*C.uchar)(unsafe.Pointer(&outTag[0])), &outLen) |
771 | if ret != 1 { | 771 | if ret != 1 { |
772 | fmt.Printf("FAIL: Test case %d (%q) - CMAC_Final() = %d, want %v\n", wt.TCID, wt.Comment, ret, wt.Result) | 772 | fmt.Printf("FAIL: Test case %d (%q) %v - CMAC_Final() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, ret, wt.Result) |
773 | return false | 773 | return false |
774 | } | 774 | } |
775 | 775 | ||
@@ -777,7 +777,7 @@ func runAesCmacTest(cipher *C.EVP_CIPHER, wt *wycheproofTestAesCmac) bool { | |||
777 | 777 | ||
778 | success := true | 778 | success := true |
779 | if bytes.Equal(tag, outTag) != (wt.Result == "valid") { | 779 | if bytes.Equal(tag, outTag) != (wt.Result == "valid") { |
780 | fmt.Printf("FAIL: Test case %d (%q) - want %v\n", wt.TCID, wt.Comment, wt.Result) | 780 | fmt.Printf("FAIL: Test case %d (%q) %v - want %v\n", wt.TCID, wt.Comment, wt.Flags, wt.Result) |
781 | success = false | 781 | success = false |
782 | } | 782 | } |
783 | return success | 783 | return success |
@@ -821,12 +821,12 @@ func checkAeadOpen(ctx *C.EVP_AEAD_CTX, iv []byte, ivLen int, aad []byte, aadLen | |||
821 | if wt.Result == "invalid" { | 821 | if wt.Result == "invalid" { |
822 | return true | 822 | return true |
823 | } | 823 | } |
824 | fmt.Printf("FAIL: Test case %d (%q) - EVP_AEAD_CTX_open() = %d, want %v\n", wt.TCID, wt.Comment, int(openRet), wt.Result) | 824 | fmt.Printf("FAIL: Test case %d (%q) %v - EVP_AEAD_CTX_open() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, int(openRet), wt.Result) |
825 | return false | 825 | return false |
826 | } | 826 | } |
827 | 827 | ||
828 | if openedMsgLen != C.size_t(msgLen) { | 828 | if openedMsgLen != C.size_t(msgLen) { |
829 | fmt.Printf("FAIL: Test case %d (%q) - open length mismatch: got %d, want %d\n", wt.TCID, wt.Comment, openedMsgLen, msgLen) | 829 | fmt.Printf("FAIL: Test case %d (%q) %v - open length mismatch: got %d, want %d\n", wt.TCID, wt.Comment, wt.Flags, openedMsgLen, msgLen) |
830 | return false | 830 | return false |
831 | } | 831 | } |
832 | 832 | ||
@@ -839,7 +839,7 @@ func checkAeadOpen(ctx *C.EVP_AEAD_CTX, iv []byte, ivLen int, aad []byte, aadLen | |||
839 | if bytes.Equal(openedMsg, msg) || wt.Result == "invalid" { | 839 | if bytes.Equal(openedMsg, msg) || wt.Result == "invalid" { |
840 | success = true | 840 | success = true |
841 | } else { | 841 | } else { |
842 | fmt.Printf("FAIL: Test case %d (%q) - msg match: %t; want %v\n", wt.TCID, wt.Comment, bytes.Equal(openedMsg, msg), wt.Result) | 842 | fmt.Printf("FAIL: Test case %d (%q) %v - msg match: %t; want %v\n", wt.TCID, wt.Comment, wt.Flags, bytes.Equal(openedMsg, msg), wt.Result) |
843 | } | 843 | } |
844 | return success | 844 | return success |
845 | } | 845 | } |
@@ -853,12 +853,12 @@ func checkAeadSeal(ctx *C.EVP_AEAD_CTX, iv []byte, ivLen int, aad []byte, aadLen | |||
853 | sealRet := C.EVP_AEAD_CTX_seal(ctx, (*C.uint8_t)(unsafe.Pointer(&sealed[0])), (*C.size_t)(unsafe.Pointer(&sealedLen)), C.size_t(maxOutLen), (*C.uint8_t)(unsafe.Pointer(&iv[0])), C.size_t(ivLen), (*C.uint8_t)(unsafe.Pointer(&msg[0])), C.size_t(msgLen), (*C.uint8_t)(unsafe.Pointer(&aad[0])), C.size_t(aadLen)) | 853 | sealRet := C.EVP_AEAD_CTX_seal(ctx, (*C.uint8_t)(unsafe.Pointer(&sealed[0])), (*C.size_t)(unsafe.Pointer(&sealedLen)), C.size_t(maxOutLen), (*C.uint8_t)(unsafe.Pointer(&iv[0])), C.size_t(ivLen), (*C.uint8_t)(unsafe.Pointer(&msg[0])), C.size_t(msgLen), (*C.uint8_t)(unsafe.Pointer(&aad[0])), C.size_t(aadLen)) |
854 | 854 | ||
855 | if sealRet != 1 { | 855 | if sealRet != 1 { |
856 | fmt.Printf("FAIL: Test case %d (%q) - EVP_AEAD_CTX_seal() = %d, want %v\n", wt.TCID, wt.Comment, int(sealRet), wt.Result) | 856 | 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) |
857 | return false | 857 | return false |
858 | } | 858 | } |
859 | 859 | ||
860 | if sealedLen != C.size_t(maxOutLen) { | 860 | if sealedLen != C.size_t(maxOutLen) { |
861 | fmt.Printf("FAIL: Test case %d (%q) - seal length mismatch: got %d, want %d\n", wt.TCID, wt.Comment, sealedLen, maxOutLen) | 861 | fmt.Printf("FAIL: Test case %d (%q) %v - seal length mismatch: got %d, want %d\n", wt.TCID, wt.Comment, wt.Flags, sealedLen, maxOutLen) |
862 | return false | 862 | return false |
863 | } | 863 | } |
864 | 864 | ||
@@ -869,7 +869,7 @@ func checkAeadSeal(ctx *C.EVP_AEAD_CTX, iv []byte, ivLen int, aad []byte, aadLen | |||
869 | if bytes.Equal(sealedCt, ct) && bytes.Equal(sealedTag, tag) || wt.Result == "invalid" { | 869 | if bytes.Equal(sealedCt, ct) && bytes.Equal(sealedTag, tag) || wt.Result == "invalid" { |
870 | success = true | 870 | success = true |
871 | } else { | 871 | } else { |
872 | fmt.Printf("FAIL: Test case %d (%q) - EVP_AEAD_CTX_seal() = %d, ct match: %t, tag match: %t; want %v\n", wt.TCID, wt.Comment, int(sealRet), bytes.Equal(sealedCt, ct), bytes.Equal(sealedTag, tag), wt.Result) | 872 | fmt.Printf("FAIL: Test case %d (%q) %v - EVP_AEAD_CTX_seal() = %d, ct match: %t, tag match: %t; want %v\n", wt.TCID, wt.Comment, wt.Flags, int(sealRet), bytes.Equal(sealedCt, ct), bytes.Equal(sealedTag, tag), wt.Result) |
873 | } | 873 | } |
874 | return success | 874 | return success |
875 | } | 875 | } |
@@ -904,13 +904,13 @@ func runChaCha20Poly1305Test(iv_len int, key_len int, tag_len int, wt *wycheproo | |||
904 | 904 | ||
905 | keyLen, ivLen, aadLen, tagLen := len(key), len(iv), len(aad), len(tag) | 905 | keyLen, ivLen, aadLen, tagLen := len(key), len(iv), len(aad), len(tag) |
906 | if key_len != keyLen || iv_len != ivLen || tag_len != tagLen { | 906 | if key_len != keyLen || iv_len != ivLen || tag_len != tagLen { |
907 | fmt.Printf("FAIL: Test case %d (%q) - length mismatch; key: got %d, want %d; IV: got %d, want %d; tag: got %d, want %d\n", wt.TCID, wt.Comment, keyLen, key_len, ivLen, iv_len, tagLen, tag_len) | 907 | fmt.Printf("FAIL: Test case %d (%q) %v - length mismatch; key: got %d, want %d; IV: got %d, want %d; tag: got %d, want %d\n", wt.TCID, wt.Comment, wt.Flags, keyLen, key_len, ivLen, iv_len, tagLen, tag_len) |
908 | return false | 908 | return false |
909 | } | 909 | } |
910 | 910 | ||
911 | msgLen, ctLen := len(msg), len(ct) | 911 | msgLen, ctLen := len(msg), len(ct) |
912 | if msgLen != ctLen { | 912 | if msgLen != ctLen { |
913 | fmt.Printf("FAIL: Test case %d (%q) - length mismatch: msgLen = %d, ctLen = %d\n", wt.TCID, wt.Comment, msgLen, ctLen) | 913 | fmt.Printf("FAIL: Test case %d (%q) %v - length mismatch: msgLen = %d, ctLen = %d\n", wt.TCID, wt.Comment, wt.Flags, msgLen, ctLen) |
914 | return false | 914 | return false |
915 | } | 915 | } |
916 | 916 | ||
@@ -981,7 +981,7 @@ func runDSATest(dsa *C.DSA, h hash.Hash, wt *wycheproofTestDSA) bool { | |||
981 | 981 | ||
982 | success := true | 982 | success := true |
983 | if (ret == 1) != (wt.Result == "valid") { | 983 | if (ret == 1) != (wt.Result == "valid") { |
984 | fmt.Printf("FAIL: Test case %d (%q) - DSA_verify() = %d, want %v\n", wt.TCID, wt.Comment, ret, wt.Result) | 984 | fmt.Printf("FAIL: Test case %d (%q) %v - DSA_verify() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, ret, wt.Result) |
985 | success = false | 985 | success = false |
986 | } | 986 | } |
987 | return success | 987 | return success |
@@ -1104,7 +1104,7 @@ func runECDHTest(nid int, doECpoint bool, wt *wycheproofTestECDH) bool { | |||
1104 | 1104 | ||
1105 | ret := C.EC_KEY_set_private_key(privKey, bnPriv) | 1105 | ret := C.EC_KEY_set_private_key(privKey, bnPriv) |
1106 | if ret != 1 { | 1106 | if ret != 1 { |
1107 | fmt.Printf("FAIL: Test case %d (%q) - EC_KEY_set_private_key() = %d, want %v\n", wt.TCID, wt.Comment, ret, wt.Result) | 1107 | fmt.Printf("FAIL: Test case %d (%q) %v - EC_KEY_set_private_key() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, ret, wt.Result) |
1108 | return false | 1108 | return false |
1109 | } | 1109 | } |
1110 | 1110 | ||
@@ -1148,7 +1148,7 @@ func runECDHTest(nid int, doECpoint bool, wt *wycheproofTestECDH) bool { | |||
1148 | } | 1148 | } |
1149 | return true | 1149 | return true |
1150 | } | 1150 | } |
1151 | fmt.Printf("FAIL: Test case %d (%q) - ASN decoding failed: want %v\n", wt.TCID, wt.Comment, wt.Result) | 1151 | fmt.Printf("FAIL: Test case %d (%q) %v - ASN decoding failed: want %v\n", wt.TCID, wt.Comment, wt.Flags, wt.Result) |
1152 | return false | 1152 | return false |
1153 | } | 1153 | } |
1154 | 1154 | ||
@@ -1168,7 +1168,7 @@ func runECDHTest(nid int, doECpoint bool, wt *wycheproofTestECDH) bool { | |||
1168 | if wt.Result == "invalid" { | 1168 | if wt.Result == "invalid" { |
1169 | return true | 1169 | return true |
1170 | } | 1170 | } |
1171 | fmt.Printf("FAIL: Test case %d (%q) - ECDH_compute_key() = %d, want %d, result: %v\n", wt.TCID, wt.Comment, ret, int(secLen), wt.Result) | 1171 | fmt.Printf("FAIL: Test case %d (%q) %v - ECDH_compute_key() = %d, want %d, result: %v\n", wt.TCID, wt.Comment, wt.Flags, ret, int(secLen), wt.Result) |
1172 | return false | 1172 | return false |
1173 | } | 1173 | } |
1174 | 1174 | ||
@@ -1179,7 +1179,7 @@ func runECDHTest(nid int, doECpoint bool, wt *wycheproofTestECDH) bool { | |||
1179 | 1179 | ||
1180 | success := true | 1180 | success := true |
1181 | if !bytes.Equal(shared, secret) { | 1181 | if !bytes.Equal(shared, secret) { |
1182 | fmt.Printf("FAIL: Test case %d (%q) - expected and computed shared secret do not match, want %v\n", wt.TCID, wt.Comment, wt.Result) | 1182 | fmt.Printf("FAIL: Test case %d (%q) %v - expected and computed shared secret do not match, want %v\n", wt.TCID, wt.Comment, wt.Flags, wt.Result) |
1183 | success = false | 1183 | success = false |
1184 | } | 1184 | } |
1185 | return success | 1185 | return success |
@@ -1240,7 +1240,7 @@ func runECDSATest(ecKey *C.EC_KEY, nid int, h hash.Hash, wt *wycheproofTestECDSA | |||
1240 | // XXX audit acceptable cases... | 1240 | // XXX audit acceptable cases... |
1241 | success := true | 1241 | success := true |
1242 | if (ret == 1) != (wt.Result == "valid") && wt.Result != "acceptable" { | 1242 | if (ret == 1) != (wt.Result == "valid") && wt.Result != "acceptable" { |
1243 | fmt.Printf("FAIL: Test case %d (%q) - ECDSA_verify() = %d, want %v\n", wt.TCID, wt.Comment, int(ret), wt.Result) | 1243 | fmt.Printf("FAIL: Test case %d (%q) %v - ECDSA_verify() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, int(ret), wt.Result) |
1244 | success = false | 1244 | success = false |
1245 | } | 1245 | } |
1246 | if acceptableAudit && ret == 1 && wt.Result == "acceptable" { | 1246 | if acceptableAudit && ret == 1 && wt.Result == "acceptable" { |
@@ -1338,7 +1338,7 @@ func runRSASSATest(rsa *C.RSA, h hash.Hash, sha *C.EVP_MD, mgfSha *C.EVP_MD, sLe | |||
1338 | if wt.Result == "invalid" { | 1338 | if wt.Result == "invalid" { |
1339 | return true | 1339 | return true |
1340 | } | 1340 | } |
1341 | fmt.Printf("FAIL: Test case %d (%q) - RSA_public_decrypt() = %d, want %v\n", wt.TCID, wt.Comment, int(ret), wt.Result) | 1341 | fmt.Printf("FAIL: Test case %d (%q) %v - RSA_public_decrypt() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, int(ret), wt.Result) |
1342 | return false | 1342 | return false |
1343 | } | 1343 | } |
1344 | 1344 | ||
@@ -1354,7 +1354,7 @@ func runRSASSATest(rsa *C.RSA, h hash.Hash, sha *C.EVP_MD, mgfSha *C.EVP_MD, sLe | |||
1354 | } else if ret == 0 && (wt.Result == "invalid" || wt.Result == "acceptable") { | 1354 | } else if ret == 0 && (wt.Result == "invalid" || wt.Result == "acceptable") { |
1355 | success = true | 1355 | success = true |
1356 | } else { | 1356 | } else { |
1357 | fmt.Printf("FAIL: Test case %d (%q) - RSA_verify_PKCS1_PSS_mgf1() = %d, want %v\n", wt.TCID, wt.Comment, int(ret), wt.Result) | 1357 | fmt.Printf("FAIL: Test case %d (%q) %v - RSA_verify_PKCS1_PSS_mgf1() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, int(ret), wt.Result) |
1358 | } | 1358 | } |
1359 | return success | 1359 | return success |
1360 | } | 1360 | } |
@@ -1432,7 +1432,7 @@ func runRSATest(rsa *C.RSA, nid int, h hash.Hash, wt *wycheproofTestRSA) bool { | |||
1432 | // XXX audit acceptable cases... | 1432 | // XXX audit acceptable cases... |
1433 | success := true | 1433 | success := true |
1434 | if (ret == 1) != (wt.Result == "valid") && wt.Result != "acceptable" { | 1434 | if (ret == 1) != (wt.Result == "valid") && wt.Result != "acceptable" { |
1435 | fmt.Printf("FAIL: Test case %d (%q) - RSA_verify() = %d, want %v\n", wt.TCID, wt.Comment, int(ret), wt.Result) | 1435 | fmt.Printf("FAIL: Test case %d (%q) %v - RSA_verify() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, int(ret), wt.Result) |
1436 | success = false | 1436 | success = false |
1437 | } | 1437 | } |
1438 | if acceptableAudit && ret == 1 && wt.Result == "acceptable" { | 1438 | if acceptableAudit && ret == 1 && wt.Result == "acceptable" { |
@@ -1506,7 +1506,7 @@ func runX25519Test(wt *wycheproofTestX25519) bool { | |||
1506 | // XXX audit acceptable cases... | 1506 | // XXX audit acceptable cases... |
1507 | success := true | 1507 | success := true |
1508 | if result != (wt.Result == "valid") && wt.Result != "acceptable" { | 1508 | if result != (wt.Result == "valid") && wt.Result != "acceptable" { |
1509 | fmt.Printf("FAIL: Test case %d (%q) - X25519(), want %v\n", wt.TCID, wt.Comment, wt.Result) | 1509 | fmt.Printf("FAIL: Test case %d (%q) %v - X25519(), want %v\n", wt.TCID, wt.Comment, wt.Flags, wt.Result) |
1510 | success = false | 1510 | success = false |
1511 | } | 1511 | } |
1512 | if acceptableAudit && result && wt.Result == "acceptable" { | 1512 | if acceptableAudit && result && wt.Result == "acceptable" { |