From d8085cc427c0e8dda9fdd9dd703c88c8eb798008 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Wed, 15 Apr 2026 11:53:06 -0500 Subject: [PATCH] src/ssl_load.c, wolfssl/ssl.h, tests/api.c: rename wolfSSL*PrivateKey_id() to wolfSSL*PrivateKey_Id_ex(), and add missing WOLF_PRIVATE_KEY_ID gating. --- src/ssl_load.c | 20 ++++++++++---------- tests/api.c | 14 ++++++++------ wolfssl/ssl.h | 14 +++++++++----- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/ssl_load.c b/src/ssl_load.c index 1f16cc6f0d..5c83e88c5a 100644 --- a/src/ssl_load.c +++ b/src/ssl_load.c @@ -4198,12 +4198,12 @@ int wolfSSL_CTX_use_PrivateKey_Id(WOLFSSL_CTX* ctx, const unsigned char* id, * @return 1 on success. * @return 0 on failure. */ -int wolfSSL_CTX_use_PrivateKey_id(WOLFSSL_CTX* ctx, const unsigned char* id, +int wolfSSL_CTX_use_PrivateKey_Id_ex(WOLFSSL_CTX* ctx, const unsigned char* id, long sz, int devId, long keySz) { int ret; - WOLFSSL_ENTER("wolfSSL_CTX_use_PrivateKey_id"); + WOLFSSL_ENTER("wolfSSL_CTX_use_PrivateKey_Id_ex"); ret = wolfSSL_CTX_use_PrivateKey_Id(ctx, id, sz, devId); if (ret == 1) { @@ -4211,7 +4211,7 @@ int wolfSSL_CTX_use_PrivateKey_id(WOLFSSL_CTX* ctx, const unsigned char* id, ctx->privateKeySz = (int)keySz; } - WOLFSSL_LEAVE("wolfSSL_CTX_use_PrivateKey_id", ret); + WOLFSSL_LEAVE("wolfSSL_CTX_use_PrivateKey_Id_ex", ret); return ret; } @@ -4294,19 +4294,19 @@ int wolfSSL_CTX_use_AltPrivateKey_Id(WOLFSSL_CTX* ctx, const unsigned char* id, return ret; } -int wolfSSL_CTX_use_AltPrivateKey_id(WOLFSSL_CTX* ctx, const unsigned char* id, - long sz, int devId, long keySz) +int wolfSSL_CTX_use_AltPrivateKey_Id_ex(WOLFSSL_CTX* ctx, + const unsigned char* id, long sz, int devId, long keySz) { int ret; - WOLFSSL_ENTER("wolfSSL_CTX_use_AltPrivateKey_id"); + WOLFSSL_ENTER("wolfSSL_CTX_use_AltPrivateKey_Id_ex"); ret = wolfSSL_CTX_use_AltPrivateKey_Id(ctx, id, sz, devId); if (ret == 1) { ctx->altPrivateKeySz = (word32)keySz; } - WOLFSSL_LEAVE("wolfSSL_CTX_use_AltPrivateKey_id", ret); + WOLFSSL_LEAVE("wolfSSL_CTX_use_AltPrivateKey_Id_ex", ret); return ret; } @@ -4606,7 +4606,7 @@ int wolfSSL_use_PrivateKey_Id(WOLFSSL* ssl, const unsigned char* id, * @return 1 on success. * @return 0 on failure. */ -int wolfSSL_use_PrivateKey_id(WOLFSSL* ssl, const unsigned char* id, +int wolfSSL_use_PrivateKey_Id_ex(WOLFSSL* ssl, const unsigned char* id, long sz, int devId, long keySz) { int ret = wolfSSL_use_PrivateKey_Id(ssl, id, sz, devId); @@ -4703,8 +4703,8 @@ int wolfSSL_use_AltPrivateKey_Id(WOLFSSL* ssl, const unsigned char* id, long sz, return ret; } -int wolfSSL_use_AltPrivateKey_id(WOLFSSL* ssl, const unsigned char* id, long sz, - int devId, long keySz) +int wolfSSL_use_AltPrivateKey_Id_ex(WOLFSSL* ssl, const unsigned char* id, + long sz, int devId, long keySz) { int ret = wolfSSL_use_AltPrivateKey_Id(ssl, id, sz, devId); if (ret == 1) { diff --git a/tests/api.c b/tests/api.c index 332c06afd9..f17753768d 100644 --- a/tests/api.c +++ b/tests/api.c @@ -1703,8 +1703,8 @@ static int test_dual_alg_ecdsa_mldsa(void) static int test_wolfSSL_use_AltPrivateKey_Id(void) { EXPECT_DECLS; -#if defined(WOLFSSL_DUAL_ALG_CERTS) && !defined(NO_TLS) && \ - !defined(NO_WOLFSSL_CLIENT) +#if defined(WOLF_PRIVATE_KEY_ID) && defined(WOLFSSL_DUAL_ALG_CERTS) && \ + !defined(NO_TLS) && !defined(NO_WOLFSSL_CLIENT) WOLFSSL_CTX* ctx = NULL; WOLFSSL* ssl = NULL; const unsigned char id[] = { 0x01, 0x02, 0x03, 0x04 }; @@ -1724,7 +1724,8 @@ static int test_wolfSSL_use_AltPrivateKey_Id(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); -#endif /* WOLFSSL_DUAL_ALG_CERTS && !NO_TLS && !NO_WOLFSSL_CLIENT */ +#endif /* WOLF_PRIVATE_KEY_ID && WOLFSSL_DUAL_ALG_CERTS && !NO_TLS && */ + /* !NO_WOLFSSL_CLIENT */ return EXPECT_RESULT(); } @@ -1735,8 +1736,8 @@ static int test_wolfSSL_use_AltPrivateKey_Id(void) static int test_wolfSSL_use_AltPrivateKey_Label(void) { EXPECT_DECLS; -#if defined(WOLFSSL_DUAL_ALG_CERTS) && !defined(NO_TLS) && \ - !defined(NO_WOLFSSL_CLIENT) +#if defined(WOLF_PRIVATE_KEY_ID) && defined(WOLFSSL_DUAL_ALG_CERTS) && \ + !defined(NO_TLS) && !defined(NO_WOLFSSL_CLIENT) WOLFSSL_CTX* ctx = NULL; WOLFSSL* ssl = NULL; @@ -1754,7 +1755,8 @@ static int test_wolfSSL_use_AltPrivateKey_Label(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); -#endif /* WOLFSSL_DUAL_ALG_CERTS && !NO_TLS && !NO_WOLFSSL_CLIENT */ +#endif /* WOLF_PRIVATE_KEY_ID && WOLFSSL_DUAL_ALG_CERTS && !NO_TLS && */ + /* !NO_WOLFSSL_CLIENT */ return EXPECT_RESULT(); } diff --git a/wolfssl/ssl.h b/wolfssl/ssl.h index 548b9a45a5..b2cf8b2212 100644 --- a/wolfssl/ssl.h +++ b/wolfssl/ssl.h @@ -3765,7 +3765,8 @@ WOLFSSL_API int wolfSSL_make_eap_keys(WOLFSSL* ssl, void* key, unsigned int len, const unsigned char* in, long sz, int format); WOLFSSL_API int wolfSSL_CTX_use_PrivateKey_buffer(WOLFSSL_CTX* ctx, const unsigned char* in, long sz, int format); - WOLFSSL_API int wolfSSL_CTX_use_PrivateKey_id(WOLFSSL_CTX* ctx, +#ifdef WOLF_PRIVATE_KEY_ID + WOLFSSL_API int wolfSSL_CTX_use_PrivateKey_Id_ex(WOLFSSL_CTX* ctx, const unsigned char* id, long sz, int devId, long keySz); WOLFSSL_API int wolfSSL_CTX_use_PrivateKey_Id(WOLFSSL_CTX* ctx, @@ -3773,6 +3774,7 @@ WOLFSSL_API int wolfSSL_make_eap_keys(WOLFSSL* ssl, void* key, unsigned int len, int devId); WOLFSSL_API int wolfSSL_CTX_use_PrivateKey_Label(WOLFSSL_CTX* ctx, const char* label, int devId); +#endif /* WOLF_PRIVATE_KEY_ID */ WOLFSSL_API int wolfSSL_CTX_use_certificate_chain_buffer_format(WOLFSSL_CTX* ctx, const unsigned char* in, long sz, int format); WOLFSSL_API int wolfSSL_CTX_use_certificate_chain_buffer(WOLFSSL_CTX* ctx, @@ -3786,7 +3788,7 @@ WOLFSSL_API int wolfSSL_make_eap_keys(WOLFSSL* ssl, void* key, unsigned int len, #ifdef WOLFSSL_DUAL_ALG_CERTS WOLFSSL_API int wolfSSL_CTX_use_AltPrivateKey_buffer(WOLFSSL_CTX* ctx, const unsigned char* in, long sz, int format); - WOLFSSL_API int wolfSSL_CTX_use_AltPrivateKey_id(WOLFSSL_CTX* ctx, + WOLFSSL_API int wolfSSL_CTX_use_AltPrivateKey_Id_ex(WOLFSSL_CTX* ctx, const unsigned char* id, long sz, int devId, long keySz); WOLFSSL_API int wolfSSL_CTX_use_AltPrivateKey_Id(WOLFSSL_CTX* ctx, @@ -3802,7 +3804,7 @@ WOLFSSL_API int wolfSSL_make_eap_keys(WOLFSSL* ssl, void* key, unsigned int len, const unsigned char* der, int derSz); WOLFSSL_API int wolfSSL_use_PrivateKey_buffer(WOLFSSL* ssl, const unsigned char* in, long sz, int format); - WOLFSSL_API int wolfSSL_use_PrivateKey_id(WOLFSSL* ssl, const unsigned char* id, + WOLFSSL_API int wolfSSL_use_PrivateKey_Id_ex(WOLFSSL* ssl, const unsigned char* id, long sz, int devId, long keySz); WOLFSSL_API int wolfSSL_use_PrivateKey_Id(WOLFSSL* ssl, const unsigned char* id, long sz, int devId); @@ -3815,14 +3817,16 @@ WOLFSSL_API int wolfSSL_make_eap_keys(WOLFSSL* ssl, void* key, unsigned int len, #ifdef WOLFSSL_DUAL_ALG_CERTS WOLFSSL_API int wolfSSL_use_AltPrivateKey_buffer(WOLFSSL* ssl, const unsigned char* in, long sz, int format); - WOLFSSL_API int wolfSSL_use_AltPrivateKey_id(WOLFSSL* ssl, +#endif /* WOLFSSL_DUAL_ALG_CERTS */ +#ifdef WOLF_PRIVATE_KEY_ID + WOLFSSL_API int wolfSSL_use_AltPrivateKey_Id_ex(WOLFSSL* ssl, const unsigned char* id, long sz, int devId, long keySz); WOLFSSL_API int wolfSSL_use_AltPrivateKey_Id(WOLFSSL* ssl, const unsigned char* id, long sz, int devId); WOLFSSL_API int wolfSSL_use_AltPrivateKey_Label(WOLFSSL* ssl, const char* label, int devId); -#endif +#endif /* WOLF_PRIVATE_KEY_ID */ #if (defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)) && \ defined(KEEP_OUR_CERT)