mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-17 20:42:44 +00:00
Use loop instead goto and fix misleading variable name
Signed-off-by: Przemyslaw Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
parent
dc8d7d9211
commit
d80b6ed46d
@ -4860,7 +4860,7 @@ static psa_status_t psa_generate_derived_ecc_key_weierstrass_helper(
|
|||||||
size_t bits,
|
size_t bits,
|
||||||
psa_key_derivation_operation_t *operation,
|
psa_key_derivation_operation_t *operation,
|
||||||
uint8_t **data,
|
uint8_t **data,
|
||||||
unsigned *error)
|
unsigned *key_out_of_range)
|
||||||
{
|
{
|
||||||
mbedtls_mpi N;
|
mbedtls_mpi N;
|
||||||
mbedtls_mpi k;
|
mbedtls_mpi k;
|
||||||
@ -4931,7 +4931,7 @@ static psa_status_t psa_generate_derived_ecc_key_weierstrass_helper(
|
|||||||
*/
|
*/
|
||||||
MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &diff_N_2, &N, 2) );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &diff_N_2, &N, 2) );
|
||||||
MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &k, diff_N_2.n ) );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &k, diff_N_2.n ) );
|
||||||
MBEDTLS_MPI_CHK( mbedtls_mpi_lt_mpi_ct( &diff_N_2, &k, error ) );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_lt_mpi_ct( &diff_N_2, &k, key_out_of_range ) );
|
||||||
|
|
||||||
/* 5. Output k + 1 as the private key. */
|
/* 5. Output k + 1 as the private key. */
|
||||||
MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( &k, &k, 1));
|
MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( &k, &k, 1));
|
||||||
@ -4969,14 +4969,13 @@ static psa_status_t psa_generate_derived_key_internal(
|
|||||||
if ( PSA_KEY_TYPE_ECC_GET_FAMILY( slot->attr.type ) != PSA_ECC_FAMILY_MONTGOMERY )
|
if ( PSA_KEY_TYPE_ECC_GET_FAMILY( slot->attr.type ) != PSA_ECC_FAMILY_MONTGOMERY )
|
||||||
{
|
{
|
||||||
/* Weierstrass elliptic curve */
|
/* Weierstrass elliptic curve */
|
||||||
unsigned key_err = 0;
|
unsigned key_out_of_range = 0;
|
||||||
gen_ecc_key:
|
do
|
||||||
status = psa_generate_derived_ecc_key_weierstrass_helper(slot, bits, operation, &data, &key_err);
|
{
|
||||||
if( status != PSA_SUCCESS )
|
status = psa_generate_derived_ecc_key_weierstrass_helper(slot, bits, operation, &data, &key_out_of_range);
|
||||||
goto exit;
|
if( status != PSA_SUCCESS )
|
||||||
/* Key has been created, but it doesn't meet criteria. */
|
goto exit;
|
||||||
if (key_err)
|
} while ( key_out_of_range );
|
||||||
goto gen_ecc_key;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user