mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 03:34:39 +02:00
refactor wc_curve25519_make_key() to use wc_curve25519_make_pub() to complete the pair. also, add call to fe_init() in the non-NXP codepath of wc_curve25519_make_pub() (note fe_init() is currently a no-op).
This commit is contained in:
@@ -83,6 +83,7 @@ int wc_curve25519_make_pub(int public_size, byte* public, int private_size, cons
|
||||
XMEMCPY(public, wc_pub.point, CURVE25519_KEYSIZE);
|
||||
}
|
||||
#else
|
||||
fe_init();
|
||||
ret = curve25519(public, private, kCurve25519BasePoint);
|
||||
#endif
|
||||
|
||||
@@ -91,10 +92,7 @@ int wc_curve25519_make_pub(int public_size, byte* public, int private_size, cons
|
||||
|
||||
int wc_curve25519_make_key(WC_RNG* rng, int keysize, curve25519_key* key)
|
||||
{
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
const ECPoint* basepoint = nxp_ltc_curve25519_GetBasePoint();
|
||||
#endif
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
if (key == NULL || rng == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
@@ -103,10 +101,6 @@ int wc_curve25519_make_key(WC_RNG* rng, int keysize, curve25519_key* key)
|
||||
if (keysize != CURVE25519_KEYSIZE)
|
||||
return ECC_BAD_ARG_E;
|
||||
|
||||
#ifndef FREESCALE_LTC_ECC
|
||||
fe_init();
|
||||
#endif
|
||||
|
||||
/* random number for private key */
|
||||
ret = wc_RNG_GenerateBlock(rng, key->k.point, keysize);
|
||||
if (ret != 0)
|
||||
@@ -117,19 +111,7 @@ int wc_curve25519_make_key(WC_RNG* rng, int keysize, curve25519_key* key)
|
||||
key->k.point[CURVE25519_KEYSIZE-1] &= 63; /* same &=127 because |=64 after */
|
||||
key->k.point[CURVE25519_KEYSIZE-1] |= 64;
|
||||
|
||||
/* compute public key */
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
ret = nxp_ltc_curve25519(&key->p, key->k.point, basepoint, kLTC_Weierstrass); /* input basepoint on Weierstrass curve */
|
||||
#else
|
||||
ret = curve25519(key->p.point, key->k.point, kCurve25519BasePoint);
|
||||
#endif
|
||||
if (ret != 0) {
|
||||
ForceZero(key->k.point, keysize);
|
||||
ForceZero(key->p.point, keysize);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return wc_curve25519_make_pub((int)sizeof key->p.point, key->p.point, sizeof key->k.point, key->k.point);
|
||||
}
|
||||
|
||||
#ifdef HAVE_CURVE25519_SHARED_SECRET
|
||||
|
Reference in New Issue
Block a user