diff options
| author | tb <> | 2018-08-29 19:00:41 +0000 |
|---|---|---|
| committer | tb <> | 2018-08-29 19:00:41 +0000 |
| commit | 4d501b1827bdf038bf03a295447b6a7fd08190ae (patch) | |
| tree | b2232c5890fbd5a2da003dddfc4ed698f76c6e20 /src | |
| parent | 4ab2892d7d0b22af80af4e05b26b55b0eb2d2882 (diff) | |
| download | openbsd-4d501b1827bdf038bf03a295447b6a7fd08190ae.tar.gz openbsd-4d501b1827bdf038bf03a295447b6a7fd08190ae.tar.bz2 openbsd-4d501b1827bdf038bf03a295447b6a7fd08190ae.zip | |
Calculate and check tag during AES-CCM encryption test.
Diffstat (limited to 'src')
| -rw-r--r-- | src/regress/lib/libcrypto/wycheproof/wycheproof.go | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go index 5e61ebb30b..9022279346 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.33 2018/08/29 18:59:22 tb Exp $ */ | 1 | /* $OpenBSD: wycheproof.go,v 1.34 2018/08/29 19:00:41 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> |
| @@ -480,6 +480,18 @@ func checkAesCcm(ctx *C.EVP_CIPHER_CTX, doEncrypt int, key []byte, keyLen int, i | |||
| 480 | return false | 480 | return false |
| 481 | } | 481 | } |
| 482 | 482 | ||
| 483 | if doEncrypt == 1 { | ||
| 484 | var tmpLen C.int | ||
| 485 | dummyOut := make([]byte, 16) | ||
| 486 | |||
| 487 | ret = C.EVP_CipherFinal_ex(ctx, (*C.uchar)(unsafe.Pointer(&dummyOut[0])), &tmpLen) | ||
| 488 | if ret != 1 { | ||
| 489 | fmt.Printf("FAIL: Test case %d (%q) [%v] - EVP_CipherFinal_ex() failed: got %d, want %v\n", wt.TCID, wt.Comment, action, ret, wt.Result) | ||
| 490 | return false | ||
| 491 | } | ||
| 492 | cipherOutLen += tmpLen | ||
| 493 | } | ||
| 494 | |||
| 483 | if cipherOutLen != C.int(outLen) { | 495 | if cipherOutLen != C.int(outLen) { |
| 484 | fmt.Printf("FAIL: Test case %d (%q) [%v] - cipherOutLen %d != outLen %d. Result %v\n", wt.TCID, wt.Comment, cipherOutLen, action, outLen, wt.Result) | 496 | fmt.Printf("FAIL: Test case %d (%q) [%v] - cipherOutLen %d != outLen %d. Result %v\n", wt.TCID, wt.Comment, cipherOutLen, action, outLen, wt.Result) |
| 485 | return false | 497 | return false |
| @@ -490,6 +502,18 @@ func checkAesCcm(ctx *C.EVP_CIPHER_CTX, doEncrypt int, key []byte, keyLen int, i | |||
| 490 | fmt.Printf("FAIL: Test case %d (%q) [%v] - expected and computed output do not match. Result: %v\n", wt.TCID, wt.Comment, action, wt.Result) | 502 | fmt.Printf("FAIL: Test case %d (%q) [%v] - expected and computed output do not match. Result: %v\n", wt.TCID, wt.Comment, action, wt.Result) |
| 491 | success = false | 503 | success = false |
| 492 | } | 504 | } |
| 505 | if doEncrypt == 1 { | ||
| 506 | tagOut := make([]byte, tagLen) | ||
| 507 | ret = C.EVP_CIPHER_CTX_ctrl(ctx, C.EVP_CTRL_CCM_GET_TAG, C.int(tagLen), unsafe.Pointer(&tagOut[0])) | ||
| 508 | if ret != 1 { | ||
| 509 | fmt.Printf("FAIL: Test case %d (%q) [%v] - EVP_CIPHER_CTX_ctrl() failed: got %d, want %v\n", wt.TCID, wt.Comment, action, ret, wt.Result) | ||
| 510 | return false | ||
| 511 | } | ||
| 512 | if bytes.Equal(tagOut, tag) != (wt.Result == "valid") { | ||
| 513 | fmt.Printf("FAIL: Test case %d (%q) [%v] - expected and computed tag do not match. Result: %v\n", wt.TCID, wt.Comment, action, ret, wt.Result) | ||
| 514 | success = false | ||
| 515 | } | ||
| 516 | } | ||
| 493 | return success | 517 | return success |
| 494 | } | 518 | } |
| 495 | 519 | ||
