FreeRTOS-Plus/ThirdParty/WolfSSL-FIPS-Ready/wolfcrypt/src/curve25519.c
/* 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.
 */
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.
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;
    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); 
        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_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 ; 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 ) ; if ( ret == 0 ) XMEMCPY ( pub , wc_pub . point , CURVE25519_KEYSIZE ) ; } #else fe_init ( ) ; ret = curve25519 ( pub , priv , kCurve25519BasePoint ) ; #endif return ret ; }
compute the public key from an existing private key, using bare vectors.
compute the public key from an existing private key using bare vectors .
/* check clamping */ /* input basepoint on Weierstrass curve */