Fix up based on peer feedback

This commit is contained in:
kaleb-himes
2019-12-18 10:55:20 -07:00
parent ad3e105303
commit 2607cf3429

View File

@@ -55,47 +55,36 @@ int wc_ecc_make_key(WC_RNG* rng, int keysize, ecc_key* key);
/*! /*!
\ingroup ECC \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 0 Returned on success.
\return BAD_FUNC_ARG Returns if key or rng structure is NULL. \return ECC_BAD_ARG_E Returned if rng or key evaluate to NULL
\return INVALID_DEV_ID Returns if crypto callback set and bad device id. \return BAD_FUNC_ARG Returned if the specified key size is not in the
\return ECC_BAD_ARG_E if keysize is invalid correct range of supported keys
\return ECC_CURVE_OID_E if invalid curve specified \return MEMORY_E Returned if there is an error allocating memory while
computing the ecc key
\param key Pointer to store the created key. \return MP_INIT_E may be returned if there is an error while computing
\param keysize size of key to be created in bytes (32-bytes = 256-bits) the ecc key
\param rng Rng to be used in key creation \return MP_READ_E may be returned if there is an error while computing
the ecc key
_Example_ \return MP_CMP_E may be returned if there is an error while computing the
\code ecc key
ecc_key key; \return MP_INVMOD_E may be returned if there is an error while computing
int ret; the ecc key
WC_WC_RNG rng; \return MP_EXPTMOD_E may be returned if there is an error while computing
wc_ecc_init(&key); the ecc key
wc_InitRng(&rng); \return MP_MOD_E may be returned if there is an error while computing the
ret = wc_ecc_make_key(&rng, 32, &key); ecc key
if (ret != MP_OKAY) { \return MP_MUL_E may be returned if there is an error while computing the
// error handling ecc key
} \return MP_ADD_E may be returned if there is an error while computing the
ecc key
\endcode \return MP_MULMOD_E may be returned if there is an error while computing
the ecc key
\sa wc_ecc_make_key_ex \return MP_TO_E may be returned if there is an error while computing the
*/ ecc key
WOLFSSL_API \return MP_MEM may be returned if there is an error while computing the
int wc_ecc_make_key_ex(WC_RNG* rng, int keysize, ecc_key* key, int curve_id); ecc key
/*!
\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
\param key Pointer to store the created key. \param key Pointer to store the created key.
\param keysize size of key to be created in bytes, set based on curveId \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); wc_InitRng(&rng);
int curveId = ECC_SECP521R1; int curveId = ECC_SECP521R1;
int keySize = wc_ecc_get_curve_size_from_id(curveId); 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) { if (ret != MP_OKAY) {
// error handling // 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 \sa wc_ecc_get_curve_size_from_id
*/ */
WOLFSSL_API 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); int wc_ecc_check_key(ecc_key* key);
/*! /*!