diff options
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 adf147651d..d2c2a30757 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.59 2018/09/22 00:10:18 tb Exp $ */ | 1 | /* $OpenBSD: wycheproof.go,v 1.60 2018/09/22 00:14:37 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> |
@@ -340,10 +340,10 @@ func checkAesCbcPkcs5(ctx *C.EVP_CIPHER_CTX, doEncrypt int, key []byte, keyLen i | |||
340 | ret = C.EVP_CipherUpdate(ctx, (*C.uchar)(unsafe.Pointer(&cipherOut[0])), &cipherOutLen, (*C.uchar)(unsafe.Pointer(&in[0])), C.int(inLen)) | 340 | ret = C.EVP_CipherUpdate(ctx, (*C.uchar)(unsafe.Pointer(&cipherOut[0])), &cipherOutLen, (*C.uchar)(unsafe.Pointer(&in[0])), C.int(inLen)) |
341 | if ret != 1 { | 341 | if ret != 1 { |
342 | if wt.Result == "invalid" { | 342 | if wt.Result == "invalid" { |
343 | 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) | 343 | fmt.Printf("INFO: Test case %d (%q) [%v] %v - EVP_CipherUpdate() = %d, want %v\n", wt.TCID, wt.Comment, action, wt.Flags, ret, wt.Result) |
344 | return true | 344 | return true |
345 | } | 345 | } |
346 | 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) | 346 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - EVP_CipherUpdate() = %d, want %v\n", wt.TCID, wt.Comment, action, wt.Flags, ret, wt.Result) |
347 | return false | 347 | return false |
348 | } | 348 | } |
349 | 349 | ||
@@ -353,13 +353,13 @@ func checkAesCbcPkcs5(ctx *C.EVP_CIPHER_CTX, doEncrypt int, key []byte, keyLen i | |||
353 | if wt.Result == "invalid" { | 353 | if wt.Result == "invalid" { |
354 | return true | 354 | return true |
355 | } | 355 | } |
356 | 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) | 356 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - EVP_CipherFinal_ex() = %d, want %v\n", wt.TCID, wt.Comment, action, wt.Flags, ret, wt.Result) |
357 | return false | 357 | return false |
358 | } | 358 | } |
359 | 359 | ||
360 | cipherOutLen += finallen | 360 | cipherOutLen += finallen |
361 | if cipherOutLen != C.int(outLen) && wt.Result != "invalid" { | 361 | if cipherOutLen != C.int(outLen) && wt.Result != "invalid" { |
362 | 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) | 362 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - open length mismatch: got %d, want %d\n", wt.TCID, wt.Comment, action, wt.Flags, cipherOutLen, outLen) |
363 | return false | 363 | return false |
364 | } | 364 | } |
365 | 365 | ||
@@ -375,7 +375,7 @@ func checkAesCbcPkcs5(ctx *C.EVP_CIPHER_CTX, doEncrypt int, key []byte, keyLen i | |||
375 | fmt.Printf("AUDIT: Test case %d (%q) %v\n", wt.TCID, wt.Comment, wt.Flags) | 375 | fmt.Printf("AUDIT: Test case %d (%q) %v\n", wt.TCID, wt.Comment, wt.Flags) |
376 | } | 376 | } |
377 | } else { | 377 | } else { |
378 | 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) | 378 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - msg match: %t; want %v\n", wt.TCID, wt.Comment, action, wt.Flags, bytes.Equal(openedMsg, out), wt.Result) |
379 | } | 379 | } |
380 | return success | 380 | return success |
381 | } | 381 | } |
@@ -492,7 +492,7 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int, key [] | |||
492 | if wt.Comment == "Nonce is too long" || wt.Comment == "Invalid nonce size" || wt.Comment == "0 size IV is not valid" { | 492 | if wt.Comment == "Nonce is too long" || wt.Comment == "Invalid nonce size" || wt.Comment == "0 size IV is not valid" { |
493 | return true | 493 | return true |
494 | } | 494 | } |
495 | 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) | 495 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - setting IV len to %d failed. got %d, want %v\n", wt.TCID, wt.Comment, action, wt.Flags, ivLen, ret, wt.Result) |
496 | return false | 496 | return false |
497 | } | 497 | } |
498 | 498 | ||
@@ -502,14 +502,14 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int, key [] | |||
502 | if wt.Comment == "Invalid tag size" { | 502 | if wt.Comment == "Invalid tag size" { |
503 | return true | 503 | return true |
504 | } | 504 | } |
505 | 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) | 505 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - setting tag length to %d failed. got %d, want %v\n", wt.TCID, wt.Comment, action, wt.Flags, tagLen, ret, wt.Result) |
506 | return false | 506 | return false |
507 | } | 507 | } |
508 | } | 508 | } |
509 | 509 | ||
510 | ret = C.EVP_CipherInit_ex(ctx, nil, nil, (*C.uchar)(unsafe.Pointer(&key[0])), (*C.uchar)(unsafe.Pointer(&iv[0])), C.int(doEncrypt)) | 510 | ret = C.EVP_CipherInit_ex(ctx, nil, nil, (*C.uchar)(unsafe.Pointer(&key[0])), (*C.uchar)(unsafe.Pointer(&iv[0])), C.int(doEncrypt)) |
511 | if ret != 1 { | 511 | if ret != 1 { |
512 | 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) | 512 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - setting key and IV failed. got %d, want %v\n", wt.TCID, wt.Comment, action, wt.Flags, ret, wt.Result) |
513 | return false | 513 | return false |
514 | } | 514 | } |
515 | 515 | ||
@@ -517,14 +517,14 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int, key [] | |||
517 | if doCCM { | 517 | if doCCM { |
518 | ret = C.EVP_CipherUpdate(ctx, nil, &cipherOutLen, nil, C.int(inLen)) | 518 | ret = C.EVP_CipherUpdate(ctx, nil, &cipherOutLen, nil, C.int(inLen)) |
519 | if ret != 1 { | 519 | if ret != 1 { |
520 | 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) | 520 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - setting input length to %d failed. got %d, want %v\n", wt.TCID, wt.Comment, action, wt.Flags, inLen, ret, wt.Result) |
521 | return false | 521 | return false |
522 | } | 522 | } |
523 | } | 523 | } |
524 | 524 | ||
525 | ret = C.EVP_CipherUpdate(ctx, nil, &cipherOutLen, (*C.uchar)(unsafe.Pointer(&aad[0])), C.int(aadLen)) | 525 | ret = C.EVP_CipherUpdate(ctx, nil, &cipherOutLen, (*C.uchar)(unsafe.Pointer(&aad[0])), C.int(aadLen)) |
526 | if ret != 1 { | 526 | if ret != 1 { |
527 | 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) | 527 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - processing AAD failed. got %d, want %v\n", wt.TCID, wt.Comment, action, wt.Flags, ret, wt.Result) |
528 | return false | 528 | return false |
529 | } | 529 | } |
530 | 530 | ||
@@ -539,7 +539,7 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int, key [] | |||
539 | if wt.Result == "invalid" { | 539 | if wt.Result == "invalid" { |
540 | return true | 540 | return true |
541 | } | 541 | } |
542 | 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) | 542 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - EVP_CipherUpdate() = %d, want %v\n", wt.TCID, wt.Comment, action, wt.Flags, ret, wt.Result) |
543 | return false | 543 | return false |
544 | } | 544 | } |
545 | 545 | ||
@@ -549,27 +549,27 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int, key [] | |||
549 | 549 | ||
550 | ret = C.EVP_CipherFinal_ex(ctx, (*C.uchar)(unsafe.Pointer(&dummyOut[0])), &tmpLen) | 550 | ret = C.EVP_CipherFinal_ex(ctx, (*C.uchar)(unsafe.Pointer(&dummyOut[0])), &tmpLen) |
551 | if ret != 1 { | 551 | if ret != 1 { |
552 | 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) | 552 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - EVP_CipherFinal_ex() = %d, want %v\n", wt.TCID, wt.Comment, action, wt.Flags, ret, wt.Result) |
553 | return false | 553 | return false |
554 | } | 554 | } |
555 | cipherOutLen += tmpLen | 555 | cipherOutLen += tmpLen |
556 | } | 556 | } |
557 | 557 | ||
558 | if cipherOutLen != C.int(outLen) { | 558 | if cipherOutLen != C.int(outLen) { |
559 | 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) | 559 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - cipherOutLen %d != outLen %d. Result %v\n", wt.TCID, wt.Comment, action, wt.Flags, cipherOutLen, outLen, wt.Result) |
560 | return false | 560 | return false |
561 | } | 561 | } |
562 | 562 | ||
563 | success := true | 563 | success := true |
564 | if !bytes.Equal(cipherOut, out) { | 564 | if !bytes.Equal(cipherOut, out) { |
565 | 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) | 565 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - expected and computed output do not match. Result: %v\n", wt.TCID, wt.Comment, action, wt.Flags, wt.Result) |
566 | success = false | 566 | success = false |
567 | } | 567 | } |
568 | if doEncrypt == 1 { | 568 | if doEncrypt == 1 { |
569 | tagOut := make([]byte, tagLen) | 569 | tagOut := make([]byte, tagLen) |
570 | ret = C.EVP_CIPHER_CTX_ctrl(ctx, ctrlGetTag, C.int(tagLen), unsafe.Pointer(&tagOut[0])) | 570 | ret = C.EVP_CIPHER_CTX_ctrl(ctx, ctrlGetTag, C.int(tagLen), unsafe.Pointer(&tagOut[0])) |
571 | if ret != 1 { | 571 | if ret != 1 { |
572 | 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) | 572 | fmt.Printf("FAIL: Test case %d (%q) [%v] %v - EVP_CIPHER_CTX_ctrl() = %d, want %v\n", wt.TCID, wt.Comment, action, wt.Flags, ret, wt.Result) |
573 | return false | 573 | return false |
574 | } | 574 | } |
575 | 575 | ||
@@ -580,7 +580,7 @@ func checkAesAead(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int, key [] | |||
580 | // support to the length of 96 bits, to promote | 580 | // support to the length of 96 bits, to promote |
581 | // interoperability, efficiency and simplicity of design." | 581 | // interoperability, efficiency and simplicity of design." |
582 | if bytes.Equal(tagOut, tag) != (wt.Result == "valid" || wt.Result == "acceptable") { | 582 | if bytes.Equal(tagOut, tag) != (wt.Result == "valid" || wt.Result == "acceptable") { |
583 | 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) | 583 | 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, action, wt.Flags, ret, wt.Result) |
584 | success = false | 584 | success = false |
585 | } | 585 | } |
586 | if success && acceptableAudit && wt.Result == "acceptable" { | 586 | if success && acceptableAudit && wt.Result == "acceptable" { |