Clarify why we set num_ops to 1 in iop key generation

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
This commit is contained in:
Waleed Elmelegy 2024-11-29 17:29:39 +00:00
parent 6305f5d6ef
commit 19d418a471
2 changed files with 10 additions and 0 deletions

View File

@ -645,6 +645,10 @@ psa_status_t mbedtls_psa_ecp_generate_key_iop_complete(
return mbedtls_to_psa_error(status);
}
/* Our implementation of key generation only generates the private key
which doesn't invlolve any ECC arithmetic operations so number of ops
is less than 1 but we round up to 1 to differentiate between num ops of
0 which means no work has been done this facilitates testing. */
operation->num_ops = 1;
status = mbedtls_mpi_write_binary(&operation->ecp.d, key_output, key_output_size);

View File

@ -10174,6 +10174,12 @@ void generate_key(int type_arg,
if (status == PSA_SUCCESS || status == PSA_OPERATION_INCOMPLETE) {
num_ops = psa_generate_key_iop_get_num_ops(&operation);
/* Our implementation of key generation only generates the private key
which doesn't invlolve any ECC arithmetic operations so number of ops
is less than 1 but we round up to 1 to differentiate between num ops of
0 which means no work has been done this facilitates testing.
It is acceptable however for other implementations to set the number of
ops to zero. */
TEST_LE_U(num_ops_prior + 1, num_ops);
num_ops_prior = num_ops;