Skip to content

Commit d952ef6

Browse files
committed
Address CI failures
1 parent 02d8449 commit d952ef6

2 files changed

Lines changed: 11 additions & 33 deletions

File tree

wolfcrypt/src/ecc.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14484,12 +14484,8 @@ int wc_ecc_encrypt_ex(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
1448414484

1448514485
RESTORE_VECTOR_REGISTERS();
1448614486

14487-
if (sharedSecret != NULL) {
14488-
ForceZero(sharedSecret, sharedSz);
14489-
}
14490-
if (keys != NULL) {
14491-
ForceZero(keys, (word32)keysLen);
14492-
}
14487+
ForceZero(sharedSecret, sharedSz);
14488+
ForceZero(keys, (word32)keysLen);
1449314489
WC_FREE_VAR_EX(sharedSecret, ctx->heap, DYNAMIC_TYPE_ECC_BUFFER);
1449414490
WC_FREE_VAR_EX(keys, ctx->heap, DYNAMIC_TYPE_ECC_BUFFER);
1449514491

@@ -14888,12 +14884,8 @@ int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
1488814884
if (pubKey == peerKey)
1488914885
wc_ecc_free(peerKey);
1489014886
#endif
14891-
if (sharedSecret != NULL) {
14892-
ForceZero(sharedSecret, sharedSz);
14893-
}
14894-
if (keys != NULL) {
14895-
ForceZero(keys, (word32)keysLen);
14896-
}
14887+
ForceZero(sharedSecret, sharedSz);
14888+
ForceZero(keys, (word32)keysLen);
1489714889
#ifdef WOLFSSL_SMALL_STACK
1489814890
#ifndef WOLFSSL_ECIES_OLD
1489914891
XFREE(peerKey, ctx->heap, DYNAMIC_TYPE_ECC_BUFFER);

wolfcrypt/src/hpke.c

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -796,12 +796,8 @@ static int wc_HpkeEncap(Hpke* hpke, void* ephemeralKey, void* receiverKey,
796796
hpke->Npk * 2, sharedSecret);
797797
}
798798

799-
if (dh != NULL) {
800-
ForceZero(dh, hpke->Ndh);
801-
}
802-
if (kemContext != NULL) {
803-
ForceZero(kemContext, hpke->Npk * 2);
804-
}
799+
ForceZero(dh, hpke->Ndh);
800+
ForceZero(kemContext, hpke->Npk * 2);
805801
WC_FREE_VAR_EX(dh, hpke->heap, DYNAMIC_TYPE_TMP_BUFFER);
806802
WC_FREE_VAR_EX(kemContext, hpke->heap, DYNAMIC_TYPE_TMP_BUFFER);
807803

@@ -833,9 +829,7 @@ static int wc_HpkeSetupBaseSender(Hpke* hpke, HpkeBaseContext* context,
833829
infoSz);
834830
}
835831

836-
if (sharedSecret != NULL) {
837-
ForceZero(sharedSecret, hpke->Nsecret);
838-
}
832+
ForceZero(sharedSecret, hpke->Nsecret);
839833
WC_FREE_VAR_EX(sharedSecret, hpke->heap, DYNAMIC_TYPE_TMP_BUFFER);
840834

841835
return ret;
@@ -923,9 +917,7 @@ int wc_HpkeSealBase(Hpke* hpke, void* ephemeralKey, void* receiverKey,
923917

924918
PRIVATE_KEY_LOCK();
925919

926-
if (context != NULL) {
927-
ForceZero(context, sizeof(HpkeBaseContext));
928-
}
920+
ForceZero(context, sizeof(HpkeBaseContext));
929921
WC_FREE_VAR_EX(context, hpke->heap, DYNAMIC_TYPE_TMP_BUFFER);
930922

931923
return ret;
@@ -1044,9 +1036,7 @@ static int wc_HpkeDecap(Hpke* hpke, void* receiverKey, const byte* pubKey,
10441036
hpke->Npk * 2, sharedSecret);
10451037
}
10461038

1047-
if (dh != NULL) {
1048-
ForceZero(dh, hpke->Ndh);
1049-
}
1039+
ForceZero(dh, hpke->Ndh);
10501040
WC_FREE_VAR_EX(dh, hpke->heap, DYNAMIC_TYPE_TMP_BUFFER);
10511041
WC_FREE_VAR_EX(kemContext, hpke->heap, DYNAMIC_TYPE_TMP_BUFFER);
10521042

@@ -1073,9 +1063,7 @@ static int wc_HpkeSetupBaseReceiver(Hpke* hpke, HpkeBaseContext* context,
10731063
infoSz);
10741064
}
10751065

1076-
if (sharedSecret != NULL) {
1077-
ForceZero(sharedSecret, hpke->Nsecret);
1078-
}
1066+
ForceZero(sharedSecret, hpke->Nsecret);
10791067
WC_FREE_VAR_EX(sharedSecret, hpke->heap, DYNAMIC_TYPE_TMP_BUFFER);
10801068

10811069
return ret;
@@ -1162,9 +1150,7 @@ int wc_HpkeOpenBase(Hpke* hpke, void* receiverKey, const byte* pubKey,
11621150

11631151
PRIVATE_KEY_LOCK();
11641152

1165-
if (context != NULL) {
1166-
ForceZero(context, sizeof(HpkeBaseContext));
1167-
}
1153+
ForceZero(context, sizeof(HpkeBaseContext));
11681154
WC_FREE_VAR_EX(context, hpke->heap, DYNAMIC_TYPE_TMP_BUFFER);
11691155

11701156
return ret;

0 commit comments

Comments
 (0)