Skip to content
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

Implement design #9

Merged
merged 2 commits into from
May 19, 2020
Merged

Conversation

hug-dev
Copy link
Member

@hug-dev hug-dev commented May 15, 2020

Implement the design of the psa-crypto crate as discussed in #8
This is not finished but the PR is done for early reviews/comments.

I decided to remove id from the Attributes as it seemed weird to have this value as both an input of the function (for persistant keys keys) and an output. I replaced it with Option<u32> which represent a tentative of ID for the called that wants to generate a persistent key.

Most of the Attributes and Algorithm structures were taken from the Parsec Rust Interface. Because ANY_HASH can only be used for hash-and-sign algorithm, I decided to remove it from the Hash enumeration and to create the SignHash one, just for asymmetric signature functions.

Things yet to be done:

  • add the conversion of Rust abstracted types to FFI types and the other way around
  • complete documentation
  • add examples
  • add the interface for Secure Element drivers (possibly under a feature)

Moves the shim function in the psa-crypto-sys as they are part of the
PSA Crypto API.
Deletes the other higher-level functions in favor of the psa-crypto
crate design implementation to come.

Signed-off-by: Hugues de Valon <[email protected]>
Creates the directory structures, the structures, types and functions as
defined in parallaxsecond#8
The implementation is currently only limited to key management and
asymmetric signature functions.

Signed-off-by: Hugues de Valon <[email protected]>
@hug-dev hug-dev self-assigned this May 15, 2020
@hug-dev hug-dev added the enhancement New feature or request label May 15, 2020
Copy link
Member

@ionut-arm ionut-arm left a comment

Choose a reason for hiding this comment

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

Nice!

I'm assuming you still have some stuff to do around the From blocks that aren't actually implemented yet?

Also, are we going to keep the algorithms and key properties types here and import them from here in the interface?

psa-crypto/src/operations/key_management.rs Show resolved Hide resolved
psa-crypto/src/types/status.rs Show resolved Hide resolved
psa-crypto/src/types/status.rs Show resolved Hide resolved
Comment on lines +421 to +423
fn from(_attributes: Attributes) -> Self {
unsafe { psa_crypto_sys::psa_key_attributes_init() }
}
Copy link
Member

Choose a reason for hiding this comment

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

This will be expanded at some point?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! This is now just a stub to make it compile.

psa-crypto/src/types/key.rs Show resolved Hide resolved
psa-crypto/src/types/key.rs Show resolved Hide resolved
Copy link
Member Author

@hug-dev hug-dev left a comment

Choose a reason for hiding this comment

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

I'm assuming you still have some stuff to do around the From blocks that aren't actually implemented yet?

Yes! I did the minimum on those ones to make them compile

Also, are we going to keep the algorithms and key properties types here and import them from here in the interface?

Yes, that was what I thought. Import Type and Algorithm mainly I think. In Parsec we have to redefine the Attributes structure as we do not use lifetimes or we could just use it as it is but leave it unchecked.

psa-crypto/src/operations/key_management.rs Show resolved Hide resolved
psa-crypto/src/types/key.rs Show resolved Hide resolved
psa-crypto/src/types/key.rs Show resolved Hide resolved
Comment on lines +421 to +423
fn from(_attributes: Attributes) -> Self {
unsafe { psa_crypto_sys::psa_key_attributes_init() }
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! This is now just a stub to make it compile.

psa-crypto/src/types/status.rs Show resolved Hide resolved
psa-crypto/src/types/status.rs Show resolved Hide resolved
Copy link
Collaborator

@egrimley-arm egrimley-arm left a comment

Choose a reason for hiding this comment

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

LGTM

@hug-dev
Copy link
Member Author

hug-dev commented May 19, 2020

Don't hesitate raising issues for bugs or concerns over the design. This is still at the state of "prototype", we shall be adding more tests and examples.

@hug-dev hug-dev merged commit f6c6fb8 into parallaxsecond:master May 19, 2020
@hug-dev hug-dev deleted the implement-design branch May 19, 2020 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants