Skip to content

Commit d1c321a

Browse files
committed
Don't override errors when blinding the priv key
1 parent 6914f08 commit d1c321a

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

src/ssl_load.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,26 +1354,31 @@ static int ProcessBufferPrivateKey(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
13541354
#endif /* WOLFSSL_ENCRYPTED_KEYS && !NO_PWDBASED */
13551355

13561356
#ifdef WOLFSSL_BLIND_PRIVATE_KEY
1357+
{
1358+
int blindRet = 0;
13571359
#ifdef WOLFSSL_DUAL_ALG_CERTS
1358-
if (type == ALT_PRIVATEKEY_TYPE) {
1360+
if (type == ALT_PRIVATEKEY_TYPE) {
1361+
if (ssl != NULL) {
1362+
blindRet = wolfssl_priv_der_blind(ssl->rng, ssl->buffers.altKey,
1363+
&ssl->buffers.altKeyMask);
1364+
}
1365+
else {
1366+
blindRet = wolfssl_priv_der_blind(NULL, ctx->altPrivateKey,
1367+
&ctx->altPrivateKeyMask);
1368+
}
1369+
}
1370+
else
1371+
#endif
13591372
if (ssl != NULL) {
1360-
ret = wolfssl_priv_der_blind(ssl->rng, ssl->buffers.altKey,
1361-
&ssl->buffers.altKeyMask);
1373+
blindRet = wolfssl_priv_der_blind(ssl->rng, ssl->buffers.key,
1374+
&ssl->buffers.keyMask);
13621375
}
13631376
else {
1364-
ret = wolfssl_priv_der_blind(NULL, ctx->altPrivateKey,
1365-
&ctx->altPrivateKeyMask);
1377+
blindRet = wolfssl_priv_der_blind(NULL, ctx->privateKey,
1378+
&ctx->privateKeyMask);
13661379
}
1367-
}
1368-
else
1369-
#endif
1370-
if (ssl != NULL) {
1371-
ret = wolfssl_priv_der_blind(ssl->rng, ssl->buffers.key,
1372-
&ssl->buffers.keyMask);
1373-
}
1374-
else {
1375-
ret = wolfssl_priv_der_blind(NULL, ctx->privateKey,
1376-
&ctx->privateKeyMask);
1380+
if (ret == 0 && blindRet != 0)
1381+
ret = blindRet;
13771382
}
13781383
#endif
13791384

0 commit comments

Comments
 (0)