diff options
| author | tb <> | 2018-09-21 23:16:16 +0000 |
|---|---|---|
| committer | tb <> | 2018-09-21 23:16:16 +0000 |
| commit | 5cfc2bfe4187eb0aafadc7826e3b911184bfffae (patch) | |
| tree | 3677d350b5ed466f3999e4c378e39a0a252a7d68 /src | |
| parent | aecad15fdcc99d1f840ebff00add9a002b5c82de (diff) | |
| download | openbsd-5cfc2bfe4187eb0aafadc7826e3b911184bfffae.tar.gz openbsd-5cfc2bfe4187eb0aafadc7826e3b911184bfffae.tar.bz2 openbsd-5cfc2bfe4187eb0aafadc7826e3b911184bfffae.zip | |
Print the flags field in INFO: and FAIL: messages. It's helpful in
identifying the important failures while auditing.
Diffstat (limited to 'src')
| -rw-r--r-- | src/regress/lib/libcrypto/wycheproof/wycheproof.go | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go index f5747e9ecd..313965d260 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.57 2018/09/18 01:05:37 tb Exp $ */ | 1 | /* $OpenBSD: wycheproof.go,v 1.58 2018/09/21 23:16:16 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> |
| @@ -338,10 +338,10 @@ func checkAesCbcPkcs5(ctx *C.EVP_CIPHER_CTX, doEncrypt int, key []byte, keyLen i | |||
| 338 | ret = C.EVP_CipherUpdate(ctx, (*C.uchar)(unsafe.Pointer(&cipherOut[0])), &cipherOutLen, (*C.uchar)(unsafe.Pointer(&in[0])), C.int(inLen)) | 338 | ret = C.EVP_CipherUpdate(ctx, (*C.uchar)(unsafe.Pointer(&cipherOut[0])), &cipherOutLen, (*C.uchar)(unsafe.Pointer(&in[0])), C.int(inLen)) |
| 339 | if ret != 1 { | 339 | if ret != 1 { |
| 340 | if wt.Result == "invalid" { | 340 | if wt.Result == "invalid" { |
| 341 | fmt.Printf("INFO: Test case %d (%q) [%v] - EVP_CipherUpdate() = %d, want %v\n", wt.TCID, wt.Comment, action, ret, wt.Result) | 341 | fmt.Printf("INFO: Test case %d (%q) [%v] %v - EVP_CipherUpdate() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, action, ret, wt.Result) |
| 342 | return true | 342 | return true |
| 343 | } | 343 | } |
| 344 | fmt.Printf("FAIL: Test case %d (%q) [%v] - EVP_CipherUpdate() = %d, want %v\n", wt.TCID, wt.Comment, action, ret, wt.Result) | 344 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - EVP_CipherUpdate() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, action, ret, wt.Result) |
| 345 | return false | 345 | return false |
| 346 | } | 346 | } |
| 347 | 347 | ||
| @@ -351,13 +351,13 @@ func checkAesCbcPkcs5(ctx *C.EVP_CIPHER_CTX, doEncrypt int, key []byte, keyLen i | |||
| 351 | if wt.Result == "invalid" { | 351 | if wt.Result == "invalid" { |
| 352 | return true | 352 | return true |
| 353 | } | 353 | } |
| 354 | fmt.Printf("FAIL: Test case %d (%q) [%v] - EVP_CipherFinal_ex() = %d, want %v\n", wt.TCID, wt.Comment, action, ret, wt.Result) | 354 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - EVP_CipherFinal_ex() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, action, ret, wt.Result) |
| 355 | return false | 355 | return false |
| 356 | } | 356 | } |
| 357 | 357 | ||
| 358 | cipherOutLen += finallen | 358 | cipherOutLen += finallen |
| 359 | if cipherOutLen != C.int(outLen) && wt.Result != "invalid" { | 359 | if cipherOutLen != C.int(outLen) && wt.Result != "invalid" { |
| 360 | fmt.Printf("FAIL: Test case %d (%q) [%v] - open length mismatch: got %d, want %d\n", wt.TCID, wt.Comment, action, cipherOutLen, outLen) | 360 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - open length mismatch: got %d, want %d\n", wt.TCID, wt.Comment, wt.Flags, action, cipherOutLen, outLen) |
| 361 | return false | 361 | return false |
| 362 | } | 362 | } |
| 363 | 363 | ||
| @@ -370,7 +370,7 @@ func checkAesCbcPkcs5(ctx *C.EVP_CIPHER_CTX, doEncrypt int, key []byte, keyLen i | |||
| 370 | if bytes.Equal(openedMsg, out) || wt.Result == "invalid" { | 370 | if bytes.Equal(openedMsg, out) || wt.Result == "invalid" { |
| 371 | success = true | 371 | success = true |
| 372 | } else { | 372 | } else { |
| 373 | fmt.Printf("FAIL: Test case %d (%q) [%v] - msg match: %t; want %v\n", wt.TCID, wt.Comment, action, bytes.Equal(openedMsg, out), wt.Result) | 373 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - msg match: %t; want %v\n", wt.TCID, wt.Comment, wt.Flags, action, bytes.Equal(openedMsg, out), wt.Result) |
| 374 | } | 374 | } |
| 375 | return success | 375 | return success |
| 376 | } | 376 | } |
| @@ -487,7 +487,7 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int, key [] | |||
| 487 | if wt.Comment == "Nonce is too long" || wt.Comment == "Invalid nonce size" || wt.Comment == "0 size IV is not valid" { | 487 | if wt.Comment == "Nonce is too long" || wt.Comment == "Invalid nonce size" || wt.Comment == "0 size IV is not valid" { |
| 488 | return true | 488 | return true |
| 489 | } | 489 | } |
| 490 | fmt.Printf("FAIL: Test case %d (%q) [%v] - setting IV len to %d failed. got %d, want %v\n", wt.TCID, wt.Comment, action, ivLen, ret, wt.Result) | 490 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - setting IV len to %d failed. got %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, action, ivLen, ret, wt.Result) |
| 491 | return false | 491 | return false |
| 492 | } | 492 | } |
| 493 | 493 | ||
| @@ -497,14 +497,14 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int, key [] | |||
| 497 | if wt.Comment == "Invalid tag size" { | 497 | if wt.Comment == "Invalid tag size" { |
| 498 | return true | 498 | return true |
| 499 | } | 499 | } |
| 500 | fmt.Printf("FAIL: Test case %d (%q) [%v] - setting tag length to %d failed. got %d, want %v\n", wt.TCID, wt.Comment, action, tagLen, ret, wt.Result) | 500 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - setting tag length to %d failed. got %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, action, tagLen, ret, wt.Result) |
| 501 | return false | 501 | return false |
| 502 | } | 502 | } |
| 503 | } | 503 | } |
| 504 | 504 | ||
| 505 | ret = C.EVP_CipherInit_ex(ctx, nil, nil, (*C.uchar)(unsafe.Pointer(&key[0])), (*C.uchar)(unsafe.Pointer(&iv[0])), C.int(doEncrypt)) | 505 | ret = C.EVP_CipherInit_ex(ctx, nil, nil, (*C.uchar)(unsafe.Pointer(&key[0])), (*C.uchar)(unsafe.Pointer(&iv[0])), C.int(doEncrypt)) |
| 506 | if ret != 1 { | 506 | if ret != 1 { |
| 507 | fmt.Printf("FAIL: Test case %d (%q) [%v] - setting key and IV failed. got %d, want %v\n", wt.TCID, wt.Comment, action, ret, wt.Result) | 507 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - setting key and IV failed. got %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, action, ret, wt.Result) |
| 508 | return false | 508 | return false |
| 509 | } | 509 | } |
| 510 | 510 | ||
| @@ -512,14 +512,14 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int, key [] | |||
| 512 | if doCCM { | 512 | if doCCM { |
| 513 | ret = C.EVP_CipherUpdate(ctx, nil, &cipherOutLen, nil, C.int(inLen)) | 513 | ret = C.EVP_CipherUpdate(ctx, nil, &cipherOutLen, nil, C.int(inLen)) |
| 514 | if ret != 1 { | 514 | if ret != 1 { |
| 515 | fmt.Printf("FAIL: Test case %d (%q) [%v] - setting input length to %d failed. got %d, want %v\n", wt.TCID, wt.Comment, action, inLen, ret, wt.Result) | 515 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - setting input length to %d failed. got %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, action, inLen, ret, wt.Result) |
| 516 | return false | 516 | return false |
| 517 | } | 517 | } |
| 518 | } | 518 | } |
| 519 | 519 | ||
| 520 | ret = C.EVP_CipherUpdate(ctx, nil, &cipherOutLen, (*C.uchar)(unsafe.Pointer(&aad[0])), C.int(aadLen)) | 520 | ret = C.EVP_CipherUpdate(ctx, nil, &cipherOutLen, (*C.uchar)(unsafe.Pointer(&aad[0])), C.int(aadLen)) |
| 521 | if ret != 1 { | 521 | if ret != 1 { |
| 522 | fmt.Printf("FAIL: Test case %d (%q) [%v] - processing AAD failed. got %d, want %v\n", wt.TCID, wt.Comment, action, ret, wt.Result) | 522 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - processing AAD failed. got %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, action, ret, wt.Result) |
| 523 | return false | 523 | return false |
| 524 | } | 524 | } |
| 525 | 525 | ||
| @@ -534,7 +534,7 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int, key [] | |||
| 534 | if wt.Result == "invalid" { | 534 | if wt.Result == "invalid" { |
| 535 | return true | 535 | return true |
| 536 | } | 536 | } |
| 537 | fmt.Printf("FAIL: Test case %d (%q) [%v] - EVP_CipherUpdate() = %d, want %v\n", wt.TCID, wt.Comment, action, ret, wt.Result) | 537 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - EVP_CipherUpdate() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, action, ret, wt.Result) |
| 538 | return false | 538 | return false |
| 539 | } | 539 | } |
| 540 | 540 | ||
| @@ -544,27 +544,27 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int, key [] | |||
| 544 | 544 | ||
| 545 | ret = C.EVP_CipherFinal_ex(ctx, (*C.uchar)(unsafe.Pointer(&dummyOut[0])), &tmpLen) | 545 | ret = C.EVP_CipherFinal_ex(ctx, (*C.uchar)(unsafe.Pointer(&dummyOut[0])), &tmpLen) |
| 546 | if ret != 1 { | 546 | if ret != 1 { |
| 547 | fmt.Printf("FAIL: Test case %d (%q) [%v] - EVP_CipherFinal_ex() = %d, want %v\n", wt.TCID, wt.Comment, action, ret, wt.Result) | 547 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - EVP_CipherFinal_ex() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, action, ret, wt.Result) |
| 548 | return false | 548 | return false |
| 549 | } | 549 | } |
| 550 | cipherOutLen += tmpLen | 550 | cipherOutLen += tmpLen |
| 551 | } | 551 | } |
| 552 | 552 | ||
| 553 | if cipherOutLen != C.int(outLen) { | 553 | if cipherOutLen != C.int(outLen) { |
| 554 | fmt.Printf("FAIL: Test case %d (%q) [%v] - cipherOutLen %d != outLen %d. Result %v\n", wt.TCID, wt.Comment, action, cipherOutLen, outLen, wt.Result) | 554 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - cipherOutLen %d != outLen %d. Result %v\n", wt.TCID, wt.Comment, wt.Flags, action, cipherOutLen, outLen, wt.Result) |
| 555 | return false | 555 | return false |
| 556 | } | 556 | } |
| 557 | 557 | ||
| 558 | success := true | 558 | success := true |
| 559 | if !bytes.Equal(cipherOut, out) { | 559 | if !bytes.Equal(cipherOut, out) { |
| 560 | 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) | 560 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - expected and computed output do not match. Result: %v\n", wt.TCID, wt.Comment, wt.Flags, action, wt.Result) |
| 561 | success = false | 561 | success = false |
| 562 | } | 562 | } |
| 563 | if doEncrypt == 1 { | 563 | if doEncrypt == 1 { |
| 564 | tagOut := make([]byte, tagLen) | 564 | tagOut := make([]byte, tagLen) |
| 565 | ret = C.EVP_CIPHER_CTX_ctrl(ctx, ctrlGetTag, C.int(tagLen), unsafe.Pointer(&tagOut[0])) | 565 | ret = C.EVP_CIPHER_CTX_ctrl(ctx, ctrlGetTag, C.int(tagLen), unsafe.Pointer(&tagOut[0])) |
| 566 | if ret != 1 { | 566 | if ret != 1 { |
| 567 | fmt.Printf("FAIL: Test case %d (%q) [%v] - EVP_CIPHER_CTX_ctrl() = %d, want %v\n", wt.TCID, wt.Comment, action, ret, wt.Result) | 567 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - EVP_CIPHER_CTX_ctrl() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, action, ret, wt.Result) |
| 568 | return false | 568 | return false |
| 569 | } | 569 | } |
| 570 | 570 | ||
| @@ -575,7 +575,7 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int, key [] | |||
| 575 | // support to the length of 96 bits, to promote | 575 | // support to the length of 96 bits, to promote |
| 576 | // interoperability, efficiency and simplicity of design." | 576 | // interoperability, efficiency and simplicity of design." |
| 577 | if bytes.Equal(tagOut, tag) != (wt.Result == "valid" || wt.Result == "acceptable") { | 577 | if bytes.Equal(tagOut, tag) != (wt.Result == "valid" || wt.Result == "acceptable") { |
| 578 | fmt.Printf("FAIL: Test case %d (%q) [%v] - expected and computed tag do not match - ret: %d, Result: %v\n", wt.TCID, wt.Comment, action, ret, wt.Result) | 578 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - expected and computed tag do not match - ret: %d, Result: %v\n", wt.TCID, wt.Comment, wt.Flags, action, ret, wt.Result) |
| 579 | success = false | 579 | success = false |
| 580 | } | 580 | } |
| 581 | } | 581 | } |
