Update wolfSSL to the latest version(v.4.5.0) (#303)

* deleted old version wolfSSL before updating

* updated wolfSSL to the latest version(v4.4.0)

* updated wolfSSL to the latest version(v4.4.0)

* added macros for timing resistance

* Add wolfSSL-FIPS-Ready to Demo and Source

* Add wolfSSL-FIPS-Ready to Demo and Source

* Update README_wolfSSL_FIPS_Ready.md

* Remove unused files

* Update to wolfSSL-4.5.0-FIPS-Ready

* Increase FIPS version number for the default

* Update wolfSSL to the latest version(v.4.5.0)

* Fix version number

* Fix comments from github

Co-authored-by: RichardBarry <3073890+RichardBarry@users.noreply.github.com>
Co-authored-by: Ming Yue <mingyue86010@gmail.com>
Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com>
Co-authored-by: Cobus van Eeden <35851496+cobusve@users.noreply.github.com>
Co-authored-by: Alfred Gedeon <alfred2g@hotmail.com>
This commit is contained in:
TakayukiMatsuo 2020-10-24 11:35:06 +09:00 committed by GitHub
parent ee588710dd
commit c44794cd11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
471 changed files with 792175 additions and 60158 deletions

View file

@ -51,14 +51,49 @@ const curve25519_set_type curve25519_sets[] = {
}
};
static const unsigned char kCurve25519BasePoint[CURVE25519_KEYSIZE] = {9};
/* compute the public key from an existing private key, using bare vectors.
*
* return value is propagated from curve25519() (0 on success), or ECC_BAD_ARG_E,
* and the byte vectors are little endian.
*/
int wc_curve25519_make_pub(int public_size, byte* pub, int private_size,
const byte* priv) {
int ret;
if ((public_size != CURVE25519_KEYSIZE) ||
(private_size != CURVE25519_KEYSIZE)) {
return ECC_BAD_ARG_E;
}
if ((pub == NULL) || (priv == NULL))
return ECC_BAD_ARG_E;
/* check clamping */
if ((priv[0] & ~248) ||
(priv[CURVE25519_KEYSIZE-1] & 128)) {
return ECC_BAD_ARG_E;
}
#ifdef FREESCALE_LTC_ECC
{
const ECPoint* basepoint = nxp_ltc_curve25519_GetBasePoint();
ECPoint wc_pub;
ret = nxp_ltc_curve25519(&wc_pub, priv, basepoint, kLTC_Weierstrass); /* input basepoint on Weierstrass curve */
if (ret == 0)
XMEMCPY(pub, wc_pub.point, CURVE25519_KEYSIZE);
}
#else
fe_init();
ret = curve25519(pub, priv, kCurve25519BasePoint);
#endif
return ret;
}
int wc_curve25519_make_key(WC_RNG* rng, int keysize, curve25519_key* key)
{
#ifdef FREESCALE_LTC_ECC
const ECPoint* basepoint = wc_curve25519_GetBasePoint();
#else
unsigned char basepoint[CURVE25519_KEYSIZE] = {9};
#endif
int ret;
int ret;
if (key == NULL || rng == NULL)
return BAD_FUNC_ARG;
@ -67,10 +102,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)
@ -81,19 +112,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 = wc_curve25519(&key->p, key->k.point, basepoint, kLTC_Weierstrass); /* input basepoint on Weierstrass curve */
#else
ret = curve25519(key->p.point, key->k.point, basepoint);
#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
@ -127,7 +146,7 @@ int wc_curve25519_shared_secret_ex(curve25519_key* private_key,
return ECC_BAD_ARG_E;
#ifdef FREESCALE_LTC_ECC
ret = wc_curve25519(&o, private_key->k.point, &public_key->p, kLTC_Curve25519 /* input point P on Curve25519 */);
ret = nxp_ltc_curve25519(&o, private_key->k.point, &public_key->p, kLTC_Curve25519 /* input point P on Curve25519 */);
#else
ret = curve25519(o, private_key->k.point, public_key->p.point);
#endif