ecp_curves: Updated input argument for mbedtls_ecp_modulus_setup
.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
This commit is contained in:
parent
be1bf15f76
commit
1d3e332986
2 changed files with 18 additions and 18 deletions
|
@ -5831,20 +5831,20 @@ int mbedtls_ecp_mod_p256k1_raw(mbedtls_mpi_uint *X, size_t X_limbs)
|
|||
MBEDTLS_STATIC_TESTABLE
|
||||
int mbedtls_ecp_modulus_setup(mbedtls_mpi_mod_modulus *N,
|
||||
const mbedtls_ecp_group_id id,
|
||||
const mbedtls_ecp_curve_type ctype)
|
||||
const mbedtls_ecp_modulus_type ctype)
|
||||
{
|
||||
mbedtls_mpi_uint *p = NULL;
|
||||
size_t p_limbs;
|
||||
|
||||
if (!(ctype == (mbedtls_ecp_curve_type) MBEDTLS_ECP_MOD_COORDINATE || \
|
||||
ctype == (mbedtls_ecp_curve_type) MBEDTLS_ECP_MOD_SCALAR)) {
|
||||
if (!(ctype == (mbedtls_ecp_modulus_type) MBEDTLS_ECP_MOD_COORDINATE || \
|
||||
ctype == (mbedtls_ecp_modulus_type) MBEDTLS_ECP_MOD_SCALAR)) {
|
||||
return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
|
||||
}
|
||||
|
||||
switch (id) {
|
||||
#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
|
||||
case MBEDTLS_ECP_DP_SECP192R1:
|
||||
if (ctype == (mbedtls_ecp_curve_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
if (ctype == (mbedtls_ecp_modulus_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
p = (mbedtls_mpi_uint *) secp192r1_p;
|
||||
p_limbs = CHARS_TO_LIMBS(sizeof(secp192r1_p));
|
||||
} else {
|
||||
|
@ -5856,7 +5856,7 @@ int mbedtls_ecp_modulus_setup(mbedtls_mpi_mod_modulus *N,
|
|||
|
||||
#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
|
||||
case MBEDTLS_ECP_DP_SECP224R1:
|
||||
if (ctype == (mbedtls_ecp_curve_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
if (ctype == (mbedtls_ecp_modulus_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
p = (mbedtls_mpi_uint *) secp224r1_p;
|
||||
p_limbs = CHARS_TO_LIMBS(sizeof(secp224r1_p));
|
||||
} else {
|
||||
|
@ -5868,7 +5868,7 @@ int mbedtls_ecp_modulus_setup(mbedtls_mpi_mod_modulus *N,
|
|||
|
||||
#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
|
||||
case MBEDTLS_ECP_DP_SECP256R1:
|
||||
if (ctype == (mbedtls_ecp_curve_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
if (ctype == (mbedtls_ecp_modulus_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
p = (mbedtls_mpi_uint *) secp256r1_p;
|
||||
p_limbs = CHARS_TO_LIMBS(sizeof(secp256r1_p));
|
||||
} else {
|
||||
|
@ -5880,7 +5880,7 @@ int mbedtls_ecp_modulus_setup(mbedtls_mpi_mod_modulus *N,
|
|||
|
||||
#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
|
||||
case MBEDTLS_ECP_DP_SECP384R1:
|
||||
if (ctype == (mbedtls_ecp_curve_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
if (ctype == (mbedtls_ecp_modulus_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
p = (mbedtls_mpi_uint *) secp384r1_p;
|
||||
p_limbs = CHARS_TO_LIMBS(sizeof(secp384r1_p));
|
||||
} else {
|
||||
|
@ -5892,7 +5892,7 @@ int mbedtls_ecp_modulus_setup(mbedtls_mpi_mod_modulus *N,
|
|||
|
||||
#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
|
||||
case MBEDTLS_ECP_DP_SECP521R1:
|
||||
if (ctype == (mbedtls_ecp_curve_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
if (ctype == (mbedtls_ecp_modulus_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
p = (mbedtls_mpi_uint *) secp521r1_p;
|
||||
p_limbs = CHARS_TO_LIMBS(sizeof(secp521r1_p));
|
||||
} else {
|
||||
|
@ -5904,7 +5904,7 @@ int mbedtls_ecp_modulus_setup(mbedtls_mpi_mod_modulus *N,
|
|||
|
||||
#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED)
|
||||
case MBEDTLS_ECP_DP_BP256R1:
|
||||
if (ctype == (mbedtls_ecp_curve_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
if (ctype == (mbedtls_ecp_modulus_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
p = (mbedtls_mpi_uint *) brainpoolP256r1_p;
|
||||
p_limbs = CHARS_TO_LIMBS(sizeof(brainpoolP256r1_p));
|
||||
} else {
|
||||
|
@ -5916,7 +5916,7 @@ int mbedtls_ecp_modulus_setup(mbedtls_mpi_mod_modulus *N,
|
|||
|
||||
#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED)
|
||||
case MBEDTLS_ECP_DP_BP384R1:
|
||||
if (ctype == (mbedtls_ecp_curve_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
if (ctype == (mbedtls_ecp_modulus_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
p = (mbedtls_mpi_uint *) brainpoolP384r1_p;
|
||||
p_limbs = CHARS_TO_LIMBS(sizeof(brainpoolP384r1_p));
|
||||
} else {
|
||||
|
@ -5928,7 +5928,7 @@ int mbedtls_ecp_modulus_setup(mbedtls_mpi_mod_modulus *N,
|
|||
|
||||
#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED)
|
||||
case MBEDTLS_ECP_DP_BP512R1:
|
||||
if (ctype == (mbedtls_ecp_curve_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
if (ctype == (mbedtls_ecp_modulus_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
p = (mbedtls_mpi_uint *) brainpoolP512r1_p;
|
||||
p_limbs = CHARS_TO_LIMBS(sizeof(brainpoolP512r1_p));
|
||||
} else {
|
||||
|
@ -5940,7 +5940,7 @@ int mbedtls_ecp_modulus_setup(mbedtls_mpi_mod_modulus *N,
|
|||
|
||||
#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED)
|
||||
case MBEDTLS_ECP_DP_CURVE25519:
|
||||
if (ctype == (mbedtls_ecp_curve_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
if (ctype == (mbedtls_ecp_modulus_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
p = (mbedtls_mpi_uint *) curve25519_p;
|
||||
p_limbs = CHARS_TO_LIMBS(sizeof(curve25519_p));
|
||||
} else {
|
||||
|
@ -5952,7 +5952,7 @@ int mbedtls_ecp_modulus_setup(mbedtls_mpi_mod_modulus *N,
|
|||
|
||||
#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
|
||||
case MBEDTLS_ECP_DP_SECP192K1:
|
||||
if (ctype == (mbedtls_ecp_curve_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
if (ctype == (mbedtls_ecp_modulus_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
p = (mbedtls_mpi_uint *) secp192k1_p;
|
||||
p_limbs = CHARS_TO_LIMBS(sizeof(secp192k1_p));
|
||||
} else {
|
||||
|
@ -5964,7 +5964,7 @@ int mbedtls_ecp_modulus_setup(mbedtls_mpi_mod_modulus *N,
|
|||
|
||||
#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED)
|
||||
case MBEDTLS_ECP_DP_SECP224K1:
|
||||
if (ctype == (mbedtls_ecp_curve_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
if (ctype == (mbedtls_ecp_modulus_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
p = (mbedtls_mpi_uint *) secp224k1_p;
|
||||
p_limbs = CHARS_TO_LIMBS(sizeof(secp224k1_p));
|
||||
} else {
|
||||
|
@ -5976,7 +5976,7 @@ int mbedtls_ecp_modulus_setup(mbedtls_mpi_mod_modulus *N,
|
|||
|
||||
#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
|
||||
case MBEDTLS_ECP_DP_SECP256K1:
|
||||
if (ctype == (mbedtls_ecp_curve_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
if (ctype == (mbedtls_ecp_modulus_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
p = (mbedtls_mpi_uint *) secp256k1_p;
|
||||
p_limbs = CHARS_TO_LIMBS(sizeof(secp256k1_p));
|
||||
} else {
|
||||
|
@ -5988,7 +5988,7 @@ int mbedtls_ecp_modulus_setup(mbedtls_mpi_mod_modulus *N,
|
|||
|
||||
#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
|
||||
case MBEDTLS_ECP_DP_CURVE448:
|
||||
if (ctype == (mbedtls_ecp_curve_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
if (ctype == (mbedtls_ecp_modulus_type) MBEDTLS_ECP_MOD_COORDINATE) {
|
||||
p = (mbedtls_mpi_uint *) curve448_p;
|
||||
p_limbs = CHARS_TO_LIMBS(sizeof(curve448_p));
|
||||
} else {
|
||||
|
|
|
@ -306,7 +306,7 @@ int mbedtls_ecp_mod_p448_raw(mbedtls_mpi_uint *X, size_t X_limbs);
|
|||
* \param[in,out] N The address of the modulus structure to populate.
|
||||
* Must be initialized.
|
||||
* \param[in] id The mbedtls_ecp_group_id for which to initialise the modulus.
|
||||
* \param[in] ctype The mbedtls_ecp_curve_type identifier for a coordinate modulus (P)
|
||||
* \param[in] ctype The mbedtls_ecp_modulus_type identifier for a coordinate modulus (P)
|
||||
* or a scalar modulus (N).
|
||||
*
|
||||
* \return \c 0 if successful.
|
||||
|
@ -317,7 +317,7 @@ int mbedtls_ecp_mod_p448_raw(mbedtls_mpi_uint *X, size_t X_limbs);
|
|||
MBEDTLS_STATIC_TESTABLE
|
||||
int mbedtls_ecp_modulus_setup(mbedtls_mpi_mod_modulus *N,
|
||||
const mbedtls_ecp_group_id id,
|
||||
const mbedtls_ecp_curve_type ctype);
|
||||
const mbedtls_ecp_modulus_type ctype);
|
||||
|
||||
#endif /* MBEDTLS_TEST_HOOKS && MBEDTLS_ECP_C */
|
||||
|
||||
|
|
Loading…
Reference in a new issue