-
Notifications
You must be signed in to change notification settings - Fork 9
Add hardware signing and key exporting #3
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
Add hardware signing and key exporting #3
Conversation
@gilles-peskine-arm copied from #2:
Apparently, you can't change the PR's "from" part, and the PR didn't see any new commits added to the repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good except for some confusion between ATCA and PSA return codes in the error-catching macros.
@gilles-peskine-arm - I've added the changes you've requested. Thanks! |
atecc608a_se.c
Outdated
status = PSA_SUCCESS; \ | ||
} while(0) | ||
|
||
#define ASSERT_SUCCESS(expression) ASSERT_STATUS(expression,ATCA_SUCCESS, \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: I'd recommend spaces after commas for readabilty.
atecc608a_se.c
Outdated
} | ||
} | ||
|
||
psa_status_t atecc608a_get_serial_number(uint8_t* buffer, size_t buffer_size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add a serial number getting function as a public function? Seems unrelated to implementing signature and key exporting, at least. This is potentially useful for verifying that the hardware is reachable and returns something when asked, but I don't see us needing this right now; it's just a fun debug print in an example.
atecc608a_se.c
Outdated
return status; | ||
} | ||
|
||
psa_status_t atecc608a_check_config_locked() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be static?
atecc608a_se.c
Outdated
return status; | ||
} | ||
|
||
psa_status_t atecc608a_export_public_key(psa_key_slot_number_t key, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be static?
atecc608a_se.c
Outdated
return status; | ||
} | ||
|
||
psa_status_t atecc608a_asymmetric_sign(psa_key_slot_number_t key_slot, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be static?
exit: | ||
ATCAB_DEINIT(); | ||
return status; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make these functions static, the driver C file should have a global, linker-visible struct filled in with the driver callbacks. The example or anything using the atecc608s can then use the functions through the struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, we can do it this way if it's the only thing we want to have here. I've even thought about adding a function to print the configuration zone (this might be useful for validation), but after your suggestion - we can have that in an utils.h in the example too.
atecc608a_se.h
Outdated
size_t hash_length, | ||
uint8_t *p_signature, | ||
size_t signature_size, | ||
size_t *p_signature_length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend only exporting the driver struct from the header file, keeping all implementation internal to the C file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good, a couple of places need comments.
bd86f5d
to
e702d32
Compare
e702d32
to
b731c9f
Compare
@Patater, @gilles-peskine-arm - I've added your suggestions. Please re-review. |
@gilles-peskine-arm - I've made the utility functions and macros that you've mentioned visible. |
271d2fe
to
51f2ba2
Compare
486bad7
486bad7
to
ad2e8b7
Compare
…porting Add verification and public key importing
This is a continuation of #2.
This PR implements hardware ECDSA signing and public key exporting using ATECC608A or ATECC508A.
Prerequisite - a cryptoauth device (508A or 608A) comissioned, with a locked configuration and a private key generated in slot 0 (warning - configuration locking is irreversible!). An example application doing this with a quite safe config can be seen here.
This PR is a prerequisite for ARMmbed/mbed-os-example-atecc608a#2.