Skip to content

Commit da06e1a

Browse files
authored
Merge pull request wolfSSL#9558 from kareem-wolfssl/zd20944_2
Move Curve25519 public key check to make_pub/make_pub_blind to cover the case where they are called directly by an application.
2 parents 7a326ef + c238def commit da06e1a

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

wolfcrypt/src/curve25519.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,15 @@ int wc_curve25519_make_pub(int public_size, byte* pub, int private_size,
202202
#endif /* !WOLFSSL_CURVE25519_BLINDING */
203203
#endif /* FREESCALE_LTC_ECC */
204204

205+
/* If WOLFSSL_CURVE25519_BLINDING is defined, this check is run in
206+
* wc_curve25519_make_pub_blind since it could be called directly. */
207+
#if !defined(WOLFSSL_CURVE25519_BLINDING) || defined(FREESCALE_LTC_ECC)
208+
if (ret == 0) {
209+
ret = wc_curve25519_check_public(pub, (word32)public_size,
210+
EC25519_LITTLE_ENDIAN);
211+
}
212+
#endif
213+
205214
return ret;
206215
}
207216

@@ -297,6 +306,11 @@ int wc_curve25519_make_pub_blind(int public_size, byte* pub, int private_size,
297306
ret = curve25519_smul_blind(pub, priv, (byte*)kCurve25519BasePoint, rng);
298307
#endif
299308

309+
if (ret == 0) {
310+
ret = wc_curve25519_check_public(pub, (word32)public_size,
311+
EC25519_LITTLE_ENDIAN);
312+
}
313+
300314
return ret;
301315
}
302316
#endif
@@ -463,11 +477,6 @@ int wc_curve25519_make_key(WC_RNG* rng, int keysize, curve25519_key* key)
463477
ret = wc_curve25519_make_pub((int)sizeof(key->p.point), key->p.point,
464478
(int)sizeof(key->k), key->k);
465479
#endif
466-
if (ret == 0) {
467-
ret = wc_curve25519_check_public(key->p.point,
468-
(word32)sizeof(key->p.point),
469-
EC25519_LITTLE_ENDIAN);
470-
}
471480
key->pubSet = (ret == 0);
472481
}
473482
#endif

0 commit comments

Comments
 (0)