From acfaa0edfd1a46405f11f084ce62e978607b876f Mon Sep 17 00:00:00 2001 From: tb <> Date: Sun, 2 Sep 2018 17:05:51 +0000 Subject: Use a Boolean rather than repeated string comparison. --- src/regress/lib/libcrypto/wycheproof/wycheproof.go | 8 +++++--- 1 file 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 @@ -/* $OpenBSD: wycheproof.go,v 1.39 2018/09/01 05:57:23 tb Exp $ */ +/* $OpenBSD: wycheproof.go,v 1.40 2018/09/02 17:05:51 tb Exp $ */ /* * Copyright (c) 2018 Joel Sing * Copyright (c) 2018 Theo Buehler @@ -458,8 +458,10 @@ func checkAesCcmOrGcm(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int, ke var ctrlSetTag C.int var ctrlGetTag C.int + doCCM := false switch algorithm { case "AES-CCM": + doCCM = true ctrlSetIVLen = C.EVP_CTRL_CCM_SET_IVLEN ctrlSetTag = C.EVP_CTRL_CCM_SET_TAG ctrlGetTag = C.EVP_CTRL_CCM_GET_TAG @@ -493,7 +495,7 @@ func checkAesCcmOrGcm(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int, ke return false } - if doEncrypt == 0 || algorithm == "AES-CCM" { + if doEncrypt == 0 || doCCM { ret = C.EVP_CIPHER_CTX_ctrl(ctx, ctrlSetTag, C.int(tagLen), setTag) if ret != 1 { if wt.Comment == "Invalid tag size" { @@ -511,7 +513,7 @@ func checkAesCcmOrGcm(algorithm string, ctx *C.EVP_CIPHER_CTX, doEncrypt int, ke } var cipherOutLen C.int - if algorithm == "AES-CCM" { + if doCCM { ret = C.EVP_CipherUpdate(ctx, nil, &cipherOutLen, nil, C.int(inLen)) if ret != 1 { 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) -- cgit v1.2.3-55-g6feb