From 1aaf058ac758b22a83c2153843f0263786fffbe6 Mon Sep 17 00:00:00 2001 From: tb Date: Tue, 2 Jan 2024 18:48:02 +0000 Subject: [PATCH] Two spellings of key length are enough The API is called EVP_CIPHER_CTX_set_key_length() it has an argument called keylen and, the EVP_CIPHER_CTX's member is called key_len. One of the three is trivial to adjust, so do it. --- lib/libcrypto/evp/evp_cipher.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/libcrypto/evp/evp_cipher.c b/lib/libcrypto/evp/evp_cipher.c index 38aeaa00301..c762c968eb9 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.6 2024/01/02 18:30:27 tb Exp $ */ +/* $OpenBSD: evp_cipher.c,v 1.7 2024/01/02 18:48:02 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -643,15 +643,16 @@ EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *ctx) } int -EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *ctx, int keylen) +EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *ctx, int key_len) { + /* XXX - remove this. It's unused. */ if (ctx->cipher->flags & EVP_CIPH_CUSTOM_KEY_LENGTH) return EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_KEY_LENGTH, - keylen, NULL); - if (ctx->key_len == keylen) + key_len, NULL); + if (ctx->key_len == key_len) return 1; - if (keylen > 0 && (ctx->cipher->flags & EVP_CIPH_VARIABLE_LENGTH)) { - ctx->key_len = keylen; + if (key_len > 0 && (ctx->cipher->flags & EVP_CIPH_VARIABLE_LENGTH)) { + ctx->key_len = key_len; return 1; } EVPerror(EVP_R_INVALID_KEY_LENGTH); -- 2.20.1