Skip to content

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

Merged
merged 12 commits into from
May 29, 2019

Conversation

AndrzejKurek
Copy link
Contributor

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.

@AndrzejKurek
Copy link
Contributor Author

AndrzejKurek commented May 24, 2019

@gilles-peskine-arm copied from #2:

unfortunately due to the change of repository visibility (from private to public), my fork has been disconnected and this PR had to be recreated here: #3

Apparently, you can't change the PR's "from" part, and the PR didn't see any new commits added to the repository.

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.

Looks good except for some confusion between ATCA and PSA return codes in the error-catching macros.

@AndrzejKurek
Copy link
Contributor Author

@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, \
Copy link
Contributor

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,
Copy link
Contributor

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()
Copy link
Contributor

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,
Copy link
Contributor

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,
Copy link
Contributor

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;
}
Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

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.

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.

The code looks good, a couple of places need comments.

@AndrzejKurek
Copy link
Contributor Author

@Patater, @gilles-peskine-arm - I've added your suggestions. Please re-review.

@AndrzejKurek AndrzejKurek requested review from gilles-peskine-arm and Patater and removed request for gilles-peskine-arm May 27, 2019 11:18
@AndrzejKurek
Copy link
Contributor Author

@gilles-peskine-arm - I've made the utility functions and macros that you've mentioned visible.

Patater
Patater previously approved these changes May 28, 2019
@AndrzejKurek AndrzejKurek dismissed stale reviews from gilles-peskine-arm and Patater via 486bad7 May 29, 2019 07:20
@AndrzejKurek AndrzejKurek requested review from Patater and gilles-peskine-arm and removed request for Patater May 29, 2019 07:30
@Patater Patater merged commit 98089e1 into ARMmbed:mbed-cryptoauthlib May 29, 2019
rajkan01 pushed a commit to rajkan01/mbed-os-atecc608a that referenced this pull request Nov 17, 2020
…porting

Add verification and public key importing
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