From: Pauli Date: Wed, 6 Aug 2025 02:25:00 +0000 (+1000) Subject: lms: convert to using generated parameter decoding X-Git-Tag: openssl-3.6.0-alpha1~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=326c36c418e83a959ee3d40193d5681435175959;p=thirdparty%2Fopenssl.git lms: convert to using generated parameter decoding Reviewed-by: Tomas Mraz Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/28275) --- diff --git a/crypto/lms/lms_pubkey_decode.c b/crypto/lms/lms_pubkey_decode.c index 10e7b3a80e2..1e4ac036222 100644 --- a/crypto/lms/lms_pubkey_decode.c +++ b/crypto/lms/lms_pubkey_decode.c @@ -121,15 +121,12 @@ err: * @param lmskey The LMS_KEY to load the public key data into. * @returns 1 on success, or 0 otherwise. */ -int ossl_lms_pubkey_from_params(const OSSL_PARAM params[], LMS_KEY *lmskey) +int ossl_lms_pubkey_from_params(const OSSL_PARAM *pub, LMS_KEY *lmskey) { - const OSSL_PARAM *p = NULL; - - p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PUB_KEY); - if (p != NULL) { - if (p->data == NULL - || p->data_type != OSSL_PARAM_OCTET_STRING - || !ossl_lms_pubkey_decode(p->data, p->data_size, lmskey)) + if (pub != NULL) { + if (pub->data == NULL + || pub->data_type != OSSL_PARAM_OCTET_STRING + || !ossl_lms_pubkey_decode(pub->data, pub->data_size, lmskey)) return 0; } return 1; diff --git a/include/crypto/lms.h b/include/crypto/lms.h index dd3fa4f541d..f5461c570d9 100644 --- a/include/crypto/lms.h +++ b/include/crypto/lms.h @@ -151,7 +151,7 @@ int ossl_lms_key_equal(const LMS_KEY *key1, const LMS_KEY *key2, int selection); int ossl_lms_key_valid(const LMS_KEY *key, int selection); int ossl_lms_key_has(const LMS_KEY *key, int selection); -int ossl_lms_pubkey_from_params(const OSSL_PARAM params[], LMS_KEY *lmskey); +int ossl_lms_pubkey_from_params(const OSSL_PARAM *pub, LMS_KEY *lmskey); int ossl_lms_pubkey_decode(const unsigned char *pub, size_t publen, LMS_KEY *lmskey); size_t ossl_lms_pubkey_length(const unsigned char *data, size_t datalen); diff --git a/providers/implementations/keymgmt/lms_kmgmt.c.in b/providers/implementations/keymgmt/lms_kmgmt.c.in index 5c3a1812501..7ba2c9d229c 100644 --- a/providers/implementations/keymgmt/lms_kmgmt.c.in +++ b/providers/implementations/keymgmt/lms_kmgmt.c.in @@ -6,10 +6,14 @@ * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ +{- +use OpenSSL::paramnames qw(produce_param_decoder); +-} #include #include #include +#include #include "crypto/lms.h" #include "internal/param_build_set.h" #include "prov/implementations.h" @@ -63,27 +67,30 @@ static int lms_match(const void *keydata1, const void *keydata2, int selection) return ossl_lms_key_equal(key1, key2, selection); } +{- produce_param_decoder('lms_import', + (['PKEY_PARAM_PUB_KEY', 'pub', 'octet_string'], + )); -} + static int lms_import(void *keydata, int selection, const OSSL_PARAM params[]) { LMS_KEY *key = keydata; + struct lms_import_st p; - if (!ossl_prov_is_running() || key == NULL) + if (!ossl_prov_is_running() + || key == NULL + || !lms_import_decoder(params, &p)) return 0; if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) == 0) return 0; - return ossl_lms_pubkey_from_params(params, key); + return ossl_lms_pubkey_from_params(p.pub, key); } -static const OSSL_PARAM lms_key_types[] = { - OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PUB_KEY, NULL, 0), - OSSL_PARAM_END -}; static const OSSL_PARAM *lms_imexport_types(int selection) { if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) - return lms_key_types; + return lms_import_list; return NULL; }