@@ -6094,20 +6094,11 @@ WOLFSSL_ABI
60946094int wc_ecc_init_ex(ecc_key* key, void* heap, int devId)
60956095{
60966096 int ret = 0;
6097- #if defined(HAVE_PKCS11)
6098- int isPkcs11 = 0;
6099- #endif
61006097
61016098 if (key == NULL) {
61026099 return BAD_FUNC_ARG;
61036100 }
61046101
6105- #if defined(HAVE_PKCS11)
6106- if (key->isPkcs11) {
6107- isPkcs11 = 1;
6108- }
6109- #endif
6110-
61116102#ifdef ECC_DUMP_OID
61126103 wc_ecc_dump_oids();
61136104#endif
@@ -6161,16 +6152,17 @@ int wc_ecc_init_ex(ecc_key* key, void* heap, int devId)
61616152#endif
61626153
61636154#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
6164- #if defined(HAVE_PKCS11)
6165- if (!isPkcs11)
6155+ #ifdef WOLF_CRYPTO_CB
6156+ /* prefer crypto callback */
6157+ if (key->devId != INVALID_DEVID)
61666158 #endif
6167- {
6168- /* handle as async */
6169- ret = wolfAsync_DevCtxInit(&key->asyncDev, WOLFSSL_ASYNC_MARKER_ECC,
6170- key->heap, devId);
6171- }
6172- #elif defined(HAVE_PKCS11 )
6173- (void)isPkcs11 ;
6159+ {
6160+ /* handle as async */
6161+ ret = wolfAsync_DevCtxInit(&key->asyncDev, WOLFSSL_ASYNC_MARKER_ECC,
6162+ key->heap, devId);
6163+ }
6164+ if (ret != 0 )
6165+ return ret ;
61746166#endif
61756167
61766168#if defined(WOLFSSL_DSP)
@@ -6222,12 +6214,6 @@ int wc_ecc_init_id(ecc_key* key, unsigned char* id, int len, void* heap,
62226214 ret = BAD_FUNC_ARG;
62236215 if (ret == 0 && (len < 0 || len > ECC_MAX_ID_LEN))
62246216 ret = BUFFER_E;
6225-
6226- #if defined(HAVE_PKCS11)
6227- XMEMSET(key, 0, sizeof(ecc_key));
6228- key->isPkcs11 = 1;
6229- #endif
6230-
62316217 if (ret == 0)
62326218 ret = wc_ecc_init_ex(key, heap, devId);
62336219 if (ret == 0 && id != NULL && len != 0) {
@@ -6257,12 +6243,6 @@ int wc_ecc_init_label(ecc_key* key, const char* label, void* heap, int devId)
62576243 if (labelLen == 0 || labelLen > ECC_MAX_LABEL_LEN)
62586244 ret = BUFFER_E;
62596245 }
6260-
6261- #if defined(HAVE_PKCS11)
6262- XMEMSET(key, 0, sizeof(ecc_key));
6263- key->isPkcs11 = 1;
6264- #endif
6265-
62666246 if (ret == 0)
62676247 ret = wc_ecc_init_ex(key, heap, devId);
62686248 if (ret == 0) {
@@ -7177,7 +7157,7 @@ int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng,
71777157
71787158
71797159#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC) && \
7180- defined(WOLFSSL_ASYNC_CRYPT_SW)
7160+ defined(WOLFSSL_ASYNC_CRYPT_SW)
71817161 if (key->asyncDev.marker == WOLFSSL_ASYNC_MARKER_ECC) {
71827162 if (wc_AsyncSwInit(&key->asyncDev, ASYNC_SW_ECC_SIGN)) {
71837163 WC_ASYNC_SW* sw = &key->asyncDev.sw;
0 commit comments