Skip to content

Commit 2ac0d47

Browse files
committed
Fix for async edge case with Intel QuickAssist/Cavium Nitrox that was broken in PR #6783. Was causing re-entry and multiple calls for some operations like DH KeyGen that don't advance state on completion. wolfSSL/wolfAsyncCrypt#71
1 parent 0455224 commit 2ac0d47

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/internal.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7624,6 +7624,12 @@ int AllocKey(WOLFSSL* ssl, int type, void** pKey)
76247624
/* Sanity check key destination */
76257625
if (*pKey != NULL) {
76267626
WOLFSSL_MSG("Key already present!");
7627+
#ifdef WOLFSSL_ASYNC_CRYPT
7628+
/* allow calling this again for async reentry */
7629+
if (ssl->error == WC_PENDING_E) {
7630+
return 0;
7631+
}
7632+
#endif
76277633
return BAD_STATE_E;
76287634
}
76297635

@@ -38891,14 +38897,17 @@ int wolfSSL_AsyncPop(WOLFSSL* ssl, byte* state)
3889138897
XMEMSET(&asyncDev->event, 0, sizeof(WOLF_EVENT));
3889238898
ssl->asyncDev = NULL;
3889338899
}
38894-
#if !defined(WOLFSSL_ASYNC_CRYPT_SW) && \
38895-
(defined(WOLF_CRYPTO_CB) || defined(HAVE_PK_CALLBACKS))
38900+
/* for crypto or PK callback, if pending remove from queue */
38901+
#if (defined(WOLF_CRYPTO_CB) || defined(HAVE_PK_CALLBACKS)) && \
38902+
!defined(WOLFSSL_ASYNC_CRYPT_SW) && !defined(HAVE_INTEL_QA) && \
38903+
!defined(HAVE_CAVIUM)
3889638904
else if (ret == WC_PENDING_E) {
3889738905
/* Allow the underlying crypto API to be called again to trigger the
3889838906
* crypto or PK callback. The actual callback must be called, since
3889938907
* the completion is not detected in the poll like Intel QAT or
3890038908
* Nitrox */
3890138909
ret = wolfEventQueue_Remove(&ssl->ctx->event_queue, event);
38910+
3890238911
}
3890338912
#endif
3890438913
}

0 commit comments

Comments
 (0)