diff options
author | tb <> | 2018-09-02 17:05:51 +0000 |
---|---|---|
committer | tb <> | 2018-09-02 17:05:51 +0000 |
commit | acfaa0edfd1a46405f11f084ce62e978607b876f (patch) | |
tree | 6b738b5bfaf5dd8c2aaf22a002f166312c39b048 /src | |
parent | 032a3a2fcea899b2b2d4e0df7f5c241822442ac3 (diff) | |
download | openbsd-acfaa0edfd1a46405f11f084ce62e978607b876f.tar.gz openbsd-acfaa0edfd1a46405f11f084ce62e978607b876f.tar.bz2 openbsd-acfaa0edfd1a46405f11f084ce62e978607b876f.zip |
Use a Boolean rather than repeated string comparison.
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/wycheproof/wycheproof.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go index f9cc82d5c7..dc6702c7ae 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.39 2018/09/01 05:57:23 tb Exp $ */ | 1 | /* $OpenBSD: wycheproof.go,v 1.40 2018/09/02 17:05:51 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> |
@@ -458,8 +458,10 @@ func checkAesCcmOrGcm(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int, ke | |||
458 | var ctrlSetTag C.int | 458 | var ctrlSetTag C.int |
459 | var ctrlGetTag C.int | 459 | var ctrlGetTag C.int |
460 | 460 | ||
461 | doCCM := false | ||
461 | switch algorithm { | 462 | switch algorithm { |
462 | case "AES-CCM": | 463 | case "AES-CCM": |
464 | doCCM = true | ||
463 | ctrlSetIVLen = C.EVP_CTRL_CCM_SET_IVLEN | 465 | ctrlSetIVLen = C.EVP_CTRL_CCM_SET_IVLEN |
464 | ctrlSetTag = C.EVP_CTRL_CCM_SET_TAG | 466 | ctrlSetTag = C.EVP_CTRL_CCM_SET_TAG |
465 | ctrlGetTag = C.EVP_CTRL_CCM_GET_TAG | 467 | ctrlGetTag = C.EVP_CTRL_CCM_GET_TAG |
@@ -493,7 +495,7 @@ func checkAesCcmOrGcm(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int, ke | |||
493 | return false | 495 | return false |
494 | } | 496 | } |
495 | 497 | ||
496 | if doEncrypt == 0 || algorithm == "AES-CCM" { | 498 | if doEncrypt == 0 || doCCM { |
497 | ret = C.EVP_CIPHER_CTX_ctrl(ctx, ctrlSetTag, C.int(tagLen), setTag) | 499 | ret = C.EVP_CIPHER_CTX_ctrl(ctx, ctrlSetTag, C.int(tagLen), setTag) |
498 | if ret != 1 { | 500 | if ret != 1 { |
499 | if wt.Comment == "Invalid tag size" { | 501 | if wt.Comment == "Invalid tag size" { |
@@ -511,7 +513,7 @@ func checkAesCcmOrGcm(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int, ke | |||
511 | } | 513 | } |
512 | 514 | ||
513 | var cipherOutLen C.int | 515 | var cipherOutLen C.int |
514 | if algorithm == "AES-CCM" { | 516 | if doCCM { |
515 | ret = C.EVP_CipherUpdate(ctx, nil, &cipherOutLen, nil, C.int(inLen)) | 517 | ret = C.EVP_CipherUpdate(ctx, nil, &cipherOutLen, nil, C.int(inLen)) |
516 | if ret != 1 { | 518 | if ret != 1 { |
517 | 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) | 519 | 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) |