From a0acfa787e3801f2f84a4452a90790f7d8ecc14d Mon Sep 17 00:00:00 2001 From: tb Date: Tue, 2 Jan 2024 20:00:45 +0000 Subject: [PATCH] Simplify EVP_CIPHER_{asn1_to_param,parma_to_asn1}() There's no need for a ret variable and else if/else --- lib/libcrypto/evp/evp_cipher.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/lib/libcrypto/evp/evp_cipher.c b/lib/libcrypto/evp/evp_cipher.c index 82441cbc948..0e8c565b7e3 100644 --- a/lib/libcrypto/evp/evp_cipher.c +++ b/lib/libcrypto/evp/evp_cipher.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_cipher.c,v 1.8 2024/01/02 19:56:43 tb Exp $ */ +/* $OpenBSD: evp_cipher.c,v 1.9 2024/01/02 20:00:45 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -923,29 +923,25 @@ EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags) int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) { - int ret; - if (ctx->cipher->set_asn1_parameters != NULL) - ret = ctx->cipher->set_asn1_parameters(ctx, type); - else if (ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) - ret = EVP_CIPHER_set_asn1_iv(ctx, type); - else - ret = -1; - return (ret); + return ctx->cipher->set_asn1_parameters(ctx, type); + + if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) != 0) + return EVP_CIPHER_set_asn1_iv(ctx, type); + + return -1; } int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) { - int ret; - if (ctx->cipher->get_asn1_parameters != NULL) - ret = ctx->cipher->get_asn1_parameters(ctx, type); - else if (ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) - ret = EVP_CIPHER_get_asn1_iv(ctx, type); - else - ret = -1; - return (ret); + return ctx->cipher->get_asn1_parameters(ctx, type); + + if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) != 0) + return EVP_CIPHER_get_asn1_iv(ctx, type); + + return -1; } int -- 2.20.1