FreeRTOS-Plus/ThirdParty/WolfSSL-FIPS-Ready/wolfcrypt/src/curve25519.c
/* curve25519 private key import only. (Big or Little endian)
 * return 0 on success */
curve25519 private key import only. (Big or Little endian)
return 0 on success
curve25519 private key import only . ( Big or Little endian ) return 0 on success
int wc_curve25519_import_private_ex(const byte* priv, word32 privSz,
                                    curve25519_key* key, int endian)
{
    if (key == NULL || priv == NULL)
        return BAD_FUNC_ARG;
    if ((int)privSz != CURVE25519_KEYSIZE)
        return ECC_BAD_ARG_E;
    if (endian == EC25519_BIG_ENDIAN) {
        int i;
        for (i = 0; i < CURVE25519_KEYSIZE; i++)
            key->k.point[i] = priv[CURVE25519_KEYSIZE - i - 1];
    }
    else
        XMEMCPY(key->k.point, priv, CURVE25519_KEYSIZE);
    key->dp = &curve25519_sets[0];
    key->k.point[0] &= 248;
    key->k.point[privSz-1] &= 63; 
    key->k.point[privSz-1] |= 64;
    return 0;
}
int wc_curve25519_import_private_ex ( const byte * priv , word32 privSz , curve25519_key * key , int endian ) { if ( key == NULL || priv == NULL ) return BAD_FUNC_ARG ; if ( ( int ) privSz != CURVE25519_KEYSIZE ) return ECC_BAD_ARG_E ; if ( endian == EC25519_BIG_ENDIAN ) { int i ; for ( i = 0 ; i < CURVE25519_KEYSIZE ; i ++ ) key -> k . point [ i ] = priv [ CURVE25519_KEYSIZE - i - 1 ] ; } else XMEMCPY ( key -> k . point , priv , CURVE25519_KEYSIZE ) ; key -> dp = & curve25519_sets [ 0 ] ; key -> k . point [ 0 ] &= 248 ; key -> k . point [ privSz - 1 ] &= 63 ; key -> k . point [ privSz - 1 ] |= 64 ; return 0 ; }
curve25519 private key import only.
curve25519 private key import only .
/* sanity check */ /* check size of incoming keys */ /* read the key in Big Endian format */ /* Clamp the key */ /* same &=127 because |=64 after */