Skip to content

New function psa_hash_clone #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 22, 2019

Conversation

gilles-peskine-arm
Copy link
Collaborator

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.
@gilles-peskine-arm gilles-peskine-arm added enhancement New feature or request needs: review The pull request is ready for review. This generally means that it has no known issues. labels Jan 19, 2019
@hanno-becker hanno-becker self-requested a review January 21, 2019 13:09
* \retval #PSA_ERROR_BAD_STATE
* \p source_operation is not an active hash operation.
* \retval #PSA_ERROR_BAD_STATE
* \p source_operation is active.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two return value documentations seem to contradict each other.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I fixed the copypasta.

@@ -921,6 +921,24 @@ 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.
*
* \param[in] source_operation The active hash operation to clone.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@@ -1421,6 +1421,67 @@ psa_status_t psa_hash_verify( psa_hash_operation_t *operation,
return( PSA_SUCCESS );
}

psa_status_t psa_hash_clone(const psa_hash_operation_t *source_operation,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

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 ) );

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

@@ -921,6 +921,24 @@ 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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link

@hanno-becker hanno-becker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

hanno-becker
hanno-becker previously approved these changes Jan 21, 2019
@@ -1421,6 +1421,67 @@ psa_status_t psa_hash_verify( psa_hash_operation_t *operation,
return( PSA_SUCCESS );
}

psa_status_t psa_hash_clone(const psa_hash_operation_t *source_operation,
psa_hash_operation_t *target_operation)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: spaces before and after the parentheses.

@yanesca
Copy link
Collaborator

yanesca commented Jan 22, 2019

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

@yanesca yanesca removed the needs: review The pull request is ready for review. This generally means that it has no known issues. label Jan 22, 2019
@Patater Patater added the needs: ci Needs a passing full CI run label Jan 22, 2019
@Patater
Copy link
Contributor

Patater commented Jan 22, 2019

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

@Patater Patater merged commit 494624d into ARMmbed:development Jan 22, 2019
AndrzejKurek pushed a commit to AndrzejKurek/mbed-crypto that referenced this pull request Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs: ci Needs a passing full CI run
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants