Skip to content

Merge psa api branch into development #231

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 41 commits into from
Aug 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b84b6a6
Add some negative tests for policy checks
gilles-peskine-arm Jul 30, 2019
91e8c33
Add infrastructure for key attribute flags
gilles-peskine-arm Aug 2, 2019
74f3352
Add missing guard around a union field
gilles-peskine-arm Aug 2, 2019
c8000c0
Add slot_number attribute
gilles-peskine-arm Aug 2, 2019
5fe5e27
Test slot_number attribute
gilles-peskine-arm Aug 2, 2019
5a68056
Rename internal macro to pass check-names.sh
gilles-peskine-arm Aug 5, 2019
013f547
Fix erasure of external flags
gilles-peskine-arm Aug 7, 2019
094dac1
Fix copypasta
gilles-peskine-arm Aug 7, 2019
edbed56
Rename psa_internal_allocate_key_slot to psa_get_empty_key_slot
gilles-peskine-arm Aug 7, 2019
0a23322
Improve documentation of the allocate method
gilles-peskine-arm Aug 5, 2019
ae9964d
Add validate_slot_number method to SE drivers
gilles-peskine-arm Aug 5, 2019
46d9439
Support slot_number attribute when creating a key
gilles-peskine-arm Aug 5, 2019
0a11044
Test restarting after creating a key in a specific slot
gilles-peskine-arm Aug 5, 2019
311809a
Merge pull request #201 from gilles-peskine-arm/psa-se_driver-set_key…
gilles-peskine-arm Aug 8, 2019
9d75202
Clarify and expand the documentation of the allocate/create sequence
gilles-peskine-arm Aug 9, 2019
fdbc544
Merge pull request #192 from gilles-peskine-arm/psa-test-policy_bad_a…
gilles-peskine-arm Aug 9, 2019
b231d99
Merge pull request #202 from gilles-peskine-arm/psa-se_driver-choose_…
gilles-peskine-arm Aug 9, 2019
df17914
psa_start_key_creation: take the method as a parameter
gilles-peskine-arm Jul 15, 2019
e88c2c1
Pass the key creation method to drivers
gilles-peskine-arm Aug 5, 2019
d772958
New function mbedtls_psa_register_se_key
gilles-peskine-arm Aug 5, 2019
a5f8749
SE key registration: call p_validate_slot_number
gilles-peskine-arm Aug 5, 2019
49bd582
Test the call to p_validate_slot_number when registering a key
gilles-peskine-arm Aug 5, 2019
5a2d152
Merge pull request #183 from gilles-peskine-arm/psa-se_driver-registe…
gilles-peskine-arm Aug 9, 2019
f3801ff
Update import_key and generate_key SE methods to the current API
gilles-peskine-arm Aug 6, 2019
1179208
SE keys: implement and smoke-test p_generate
gilles-peskine-arm Aug 6, 2019
edc6424
SE driver support: Implement sign and verify hooks
gilles-peskine-arm Aug 7, 2019
eecadde
SE support: Test sign and verify hooks with a passthrough driver
gilles-peskine-arm Aug 7, 2019
c068ded
RAM test driver: improve key creation
gilles-peskine-arm Aug 9, 2019
af906f8
RAM test driver: implement export_public
gilles-peskine-arm Aug 9, 2019
8df72f2
SE generate/sign/verify tests: also test export_public
gilles-peskine-arm Aug 9, 2019
30e13eb
Merge pull request #211 from gilles-peskine-arm/psa-se_driver-generat…
gilles-peskine-arm Aug 12, 2019
b4e73e9
Add some design notes about multipart operation structures
gilles-peskine-arm Aug 13, 2019
3f7cd62
Document better what wiping a key slot does not do
gilles-peskine-arm Aug 13, 2019
8fe253a
SE keys: test that psa_destroy_key removes the key from storage
gilles-peskine-arm Aug 13, 2019
caec278
SE keys: make psa_destroy_key remove the key from storage
gilles-peskine-arm Aug 13, 2019
9ce31c4
Note about destroying a key with other open handles
gilles-peskine-arm Aug 13, 2019
4b7f340
Clean up status code handling inside psa_destroy_key
gilles-peskine-arm Aug 13, 2019
5da7b3e
Drivers must have a psa_destroy_key method
gilles-peskine-arm Aug 13, 2019
c9d7f94
Add issue numbers for some missing parts of secure element support
gilles-peskine-arm Aug 13, 2019
bbdf310
Merge pull request #221 from gilles-peskine-arm/annotate_todo_comment…
gilles-peskine-arm Aug 14, 2019
572a16e
Merge branch 'psa-api-1.0-beta' into api-to-development
dgreen-arm Aug 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions include/psa/crypto_extra.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,117 @@ static inline psa_algorithm_t psa_get_key_enrollment_algorithm(
return( attributes->core.policy.alg2 );
}

