From c2782d1f52bceb30584b71c11631e00eacebcc4e Mon Sep 17 00:00:00 2001 From: jsing <> Date: Mon, 19 May 2025 04:32:52 +0000 Subject: Simplify EVP AES code for ECB. AES_ecb_encrypt() does not really do ECB - provide an aes_ecb_encrypt_internal that actually does multiple blocks and call this from aes_ecb_cipher(). Provide ECB with its own key initialisation function, which allows aes_init_key() to be simplified considerably. The block function pointer is now unused, so mop this up. ok joshua@ tb@ --- src/lib/libcrypto/aes/aes.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/lib/libcrypto/aes') diff --git a/src/lib/libcrypto/aes/aes.c b/src/lib/libcrypto/aes/aes.c index 712168e9fa..1c1c61a7a9 100644 --- a/src/lib/libcrypto/aes/aes.c +++ b/src/lib/libcrypto/aes/aes.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aes.c,v 1.6 2025/05/19 04:01:07 jsing Exp $ */ +/* $OpenBSD: aes.c,v 1.7 2025/05/19 04:32:51 jsing Exp $ */ /* ==================================================================== * Copyright (c) 2002-2006 The OpenSSL Project. All rights reserved. * @@ -190,6 +190,18 @@ AES_ecb_encrypt(const unsigned char *in, unsigned char *out, } LCRYPTO_ALIAS(AES_ecb_encrypt); +void +aes_ecb_encrypt_internal(const unsigned char *in, unsigned char *out, + size_t len, const AES_KEY *key, int encrypt) +{ + while (len >= AES_BLOCK_SIZE) { + AES_ecb_encrypt(in, out, key, encrypt); + in += AES_BLOCK_SIZE; + out += AES_BLOCK_SIZE; + len -= AES_BLOCK_SIZE; + } +} + void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key, unsigned char *ivec, int *num) -- cgit v1.2.3-55-g6feb