Skip to content

Commit

Permalink
Rename interruptible_key_agreement_get_min_num_ops()
Browse files Browse the repository at this point in the history
Rename interruptible_key_agreement_get_min_num_ops()
testing helper function to
interruptible_operations_get_min_num_ops() since it's
values are not only specefic to key agreement but to
any resartable ecp operation.

Also add different key sizes and rounding up for keys
where there are no data available.

Signed-off-by: Waleed Elmelegy <[email protected]>
  • Loading branch information
waleed-elmelegy-arm committed Dec 10, 2024
1 parent 5784dc5 commit 314af07
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tf-psa-crypto/tests/suites/test_suite_psa_crypto.function
Original file line number Diff line number Diff line change
Expand Up @@ -1246,11 +1246,13 @@ static void interruptible_signverify_get_minmax_completes(uint32_t max_ops,
/* ECP need to block for a minimum number of operations even if max_ops is set to a
lower value. This functions calculates this minimum value given the curve size
and the window size. */
static uint32_t interruptible_key_agreement_get_min_num_ops(size_t key_bits)
static uint32_t interruptible_operations_get_min_num_ops(size_t key_bits)
{
/* Those values are taken from documentation of mbedtls_ecp_set_max_ops()
in ecp.h. Those values can change at any time. */
switch (key_bits) {
case 192:
case 255:
case 256:
{
const uint32_t min_values[5] = { 208, 208, 160, 136, 124 }; // P-256
Expand All @@ -1263,6 +1265,7 @@ static uint32_t interruptible_key_agreement_get_min_num_ops(size_t key_bits)
return min_values[6 - MBEDTLS_ECP_WINDOW_SIZE];
break;
}
case 448:
case 512:
case 521:
{
Expand Down Expand Up @@ -9968,7 +9971,7 @@ void key_agreement_interruptible(int alg_arg,
mbedtls_ecp_check_pubkey() */
TEST_EQUAL(num_ops_prior, MBEDTLS_ECP_OPS_CHK);

min_num_ops = interruptible_key_agreement_get_min_num_ops(key_bits);
min_num_ops = interruptible_operations_get_min_num_ops(key_bits);

do {

Expand Down

0 comments on commit 314af07

Please sign in to comment.