mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-08 17:42:09 +03:00
ecp_curves: Adjusted expected_width inputs to use BITS_TO_LIMBS
macro.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
This commit is contained in:
@@ -4922,7 +4922,7 @@ static inline void carry64(mbedtls_mpi_uint *dst, mbedtls_mpi_uint *carry)
|
||||
static int ecp_mod_p192(mbedtls_mpi *N)
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
size_t expected_width = 2 * ((192 + biL - 1) / biL);
|
||||
size_t expected_width = BITS_TO_LIMBS(192) * 2;
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_grow(N, expected_width));
|
||||
ret = mbedtls_ecp_mod_p192_raw(N->p, expected_width);
|
||||
|
||||
@@ -4936,7 +4936,7 @@ int mbedtls_ecp_mod_p192_raw(mbedtls_mpi_uint *Np, size_t Nn)
|
||||
mbedtls_mpi_uint c = 0, last_carry[WIDTH] = { 0 };
|
||||
mbedtls_mpi_uint *p, *end;
|
||||
|
||||
if (Nn != 2*((192 + biL - 1)/biL)) {
|
||||
if (Nn != BITS_TO_LIMBS(192) * 2) {
|
||||
return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
|
||||
}
|
||||
|
||||
@@ -5082,7 +5082,7 @@ static inline int8_t extract_carry(int64_t cur)
|
||||
static int ecp_mod_p224(mbedtls_mpi *N)
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
size_t expected_width = 2 * 224 / biL;
|
||||
size_t expected_width = BITS_TO_LIMBS(224) * 2;
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_grow(N, expected_width));
|
||||
ret = mbedtls_ecp_mod_p224_raw(N->p, expected_width);
|
||||
cleanup:
|
||||
@@ -5092,7 +5092,7 @@ cleanup:
|
||||
MBEDTLS_STATIC_TESTABLE
|
||||
int mbedtls_ecp_mod_p224_raw(mbedtls_mpi_uint *X, size_t X_limbs)
|
||||
{
|
||||
if (X_limbs != 2 * 224 / biL) {
|
||||
if (X_limbs != BITS_TO_LIMBS(224) * 2) {
|
||||
return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
|
||||
}
|
||||
|
||||
@@ -5135,7 +5135,7 @@ int mbedtls_ecp_mod_p224_raw(mbedtls_mpi_uint *X, size_t X_limbs)
|
||||
static int ecp_mod_p256(mbedtls_mpi *N)
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
size_t expected_width = 2 * 256 / biL;
|
||||
size_t expected_width = BITS_TO_LIMBS(256) * 2;
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_grow(N, expected_width));
|
||||
ret = mbedtls_ecp_mod_p256_raw(N->p, expected_width);
|
||||
cleanup:
|
||||
@@ -5145,7 +5145,7 @@ cleanup:
|
||||
MBEDTLS_STATIC_TESTABLE
|
||||
int mbedtls_ecp_mod_p256_raw(mbedtls_mpi_uint *X, size_t X_limbs)
|
||||
{
|
||||
if (X_limbs != 2 * 256 / biL) {
|
||||
if (X_limbs != BITS_TO_LIMBS(256) * 2) {
|
||||
return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
|
||||
}
|
||||
|
||||
@@ -5215,7 +5215,7 @@ int mbedtls_ecp_mod_p256_raw(mbedtls_mpi_uint *X, size_t X_limbs)
|
||||
static int ecp_mod_p384(mbedtls_mpi *N)
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
size_t expected_width = 2 * ((384 + biL - 1) / biL);
|
||||
size_t expected_width = BITS_TO_LIMBS(384) * 2;
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_grow(N, expected_width));
|
||||
ret = mbedtls_ecp_mod_p384_raw(N->p, expected_width);
|
||||
cleanup:
|
||||
@@ -5225,7 +5225,7 @@ cleanup:
|
||||
MBEDTLS_STATIC_TESTABLE
|
||||
int mbedtls_ecp_mod_p384_raw(mbedtls_mpi_uint *X, size_t X_limbs)
|
||||
{
|
||||
if (X_limbs != 2*((384 + biL - 1)/biL)) {
|
||||
if (X_limbs != BITS_TO_LIMBS(384) * 2) {
|
||||
return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
|
||||
}
|
||||
|
||||
@@ -5337,7 +5337,7 @@ int mbedtls_ecp_mod_p384_raw(mbedtls_mpi_uint *X, size_t X_limbs)
|
||||
static int ecp_mod_p521(mbedtls_mpi *N)
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
size_t expected_width = 2 * P521_WIDTH;
|
||||
size_t expected_width = BITS_TO_LIMBS(521) * 2;
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_grow(N, expected_width));
|
||||
ret = mbedtls_ecp_mod_p521_raw(N->p, expected_width);
|
||||
cleanup:
|
||||
@@ -5349,7 +5349,7 @@ int mbedtls_ecp_mod_p521_raw(mbedtls_mpi_uint *X, size_t X_limbs)
|
||||
{
|
||||
mbedtls_mpi_uint carry = 0;
|
||||
|
||||
if (X_limbs != 2 * P521_WIDTH || X[2 * P521_WIDTH - 1] != 0) {
|
||||
if (X_limbs != BITS_TO_LIMBS(521) * 2) {
|
||||
return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
|
||||
}
|
||||
|
||||
@@ -5423,7 +5423,7 @@ int mbedtls_ecp_mod_p521_raw(mbedtls_mpi_uint *X, size_t X_limbs)
|
||||
static int ecp_mod_p255(mbedtls_mpi *N)
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
size_t expected_width = 2 * P255_WIDTH;
|
||||
size_t expected_width = BITS_TO_LIMBS(255) * 2;
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_grow(N, expected_width));
|
||||
ret = mbedtls_ecp_mod_p255_raw(N->p, expected_width);
|
||||
cleanup:
|
||||
@@ -5434,7 +5434,7 @@ MBEDTLS_STATIC_TESTABLE
|
||||
int mbedtls_ecp_mod_p255_raw(mbedtls_mpi_uint *X, size_t X_Limbs)
|
||||
{
|
||||
|
||||
if (X_Limbs != 2 * P255_WIDTH) {
|
||||
if (X_Limbs != BITS_TO_LIMBS(255) * 2) {
|
||||
return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
|
||||
}
|
||||
|
||||
@@ -5492,7 +5492,7 @@ int mbedtls_ecp_mod_p255_raw(mbedtls_mpi_uint *X, size_t X_Limbs)
|
||||
static int ecp_mod_p448(mbedtls_mpi *N)
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
size_t expected_width = 2 * ((448 + biL - 1) / biL);
|
||||
size_t expected_width = BITS_TO_LIMBS(448) * 2;
|
||||
|
||||
/* This is required as some tests and use cases do not pass in a Bignum of
|
||||
* the correct size, and expect the growth to be done automatically, which
|
||||
@@ -5522,7 +5522,7 @@ int mbedtls_ecp_mod_p448_raw(mbedtls_mpi_uint *X, size_t X_limbs)
|
||||
size_t round;
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
|
||||
if (X_limbs <= P448_WIDTH) {
|
||||
if (X_limbs != BITS_TO_LIMBS(448) * 2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -5734,7 +5734,7 @@ cleanup:
|
||||
static int ecp_mod_p192k1(mbedtls_mpi *N)
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
size_t expected_width = 2 * ((192 + biL - 1) / biL);
|
||||
size_t expected_width = BITS_TO_LIMBS(192) * 2;
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_grow(N, expected_width));
|
||||
ret = mbedtls_ecp_mod_p192k1_raw(N->p, expected_width);
|
||||
|
||||
@@ -5750,7 +5750,7 @@ int mbedtls_ecp_mod_p192k1_raw(mbedtls_mpi_uint *X, size_t X_limbs)
|
||||
0x01, 0x00, 0x00, 0x00)
|
||||
};
|
||||
|
||||
if (X_limbs != 2 * ((192 + biL - 1) / biL)) {
|
||||
if (X_limbs != BITS_TO_LIMBS(192) * 2) {
|
||||
return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
|
||||
}
|
||||
|
||||
@@ -5768,7 +5768,7 @@ int mbedtls_ecp_mod_p192k1_raw(mbedtls_mpi_uint *X, size_t X_limbs)
|
||||
static int ecp_mod_p224k1(mbedtls_mpi *N)
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
size_t expected_width = 2 * 224 / biL;
|
||||
size_t expected_width = BITS_TO_LIMBS(224) * 2;
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_grow(N, expected_width));
|
||||
ret = mbedtls_ecp_mod_p224k1_raw(N->p, expected_width);
|
||||
|
||||
@@ -5784,7 +5784,7 @@ int mbedtls_ecp_mod_p224k1_raw(mbedtls_mpi_uint *X, size_t X_limbs)
|
||||
0x01, 0x00, 0x00, 0x00)
|
||||
};
|
||||
|
||||
if (X_limbs != 2 * 224 / biL) {
|
||||
if (X_limbs != BITS_TO_LIMBS(224) * 2) {
|
||||
return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
|
||||
}
|
||||
|
||||
@@ -5802,7 +5802,7 @@ int mbedtls_ecp_mod_p224k1_raw(mbedtls_mpi_uint *X, size_t X_limbs)
|
||||
static int ecp_mod_p256k1(mbedtls_mpi *N)
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
size_t expected_width = 2 * ((256 + biL - 1) / biL);
|
||||
size_t expected_width = BITS_TO_LIMBS(256) * 2;
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_grow(N, expected_width));
|
||||
ret = mbedtls_ecp_mod_p256k1_raw(N->p, expected_width);
|
||||
|
||||
@@ -5818,7 +5818,7 @@ int mbedtls_ecp_mod_p256k1_raw(mbedtls_mpi_uint *X, size_t X_limbs)
|
||||
0x01, 0x00, 0x00, 0x00)
|
||||
};
|
||||
|
||||
if (X_limbs != 2 * ((256 + biL - 1) / biL)) {
|
||||
if (X_limbs != BITS_TO_LIMBS(256) * 2) {
|
||||
return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user