mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-03 20:54:41 +02:00
Fix up based on peer feedback
This commit is contained in:
@@ -55,47 +55,36 @@ int wc_ecc_make_key(WC_RNG* rng, int keysize, ecc_key* key);
|
||||
/*!
|
||||
\ingroup ECC
|
||||
|
||||
\brief Create an ECC key of specified size.
|
||||
\brief This function generates a new ecc_key and stores it in key.
|
||||
|
||||
\return MP_OKAY Success, key was created without issues.
|
||||
\return BAD_FUNC_ARG Returns if key or rng structure is NULL.
|
||||
\return INVALID_DEV_ID Returns if crypto callback set and bad device id.
|
||||
\return ECC_BAD_ARG_E if keysize is invalid
|
||||
\return ECC_CURVE_OID_E if invalid curve specified
|
||||
|
||||
\param key Pointer to store the created key.
|
||||
\param keysize size of key to be created in bytes (32-bytes = 256-bits)
|
||||
\param rng Rng to be used in key creation
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ecc_key key;
|
||||
int ret;
|
||||
WC_WC_RNG rng;
|
||||
wc_ecc_init(&key);
|
||||
wc_InitRng(&rng);
|
||||
ret = wc_ecc_make_key(&rng, 32, &key);
|
||||
if (ret != MP_OKAY) {
|
||||
// error handling
|
||||
}
|
||||
|
||||
\endcode
|
||||
|
||||
\sa wc_ecc_make_key_ex
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ecc_make_key_ex(WC_RNG* rng, int keysize, ecc_key* key, int curve_id);
|
||||
|
||||
/*!
|
||||
\ingroup ECC
|
||||
|
||||
\brief Create an ECC key of specified size.
|
||||
|
||||
\return MP_OKAY Success, key was created without issues.
|
||||
\return BAD_FUNC_ARG Returns if key or rng structure is NULL.
|
||||
\return INVALID_DEV_ID Returns if crypto callback set and bad device id.
|
||||
\return ECC_BAD_ARG_E if keysize is invalid
|
||||
\return ECC_CURVE_OID_E if invalid curve specified
|
||||
\return 0 Returned on success.
|
||||
\return ECC_BAD_ARG_E Returned if rng or key evaluate to NULL
|
||||
\return BAD_FUNC_ARG Returned if the specified key size is not in the
|
||||
correct range of supported keys
|
||||
\return MEMORY_E Returned if there is an error allocating memory while
|
||||
computing the ecc key
|
||||
\return MP_INIT_E may be returned if there is an error while computing
|
||||
the ecc key
|
||||
\return MP_READ_E may be returned if there is an error while computing
|
||||
the ecc key
|
||||
\return MP_CMP_E may be returned if there is an error while computing the
|
||||
ecc key
|
||||
\return MP_INVMOD_E may be returned if there is an error while computing
|
||||
the ecc key
|
||||
\return MP_EXPTMOD_E may be returned if there is an error while computing
|
||||
the ecc key
|
||||
\return MP_MOD_E may be returned if there is an error while computing the
|
||||
ecc key
|
||||
\return MP_MUL_E may be returned if there is an error while computing the
|
||||
ecc key
|
||||
\return MP_ADD_E may be returned if there is an error while computing the
|
||||
ecc key
|
||||
\return MP_MULMOD_E may be returned if there is an error while computing
|
||||
the ecc key
|
||||
\return MP_TO_E may be returned if there is an error while computing the
|
||||
ecc key
|
||||
\return MP_MEM may be returned if there is an error while computing the
|
||||
ecc key
|
||||
|
||||
\param key Pointer to store the created key.
|
||||
\param keysize size of key to be created in bytes, set based on curveId
|
||||
@@ -111,7 +100,7 @@ int wc_ecc_make_key_ex(WC_RNG* rng, int keysize, ecc_key* key, int curve_id);
|
||||
wc_InitRng(&rng);
|
||||
int curveId = ECC_SECP521R1;
|
||||
int keySize = wc_ecc_get_curve_size_from_id(curveId);
|
||||
ret = wc_ecc_make_key(&rng, keySize, &key, curveId);
|
||||
ret = wc_ecc_make_key_ex(&rng, keySize, &key, curveId);
|
||||
if (ret != MP_OKAY) {
|
||||
// error handling
|
||||
}
|
||||
@@ -122,6 +111,42 @@ int wc_ecc_make_key_ex(WC_RNG* rng, int keysize, ecc_key* key, int curve_id);
|
||||
\sa wc_ecc_get_curve_size_from_id
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ecc_make_key_ex(WC_RNG* rng, int keysize, ecc_key* key, int curve_id);
|
||||
|
||||
/*!
|
||||
\ingroup ECC
|
||||
|
||||
\brief Perform sanity checks on ecc key validity.
|
||||
|
||||
\return MP_OKAY Success, key is OK.
|
||||
\return BAD_FUNC_ARG Returns if key is NULL.
|
||||
\return ECC_INF_E Returns if wc_ecc_point_is_at_infinity returns 1.
|
||||
|
||||
\param key Pointer to key to check.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ecc_key key;
|
||||
WC_WC_RNG rng;
|
||||
int check_result;
|
||||
wc_ecc_init(&key);
|
||||
wc_InitRng(&rng);
|
||||
wc_ecc_make_key(&rng, 32, &key);
|
||||
check_result = wc_ecc_check_key(&key);
|
||||
|
||||
if (check_result == MP_OKAY)
|
||||
{
|
||||
// key check succeeded
|
||||
}
|
||||
else
|
||||
{
|
||||
// key check failed
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ecc_point_is_at_infinity
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ecc_check_key(ecc_key* key);
|
||||
|
||||
/*!
|
||||
|
Reference in New Issue
Block a user