Skip to content

Commit 259fb1b

Browse files
committed
Fix mutex guards to use WP_SINGLE_THREADED
1 parent 9d44125 commit 259fb1b

6 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/wp_dh_kmgmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ static wp_Dh* wp_dh_new(WOLFPROV_CTX *provCtx)
401401
WOLFPROV_MSG_DEBUG_RETCODE(WP_LOG_LEVEL_DEBUG, "wc_InitDhKey_ex", rc);
402402
ok = 0;
403403
}
404-
#ifndef SINGLE_THREADED
404+
#ifndef WP_SINGLE_THREADED
405405
if (ok) {
406406
rc = wc_InitMutex(&dh->mutex);
407407
if (rc != 0) {

src/wp_ecc_kmgmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ static wp_Ecc* wp_ecc_new(WOLFPROV_CTX *provCtx)
350350
}
351351
}
352352

353-
#ifndef SINGLE_THREADED
353+
#ifndef WP_SINGLE_THREADED
354354
if (ok) {
355355
rc = wc_InitMutex(&ecc->mutex);
356356
if (rc != 0) {

src/wp_ecx_kmgmt.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static wp_Ecx* wp_ecx_new(WOLFPROV_CTX* provCtx, const wp_EcxData* data)
283283
ok = 0;
284284
}
285285

286-
#ifndef SINGLE_THREADED
286+
#ifndef WP_SINGLE_THREADED
287287
if (ok) {
288288
rc = wc_InitMutex(&ecx->mutex);
289289
if (rc != 0) {
@@ -698,6 +698,9 @@ static int wp_ecx_match_priv_key(const wp_Ecx* ecx1, const wp_Ecx* ecx2)
698698
ok = 0;
699699
}
700700

701+
OPENSSL_cleanse(key1, sizeof(key1));
702+
OPENSSL_cleanse(key2, sizeof(key2));
703+
701704
WOLFPROV_LEAVE(WP_LOG_COMP_KE, __FILE__ ":" WOLFPROV_STRINGIZE(__LINE__), ok);
702705
return ok;
703706
}
@@ -1273,8 +1276,7 @@ static int wp_ecx_gen_set_params(wp_EcxGenCtx* ctx, const OSSL_PARAM params[])
12731276
&name)) {
12741277
ok = 0;
12751278
}
1276-
if (ok && (name != NULL) && (XSTRNCMP(name, ctx->name,
1277-
XSTRLEN(name)) != 0)) {
1279+
if (ok && (name != NULL) && (XSTRCMP(name, ctx->name) != 0)) {
12781280
ok = 0;
12791281
}
12801282

src/wp_kdf_kmgmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static wp_Kdf* wp_kdf_new(WOLFPROV_CTX *provCtx)
9696
kdf = (wp_Kdf*)OPENSSL_zalloc(sizeof(*kdf));
9797
}
9898
if (kdf != NULL) {
99-
#ifndef SINGLE_THREADED
99+
#ifndef WP_SINGLE_THREADED
100100
int rc = wc_InitMutex(&kdf->mutex);
101101
if (rc != 0) {
102102
WOLFPROV_MSG_DEBUG_RETCODE(WP_LOG_LEVEL_DEBUG, "wc_InitMutex", rc);

src/wp_mac_kmgmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static wp_Mac* wp_mac_new(WOLFPROV_CTX *provCtx, int type)
190190
mac = (wp_Mac*)OPENSSL_zalloc(sizeof(*mac));
191191
}
192192
if (mac != NULL) {
193-
#ifndef SINGLE_THREADED
193+
#ifndef WP_SINGLE_THREADED
194194
int rc = wc_InitMutex(&mac->mutex);
195195
if (rc != 0) {
196196
WOLFPROV_MSG_DEBUG_RETCODE(WP_LOG_LEVEL_DEBUG, "wc_InitMutex", rc);

src/wp_rsa_kmgmt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ static wp_Rsa* wp_rsa_base_new(WOLFPROV_CTX* provCtx, int type)
470470
ok = 0;
471471
}
472472

473-
#ifndef SINGLE_THREADED
473+
#ifndef WP_SINGLE_THREADED
474474
if (ok) {
475475
rc = wc_InitMutex(&rsa->mutex);
476476
if (rc != 0) {
@@ -600,7 +600,7 @@ static int wp_rsa_pss_params_set_pss_defaults(wp_RsaPssParams* pss)
600600
pss->hashType = WP_RSA_PSS_DIGEST_DEF;
601601
pss->mgf = WP_RSA_PSS_MGF_DEF;
602602
XSTRNCPY(pss->mdName, "SHA-1", sizeof(pss->mdName));
603-
XSTRNCPY(pss->mgfMdName, "SHA-1", sizeof(pss->mdName));
603+
XSTRNCPY(pss->mgfMdName, "SHA-1", sizeof(pss->mgfMdName));
604604
pss->saltLen = WP_RSA_DEFAULT_SALT_LEN;
605605
pss->derTrailer = 1; /* Default: RFC8017 A.2.3 */
606606

@@ -1228,7 +1228,7 @@ static int wp_rsa_import_key_data(wp_Rsa* rsa, const OSSL_PARAM params[],
12281228
p = &params[i];
12291229
index = -1;
12301230
for (j = 0; j < (int)ARRAY_SIZE(wp_rsa_param_key); j++) {
1231-
if (XSTRNCMP(p->key, wp_rsa_param_key[j], XSTRLEN(p->key)) == 0) {
1231+
if (XSTRCMP(p->key, wp_rsa_param_key[j]) == 0) {
12321232
index = j;
12331233
break;
12341234
}

0 commit comments

Comments
 (0)