From bf0f1b5d6f3d32ff2ee4d5b3bb5f4909acc0b82c Mon Sep 17 00:00:00 2001 From: Pauli Date: Wed, 16 Apr 2025 17:32:13 +1000 Subject: [PATCH] AEAD params: generate a TRIE to decode AEAD cipher parameter names Reviewed-by: Dmitry Belyavskiy Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/27392) --- build.info | 6 +++- providers/implementations/ciphers/build.info | 2 ++ .../implementations/ciphers/ciphercommon.c.in | 30 +++++++++++++++++++ .../include/prov/ciphercommon.h | 4 +++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/build.info b/build.info index 329f0124637..aca3b90960d 100644 --- a/build.info +++ b/build.info @@ -48,7 +48,8 @@ DEPEND[]=include/openssl/asn1.h \ include/openssl/x509_acert.h \ include/openssl/x509_vfy.h \ include/crypto/bn_conf.h include/crypto/dso_conf.h \ - include/internal/param_names.h + include/internal/param_names.h \ + providers/implementations/ciphers/ciphercommon.c GENERATE[include/openssl/asn1.h]=include/openssl/asn1.h.in GENERATE[include/openssl/asn1t.h]=include/openssl/asn1t.h.in @@ -84,8 +85,11 @@ GENERATE[include/crypto/bn_conf.h]=include/crypto/bn_conf.h.in GENERATE[include/crypto/dso_conf.h]=include/crypto/dso_conf.h.in DEPEND[include/internal/param_names.h \ + providers/implementations/ciphers/ciphercommon.c \ include/openssl/core_names.h]=util/perl|OpenSSL/paramnames.pm GENERATE[include/internal/param_names.h]=include/internal/param_names.h.in +GENERATE[providers/implementations/ciphers/ciphercommon.c]=\ + providers/implementations/ciphers/ciphercommon.c.in GENERATE[include/openssl/core_names.h]=include/openssl/core_names.h.in IF[{- defined $target{shared_defflag} -}] diff --git a/providers/implementations/ciphers/build.info b/providers/implementations/ciphers/build.info index e9dbfecfacf..35b672c150b 100644 --- a/providers/implementations/ciphers/build.info +++ b/providers/implementations/ciphers/build.info @@ -90,6 +90,8 @@ SOURCE[$COMMON_GOAL]=\ ciphercommon_gcm.c ciphercommon_gcm_hw.c \ ciphercommon_ccm.c ciphercommon_ccm_hw.c +INCLUDE[ciphercommon.o]=. + IF[{- !$disabled{des} -}] SOURCE[$TDES_1_GOAL]=cipher_tdes.c cipher_tdes_common.c cipher_tdes_hw.c ENDIF diff --git a/providers/implementations/ciphers/ciphercommon.c.in b/providers/implementations/ciphers/ciphercommon.c.in index 3ce7de7b3e9..782b7f08231 100644 --- a/providers/implementations/ciphers/ciphercommon.c.in +++ b/providers/implementations/ciphers/ciphercommon.c.in @@ -6,18 +6,24 @@ * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ +{- +use OpenSSL::paramnames qw(produce_decoder); +-} /* * Generic dispatch table functions for ciphers. */ /* For SSL3_VERSION */ +#include #include #include #include "ciphercommon_local.h" #include "prov/provider_ctx.h" #include "prov/providercommon.h" #include "internal/skey.h" +#include "internal/e_os.h" +#include "internal/param_names.h" #include "crypto/types.h" /*- @@ -170,6 +176,20 @@ const OSSL_PARAM *ossl_cipher_aead_gettable_ctx_params( return cipher_aead_known_gettable_ctx_params; } +/* Machine generated by util/perl/OpenSSL/paramnames.pm */ +{- produce_decoder('ossl_cipher_aead_get_ctx_params_find_pidx', + ('CIPHER_PARAM_KEYLEN', + 'CIPHER_PARAM_IVLEN', + 'CIPHER_PARAM_AEAD_TAGLEN', + 'CIPHER_PARAM_IV', + 'CIPHER_PARAM_UPDATED_IV', + 'CIPHER_PARAM_AEAD_TAG', + 'CIPHER_PARAM_AEAD_TLS1_AAD_PAD', + 'CIPHER_PARAM_AEAD_TLS1_GET_IV_GEN', + 'CIPHER_PARAM_AEAD_IV_GENERATED', + )); -} +/* End of machine generated */ + static const OSSL_PARAM cipher_aead_known_settable_ctx_params[] = { OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_AEAD_IVLEN, NULL), OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_AEAD_TAG, NULL, 0), @@ -185,6 +205,16 @@ const OSSL_PARAM *ossl_cipher_aead_settable_ctx_params( return cipher_aead_known_settable_ctx_params; } +/* Machine generated by util/perl/OpenSSL/paramnames.pm */ +{- produce_decoder('ossl_cipher_aead_set_ctx_params_find_pidx', + ('CIPHER_PARAM_AEAD_IVLEN', + 'CIPHER_PARAM_AEAD_TAG', + 'CIPHER_PARAM_AEAD_TLS1_AAD', + 'CIPHER_PARAM_AEAD_TLS1_IV_FIXED', + 'CIPHER_PARAM_AEAD_TLS1_SET_IV_INV', + )); -} +/* End of machine generated */ + void ossl_cipher_generic_reset_ctx(PROV_CIPHER_CTX *ctx) { if (ctx != NULL && ctx->alloced) { diff --git a/providers/implementations/include/prov/ciphercommon.h b/providers/implementations/include/prov/ciphercommon.h index 46efdc80033..7d908c03aa3 100644 --- a/providers/implementations/include/prov/ciphercommon.h +++ b/providers/implementations/include/prov/ciphercommon.h @@ -372,4 +372,8 @@ int ossl_cipher_trailingdata(unsigned char *buf, size_t *buflen, size_t blocksize, const unsigned char **in, size_t *inlen); +/* Machine generated TRIE based OSSL_PARAM name parsers */ +int ossl_cipher_aead_get_ctx_params_find_pidx(const char *); +int ossl_cipher_aead_set_ctx_params_find_pidx(const char *); + #endif -- 2.47.2