-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Openless PSA crypto APIs implementation #3547
Openless PSA crypto APIs implementation #3547
Commits on Nov 9, 2020
-
Split persistence and key id validation
With key usage based on key identifiers and not key handles (openless APIs), volatile keys will also have a key identifier. Thus, isolate key identifier validation from key persistence validation to clarify that key identifiers are not specific to persistent keys. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for d2ed481 - Browse repository at this point
Copy the full SHA d2ed481View commit details
Commits on Nov 10, 2020
-
Volatile key identifiers are introduced in PSA Crypto API v1.0.0. They are returned by the APIs when importing or generating or deriving a volatile key. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 2a99315 - Browse repository at this point
Copy the full SHA 2a99315View commit details -
psa: slot mgmt: Don't use handles to loop through slot array
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 98a54dd - Browse repository at this point
Copy the full SHA 98a54ddView commit details -
Introduce PSA_KEY_HANDLE_INIT macro
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 91e9515 - Browse repository at this point
Copy the full SHA 91e9515View commit details -
Introduce psa_key_handle_is_null inline function
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for c26f8d4 - Browse repository at this point
Copy the full SHA c26f8d4View commit details -
Introduce psa_key_handle_equal inline function
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 47a8561 - Browse repository at this point
Copy the full SHA 47a8561View commit details -
Define handles as key identifiers
Define psa_key_handle_t to be equal to mbedtls_svc_key_id_t. Make the handle of a persistent key be equal to its key identifier. For volatile keys, make the key handle equal to the volatile key identifier of the created volatile key. The unit tests are modified just to make them compile not to make them run successfully. They are fixed in the subsequent commits. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for c4d1b51 - Browse repository at this point
Copy the full SHA c4d1b51View commit details -
tests: Fix invalid key identifier error code
PSA Crypto API spec defines the error code for an invalid key identifier as PSA_ERROR_INVALID_HANDLE. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 2d52eb2 - Browse repository at this point
Copy the full SHA 2d52eb2View commit details -
tests: Fix error codes when using "invalid" handles
As handles are now key identifiers, a handle may be valid now even if it does not refer to any key known to the library. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 432e19c - Browse repository at this point
Copy the full SHA 432e19cView commit details -
tests: Fix checks of volatile key identifier
Volatile keys have now a volatile non-null key identifier. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 4184107 - Browse repository at this point
Copy the full SHA 4184107View commit details -
tests: Fix persistent slot lifecycle tests
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for e4f6d5c - Browse repository at this point
Copy the full SHA e4f6d5cView commit details -
psa: Move from key handle to key identifier
Move all the PSA crypto APIs using key handles to use key identifiers but psa_key_open() and psa_key_close(). This is done without modifying any test as key handles and key identifiers are now the same. Update the library modules using PSA crypto APIs to get rid of key handles. Programs and unit tests are updated to not use key handles in subsequent commits, not in this one. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for cf56a0a - Browse repository at this point
Copy the full SHA cf56a0aView commit details -
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 277a85f - Browse repository at this point
Copy the full SHA 277a85fView commit details -
State PSA_CRYPTO_KEY_ID_ENCODES_OWNER and USE_PSA_CRYPTO incompatibility
Code under MBEDTLS_USE_PSA_CRYPTO define is PSA client code intended to use key identifiers of type psa_key_id_t. Thus the MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER configuration option is incompatible with MBEDTLS_USE_PSA_CRYPTO. State this in config.h and check_config.h. As a consequence: . remove MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER from the full configuration, as MBEDTLS_USE_PSA_CRYPTO is part of it. . add a new component in all.sh to keep testing the library when MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER is set. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for c3623db - Browse repository at this point
Copy the full SHA c3623dbView commit details -
Adapt programs to PSA openless APIs
PSA and SSL programs are PSA clients thus should use psa_key_id_t as the type for key identifiers, not mbedtls_svc_key_id_t. As a consequence, PSA, ssl_server2 and ssl_client2 programs cannot compile and must not be compiled if MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER is defined. Thus, add MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER compilation guard to those programs. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for adc2ff2 - Browse repository at this point
Copy the full SHA adc2ff2View commit details -
tests: Adapt PSA tests to openless APIs
psa_key_handle_equal() is removed as not used anymore. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 5425a21 - Browse repository at this point
Copy the full SHA 5425a21View commit details -
tests: slot mgmt: Add purge checks in volatile key lifecycle test
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 3930997 - Browse repository at this point
Copy the full SHA 3930997View commit details -
tests: slot mgmt: Rename ways of invalidating keys
Rename ways of invalidating keys before introducing key purging tests because the "CLOSE_BY" prefix doesn't get on well with the purge operation. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for e7e86cf - Browse repository at this point
Copy the full SHA e7e86cfView commit details -
tests: slot mgmt: Fix test data
For persistent keys there were two successive INVALIDATE_BY_(CLOSING/DESTROYING) identical tests where the comments of the second test rather indicated that it should had been an INVALIDATE_BY_(CLOSING/DESTROYING)_WITH_SHUTDOWN test. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 994b805 - Browse repository at this point
Copy the full SHA 994b805View commit details -
tests: slot mgmt: Add psa_purge_key testing
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for f67aefe - Browse repository at this point
Copy the full SHA f67aefeView commit details -
Forbid volatile key identifiers for non volatile keys
Volatile key identifiers in the vendor range are reserved to volatile keys thus don't allow them for persistent keys when creating a key. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for fc9c556 - Browse repository at this point
Copy the full SHA fc9c556View commit details -
Merge search of loaded volatile and persistent keys
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 97c8ad5 - Browse repository at this point
Copy the full SHA 97c8ad5View commit details -
In case of persistent keys, do not load the key in a slot before to close/purge it. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 5134519 - Browse repository at this point
Copy the full SHA 5134519View commit details -
Improve psa_key_start_creation description
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 3c76a42 - Browse repository at this point
Copy the full SHA 3c76a42View commit details -
Add mbedtls_set_key_owner_id API
Add the mbedtls_set_key_owner_id API, API specific to the MbedTLS PSA implementation. The API allows to define the owner of volatile keys. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 6b5ff53 - Browse repository at this point
Copy the full SHA 6b5ff53View commit details -
Add tests checking owner of volatile keys
When key identifiers encode key owner, add tests checking that: . the key owner of an imported volatile key is the one specified. . a key identifier of a volatile key with a valid PSA key identifier but the wrong owner is rejected. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 390f607 - Browse repository at this point
Copy the full SHA 390f607View commit details -
tests: psa: Use PSA_KEY_LIFETIME_IS_VOLATILE where it should
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for f1ff9a8 - Browse repository at this point
Copy the full SHA f1ff9a8View commit details -
psa: Fix references to macros in comments
This commit tries to fix the usage of #MACRO_NAME to reference macros in comments. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 9678355 - Browse repository at this point
Copy the full SHA 9678355View commit details -
psa: Improve key creation documentation
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 4067d1c - Browse repository at this point
Copy the full SHA 4067d1cView commit details -
psa: Fix tests/handling of lifetime incompatible with location
The lifetime of key attributes now encodes whether a key is volatile/persistent or not AND its location. Fix PSA code where the fact that the lifetime encodes the key location was not taken into account properly. Fix the impacted tests and add two non regression tests. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for d98059d - Browse repository at this point
Copy the full SHA d98059dView commit details -
Add key id check when creating a volatile key
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 65f38a3 - Browse repository at this point
Copy the full SHA 65f38a3View commit details -
psa: Forbid creation/registration of keys in vendor range
The identifier of keys created/registred should be in the application range. This is by spec for key creation. This may change for registered key. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 54b9008 - Browse repository at this point
Copy the full SHA 54b9008View commit details -
psa: mgmt: Add key slot access counter
Add key slot access counter to be able to state if a key slot containing the description of a permanent key can be reset or reset and re-used. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for f95a2b1 - Browse repository at this point
Copy the full SHA f95a2b1View commit details -
psa: slot mgmt: Add unaccessed slots counter in stats
Add a counter of unaccessed slots and use it in tests to check that at the end of PSA tests all key slot are unaccessed. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 0c3752a - Browse repository at this point
Copy the full SHA 0c3752aView commit details -
psa: Add access counter check in slot wipe
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for ddd3d05 - Browse repository at this point
Copy the full SHA ddd3d05View commit details -
psa: Do not reset a key slot under access
When psa_close/destroy/purge_key is called, do not reset a key slot containing the description of a persistent key if it is currently accessed. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for f291111 - Browse repository at this point
Copy the full SHA f291111View commit details -
When looking for an empty key slot to store the description of a key, if all key slots are in use, reuse the first encountered and unaccessed key slot containing the description of a permanent key. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for a5b894f - Browse repository at this point
Copy the full SHA a5b894fView commit details
Commits on Nov 11, 2020
-
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 77c89f5 - Browse repository at this point
Copy the full SHA 77c89f5View commit details -
Prefer persistent over permanent
For consistency across the code base, prefer persistent over permanent to qualify a key stored in persistent storage. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 19daca9 - Browse repository at this point
Copy the full SHA 19daca9View commit details
Commits on Nov 13, 2020
-
Miscellaneous documentation improvements
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 7587ae4 - Browse repository at this point
Copy the full SHA 7587ae4View commit details -
Miscellaneous coding style fixes
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 7d54f66 - Browse repository at this point
Copy the full SHA 7d54f66View commit details
Commits on Nov 19, 2020
-
psa: slot mgmt: Improve psa_search_key_in_slots implementation
In case of a volatile key identifier, no need to check first the validity of the key identifier, a volatile key identifier is valid. Move to a forward search for non-volatile key identifiers as now key slots with small index are allocated first by psa_get_empty_key_slot(). Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for f473d8b - Browse repository at this point
Copy the full SHA f473d8bView commit details -
psa: slot mgmt: Simplify psa_validate_key_id
Special handling of volatile key identifiers is not needed eventually, they can be handled just as key identifier in the vendor range. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for cbd7bea - Browse repository at this point
Copy the full SHA cbd7beaView commit details -
tests: psa crypto: Fix lifetime_is_secure_element()
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 9e12f8f - Browse repository at this point
Copy the full SHA 9e12f8fView commit details -
programs: ssl: Fix printf parameter type cast
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for c985114 - Browse repository at this point
Copy the full SHA c985114View commit details -
psa: Remove error message output
Remove error message output in case of unexpected access counter as Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 4640c15 - Browse repository at this point
Copy the full SHA 4640c15View commit details -
psa: slot mgmt: Add access counter overflow check
It adds a bit a code for not much but that way we are such that a count overflow cannot occur. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for cbf6a1d - Browse repository at this point
Copy the full SHA cbf6a1dView commit details -
psa: Decrement slot access count when finalizing key creation
Decrement the slot access count in psa_finish_key_creation() when the finalization succeeds instead of in functions calling psa_finish_key_creation(). That way the decrementation cannot be forgotten and it reduces the code size. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 5097294 - Browse repository at this point
Copy the full SHA 5097294View commit details -
psa: Move key identifier return to psa_finish_key_creation()
Move the return of the identifier of a created key from psa_start_key_creation() to psa_finish_key_creation(). That way in case of creation error, it is less likely to return the identifier that was temporarily assigned to the key while trying to create it. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 81709fc - Browse repository at this point
Copy the full SHA 81709fcView commit details -
tests: slot mgmt: Improve key_slot_eviction_to_import_new_key test
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for ab79bd2 - Browse repository at this point
Copy the full SHA ab79bd2View commit details -
psa: Rename functions to get a key slot
Rename functions to get a key slot: . to make their naming more consistent . to emphasize that those functions set a lock on the key slot they return to protect it from being wiped out and re-used while some part of the library is accessing it. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 5c52292 - Browse repository at this point
Copy the full SHA 5c52292View commit details -
psa stats: Count locked slots instead of unlocked ones
Count locked slots and not unlocked ones to align with the other statistics counters. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 1ad1eee - Browse repository at this point
Copy the full SHA 1ad1eeeView commit details -
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for a3d9dac - Browse repository at this point
Copy the full SHA a3d9dacView commit details
Commits on Nov 20, 2020
-
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 1d12d87 - Browse repository at this point
Copy the full SHA 1d12d87View commit details -
tests: psa: Reset key attributes where needed
After a call to psa_get_key_attributes() to retrieve the attributes of a key into a psa_key_attributes_t structure, a call to psa_reset_key_attributes() is mandated to free the resources that may be referenced by the psa_key_attributes_t structure. Not calling psa_reset_key_attributes() may result in a memory leak. When a test function calls psa_get_key_parameters() the associated key attributes are systematically reset in the clean-up part of the function with a comment to emphasize the need for the reset and make it more visible. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Configuration menu - View commit details
-
Copy full SHA for 3a4f0e3 - Browse repository at this point
Copy the full SHA 3a4f0e3View commit details