summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2025-07-22 09:29:31 +0000
committerjsing <>2025-07-22 09:29:31 +0000
commit51d40afc578a2778ef71c7194bb3b8499b0610f3 (patch)
tree651b72b7850bc9998617d3adacbd7b1f2af7af21 /src
parentef16ba98ee6bf1fad529d5b66f4dd0d862d1255c (diff)
downloadopenbsd-51d40afc578a2778ef71c7194bb3b8499b0610f3.tar.gz
openbsd-51d40afc578a2778ef71c7194bb3b8499b0610f3.tar.bz2
openbsd-51d40afc578a2778ef71c7194bb3b8499b0610f3.zip
Remove remaining block128_f casts from EVP AES.
Use aes_encrypt_block128() instead of AES_encrypt(), avoiding risky casts.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/aes/aes_local.h5
-rw-r--r--src/lib/libcrypto/evp/e_aes.c8
2 files changed, 8 insertions, 5 deletions
diff --git a/src/lib/libcrypto/aes/aes_local.h b/src/lib/libcrypto/aes/aes_local.h
index 539373ea06..a265eaac1d 100644
--- a/src/lib/libcrypto/aes/aes_local.h
+++ b/src/lib/libcrypto/aes/aes_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: aes_local.h,v 1.10 2025/07/21 10:24:23 jsing Exp $ */ 1/* $OpenBSD: aes_local.h,v 1.11 2025/07/22 09:29:31 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -63,6 +63,9 @@ __BEGIN_HIDDEN_DECLS
63/* This controls loop-unrolling in aes_core.c */ 63/* This controls loop-unrolling in aes_core.c */
64#undef FULL_UNROLL 64#undef FULL_UNROLL
65 65
66void aes_encrypt_block128(const unsigned char *in, unsigned char *out,
67 const void *key);
68
66void aes_ctr32_encrypt_ctr128f(const unsigned char *in, unsigned char *out, 69void aes_ctr32_encrypt_ctr128f(const unsigned char *in, unsigned char *out,
67 size_t blocks, const void *key, const unsigned char ivec[AES_BLOCK_SIZE]); 70 size_t blocks, const void *key, const unsigned char ivec[AES_BLOCK_SIZE]);
68 71
diff --git a/src/lib/libcrypto/evp/e_aes.c b/src/lib/libcrypto/evp/e_aes.c
index 005f1c49b2..63c9f9654c 100644
--- a/src/lib/libcrypto/evp/e_aes.c
+++ b/src/lib/libcrypto/evp/e_aes.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: e_aes.c,v 1.81 2025/07/22 09:13:49 jsing Exp $ */ 1/* $OpenBSD: e_aes.c,v 1.82 2025/07/22 09:29:31 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -818,7 +818,7 @@ aes_gcm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
818 return 1; 818 return 1;
819 if (key) { 819 if (key) {
820 AES_set_encrypt_key(key, ctx->key_len * 8, &gctx->ks); 820 AES_set_encrypt_key(key, ctx->key_len * 8, &gctx->ks);
821 CRYPTO_gcm128_init(&gctx->gcm, &gctx->ks, (block128_f)AES_encrypt); 821 CRYPTO_gcm128_init(&gctx->gcm, &gctx->ks, aes_encrypt_block128);
822 822
823 /* If we have an iv can set it directly, otherwise use 823 /* If we have an iv can set it directly, otherwise use
824 * saved IV. 824 * saved IV.
@@ -1229,7 +1229,7 @@ aes_ccm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
1229 if (key) { 1229 if (key) {
1230 AES_set_encrypt_key(key, ctx->key_len * 8, &cctx->ks); 1230 AES_set_encrypt_key(key, ctx->key_len * 8, &cctx->ks);
1231 CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L, 1231 CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L,
1232 &cctx->ks, (block128_f)AES_encrypt); 1232 &cctx->ks, aes_encrypt_block128);
1233 cctx->key_set = 1; 1233 cctx->key_set = 1;
1234 } 1234 }
1235 if (iv) { 1235 if (iv) {
@@ -1402,7 +1402,7 @@ aead_aes_gcm_init(EVP_AEAD_CTX *ctx, const unsigned char *key, size_t key_len,
1402 return 0; 1402 return 0;
1403 1403
1404 AES_set_encrypt_key(key, key_bits, &gcm_ctx->ks.ks); 1404 AES_set_encrypt_key(key, key_bits, &gcm_ctx->ks.ks);
1405 CRYPTO_gcm128_init(&gcm_ctx->gcm, &gcm_ctx->ks.ks, (block128_f)AES_encrypt); 1405 CRYPTO_gcm128_init(&gcm_ctx->gcm, &gcm_ctx->ks.ks, aes_encrypt_block128);
1406 gcm_ctx->tag_len = tag_len; 1406 gcm_ctx->tag_len = tag_len;
1407 ctx->aead_state = gcm_ctx; 1407 ctx->aead_state = gcm_ctx;
1408 1408