diff options
Diffstat (limited to '')
| -rw-r--r-- | src/regress/lib/libcrypto/wycheproof/wycheproof.go | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go index 5e2b4c9758..76e384fe55 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.23 2018/08/26 17:38:16 tb Exp $ */ | 1 | /* $OpenBSD: wycheproof.go,v 1.24 2018/08/26 17:43:39 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> |
| @@ -244,12 +244,15 @@ func hashFromString(hs string) (hash.Hash, error) { | |||
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | func checkAesCbcPkcs5Open(ctx *C.EVP_CIPHER_CTX, key []byte, keyLen int, iv []byte, ivLen int, ct []byte, ctLen int, msg []byte, msgLen int, wt *wycheproofTestAesCbcPkcs5) bool { | 246 | func checkAesCbcPkcs5Open(ctx *C.EVP_CIPHER_CTX, key []byte, keyLen int, iv []byte, ivLen int, ct []byte, ctLen int, msg []byte, msgLen int, wt *wycheproofTestAesCbcPkcs5) bool { |
| 247 | C.EVP_CipherInit_ex(ctx, nil, nil, (*C.uchar)(unsafe.Pointer(&key[0])), (*C.uchar)(unsafe.Pointer(&iv[0])), 0) | 247 | ret := C.EVP_CipherInit_ex(ctx, nil, nil, (*C.uchar)(unsafe.Pointer(&key[0])), (*C.uchar)(unsafe.Pointer(&iv[0])), 0) |
| 248 | if ret != 1 { | ||
| 249 | log.Fatalf("EVP_CipherInit_ex failed: %d", ret) | ||
| 250 | } | ||
| 248 | 251 | ||
| 249 | out := make([]byte, ctLen) | 252 | out := make([]byte, ctLen) |
| 250 | var outlen C.int | 253 | var outlen C.int |
| 251 | 254 | ||
| 252 | ret := C.EVP_CipherUpdate(ctx, (*C.uchar)(unsafe.Pointer(&out[0])), &outlen, (*C.uchar)(unsafe.Pointer(&ct[0])), C.int(ctLen)) | 255 | ret = C.EVP_CipherUpdate(ctx, (*C.uchar)(unsafe.Pointer(&out[0])), &outlen, (*C.uchar)(unsafe.Pointer(&ct[0])), C.int(ctLen)) |
| 253 | if ret != 1 { | 256 | if ret != 1 { |
| 254 | if wt.Result == "invalid" { | 257 | if wt.Result == "invalid" { |
| 255 | fmt.Printf("INFO: Test case %d (%q) - EVP_CipherUpdate() = %d, want %v\n", wt.TCID, wt.Comment, ret, wt.Result) | 258 | fmt.Printf("INFO: Test case %d (%q) - EVP_CipherUpdate() = %d, want %v\n", wt.TCID, wt.Comment, ret, wt.Result) |
| @@ -290,12 +293,15 @@ func checkAesCbcPkcs5Open(ctx *C.EVP_CIPHER_CTX, key []byte, keyLen int, iv []by | |||
| 290 | } | 293 | } |
| 291 | 294 | ||
| 292 | func checkAesCbcPkcs5Seal(ctx *C.EVP_CIPHER_CTX, key []byte, keyLen int, iv []byte, ivLen int, ct []byte, ctLen int, msg []byte, msgLen int, wt *wycheproofTestAesCbcPkcs5) bool { | 295 | func checkAesCbcPkcs5Seal(ctx *C.EVP_CIPHER_CTX, key []byte, keyLen int, iv []byte, ivLen int, ct []byte, ctLen int, msg []byte, msgLen int, wt *wycheproofTestAesCbcPkcs5) bool { |
| 293 | C.EVP_CipherInit_ex(ctx, nil, nil, (*C.uchar)(unsafe.Pointer(&key[0])), (*C.uchar)(unsafe.Pointer(&iv[0])), 1) | 296 | ret := C.EVP_CipherInit_ex(ctx, nil, nil, (*C.uchar)(unsafe.Pointer(&key[0])), (*C.uchar)(unsafe.Pointer(&iv[0])), 1) |
| 297 | if ret != 1 { | ||
| 298 | log.Fatalf("EVP_CipherInit_ex failed: %d", ret) | ||
| 299 | } | ||
| 294 | 300 | ||
| 295 | out := make([]byte, msgLen + C.EVP_MAX_BLOCK_LENGTH) | 301 | out := make([]byte, msgLen + C.EVP_MAX_BLOCK_LENGTH) |
| 296 | var outlen C.int | 302 | var outlen C.int |
| 297 | 303 | ||
| 298 | ret := C.EVP_CipherUpdate(ctx, (*C.uchar)(unsafe.Pointer(&out[0])), &outlen, (*C.uchar)(unsafe.Pointer(&msg[0])), C.int(msgLen)) | 304 | ret = C.EVP_CipherUpdate(ctx, (*C.uchar)(unsafe.Pointer(&out[0])), &outlen, (*C.uchar)(unsafe.Pointer(&msg[0])), C.int(msgLen)) |
| 299 | if ret != 1 { | 305 | if ret != 1 { |
| 300 | if wt.Result == "invalid" { | 306 | if wt.Result == "invalid" { |
| 301 | fmt.Printf("INFO: Test case %d (%q) - EVP_CipherUpdate() = %d, want %v\n", wt.TCID, wt.Comment, ret, wt.Result) | 307 | fmt.Printf("INFO: Test case %d (%q) - EVP_CipherUpdate() = %d, want %v\n", wt.TCID, wt.Comment, ret, wt.Result) |
| @@ -395,7 +401,10 @@ func runAesCbcPkcs5TestGroup(wtg *wycheproofTestGroupAesCbcPkcs5) bool { | |||
| 395 | } | 401 | } |
| 396 | defer C.EVP_CIPHER_CTX_free(ctx) | 402 | defer C.EVP_CIPHER_CTX_free(ctx) |
| 397 | 403 | ||
| 398 | C.EVP_CipherInit_ex(ctx, cipher, nil, nil, nil, 0) | 404 | ret := C.EVP_CipherInit_ex(ctx, cipher, nil, nil, nil, 0) |
| 405 | if ret != 1 { | ||
| 406 | log.Fatalf("EVP_CipherInit_ex failed: %d", ret) | ||
| 407 | } | ||
| 399 | 408 | ||
| 400 | success := true | 409 | success := true |
| 401 | for _, wt := range wtg.Tests { | 410 | for _, wt := range wtg.Tests { |
