Skip to content

Add support for writing to and reading from a slot #6

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 2 commits into from
Jun 21, 2019

Conversation

AndrzejKurek
Copy link
Contributor

@AndrzejKurek AndrzejKurek commented Jun 11, 2019

Support added for a clear text read and write. Please review only the two write/read commits.
This is a prerequisite for ARMmbed/mbed-os-example-atecc608a#5.

Copy link

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

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

Ok, but I don't understand what this feature is for.

@@ -34,4 +34,14 @@ psa_status_t atecc608a_init();

psa_status_t atecc608a_deinit();

/** Read from a given slot at an offset. Data zone has to be locked for this
* function to work. */
psa_status_t atecc608a_read(uint16_t slot, size_t offset, uint8_t *data, size_t length);

Choose a reason for hiding this comment

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

Why would the driver expose a way to read/write at an offset? The API only provides a way to import/export the key as a whole.

Copy link
Contributor Author

@AndrzejKurek AndrzejKurek Jun 13, 2019

Choose a reason for hiding this comment

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

There is a possibility to store arbitrary data at any slot (slot 8 in our case), for example a certificate, or a signature. The user might want to write and/or read to a slot, depending on the configuration.

Choose a reason for hiding this comment

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

Ok, but that would be exposed through the API via psa_import_key and psa_export_key with the key type PSA_KEY_TYPE_RAW_DATA. These functions read/write the whole slot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I didn't know that that's the plan. I can refactor the import_key and export_key procedures to factor for that, I would just like to get a confirmation from @Patater.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds like we don't need extra function pointers in the struct then, since we have import and export function pointers already. Let's use those.

Do we want to register a new driver struct under a different lifetime for handling raw data? or add a switch statement inside the existing driver import/export function implementation?

Copy link
Contributor Author

@AndrzejKurek AndrzejKurek Jun 19, 2019

Choose a reason for hiding this comment

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

The export_key function won't know about the key type unless it's passed to it or if it will check the hardware to determine which method of reading to use.

Choose a reason for hiding this comment

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

Oh, you mean the export_key function in the driver? I guess it should receive the key attributes as an argument. Right now it only gets the size and location. Why isn't it enough to know the size and location, by the way?

Copy link
Contributor Author

@AndrzejKurek AndrzejKurek Jun 19, 2019

Choose a reason for hiding this comment

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

The public key is stored fragmented and padded, and has to be read using a dedicated atcab_get_pubkey function that converts it to a readable format. Clear text reads are used for raw data, and exporting a private key is not even possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, so the secure element API has to be updated. Should I do it? Will it be a part of a different PR? @Patater - are we planning on switching from https://github.com/Patater/mbed-crypto/tree/secure-element to an official branch?

Choose a reason for hiding this comment

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

There are other pending updates to the SE API to cope with driver registration, key registration and updates to the application API. That's on me at the moment, together with https://jira.arm.com/browse/IOTCRYPT-608 and https://jira.arm.com/browse/IOTCRYPT-778

Copy link
Contributor

@Patater Patater 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 happy with the read/write functions as implemented for now. We should register them in the driver struct's import/export, reading/writing the full slot (like a block device), when possible as part of https://github.com/ARMmbed/psa-crypto/issues/202

Example should use atecc608a_read() and atecc608a_write() directly until we have the functions registered with the driver struct.

Copy link

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

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

@Patater Patater merged commit 5f7e568 into ARMmbed:mbed-cryptoauthlib Jun 21, 2019
rajkan01 pushed a commit to rajkan01/mbed-os-atecc608a that referenced this pull request Nov 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants