Skip to content

Commit 58b9963

Browse files
Merge pull request #6266 from dgarske/zd15938_async_ecc
Fix for async ECC shared secret state
2 parents bdd4535 + 72ffa74 commit 58b9963

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

.github/workflows/async.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
config: [
1111
# Add new configs here
1212
'--enable-asynccrypt --enable-all --enable-dtls13',
13+
'--enable-asynccrypt-sw',
1314
]
1415
name: make check
1516
runs-on: ubuntu-latest

wolfcrypt/src/ecc.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4455,7 +4455,7 @@ int wc_ecc_shared_secret(ecc_key* private_key, ecc_key* public_key, byte* out,
44554455
!defined(WOLFSSL_CRYPTOCELL) && !defined(WOLFSSL_KCAPI_ECC) && \
44564456
!defined(WOLF_CRYPTO_CB_ONLY_ECC)
44574457

4458-
static int wc_ecc_shared_secret_gen_sync(ecc_key* private_key, ecc_point* point,
4458+
int wc_ecc_shared_secret_gen_sync(ecc_key* private_key, ecc_point* point,
44594459
byte* out, word32* outlen)
44604460
{
44614461
int err = MP_OKAY;
@@ -4749,11 +4749,6 @@ static int wc_ecc_shared_secret_gen_async(ecc_key* private_key,
47494749
&curve->Af->raw, &curve->Bf->raw, &curve->prime->raw,
47504750
private_key->dp->cofactor);
47514751
#endif
4752-
4753-
if (err == WC_PENDING_E) {
4754-
/* advance state, next call will handle return code processing */
4755-
private_key->state++;
4756-
}
47574752
}
47584753
else
47594754
#elif defined(WOLFSSL_ASYNC_CRYPT_SW)
@@ -4772,6 +4767,10 @@ static int wc_ecc_shared_secret_gen_async(ecc_key* private_key,
47724767
err = wc_ecc_shared_secret_gen_sync(private_key, point, out, outlen);
47734768
}
47744769

4770+
if (err == WC_PENDING_E) {
4771+
private_key->state++;
4772+
}
4773+
47754774
#if defined(HAVE_CAVIUM_V) || defined(HAVE_INTEL_QA)
47764775
wc_ecc_curve_free(curve);
47774776
FREE_CURVE_SPECS();
@@ -4826,8 +4825,7 @@ int wc_ecc_shared_secret_ex(ecc_key* private_key, ecc_point* point,
48264825
err = wc_ecc_shared_secret_gen_async(private_key, point,
48274826
out, outlen);
48284827
if (err == 0) {
4829-
/* advance state and exit early */
4830-
private_key->state++;
4828+
/* exit early */
48314829
RESTORE_VECTOR_REGISTERS();
48324830
return err;
48334831
}
@@ -8352,6 +8350,7 @@ static int ecc_verify_hash(mp_int *r, mp_int *s, const byte* hash,
83528350
if (NitroxEccIsCurveSupported(key))
83538351
#endif
83548352
{
8353+
word32 keySz = (word32)key->dp->size;
83558354
err = wc_mp_to_bigint_sz(e, &e->raw, keySz);
83568355
if (err == MP_OKAY)
83578356
err = wc_mp_to_bigint_sz(key->pubkey.x, &key->pubkey.x->raw, keySz);

wolfssl/wolfcrypt/ecc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,11 @@ WOLFSSL_API
604604
int wc_ecc_shared_secret_ex(ecc_key* private_key, ecc_point* point,
605605
byte* out, word32 *outlen);
606606

607+
/* Internal API for blocking ECDHE call */
608+
WOLFSSL_LOCAL
609+
int wc_ecc_shared_secret_gen_sync(ecc_key* private_key,
610+
ecc_point* point, byte* out, word32* outlen);
611+
607612
#if defined(WOLFSSL_ATECC508A) || defined(WOLFSSL_ATECC608A) || \
608613
defined(PLUTON_CRYPTO_ECC) || defined(WOLFSSL_CRYPTOCELL)
609614
#define wc_ecc_shared_secret_ssh wc_ecc_shared_secret

0 commit comments

Comments
 (0)