New function psa_hash_clone #18

Merged
gilles-peskine-arm merged 3 commits from psa-hash_clone into development 2019-01-22 11:35:26 -06:00
gilles-peskine-arm commented 2019-01-19 05:05:49 -06:00 (Migrated from github.com)

Clone a hash operation.

Test good cases as part as multipart tests. Add new test functions for
the state machine.

Clone a hash operation. Test good cases as part as multipart tests. Add new test functions for the state machine.
hanno-becker (Migrated from github.com) reviewed 2019-01-21 07:11:02 -06:00
@ -921,6 +921,33 @@ psa_status_t psa_hash_verify(psa_hash_operation_t *operation,
*/
hanno-becker (Migrated from github.com) commented 2019-01-21 07:11:02 -06:00

These two return value documentations seem to contradict each other.

These two return value documentations seem to contradict each other.
hanno-becker (Migrated from github.com) reviewed 2019-01-21 07:11:24 -06:00
@ -921,6 +921,33 @@ psa_status_t psa_hash_verify(psa_hash_operation_t *operation,
*/
hanno-becker (Migrated from github.com) commented 2019-01-21 07:11:24 -06:00

Do you mean \p target_operation is active in the second \retval?

Do you mean `\p target_operation is active` in the second `\retval`?
hanno-becker (Migrated from github.com) reviewed 2019-01-21 07:11:40 -06:00
@ -924,0 +932,4 @@
* two objects are independent, i.e. subsequent calls involving one of
* the objects do not affect the other object.
*
* \param[in] source_operation The active hash operation to clone.
hanno-becker (Migrated from github.com) commented 2019-01-21 07:11:40 -06:00

It should be documented that this should be initialized and active.

It should be documented that this should be initialized and active.
hanno-becker (Migrated from github.com) reviewed 2019-01-21 07:21:21 -06:00
@ -1421,6 +1421,67 @@ psa_status_t psa_hash_verify( psa_hash_operation_t *operation,
return( PSA_SUCCESS );
hanno-becker (Migrated from github.com) commented 2019-01-21 07:21:21 -06:00

Usually, the context acted upon is listed as the first argument; I'd therefore prefer the destination context to come first.

Usually, the context acted upon is listed as the first argument; I'd therefore prefer the destination context to come first.
hanno-becker (Migrated from github.com) reviewed 2019-01-21 07:27:39 -06:00
@ -1927,0 +1952,4 @@
PSA_ASSERT( psa_hash_clone( &op_source, &op_init ) );
PSA_ASSERT( psa_hash_finish( &op_init,
hash, sizeof( hash ), &hash_len ) );
PSA_ASSERT( psa_hash_clone( &op_source, &op_finished ) );
hanno-becker (Migrated from github.com) commented 2019-01-21 07:27:39 -06:00

Looking at this, I noticed that the documentation doesn't indicate the abstract state of a hash context after it has been terminated (through psa_hash_finish, psa_hash_abort, or psa_hash_verify). From my understanding, it's initialized but not setup/active. If so, you might consider documenting it, e.g. here.

Looking at this, I noticed that the documentation doesn't indicate the abstract state of a hash context after it has been terminated (through `psa_hash_finish`, `psa_hash_abort`, or `psa_hash_verify`). From my understanding, it's initialized but not setup/active. If so, you might consider documenting it, e.g. [here](https://github.com/ARMmbed/mbed-crypto/blob/ebb2c3e419911c353c731097f1aba3538cd324b9/include/psa/crypto.h#L753).
hanno-becker (Migrated from github.com) reviewed 2019-01-21 07:33:42 -06:00
@ -921,6 +921,33 @@ psa_status_t psa_hash_verify(psa_hash_operation_t *operation,
*/
psa_status_t psa_hash_abort(psa_hash_operation_t *operation);
/** Clone a hash operation.
hanno-becker (Migrated from github.com) commented 2019-01-21 07:33:42 -06:00

Everything else wouldn't make sense, but we might still mention here that the target context is active and in the same internal state as the source after a successful call to this function.

Everything else wouldn't make sense, but we might still mention here that the target context is active and in the same internal state as the source after a successful call to this function.
hanno-becker (Migrated from github.com) requested changes 2019-01-21 07:34:12 -06:00
hanno-becker (Migrated from github.com) left a comment

The code looks fine. I left a few suggestions on how to improve the documentation.

The code looks fine. I left a few suggestions on how to improve the documentation.
gilles-peskine-arm (Migrated from github.com) reviewed 2019-01-21 07:38:53 -06:00
@ -924,0 +932,4 @@
* two objects are independent, i.e. subsequent calls involving one of
* the objects do not affect the other object.
*
* \param[in] source_operation The active hash operation to clone.
gilles-peskine-arm (Migrated from github.com) commented 2019-01-21 07:38:53 -06:00

Isn't the current wording sufficent? Active implies initialized.

Isn't the current wording sufficent? Active implies initialized.
gilles-peskine-arm (Migrated from github.com) reviewed 2019-01-21 07:40:10 -06:00
@ -1421,6 +1421,67 @@ psa_status_t psa_hash_verify( psa_hash_operation_t *operation,
return( PSA_SUCCESS );
gilles-peskine-arm (Migrated from github.com) commented 2019-01-21 07:40:10 -06:00

There's no such convention in this API. There's a convention that input comes before output, and a convention that the context comes before other parameters. With an input context and an output context, the input context comes first.

There's no such convention in this API. There's a convention that input comes before output, and a convention that the context comes before other parameters. With an input context and an output context, the input context comes first.
gilles-peskine-arm (Migrated from github.com) reviewed 2019-01-21 07:46:02 -06:00
@ -1927,0 +1952,4 @@
PSA_ASSERT( psa_hash_clone( &op_source, &op_init ) );
PSA_ASSERT( psa_hash_finish( &op_init,
hash, sizeof( hash ), &hash_len ) );
PSA_ASSERT( psa_hash_clone( &op_source, &op_finished ) );
gilles-peskine-arm (Migrated from github.com) commented 2019-01-21 07:46:01 -06:00

This isn't critical to understanding the current behavior, and other types of operation should use consistent terminology, so I'll do that in a later writing pass. Tracked internally at
https://github.com/ARMmbed/psa-crypto/issues/132

This isn't critical to understanding the current behavior, and other types of operation should use consistent terminology, so I'll do that in a later writing pass. Tracked internally at https://github.com/ARMmbed/psa-crypto/issues/132
hanno-becker (Migrated from github.com) reviewed 2019-01-21 07:46:39 -06:00
@ -1421,6 +1421,67 @@ psa_status_t psa_hash_verify( psa_hash_operation_t *operation,
return( PSA_SUCCESS );
hanno-becker (Migrated from github.com) commented 2019-01-21 07:46:39 -06:00

Ok.

Ok.
hanno-becker (Migrated from github.com) reviewed 2019-01-21 07:47:55 -06:00
@ -924,0 +932,4 @@
* two objects are independent, i.e. subsequent calls involving one of
* the objects do not affect the other object.
*
* \param[in] source_operation The active hash operation to clone.
hanno-becker (Migrated from github.com) commented 2019-01-21 07:47:55 -06:00

That was an oversight on my side, because I was expecting the wording to be "The XXX. Must be YYY." instead of "The YYY XXX". I'd prefer the former, but that's not a blocker.

That was an oversight on my side, because I was expecting the wording to be "The XXX. Must be YYY." instead of "The YYY XXX". I'd prefer the former, but that's not a blocker.
hanno-becker (Migrated from github.com) reviewed 2019-01-21 07:48:16 -06:00
@ -1927,0 +1952,4 @@
PSA_ASSERT( psa_hash_clone( &op_source, &op_init ) );
PSA_ASSERT( psa_hash_finish( &op_init,
hash, sizeof( hash ), &hash_len ) );
PSA_ASSERT( psa_hash_clone( &op_source, &op_finished ) );
hanno-becker (Migrated from github.com) commented 2019-01-21 07:48:15 -06:00

Agreed.

Agreed.
gilles-peskine-arm (Migrated from github.com) reviewed 2019-01-21 07:51:13 -06:00
@ -921,6 +921,33 @@ psa_status_t psa_hash_verify(psa_hash_operation_t *operation,
*/
psa_status_t psa_hash_abort(psa_hash_operation_t *operation);
/** Clone a hash operation.
gilles-peskine-arm (Migrated from github.com) commented 2019-01-21 07:51:13 -06:00

I added a paragraph of English text that defines the behavior of the function.

I added a paragraph of English text that defines the behavior of the function.
gilles-peskine-arm (Migrated from github.com) reviewed 2019-01-21 07:51:27 -06:00
@ -921,6 +921,33 @@ psa_status_t psa_hash_verify(psa_hash_operation_t *operation,
*/
gilles-peskine-arm (Migrated from github.com) commented 2019-01-21 07:51:27 -06:00

Yes. I fixed the copypasta.

Yes. I fixed the copypasta.
hanno-becker (Migrated from github.com) reviewed 2019-01-21 08:40:08 -06:00
yanesca (Migrated from github.com) reviewed 2019-01-22 07:34:41 -06:00
@ -1421,6 +1421,67 @@ psa_status_t psa_hash_verify( psa_hash_operation_t *operation,
return( PSA_SUCCESS );
yanesca (Migrated from github.com) commented 2019-01-22 07:17:17 -06:00

Style: spaces before and after the parentheses.

Style: spaces before and after the parentheses.
yanesca commented 2019-01-22 07:35:18 -06:00 (Migrated from github.com)

Found a minor style issue, but other than that it looks good to me!

Found a minor style issue, but other than that it looks good to me!
hanno-becker (Migrated from github.com) approved these changes 2019-01-22 10:56:48 -06:00
yanesca (Migrated from github.com) approved these changes 2019-01-22 11:12:50 -06:00
Patater commented 2019-01-22 11:35:14 -06:00 (Migrated from github.com)

CI was flaky and failed DTLS proxy: 3d, gnutls server, fragmentation , a known issue.

CI was flaky and failed `DTLS proxy: 3d, gnutls server, fragmentation `, a known issue.
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!18
No description provided.