diff options
-rw-r--r-- | src/regress/lib/libcrypto/wycheproof/wycheproof.go | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go index b008ab58e7..e35c599059 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.94 2019/11/27 19:32:07 tb Exp $ */ | 1 | /* $OpenBSD: wycheproof.go,v 1.95 2019/11/27 19:34:35 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 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2018, 2019 Theo Buehler <tb@openbsd.org> |
@@ -290,7 +290,7 @@ type wycheproofPrivateKeyJwk struct { | |||
290 | } | 290 | } |
291 | 291 | ||
292 | type wycheproofTestRsaes struct { | 292 | type wycheproofTestRsaes struct { |
293 | TCID int `json:"tcId"` | 293 | TCID int `json:"tcId"` |
294 | Comment string `json:"comment"` | 294 | Comment string `json:"comment"` |
295 | Msg string `json:"msg"` | 295 | Msg string `json:"msg"` |
296 | CT string `json:"ct"` | 296 | CT string `json:"ct"` |
@@ -505,7 +505,7 @@ func checkAesCbcPkcs5(ctx *C.EVP_CIPHER_CTX, doEncrypt int, key []byte, keyLen i | |||
505 | log.Fatalf("EVP_CipherInit_ex failed: %d", ret) | 505 | log.Fatalf("EVP_CipherInit_ex failed: %d", ret) |
506 | } | 506 | } |
507 | 507 | ||
508 | cipherOut := make([]byte, inLen + C.EVP_MAX_BLOCK_LENGTH) | 508 | cipherOut := make([]byte, inLen+C.EVP_MAX_BLOCK_LENGTH) |
509 | var cipherOutLen C.int | 509 | var cipherOutLen C.int |
510 | 510 | ||
511 | ret = C.EVP_CipherUpdate(ctx, (*C.uchar)(unsafe.Pointer(&cipherOut[0])), &cipherOutLen, | 511 | ret = C.EVP_CipherUpdate(ctx, (*C.uchar)(unsafe.Pointer(&cipherOut[0])), &cipherOutLen, |
@@ -1793,7 +1793,7 @@ func runKWTestUnWrap(keySize int, key []byte, keyLen int, msg []byte, msgLen int | |||
1793 | } | 1793 | } |
1794 | ret = C.AES_unwrap_key((*C.AES_KEY)(unsafe.Pointer(&aesKey)), nil, (*C.uchar)(unsafe.Pointer(&out[0])), (*C.uchar)(unsafe.Pointer(&out[0])), (C.uint)(ctLen)) | 1794 | ret = C.AES_unwrap_key((*C.AES_KEY)(unsafe.Pointer(&aesKey)), nil, (*C.uchar)(unsafe.Pointer(&out[0])), (*C.uchar)(unsafe.Pointer(&out[0])), (C.uint)(ctLen)) |
1795 | success := false | 1795 | success := false |
1796 | if ret == C.int(ctLen - 8) && bytes.Equal(out[0:ret], msg[0:ret]) { | 1796 | if ret == C.int(ctLen-8) && bytes.Equal(out[0:ret], msg[0:ret]) { |
1797 | if acceptableAudit && wt.Result == "acceptable" { | 1797 | if acceptableAudit && wt.Result == "acceptable" { |
1798 | gatherAcceptableStatistics(wt.TCID, wt.Comment, wt.Flags) | 1798 | gatherAcceptableStatistics(wt.TCID, wt.Comment, wt.Flags) |
1799 | } | 1799 | } |
@@ -1898,7 +1898,7 @@ func runRsaesOaepTest(rsa *C.RSA, sha *C.EVP_MD, mgfSha *C.EVP_MD, wt *wycheproo | |||
1898 | 1898 | ||
1899 | to := make([]byte, rsaSize) | 1899 | to := make([]byte, rsaSize) |
1900 | 1900 | ||
1901 | ret = C.RSA_padding_check_PKCS1_OAEP_mgf1((*C.uchar)(unsafe.Pointer(&to[0])), C.int(rsaSize), (*C.uchar)(unsafe.Pointer(&decrypted[0])), C.int(rsaSize), C.int(rsaSize), (*C.uchar)(unsafe.Pointer(&label[0])), C.int(labelLen), sha, mgfSha) | 1901 | ret = C.RSA_padding_check_PKCS1_OAEP_mgf1((*C.uchar)(unsafe.Pointer(&to[0])), C.int(rsaSize), (*C.uchar)(unsafe.Pointer(&decrypted[0])), C.int(rsaSize), C.int(rsaSize), (*C.uchar)(unsafe.Pointer(&label[0])), C.int(labelLen), sha, mgfSha) |
1902 | 1902 | ||
1903 | if int(ret) != msgLen { | 1903 | if int(ret) != msgLen { |
1904 | success = (wt.Result == "invalid") | 1904 | success = (wt.Result == "invalid") |
@@ -1909,8 +1909,7 @@ func runRsaesOaepTest(rsa *C.RSA, sha *C.EVP_MD, mgfSha *C.EVP_MD, wt *wycheproo | |||
1909 | return success | 1909 | return success |
1910 | } | 1910 | } |
1911 | 1911 | ||
1912 | 1912 | to = to[:msgLen] | |
1913 | to = to[:msgLen]; | ||
1914 | if !bytes.Equal(msg, to) { | 1913 | if !bytes.Equal(msg, to) { |
1915 | success = false | 1914 | success = false |
1916 | fmt.Printf("FAIL: Test case %d (%q) %v - expected and calculated message differ. Expected: %v", wt.TCID, wt.Comment, wt.Flags, wt.Result) | 1915 | fmt.Printf("FAIL: Test case %d (%q) %v - expected and calculated message differ. Expected: %v", wt.TCID, wt.Comment, wt.Flags, wt.Result) |
@@ -2066,7 +2065,7 @@ func runRSASSATest(rsa *C.RSA, h hash.Hash, sha *C.EVP_MD, mgfSha *C.EVP_MD, sLe | |||
2066 | sig = append(sig, 0) | 2065 | sig = append(sig, 0) |
2067 | } | 2066 | } |
2068 | 2067 | ||
2069 | sigOut := make([]byte, C.RSA_size(rsa) - 11) | 2068 | sigOut := make([]byte, C.RSA_size(rsa)-11) |
2070 | if sigLen == 0 { | 2069 | if sigLen == 0 { |
2071 | sigOut = append(sigOut, 0) | 2070 | sigOut = append(sigOut, 0) |
2072 | } | 2071 | } |
@@ -2315,9 +2314,9 @@ func runTestVectors(path string, webcrypto bool) bool { | |||
2315 | case "KW": | 2314 | case "KW": |
2316 | wtg = &wycheproofTestGroupKW{} | 2315 | wtg = &wycheproofTestGroupKW{} |
2317 | case "RSAES-OAEP": | 2316 | case "RSAES-OAEP": |
2318 | wtg= &wycheproofTestGroupRsaesOaep{} | 2317 | wtg = &wycheproofTestGroupRsaesOaep{} |
2319 | case "RSAES-PKCS1-v1_5": | 2318 | case "RSAES-PKCS1-v1_5": |
2320 | wtg= &wycheproofTestGroupRsaesPkcs1{} | 2319 | wtg = &wycheproofTestGroupRsaesPkcs1{} |
2321 | case "RSASSA-PSS": | 2320 | case "RSASSA-PSS": |
2322 | wtg = &wycheproofTestGroupRSASSA{} | 2321 | wtg = &wycheproofTestGroupRSASSA{} |
2323 | case "RSASig": | 2322 | case "RSASig": |