Add size asserts to psa_crypto test suite #265

Closed
AndrzejKurek wants to merge 1 commit from test-suite-psa-zero-size-asserts into development
AndrzejKurek commented 2019-09-18 03:26:07 -05:00 (Migrated from github.com)

Add a signature size check in the psa test suites.

Add a signature size check in the psa test suites.
gilles-peskine-arm (Migrated from github.com) requested changes 2019-09-18 04:43:07 -05:00
gilles-peskine-arm (Migrated from github.com) commented 2019-09-18 04:43:03 -05:00

No. If we're decrypting an empty plaintext, output_size should be 0, and output_data will be NULL as desired.

No. If we're decrypting an empty plaintext, `output_size` should be 0, and `output_data` will be `NULL` as desired.
AndrzejKurek (Migrated from github.com) reviewed 2019-09-18 04:49:45 -05:00
AndrzejKurek (Migrated from github.com) commented 2019-09-18 04:49:45 -05:00

Ok, thanks for clarifying.

Ok, thanks for clarifying.
gilles-peskine-arm (Migrated from github.com) reviewed 2019-09-18 05:18:03 -05:00
@ -3779,6 +3779,8 @@ void sign_fail( int key_type_arg, data_t *key_data,
size_t signature_length = 0xdeadbeef;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
TEST_ASSERT( signature_size != 0 );
gilles-peskine-arm (Migrated from github.com) commented 2019-09-18 05:18:03 -05:00

Why these assertions? If we wanted to test that psa_asymmetric_sign behaves properly when given an output buffer with a bad size, this test function should be the right thing to call. If something fails with signature_size == 0 or signature_size > PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE, the something in question should be fixed.

Why these assertions? If we wanted to test that `psa_asymmetric_sign` behaves properly when given an output buffer with a bad size, this test function should be the right thing to call. If something fails with `signature_size == 0` or `signature_size > PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE`, the something in question should be fixed.
AndrzejKurek (Migrated from github.com) reviewed 2019-09-19 04:42:08 -05:00
@ -3779,6 +3779,8 @@ void sign_fail( int key_type_arg, data_t *key_data,
size_t signature_length = 0xdeadbeef;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
TEST_ASSERT( signature_size != 0 );
AndrzejKurek (Migrated from github.com) commented 2019-09-19 04:42:08 -05:00

This is due to coverity complaining on the unknown signature size. I added the same check that is made in other tests, to unify it.

This is due to coverity complaining on the unknown signature size. I added the same check that is made in other tests, to unify it.
gilles-peskine-arm (Migrated from github.com) reviewed 2019-09-19 04:59:49 -05:00
@ -3779,6 +3779,8 @@ void sign_fail( int key_type_arg, data_t *key_data,
size_t signature_length = 0xdeadbeef;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
TEST_ASSERT( signature_size != 0 );
gilles-peskine-arm (Migrated from github.com) commented 2019-09-19 04:59:49 -05:00

Ok, but in this particular test, signature_size is legitimate input. If Coverity is complaining about something, we need to look into why it's complaining, not silence it by pretending this can't happen.

Ok, but in this particular test, `signature_size` is legitimate input. If Coverity is complaining about something, we need to look into why it's complaining, not silence it by pretending this can't happen.
AndrzejKurek commented 2019-09-19 06:17:02 -05:00 (Migrated from github.com)

Closing, since the Coverity issue turned out to be a false positive.

Closing, since the Coverity issue turned out to be a false positive.

Pull request closed

Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-ARMmbed/mbed-crypto!265
No description provided.