Change test loops over to do...while

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
Paul Elliott 2023-01-20 17:13:10 +00:00
parent 6ee2408d26
commit edfc883568

View file

@ -6497,7 +6497,7 @@ void sign_hash_interruptible(int key_type_arg, data_t *key_data,
TEST_ASSERT(num_ops_prior == 0);
/* Continue performing the signature until complete. */
while (status == PSA_OPERATION_INCOMPLETE) {
do {
status = psa_sign_hash_complete(&operation, signature, signature_size,
&signature_length);
@ -6509,7 +6509,7 @@ void sign_hash_interruptible(int key_type_arg, data_t *key_data,
num_ops_prior = num_ops;
}
}
} while (status == PSA_OPERATION_INCOMPLETE);
TEST_ASSERT(status == PSA_SUCCESS);
@ -6634,10 +6634,8 @@ void sign_hash_fail_interruptible(int key_type_arg, data_t *key_data,
num_ops_prior = psa_sign_hash_get_num_ops(&operation);
TEST_ASSERT(num_ops_prior == 0);
actual_status = PSA_OPERATION_INCOMPLETE;
/* Continue performing the signature until complete. */
while (actual_status == PSA_OPERATION_INCOMPLETE) {
do {
actual_status = psa_sign_hash_complete(&operation, signature,
signature_size,
&signature_length);
@ -6656,7 +6654,7 @@ void sign_hash_fail_interruptible(int key_type_arg, data_t *key_data,
num_ops_prior = num_ops;
}
}
} while (actual_status == PSA_OPERATION_INCOMPLETE);
PSA_ASSERT(psa_sign_hash_abort(&operation));
@ -6798,14 +6796,14 @@ void sign_verify_hash_interruptible(int key_type_arg, data_t *key_data,
input_data->x, input_data->len));
/* Continue performing the signature until complete. */
while (status == PSA_OPERATION_INCOMPLETE) {
do {
status = psa_sign_hash_complete(&sign_operation, signature,
signature_size,
&signature_length);
num_completes++;
}
} while (status == PSA_OPERATION_INCOMPLETE);
TEST_ASSERT(status == PSA_SUCCESS);
@ -6819,7 +6817,6 @@ void sign_verify_hash_interruptible(int key_type_arg, data_t *key_data,
TEST_ASSERT(signature_length > 0);
num_completes = 0;
status = PSA_OPERATION_INCOMPLETE;
/* Start verification. */
PSA_ASSERT(psa_verify_hash_start(&verify_operation, key, alg,
@ -6827,11 +6824,11 @@ void sign_verify_hash_interruptible(int key_type_arg, data_t *key_data,
signature, signature_length));
/* Continue performing the signature until complete. */
while (status == PSA_OPERATION_INCOMPLETE) {
do {
status = psa_verify_hash_complete(&verify_operation);
num_completes++;
}
} while (status == PSA_OPERATION_INCOMPLETE);
TEST_ASSERT(status == PSA_SUCCESS);
@ -6848,17 +6845,15 @@ void sign_verify_hash_interruptible(int key_type_arg, data_t *key_data,
* because ECDSA may ignore the last few bits of the input. */
input_data->x[0] ^= 1;
status = PSA_OPERATION_INCOMPLETE;
/* Start verification. */
PSA_ASSERT(psa_verify_hash_start(&verify_operation, key, alg,
input_data->x, input_data->len,
signature, signature_length));
/* Continue performing the signature until complete. */
while (status == PSA_OPERATION_INCOMPLETE) {
do {
status = psa_verify_hash_complete(&verify_operation);
}
} while (status == PSA_OPERATION_INCOMPLETE);
TEST_ASSERT(status == PSA_ERROR_INVALID_SIGNATURE);
}
@ -6955,7 +6950,7 @@ void verify_hash_interruptible(int key_type_arg, data_t *key_data,
TEST_ASSERT(num_ops_prior == 0);
/* Continue performing the signature until complete. */
while (status == PSA_OPERATION_INCOMPLETE) {
do {
status = psa_verify_hash_complete(&operation);
num_completes++;
@ -6966,7 +6961,7 @@ void verify_hash_interruptible(int key_type_arg, data_t *key_data,
num_ops_prior = num_ops;
}
}
} while (status == PSA_OPERATION_INCOMPLETE);
TEST_ASSERT(status == PSA_SUCCESS);
@ -7066,10 +7061,8 @@ void verify_hash_fail_interruptible(int key_type_arg, data_t *key_data,
num_ops_prior = psa_verify_hash_get_num_ops(&operation);
TEST_ASSERT(num_ops_prior == 0);
actual_status = PSA_OPERATION_INCOMPLETE;
/* Continue performing the signature until complete. */
while (actual_status == PSA_OPERATION_INCOMPLETE) {
do {
actual_status = psa_verify_hash_complete(&operation);
num_completes++;
@ -7086,7 +7079,7 @@ void verify_hash_fail_interruptible(int key_type_arg, data_t *key_data,
num_ops_prior = num_ops;
}
}
} while (actual_status == PSA_OPERATION_INCOMPLETE);
TEST_LE_U(min_completes, num_completes);
TEST_LE_U(num_completes, max_completes);