Skip to content

Commit 26a7d59

Browse files
authored
Merge pull request #10232 from douzzer/20260415-confusing_globals
20260415-confusing_globals
2 parents faa6e98 + 4ac3c89 commit 26a7d59

7 files changed

Lines changed: 46 additions & 32 deletions

File tree

src/ssl.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15086,7 +15086,7 @@ void crypto_ex_cb_free_data(void *obj, CRYPTO_EX_cb_ctx* cb_ctx,
1508615086
}
1508715087

1508815088
/**
15089-
* get_ex_new_index is a helper function for the following
15089+
* wolfssl_local_get_ex_new_index is a helper function for the following
1509015090
* xx_get_ex_new_index functions:
1509115091
* - wolfSSL_CRYPTO_get_ex_new_index
1509215092
* - wolfSSL_CTX_get_ex_new_index
@@ -15095,7 +15095,7 @@ void crypto_ex_cb_free_data(void *obj, CRYPTO_EX_cb_ctx* cb_ctx,
1509515095
* Returns an index number greater or equal to zero on success,
1509615096
* -1 on failure.
1509715097
*/
15098-
int wolfssl_get_ex_new_index(int class_index, long ctx_l, void* ctx_ptr,
15098+
int wolfssl_local_get_ex_new_index(int class_index, long ctx_l, void* ctx_ptr,
1509915099
WOLFSSL_CRYPTO_EX_new* new_func, WOLFSSL_CRYPTO_EX_dup* dup_func,
1510015100
WOLFSSL_CRYPTO_EX_free* free_func)
1510115101
{
@@ -15161,8 +15161,8 @@ int wolfSSL_CTX_get_ex_new_index(long idx, void* arg,
1516115161

1516215162
WOLFSSL_ENTER("wolfSSL_CTX_get_ex_new_index");
1516315163

15164-
return wolfssl_get_ex_new_index(WOLF_CRYPTO_EX_INDEX_SSL_CTX, idx, arg,
15165-
new_func, dup_func, free_func);
15164+
return wolfssl_local_get_ex_new_index(WOLF_CRYPTO_EX_INDEX_SSL_CTX, idx,
15165+
arg, new_func, dup_func, free_func);
1516615166
}
1516715167

1516815168
/* Return the index that can be used for the WOLFSSL structure to store
@@ -15175,8 +15175,8 @@ int wolfSSL_get_ex_new_index(long argValue, void* arg,
1517515175
{
1517615176
WOLFSSL_ENTER("wolfSSL_get_ex_new_index");
1517715177

15178-
return wolfssl_get_ex_new_index(WOLF_CRYPTO_EX_INDEX_SSL, argValue, arg,
15179-
cb1, cb2, cb3);
15178+
return wolfssl_local_get_ex_new_index(WOLF_CRYPTO_EX_INDEX_SSL, argValue,
15179+
arg, cb1, cb2, cb3);
1518015180
}
1518115181
#endif /* HAVE_EX_DATA_CRYPTO */
1518215182

@@ -19170,7 +19170,7 @@ int wolfSSL_CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
1917019170
{
1917119171
WOLFSSL_ENTER("wolfSSL_CRYPTO_get_ex_new_index");
1917219172

19173-
return wolfssl_get_ex_new_index(class_index, argl, argp, new_func,
19173+
return wolfssl_local_get_ex_new_index(class_index, argl, argp, new_func,
1917419174
dup_func, free_func);
1917519175
}
1917619176
#endif /* HAVE_EX_DATA_CRYPTO */

src/ssl_load.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4198,20 +4198,20 @@ int wolfSSL_CTX_use_PrivateKey_Id(WOLFSSL_CTX* ctx, const unsigned char* id,
41984198
* @return 1 on success.
41994199
* @return 0 on failure.
42004200
*/
4201-
int wolfSSL_CTX_use_PrivateKey_id(WOLFSSL_CTX* ctx, const unsigned char* id,
4201+
int wolfSSL_CTX_use_PrivateKey_Id_ex(WOLFSSL_CTX* ctx, const unsigned char* id,
42024202
long sz, int devId, long keySz)
42034203
{
42044204
int ret;
42054205

4206-
WOLFSSL_ENTER("wolfSSL_CTX_use_PrivateKey_id");
4206+
WOLFSSL_ENTER("wolfSSL_CTX_use_PrivateKey_Id_ex");
42074207

42084208
ret = wolfSSL_CTX_use_PrivateKey_Id(ctx, id, sz, devId);
42094209
if (ret == 1) {
42104210
/* Set the key size which normally is calculated during decoding. */
42114211
ctx->privateKeySz = (int)keySz;
42124212
}
42134213

4214-
WOLFSSL_LEAVE("wolfSSL_CTX_use_PrivateKey_id", ret);
4214+
WOLFSSL_LEAVE("wolfSSL_CTX_use_PrivateKey_Id_ex", ret);
42154215
return ret;
42164216
}
42174217

@@ -4294,19 +4294,19 @@ int wolfSSL_CTX_use_AltPrivateKey_Id(WOLFSSL_CTX* ctx, const unsigned char* id,
42944294
return ret;
42954295
}
42964296

4297-
int wolfSSL_CTX_use_AltPrivateKey_id(WOLFSSL_CTX* ctx, const unsigned char* id,
4298-
long sz, int devId, long keySz)
4297+
int wolfSSL_CTX_use_AltPrivateKey_Id_ex(WOLFSSL_CTX* ctx,
4298+
const unsigned char* id, long sz, int devId, long keySz)
42994299
{
43004300
int ret;
43014301

4302-
WOLFSSL_ENTER("wolfSSL_CTX_use_AltPrivateKey_id");
4302+
WOLFSSL_ENTER("wolfSSL_CTX_use_AltPrivateKey_Id_ex");
43034303

43044304
ret = wolfSSL_CTX_use_AltPrivateKey_Id(ctx, id, sz, devId);
43054305
if (ret == 1) {
43064306
ctx->altPrivateKeySz = (word32)keySz;
43074307
}
43084308

4309-
WOLFSSL_LEAVE("wolfSSL_CTX_use_AltPrivateKey_id", ret);
4309+
WOLFSSL_LEAVE("wolfSSL_CTX_use_AltPrivateKey_Id_ex", ret);
43104310
return ret;
43114311
}
43124312

@@ -4606,7 +4606,7 @@ int wolfSSL_use_PrivateKey_Id(WOLFSSL* ssl, const unsigned char* id,
46064606
* @return 1 on success.
46074607
* @return 0 on failure.
46084608
*/
4609-
int wolfSSL_use_PrivateKey_id(WOLFSSL* ssl, const unsigned char* id,
4609+
int wolfSSL_use_PrivateKey_Id_ex(WOLFSSL* ssl, const unsigned char* id,
46104610
long sz, int devId, long keySz)
46114611
{
46124612
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,
47034703
return ret;
47044704
}
47054705

4706-
int wolfSSL_use_AltPrivateKey_id(WOLFSSL* ssl, const unsigned char* id, long sz,
4707-
int devId, long keySz)
4706+
int wolfSSL_use_AltPrivateKey_Id_ex(WOLFSSL* ssl, const unsigned char* id,
4707+
long sz, int devId, long keySz)
47084708
{
47094709
int ret = wolfSSL_use_AltPrivateKey_Id(ssl, id, sz, devId);
47104710
if (ret == 1) {

src/ssl_sess.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4366,8 +4366,8 @@ int wolfSSL_SESSION_get_ex_new_index(long ctx_l,void* ctx_ptr,
43664366
WOLFSSL_CRYPTO_EX_free* free_func)
43674367
{
43684368
WOLFSSL_ENTER("wolfSSL_SESSION_get_ex_new_index");
4369-
return wolfssl_get_ex_new_index(WOLF_CRYPTO_EX_INDEX_SSL_SESSION, ctx_l,
4370-
ctx_ptr, new_func, dup_func, free_func);
4369+
return wolfssl_local_get_ex_new_index(WOLF_CRYPTO_EX_INDEX_SSL_SESSION,
4370+
ctx_l, ctx_ptr, new_func, dup_func, free_func);
43714371
}
43724372
#endif /* HAVE_EX_DATA_CRYPTO */
43734373
#endif /* HAVE_EX_DATA */

src/x509.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15463,7 +15463,7 @@ int wolfSSL_X509_get_ex_new_index(int idx, void *arg,
1546315463
{
1546415464
WOLFSSL_ENTER("wolfSSL_X509_get_ex_new_index");
1546515465

15466-
return wolfssl_get_ex_new_index(WOLF_CRYPTO_EX_INDEX_X509, idx, arg,
15466+
return wolfssl_local_get_ex_new_index(WOLF_CRYPTO_EX_INDEX_X509, idx, arg,
1546715467
new_func, dup_func, free_func);
1546815468
}
1546915469
#endif

tests/api.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,8 +1703,8 @@ static int test_dual_alg_ecdsa_mldsa(void)
17031703
static int test_wolfSSL_use_AltPrivateKey_Id(void)
17041704
{
17051705
EXPECT_DECLS;
1706-
#if defined(WOLFSSL_DUAL_ALG_CERTS) && !defined(NO_TLS) && \
1707-
!defined(NO_WOLFSSL_CLIENT)
1706+
#if defined(WOLF_PRIVATE_KEY_ID) && defined(WOLFSSL_DUAL_ALG_CERTS) && \
1707+
!defined(NO_TLS) && !defined(NO_WOLFSSL_CLIENT)
17081708
WOLFSSL_CTX* ctx = NULL;
17091709
WOLFSSL* ssl = NULL;
17101710
const unsigned char id[] = { 0x01, 0x02, 0x03, 0x04 };
@@ -1724,7 +1724,8 @@ static int test_wolfSSL_use_AltPrivateKey_Id(void)
17241724

17251725
wolfSSL_free(ssl);
17261726
wolfSSL_CTX_free(ctx);
1727-
#endif /* WOLFSSL_DUAL_ALG_CERTS && !NO_TLS && !NO_WOLFSSL_CLIENT */
1727+
#endif /* WOLF_PRIVATE_KEY_ID && WOLFSSL_DUAL_ALG_CERTS && !NO_TLS && */
1728+
/* !NO_WOLFSSL_CLIENT */
17281729
return EXPECT_RESULT();
17291730
}
17301731

@@ -1735,8 +1736,8 @@ static int test_wolfSSL_use_AltPrivateKey_Id(void)
17351736
static int test_wolfSSL_use_AltPrivateKey_Label(void)
17361737
{
17371738
EXPECT_DECLS;
1738-
#if defined(WOLFSSL_DUAL_ALG_CERTS) && !defined(NO_TLS) && \
1739-
!defined(NO_WOLFSSL_CLIENT)
1739+
#if defined(WOLF_PRIVATE_KEY_ID) && defined(WOLFSSL_DUAL_ALG_CERTS) && \
1740+
!defined(NO_TLS) && !defined(NO_WOLFSSL_CLIENT)
17401741
WOLFSSL_CTX* ctx = NULL;
17411742
WOLFSSL* ssl = NULL;
17421743

@@ -1754,7 +1755,8 @@ static int test_wolfSSL_use_AltPrivateKey_Label(void)
17541755

17551756
wolfSSL_free(ssl);
17561757
wolfSSL_CTX_free(ctx);
1757-
#endif /* WOLFSSL_DUAL_ALG_CERTS && !NO_TLS && !NO_WOLFSSL_CLIENT */
1758+
#endif /* WOLF_PRIVATE_KEY_ID && WOLFSSL_DUAL_ALG_CERTS && !NO_TLS && */
1759+
/* !NO_WOLFSSL_CLIENT */
17581760
return EXPECT_RESULT();
17591761
}
17601762

wolfssl/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7336,7 +7336,7 @@ WOLFSSL_LOCAL void crypto_ex_cb_free_data(void *obj, CRYPTO_EX_cb_ctx* cb_ctx,
73367336
WOLFSSL_CRYPTO_EX_DATA* ex_data);
73377337
WOLFSSL_LOCAL int crypto_ex_cb_dup_data(const WOLFSSL_CRYPTO_EX_DATA *in,
73387338
WOLFSSL_CRYPTO_EX_DATA *out, CRYPTO_EX_cb_ctx* cb_ctx);
7339-
WOLFSSL_LOCAL int wolfssl_get_ex_new_index(int class_index, long ctx_l,
7339+
WOLFSSL_LOCAL int wolfssl_local_get_ex_new_index(int class_index, long ctx_l,
73407340
void* ctx_ptr, WOLFSSL_CRYPTO_EX_new* new_func,
73417341
WOLFSSL_CRYPTO_EX_dup* dup_func, WOLFSSL_CRYPTO_EX_free* free_func);
73427342
#endif /* HAVE_EX_DATA_CRYPTO */

wolfssl/ssl.h

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3765,14 +3765,18 @@ WOLFSSL_API int wolfSSL_make_eap_keys(WOLFSSL* ssl, void* key, unsigned int len,
37653765
const unsigned char* in, long sz, int format);
37663766
WOLFSSL_API int wolfSSL_CTX_use_PrivateKey_buffer(WOLFSSL_CTX* ctx,
37673767
const unsigned char* in, long sz, int format);
3768-
WOLFSSL_API int wolfSSL_CTX_use_PrivateKey_id(WOLFSSL_CTX* ctx,
3768+
#ifdef WOLF_PRIVATE_KEY_ID
3769+
WOLFSSL_API int wolfSSL_CTX_use_PrivateKey_Id_ex(WOLFSSL_CTX* ctx,
37693770
const unsigned char* id, long sz,
37703771
int devId, long keySz);
3772+
/* backward compatibility mapping for old confusable name. */
3773+
#define wolfSSL_CTX_use_PrivateKey_id wolfSSL_CTX_use_PrivateKey_Id_ex
37713774
WOLFSSL_API int wolfSSL_CTX_use_PrivateKey_Id(WOLFSSL_CTX* ctx,
37723775
const unsigned char* id, long sz,
37733776
int devId);
37743777
WOLFSSL_API int wolfSSL_CTX_use_PrivateKey_Label(WOLFSSL_CTX* ctx, const char* label,
37753778
int devId);
3779+
#endif /* WOLF_PRIVATE_KEY_ID */
37763780
WOLFSSL_API int wolfSSL_CTX_use_certificate_chain_buffer_format(WOLFSSL_CTX* ctx,
37773781
const unsigned char* in, long sz, int format);
37783782
WOLFSSL_API int wolfSSL_CTX_use_certificate_chain_buffer(WOLFSSL_CTX* ctx,
@@ -3786,9 +3790,11 @@ WOLFSSL_API int wolfSSL_make_eap_keys(WOLFSSL* ssl, void* key, unsigned int len,
37863790
#ifdef WOLFSSL_DUAL_ALG_CERTS
37873791
WOLFSSL_API int wolfSSL_CTX_use_AltPrivateKey_buffer(WOLFSSL_CTX* ctx,
37883792
const unsigned char* in, long sz, int format);
3789-
WOLFSSL_API int wolfSSL_CTX_use_AltPrivateKey_id(WOLFSSL_CTX* ctx,
3793+
WOLFSSL_API int wolfSSL_CTX_use_AltPrivateKey_Id_ex(WOLFSSL_CTX* ctx,
37903794
const unsigned char* id, long sz,
37913795
int devId, long keySz);
3796+
/* backward compatibility mapping for old confusable name. */
3797+
#define wolfSSL_CTX_use_AltPrivateKey_id wolfSSL_CTX_use_AltPrivateKey_Id_ex
37923798
WOLFSSL_API int wolfSSL_CTX_use_AltPrivateKey_Id(WOLFSSL_CTX* ctx,
37933799
const unsigned char* id, long sz, int devId);
37943800
WOLFSSL_API int wolfSSL_CTX_use_AltPrivateKey_Label(WOLFSSL_CTX* ctx,
@@ -3802,8 +3808,10 @@ WOLFSSL_API int wolfSSL_make_eap_keys(WOLFSSL* ssl, void* key, unsigned int len,
38023808
const unsigned char* der, int derSz);
38033809
WOLFSSL_API int wolfSSL_use_PrivateKey_buffer(WOLFSSL* ssl, const unsigned char* in,
38043810
long sz, int format);
3805-
WOLFSSL_API int wolfSSL_use_PrivateKey_id(WOLFSSL* ssl, const unsigned char* id,
3811+
WOLFSSL_API int wolfSSL_use_PrivateKey_Id_ex(WOLFSSL* ssl, const unsigned char* id,
38063812
long sz, int devId, long keySz);
3813+
/* backward compatibility mapping for old confusable name. */
3814+
#define wolfSSL_use_PrivateKey_id wolfSSL_use_PrivateKey_Id_ex
38073815
WOLFSSL_API int wolfSSL_use_PrivateKey_Id(WOLFSSL* ssl, const unsigned char* id,
38083816
long sz, int devId);
38093817
WOLFSSL_API int wolfSSL_use_PrivateKey_Label(WOLFSSL* ssl, const char* label, int devId);
@@ -3815,14 +3823,18 @@ WOLFSSL_API int wolfSSL_make_eap_keys(WOLFSSL* ssl, void* key, unsigned int len,
38153823
#ifdef WOLFSSL_DUAL_ALG_CERTS
38163824
WOLFSSL_API int wolfSSL_use_AltPrivateKey_buffer(WOLFSSL* ssl,
38173825
const unsigned char* in, long sz, int format);
3818-
WOLFSSL_API int wolfSSL_use_AltPrivateKey_id(WOLFSSL* ssl,
3826+
#endif /* WOLFSSL_DUAL_ALG_CERTS */
3827+
#ifdef WOLF_PRIVATE_KEY_ID
3828+
WOLFSSL_API int wolfSSL_use_AltPrivateKey_Id_ex(WOLFSSL* ssl,
38193829
const unsigned char* id, long sz,
38203830
int devId, long keySz);
3831+
/* backward compatibility mapping for old confusable name. */
3832+
#define wolfSSL_use_AltPrivateKey_id wolfSSL_use_AltPrivateKey_Id_ex
38213833
WOLFSSL_API int wolfSSL_use_AltPrivateKey_Id(WOLFSSL* ssl,
38223834
const unsigned char* id, long sz, int devId);
38233835
WOLFSSL_API int wolfSSL_use_AltPrivateKey_Label(WOLFSSL* ssl,
38243836
const char* label, int devId);
3825-
#endif
3837+
#endif /* WOLF_PRIVATE_KEY_ID */
38263838

38273839
#if (defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)) && \
38283840
defined(KEEP_OUR_CERT)

0 commit comments

Comments
 (0)