#if defined(MBEDTLS_PSA_CRYPTO_SE_C)

/** Retrieve the slot number where a key is stored.
*
* A slot number is only defined for keys that are stored in a secure
* element.
*
* This information is only useful if the secure element is not entirely
* managed through the PSA Cryptography API. It is up to the secure
* element driver to decide how PSA slot numbers map to any other interface
* that the secure element may have.
*
* \param[in] attributes The key attribute structure to query.
* \param[out] slot_number On success, the slot number containing the key.
*
* \retval #PSA_SUCCESS
* The key is located in a secure element, and \p *slot_number
* indicates the slot number that contains it.
* \retval #PSA_ERROR_NOT_PERMITTED
* The caller is not permitted to query the slot number.
* Mbed Crypto currently does not return this error.
* \retval #PSA_ERROR_INVALID_ARGUMENT
* The key is not located in a secure element.
*/
psa_status_t psa_get_key_slot_number(
const psa_key_attributes_t *attributes,
psa_key_slot_number_t *slot_number );

/** Choose the slot number where a key is stored.
*
* This function declares a slot number in the specified attribute
* structure.
*
* A slot number is only meaningful for keys that are stored in a secure
* element. It is up to the secure element driver to decide how PSA slot
* numbers map to any other interface that the secure element may have.
*
* \note Setting a slot number in key attributes for a key creation can
* cause the following errors when creating the key:
* - #PSA_ERROR_NOT_SUPPORTED if the selected secure element does
* not support choosing a specific slot number.
* - #PSA_ERROR_NOT_PERMITTED if the caller is not permitted to
* choose slot numbers in general or to choose this specific slot.
* - #PSA_ERROR_INVALID_ARGUMENT if the chosen slot number is not
* valid in general or not valid for this specific key.
* - #PSA_ERROR_ALREADY_EXISTS if there is already a key in the
* selected slot.
*
* \param[out] attributes The attribute structure to write to.
* \param slot_number The slot number to set.
*/
static inline void psa_set_key_slot_number(
psa_key_attributes_t *attributes,
psa_key_slot_number_t slot_number )
{
attributes->core.flags |= MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER;
attributes->slot_number = slot_number;
}

/** Remove the slot number attribute from a key attribute structure.
*
* This function undoes the action of psa_set_key_slot_number().
*
* \param[out] attributes The attribute structure to write to.
*/
static inline void psa_clear_key_slot_number(
psa_key_attributes_t *attributes )
{
attributes->core.flags &= ~MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER;
}

/** Register a key that is already present in a secure element.
*
* The key must be located in a secure element designated by the
* lifetime field in \p attributes, in the slot set with
* psa_set_key_slot_number() in the attribute structure.
* This function makes the key available through the key identifier
* specified in \p attributes.
*
* \param[in] attributes The attributes of the existing key.
*
* \retval #PSA_SUCCESS
* The key was successfully registered.
* Note that depending on the design of the driver, this may or may
* not guarantee that a key actually exists in the designated slot
* and is compatible with the specified attributes.
* \retval #PSA_ERROR_ALREADY_EXISTS
* There is already a key with the identifier specified in
* \p attributes.
* \retval #PSA_ERROR_INVALID_ARGUMENT
* \p attributes specifies a lifetime which is not located
* in a secure element.
* \retval #PSA_ERROR_INVALID_ARGUMENT
* No slot number is specified in \p attributes,
* or the specified slot number is not valid.
* \retval #PSA_ERROR_NOT_PERMITTED
* The caller is not authorized to register the specified key slot.
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
* \retval #PSA_ERROR_HARDWARE_FAILURE
* \retval #PSA_ERROR_CORRUPTION_DETECTED
* \retval #PSA_ERROR_BAD_STATE
* The library has not been previously initialized by psa_crypto_init().
* It is implementation-dependent whether a failure to initialize
* results in this error code.
*/
psa_status_t mbedtls_psa_register_se_key(
const psa_key_attributes_t *attributes);

#endif /* MBEDTLS_PSA_CRYPTO_SE_C */

/**@}*/

/**
Expand Down
Loading