From 83d2662dfa5f868bb19f8f8a9088eb9fe44d0bc5 Mon Sep 17 00:00:00 2001 From: Derek Miller Date: Fri, 15 Feb 2019 16:41:22 -0600 Subject: [PATCH 01/15] Changed opaque/transparent in functions/structs to se/accel --- include/psa/crypto_accel_driver.h | 212 ++++++++++---------- include/psa/crypto_se_driver.h | 322 +++++++++++++++--------------- 2 files changed, 267 insertions(+), 267 deletions(-) diff --git a/include/psa/crypto_accel_driver.h b/include/psa/crypto_accel_driver.h index b752fed88..72187152b 100644 --- a/include/psa/crypto_accel_driver.h +++ b/include/psa/crypto_accel_driver.h @@ -168,7 +168,7 @@ typedef void (*psa_drv_hash_abort_t)(psa_drv_hash_context_t *p_context); * The contents of this structure are implementation dependent and are * therefore not described here. */ -typedef struct psa_drv_mac_transparent_context_s psa_drv_mac_transparent_context_t; +typedef struct psa_drv_accel_mac_context_s psa_drv_accel_mac_context_t; /** \brief The function prototype for the setup operation of a * transparent-key MAC operation @@ -190,9 +190,9 @@ typedef struct psa_drv_mac_transparent_context_s psa_drv_mac_transparent_context * \retval PSA_SUCCESS * Success. */ -typedef psa_status_t (*psa_drv_mac_transparent_setup_t)(psa_drv_mac_transparent_context_t *p_context, - const uint8_t *p_key, - size_t key_length); +typedef psa_status_t (*psa_drv_accel_mac_setup_t)(psa_drv_accel_mac_context_t *p_context, + const uint8_t *p_key, + size_t key_length); /** \brief The function prototype for the update operation of a * transparent-key MAC operation @@ -212,9 +212,9 @@ typedef psa_status_t (*psa_drv_mac_transparent_setup_t)(psa_drv_mac_transparent_ * to the MAC operation * \param[in] input_length The size in bytes of the input message buffer */ -typedef psa_status_t (*psa_drv_mac_transparent_update_t)(psa_drv_mac_transparent_context_t *p_context, - const uint8_t *p_input, - size_t input_length); +typedef psa_status_t (*psa_drv_accel_mac_update_t)(psa_drv_accel_mac_context_t *p_context, + const uint8_t *p_input, + size_t input_length); /** \brief The function prototype for the finish operation of a * transparent-key MAC operation @@ -237,9 +237,9 @@ typedef psa_status_t (*psa_drv_mac_transparent_update_t)(psa_drv_mac_transparent * \retval PSA_SUCCESS * Success. */ -typedef psa_status_t (*psa_drv_mac_transparent_finish_t)(psa_drv_mac_transparent_context_t *p_context, - uint8_t *p_mac, - size_t mac_length); +typedef psa_status_t (*psa_drv_accel_mac_finish_t)(psa_drv_accel_mac_context_t *p_context, + uint8_t *p_mac, + size_t mac_length); /** \brief The function prototype for the finish and verify operation of a * transparent-key MAC operation @@ -263,9 +263,9 @@ typedef psa_status_t (*psa_drv_mac_transparent_finish_t)(psa_drv_mac_transparent * \retval PSA_SUCCESS * The operation completed successfully and the comparison matched */ -typedef psa_status_t (*psa_drv_mac_transparent_finish_verify_t)(psa_drv_mac_transparent_context_t *p_context, - const uint8_t *p_mac, - size_t mac_length); +typedef psa_status_t (*psa_drv_accel_mac_finish_verify_t)(psa_drv_accel_mac_context_t *p_context, + const uint8_t *p_mac, + size_t mac_length); /** \brief The function prototype for the abort operation for a previously * started transparent-key MAC operation @@ -283,7 +283,7 @@ typedef psa_status_t (*psa_drv_mac_transparent_finish_verify_t)(psa_drv_mac_tran * aborted * */ -typedef psa_status_t (*psa_drv_mac_transparent_abort_t)(psa_drv_mac_transparent_context_t *p_context); +typedef psa_status_t (*psa_drv_accel_mac_abort_t)(psa_drv_accel_mac_context_t *p_context); /** \brief The function prototype for a one-shot operation of a transparent-key * MAC operation @@ -306,13 +306,13 @@ typedef psa_status_t (*psa_drv_mac_transparent_abort_t)(psa_drv_mac_transparent_ * upon success * \param[in] mac_length The length in bytes of the `p_mac` buffer */ -typedef psa_status_t (*psa_drv_mac_transparent_t)(const uint8_t *p_input, - size_t input_length, - const uint8_t *p_key, - size_t key_length, - psa_algorithm_t alg, - uint8_t *p_mac, - size_t mac_length); +typedef psa_status_t (*psa_drv_accel_mac_t)(const uint8_t *p_input, + size_t input_length, + const uint8_t *p_key, + size_t key_length, + psa_algorithm_t alg, + uint8_t *p_mac, + size_t mac_length); /** \brief The function prototype for a one-shot operation of a transparent-key * MAC Verify operation @@ -337,13 +337,13 @@ typedef psa_status_t (*psa_drv_mac_transparent_t)(const uint8_t *p_input, * \retval PSA_SUCCESS * The operation completed successfully and the comparison matched */ -typedef psa_status_t (*psa_drv_mac_transparent_verify_t)(const uint8_t *p_input, - size_t input_length, - const uint8_t *p_key, - size_t key_length, - psa_algorithm_t alg, - const uint8_t *p_mac, - size_t mac_length); +typedef psa_status_t (*psa_drv_accel_mac_verify_t)(const uint8_t *p_input, + size_t input_length, + const uint8_t *p_key, + size_t key_length, + psa_algorithm_t alg, + const uint8_t *p_mac, + size_t mac_length); /**@}*/ /** \defgroup transparent_cipher Transparent Block Cipher @@ -367,7 +367,7 @@ typedef psa_status_t (*psa_drv_mac_transparent_verify_t)(const uint8_t *p_input, * The contents of this structure are implementation dependent and are * therefore not described here. */ -typedef struct psa_drv_cipher_transparent_context_s psa_drv_cipher_transparent_context_t; +typedef struct psa_drv_accel_cipher_context_s psa_drv_accel_cipher_context_t; /** \brief The function prototype for the setup operation of transparent-key * block cipher operations. @@ -395,10 +395,10 @@ typedef struct psa_drv_cipher_transparent_context_s psa_drv_cipher_transparent_c * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_cipher_transparent_setup_t)(psa_drv_cipher_transparent_context_t *p_context, - psa_encrypt_or_decrypt_t direction, - const uint8_t *p_key_data, - size_t key_data_size); +typedef psa_status_t (*psa_drv_accel_cipher_setup_t)(psa_drv_accel_cipher_context_t *p_context, + psa_encrypt_or_decrypt_t direction, + const uint8_t *p_key_data, + size_t key_data_size); /** \brief The function prototype for the set initialization vector operation * of transparent-key block cipher operations @@ -418,9 +418,9 @@ typedef psa_status_t (*psa_drv_cipher_transparent_setup_t)(psa_drv_cipher_transp * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_cipher_transparent_set_iv_t)(psa_drv_cipher_transparent_context_t *p_context, - const uint8_t *p_iv, - size_t iv_length); +typedef psa_status_t (*psa_drv_accel_cipher_set_iv_t)(psa_drv_accel_cipher_context_t *p_context, + const uint8_t *p_iv, + size_t iv_length); /** \brief The function prototype for the update operation of transparent-key * block cipher operations. @@ -447,12 +447,12 @@ typedef psa_status_t (*psa_drv_cipher_transparent_set_iv_t)(psa_drv_cipher_trans * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_cipher_transparent_update_t)(psa_drv_cipher_transparent_context_t *p_context, - const uint8_t *p_input, - size_t input_size, - uint8_t *p_output, - size_t output_size, - size_t *p_output_length); +typedef psa_status_t (*psa_drv_accel_cipher_update_t)(psa_drv_accel_cipher_context_t *p_context, + const uint8_t *p_input, + size_t input_size, + uint8_t *p_output, + size_t output_size, + size_t *p_output_length); /** \brief The function prototype for the finish operation of transparent-key * block cipher operations. @@ -476,10 +476,10 @@ typedef psa_status_t (*psa_drv_cipher_transparent_update_t)(psa_drv_cipher_trans * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_cipher_transparent_finish_t)(psa_drv_cipher_transparent_context_t *p_context, - uint8_t *p_output, - size_t output_size, - size_t *p_output_length); +typedef psa_status_t (*psa_drv_accel_cipher_finish_t)(psa_drv_accel_cipher_context_t *p_context, + uint8_t *p_output, + size_t output_size, + size_t *p_output_length); /** \brief The function prototype for the abort operation of transparent-key * block cipher operations. @@ -498,7 +498,7 @@ typedef psa_status_t (*psa_drv_cipher_transparent_finish_t)(psa_drv_cipher_trans * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_cipher_transparent_abort_t)(psa_drv_cipher_transparent_context_t *p_context); +typedef psa_status_t (*psa_drv_accel_cipher_abort_t)(psa_drv_accel_cipher_context_t *p_context); /**@}*/ @@ -553,18 +553,18 @@ typedef psa_status_t (*psa_drv_cipher_transparent_abort_t)(psa_drv_cipher_transp * \retval #PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_aead_transparent_encrypt_t)(const uint8_t *p_key, - size_t key_length, - psa_algorithm_t alg, - const uint8_t *nonce, - size_t nonce_length, - const uint8_t *additional_data, - size_t additional_data_length, - const uint8_t *plaintext, - size_t plaintext_length, - uint8_t *ciphertext, - size_t ciphertext_size, - size_t *ciphertext_length); +typedef psa_status_t (*psa_drv_accel_aead_encrypt_t)(const uint8_t *p_key, + size_t key_length, + psa_algorithm_t alg, + const uint8_t *nonce, + size_t nonce_length, + const uint8_t *additional_data, + size_t additional_data_length, + const uint8_t *plaintext, + size_t plaintext_length, + uint8_t *ciphertext, + size_t ciphertext_size, + size_t *ciphertext_length); /** Process an authenticated decryption operation using an opaque key. * @@ -604,18 +604,18 @@ typedef psa_status_t (*psa_drv_aead_transparent_encrypt_t)(const uint8_t *p_key, * \retval #PSA_SUCCESS * Success. */ -typedef psa_status_t (*psa_drv_aead_transparent_decrypt_t)(const uint8_t *p_key, - size_t key_length, - psa_algorithm_t alg, - const uint8_t *nonce, - size_t nonce_length, - const uint8_t *additional_data, - size_t additional_data_length, - const uint8_t *ciphertext, - size_t ciphertext_length, - uint8_t *plaintext, - size_t plaintext_size, - size_t *plaintext_length); +typedef psa_status_t (*psa_drv_accel_aead_decrypt_t)(const uint8_t *p_key, + size_t key_length, + psa_algorithm_t alg, + const uint8_t *nonce, + size_t nonce_length, + const uint8_t *additional_data, + size_t additional_data_length, + const uint8_t *ciphertext, + size_t ciphertext_length, + uint8_t *plaintext, + size_t plaintext_size, + size_t *plaintext_length); /**@}*/ @@ -653,14 +653,14 @@ typedef psa_status_t (*psa_drv_aead_transparent_decrypt_t)(const uint8_t *p_key, * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_asymmetric_transparent_sign_t)(const uint8_t *p_key, - size_t key_size, - psa_algorithm_t alg, - const uint8_t *p_hash, - size_t hash_length, - uint8_t *p_signature, - size_t signature_size, - size_t *p_signature_length); +typedef psa_status_t (*psa_drv_accel_asymmetric_sign_t)(const uint8_t *p_key, + size_t key_size, + psa_algorithm_t alg, + const uint8_t *p_hash, + size_t hash_length, + uint8_t *p_signature, + size_t signature_size, + size_t *p_signature_length); /** * \brief A function that verifies the signature a hash or short message using @@ -686,13 +686,13 @@ typedef psa_status_t (*psa_drv_asymmetric_transparent_sign_t)(const uint8_t *p_k * \retval PSA_SUCCESS * The signature is valid. */ -typedef psa_status_t (*psa_drv_asymmetric_transparent_verify_t)(const uint8_t *p_key, - size_t key_size, - psa_algorithm_t alg, - const uint8_t *p_hash, - size_t hash_length, - const uint8_t *p_signature, - size_t signature_length); +typedef psa_status_t (*psa_drv_accel_asymmetric_verify_t)(const uint8_t *p_key, + size_t key_size, + psa_algorithm_t alg, + const uint8_t *p_hash, + size_t hash_length, + const uint8_t *p_signature, + size_t signature_length); /** * \brief A function that encrypts a short message with a transparent @@ -730,16 +730,16 @@ typedef psa_status_t (*psa_drv_asymmetric_transparent_verify_t)(const uint8_t *p * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_asymmetric_transparent_encrypt_t)(const uint8_t *p_key, - size_t key_size, - psa_algorithm_t alg, - const uint8_t *p_input, - size_t input_length, - const uint8_t *p_salt, - size_t salt_length, - uint8_t *p_output, - size_t output_size, - size_t *p_output_length); +typedef psa_status_t (*psa_drv_accel_asymmetric_encrypt_t)(const uint8_t *p_key, + size_t key_size, + psa_algorithm_t alg, + const uint8_t *p_input, + size_t input_length, + const uint8_t *p_salt, + size_t salt_length, + uint8_t *p_output, + size_t output_size, + size_t *p_output_length); /** * \brief Decrypt a short message with a transparent asymmetric private key @@ -776,16 +776,16 @@ typedef psa_status_t (*psa_drv_asymmetric_transparent_encrypt_t)(const uint8_t * * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_asymmetric_transparent_decrypt_t)(const uint8_t *p_key, - size_t key_size, - psa_algorithm_t alg, - const uint8_t *p_input, - size_t input_length, - const uint8_t *p_salt, - size_t salt_length, - uint8_t *p_output, - size_t output_size, - size_t *p_output_length); +typedef psa_status_t (*psa_drv_accel_asymmetric_decrypt_t)(const uint8_t *p_key, + size_t key_size, + psa_algorithm_t alg, + const uint8_t *p_input, + size_t input_length, + const uint8_t *p_salt, + size_t salt_length, + uint8_t *p_output, + size_t output_size, + size_t *p_output_length); /**@}*/ diff --git a/include/psa/crypto_se_driver.h b/include/psa/crypto_se_driver.h index 057866445..7ca6d605a 100644 --- a/include/psa/crypto_se_driver.h +++ b/include/psa/crypto_se_driver.h @@ -75,9 +75,9 @@ typedef uint32_t psa_key_slot_t; * \retval PSA_SUCCESS * Success. */ -typedef psa_status_t (*psa_drv_mac_opaque_setup_t)(void *p_context, - psa_key_slot_t key_slot, - psa_algorithm_t algorithm); +typedef psa_status_t (*psa_drv_se_mac_setup_t)(void *p_context, + psa_key_slot_t key_slot, + psa_algorithm_t algorithm); /** \brief A function that continues a previously started MAC operation using * an opaque key @@ -89,9 +89,9 @@ typedef psa_status_t (*psa_drv_mac_opaque_setup_t)(void *p_context, * to the MAC operation * \param[in] input_length The size in bytes of the input message buffer */ -typedef psa_status_t (*psa_drv_mac_opaque_update_t)(void *p_context, - const uint8_t *p_input, - size_t input_length); +typedef psa_status_t (*psa_drv_se_mac_update_t)(void *p_context, + const uint8_t *p_input, + size_t input_length); /** \brief a function that completes a previously started MAC operation by * returning the resulting MAC using an opaque key @@ -109,10 +109,10 @@ typedef psa_status_t (*psa_drv_mac_opaque_update_t)(void *p_context, * \retval PSA_SUCCESS * Success. */ -typedef psa_status_t (*psa_drv_mac_opaque_finish_t)(void *p_context, - uint8_t *p_mac, - size_t mac_size, - size_t *p_mac_length); +typedef psa_status_t (*psa_drv_se_mac_finish_t)(void *p_context, + uint8_t *p_mac, + size_t mac_size, + size_t *p_mac_length); /** \brief A function that completes a previously started MAC operation by * comparing the resulting MAC against a known value using an opaque key @@ -130,16 +130,16 @@ typedef psa_status_t (*psa_drv_mac_opaque_finish_t)(void *p_context, * The operation completed successfully, but the calculated MAC did * not match the provided MAC */ -typedef psa_status_t (*psa_drv_mac_opaque_finish_verify_t)(void *p_context, - const uint8_t *p_mac, - size_t mac_length); +typedef psa_status_t (*psa_drv_se_mac_finish_verify_t)(void *p_context, + const uint8_t *p_mac, + size_t mac_length); /** \brief A function that aborts a previous started opaque-key MAC operation * \param[in,out] p_context A hardware-specific structure for the previously * started MAC operation to be aborted */ -typedef psa_status_t (*psa_drv_mac_opaque_abort_t)(void *p_context); +typedef psa_status_t (*psa_drv_se_mac_abort_t)(void *p_context); /** \brief A function that performs a MAC operation in one command and returns * the calculated MAC using an opaque key @@ -158,13 +158,13 @@ typedef psa_status_t (*psa_drv_mac_opaque_abort_t)(void *p_context); * \retval PSA_SUCCESS * Success. */ -typedef psa_status_t (*psa_drv_mac_opaque_generate_t)(const uint8_t *p_input, - size_t input_length, - psa_key_slot_t key_slot, - psa_algorithm_t alg, - uint8_t *p_mac, - size_t mac_size, - size_t *p_mac_length); +typedef psa_status_t (*psa_drv_se_mac_generate_t)(const uint8_t *p_input, + size_t input_length, + psa_key_slot_t key_slot, + psa_algorithm_t alg, + uint8_t *p_mac, + size_t mac_size, + size_t *p_mac_length); /** \brief A function that performs an MAC operation in one command and * compare the resulting MAC against a known value using an opaque key @@ -185,12 +185,12 @@ typedef psa_status_t (*psa_drv_mac_opaque_generate_t)(const uint8_t *p_input, * The operation completed successfully, but the calculated MAC did * not match the provided MAC */ -typedef psa_status_t (*psa_drv_mac_opaque_verify_t)(const uint8_t *p_input, - size_t input_length, - psa_key_slot_t key_slot, - psa_algorithm_t alg, - const uint8_t *p_mac, - size_t mac_length); +typedef psa_status_t (*psa_drv_se_mac_verify_t)(const uint8_t *p_input, + size_t input_length, + psa_key_slot_t key_slot, + psa_algorithm_t alg, + const uint8_t *p_mac, + size_t mac_length); /** \brief A struct containing all of the function pointers needed to * implement MAC operations using opaque keys. @@ -213,26 +213,26 @@ typedef struct { size_t context_size; /** Function that performs the setup operation */ - psa_drv_mac_opaque_setup_t *p_setup; - /** Function that performs the update operation + psa_drv_se_mac_setup_t *p_setup; + /** Function that performs the update operation */ - psa_drv_mac_opaque_update_t *p_update; + psa_drv_se_mac_update_t *p_update; /** Function that completes the operation */ - psa_drv_mac_opaque_finish_t *p_finish; + psa_drv_se_mac_finish_t *p_finish; /** Function that completed a MAC operation with a verify check */ - psa_drv_mac_opaque_finish_verify_t *p_finish_verify; + psa_drv_se_mac_finish_verify_t *p_finish_verify; /** Function that aborts a previoustly started operation */ - psa_drv_mac_opaque_abort_t *p_abort; + psa_drv_se_mac_abort_t *p_abort; /** Function that performs the MAC operation in one call */ - psa_drv_mac_opaque_generate_t *p_mac; + psa_drv_se_mac_generate_t *p_mac; /** Function that performs the MAC and verify operation in one call */ - psa_drv_mac_opaque_verify_t *p_mac_verify; -} psa_drv_mac_opaque_t; + psa_drv_se_mac_verify_t *p_mac_verify; +} psa_drv_se_mac_t; /**@}*/ /** \defgroup opaque_cipher Opaque Symmetric Ciphers @@ -272,10 +272,10 @@ typedef struct { * \retval PSA_SUCCESS * \retval PSA_ERROR_NOT_SUPPORTED */ -typedef psa_status_t (*psa_drv_cipher_opaque_setup_t)(void *p_context, - psa_key_slot_t key_slot, - psa_algorithm_t algorithm, - psa_encrypt_or_decrypt_t direction); +typedef psa_status_t (*psa_drv_se_cipher_setup_t)(void *p_context, + psa_key_slot_t key_slot, + psa_algorithm_t algorithm, + psa_encrypt_or_decrypt_t direction); /** \brief A function pointer that sets the initialization vector (if * necessary) for an opaque cipher operation @@ -292,9 +292,9 @@ typedef psa_status_t (*psa_drv_cipher_opaque_setup_t)(void *p_context, * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_cipher_opaque_set_iv_t)(void *p_context, - const uint8_t *p_iv, - size_t iv_length); +typedef psa_status_t (*psa_drv_se_cipher_set_iv_t)(void *p_context, + const uint8_t *p_iv, + size_t iv_length); /** \brief A function that continues a previously started opaque-key cipher * operation @@ -314,12 +314,12 @@ typedef psa_status_t (*psa_drv_cipher_opaque_set_iv_t)(void *p_context, * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_cipher_opaque_update_t)(void *p_context, - const uint8_t *p_input, - size_t input_size, - uint8_t *p_output, - size_t output_size, - size_t *p_output_length); +typedef psa_status_t (*psa_drv_se_cipher_update_t)(void *p_context, + const uint8_t *p_input, + size_t input_size, + uint8_t *p_output, + size_t output_size, + size_t *p_output_length); /** \brief A function that completes a previously started opaque-key cipher * operation @@ -335,10 +335,10 @@ typedef psa_status_t (*psa_drv_cipher_opaque_update_t)(void *p_context, * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_cipher_opaque_finish_t)(void *p_context, - uint8_t *p_output, - size_t output_size, - size_t *p_output_length); +typedef psa_status_t (*psa_drv_se_cipher_finish_t)(void *p_context, + uint8_t *p_output, + size_t output_size, + size_t *p_output_length); /** \brief A function that aborts a previously started opaque-key cipher * operation @@ -346,7 +346,7 @@ typedef psa_status_t (*psa_drv_cipher_opaque_finish_t)(void *p_context, * \param[in,out] p_context A hardware-specific structure for the * previously started cipher operation */ -typedef psa_status_t (*psa_drv_cipher_opaque_abort_t)(void *p_context); +typedef psa_status_t (*psa_drv_se_cipher_abort_t)(void *p_context); /** \brief A function that performs the ECB block mode for opaque-key cipher * operations @@ -370,13 +370,13 @@ typedef psa_status_t (*psa_drv_cipher_opaque_abort_t)(void *p_context); * \retval PSA_SUCCESS * \retval PSA_ERROR_NOT_SUPPORTED */ -typedef psa_status_t (*psa_drv_cipher_opaque_ecb_t)(psa_key_slot_t key_slot, - psa_algorithm_t algorithm, - psa_encrypt_or_decrypt_t direction, - const uint8_t *p_input, - size_t input_size, - uint8_t *p_output, - size_t output_size); +typedef psa_status_t (*psa_drv_se_cipher_ecb_t)(psa_key_slot_t key_slot, + psa_algorithm_t algorithm, + psa_encrypt_or_decrypt_t direction, + const uint8_t *p_input, + size_t input_size, + uint8_t *p_output, + size_t output_size); /** * \brief A struct containing all of the function pointers needed to implement @@ -392,23 +392,23 @@ typedef struct { /** The size in bytes of the hardware-specific Opaque Cipher context * structure */ - size_t size; + size_t size; /** Function that performs the setup operation */ - psa_drv_cipher_opaque_setup_t *p_setup; + psa_drv_se_cipher_setup_t *p_setup; /** Function that sets the IV (if necessary) */ - psa_drv_cipher_opaque_set_iv_t *p_set_iv; + psa_drv_se_cipher_set_iv_t *p_set_iv; /** Function that performs the update operation */ - psa_drv_cipher_opaque_update_t *p_update; + psa_drv_se_cipher_update_t *p_update; /** Function that completes the operation */ - psa_drv_cipher_opaque_finish_t *p_finish; + psa_drv_se_cipher_finish_t *p_finish; /** Function that aborts the operation */ - psa_drv_cipher_opaque_abort_t *p_abort; + psa_drv_se_cipher_abort_t *p_abort; /** Function that performs ECB mode for the cipher * (Danger: ECB mode should not be used directly by clients of the PSA * Crypto Client API) */ - psa_drv_cipher_opaque_ecb_t *p_ecb; -} psa_drv_cipher_opaque_t; + psa_drv_se_cipher_ecb_t *p_ecb; +} psa_drv_se_cipher_t; /**@}*/ @@ -435,13 +435,13 @@ typedef struct { * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_asymmetric_opaque_sign_t)(psa_key_slot_t key_slot, - psa_algorithm_t alg, - const uint8_t *p_hash, - size_t hash_length, - uint8_t *p_signature, - size_t signature_size, - size_t *p_signature_length); +typedef psa_status_t (*psa_drv_se_asymmetric_sign_t)(psa_key_slot_t key_slot, + psa_algorithm_t alg, + const uint8_t *p_hash, + size_t hash_length, + uint8_t *p_signature, + size_t signature_size, + size_t *p_signature_length); /** * \brief A function that verifies the signature a hash or short message using @@ -459,12 +459,12 @@ typedef psa_status_t (*psa_drv_asymmetric_opaque_sign_t)(psa_key_slot_t key_slot * \retval PSA_SUCCESS * The signature is valid. */ -typedef psa_status_t (*psa_drv_asymmetric_opaque_verify_t)(psa_key_slot_t key_slot, - psa_algorithm_t alg, - const uint8_t *p_hash, - size_t hash_length, - const uint8_t *p_signature, - size_t signature_length); +typedef psa_status_t (*psa_drv_se_asymmetric_verify_t)(psa_key_slot_t key_slot, + psa_algorithm_t alg, + const uint8_t *p_hash, + size_t hash_length, + const uint8_t *p_signature, + size_t signature_length); /** * \brief A function that encrypts a short message with an asymmetric public @@ -495,15 +495,15 @@ typedef psa_status_t (*psa_drv_asymmetric_opaque_verify_t)(psa_key_slot_t key_sl * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_asymmetric_opaque_encrypt_t)(psa_key_slot_t key_slot, - psa_algorithm_t alg, - const uint8_t *p_input, - size_t input_length, - const uint8_t *p_salt, - size_t salt_length, - uint8_t *p_output, - size_t output_size, - size_t *p_output_length); +typedef psa_status_t (*psa_drv_se_asymmetric_encrypt_t)(psa_key_slot_t key_slot, + psa_algorithm_t alg, + const uint8_t *p_input, + size_t input_length, + const uint8_t *p_salt, + size_t salt_length, + uint8_t *p_output, + size_t output_size, + size_t *p_output_length); /** * \brief Decrypt a short message with an asymmetric private key. @@ -532,15 +532,15 @@ typedef psa_status_t (*psa_drv_asymmetric_opaque_encrypt_t)(psa_key_slot_t key_s * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_asymmetric_opaque_decrypt_t)(psa_key_slot_t key_slot, - psa_algorithm_t alg, - const uint8_t *p_input, - size_t input_length, - const uint8_t *p_salt, - size_t salt_length, - uint8_t *p_output, - size_t output_size, - size_t *p_output_length); +typedef psa_status_t (*psa_drv_se_asymmetric_decrypt_t)(psa_key_slot_t key_slot, + psa_algorithm_t alg, + const uint8_t *p_input, + size_t input_length, + const uint8_t *p_salt, + size_t salt_length, + uint8_t *p_output, + size_t output_size, + size_t *p_output_length); /** * \brief A struct containing all of the function pointers needed to implement @@ -553,14 +553,14 @@ typedef psa_status_t (*psa_drv_asymmetric_opaque_decrypt_t)(psa_key_slot_t key_s */ typedef struct { /** Function that performs the asymmetric sign operation */ - psa_drv_asymmetric_opaque_sign_t *p_sign; + psa_drv_se_asymmetric_sign_t *p_sign; /** Function that performs the asymmetric verify operation */ - psa_drv_asymmetric_opaque_verify_t *p_verify; + psa_drv_se_asymmetric_verify_t *p_verify; /** Function that performs the asymmetric encrypt operation */ - psa_drv_asymmetric_opaque_encrypt_t *p_encrypt; + psa_drv_se_asymmetric_encrypt_t *p_encrypt; /** Function that performs the asymmetric decrypt operation */ - psa_drv_asymmetric_opaque_decrypt_t *p_decrypt; -} psa_drv_asymmetric_opaque_t; + psa_drv_se_asymmetric_decrypt_t *p_decrypt; +} psa_drv_se_asymmetric_t; /**@}*/ @@ -602,17 +602,17 @@ typedef struct { * \retval #PSA_SUCCESS * Success. */ -typedef psa_status_t (*psa_drv_aead_opaque_encrypt_t)(psa_key_slot_t key_slot, - psa_algorithm_t algorithm, - const uint8_t *p_nonce, - size_t nonce_length, - const uint8_t *p_additional_data, - size_t additional_data_length, - const uint8_t *p_plaintext, - size_t plaintext_length, - uint8_t *p_ciphertext, - size_t ciphertext_size, - size_t *p_ciphertext_length); +typedef psa_status_t (*psa_drv_se_aead_encrypt_t)(psa_key_slot_t key_slot, + psa_algorithm_t algorithm, + const uint8_t *p_nonce, + size_t nonce_length, + const uint8_t *p_additional_data, + size_t additional_data_length, + const uint8_t *p_plaintext, + size_t plaintext_length, + uint8_t *p_ciphertext, + size_t ciphertext_size, + size_t *p_ciphertext_length); /** Process an authenticated decryption operation using an opaque key * @@ -642,17 +642,17 @@ typedef psa_status_t (*psa_drv_aead_opaque_encrypt_t)(psa_key_slot_t key_slot, * \retval #PSA_SUCCESS * Success. */ -typedef psa_status_t (*psa_drv_aead_opaque_decrypt_t)(psa_key_slot_t key_slot, - psa_algorithm_t algorithm, - const uint8_t *p_nonce, - size_t nonce_length, - const uint8_t *p_additional_data, - size_t additional_data_length, - const uint8_t *p_ciphertext, - size_t ciphertext_length, - uint8_t *p_plaintext, - size_t plaintext_size, - size_t *p_plaintext_length); +typedef psa_status_t (*psa_drv_se_aead_decrypt_t)(psa_key_slot_t key_slot, + psa_algorithm_t algorithm, + const uint8_t *p_nonce, + size_t nonce_length, + const uint8_t *p_additional_data, + size_t additional_data_length, + const uint8_t *p_ciphertext, + size_t ciphertext_length, + uint8_t *p_plaintext, + size_t plaintext_size, + size_t *p_plaintext_length); /** * \brief A struct containing all of the function pointers needed to implement @@ -665,10 +665,10 @@ typedef psa_status_t (*psa_drv_aead_opaque_decrypt_t)(psa_key_slot_t key_slot, */ typedef struct { /** Function that performs the AEAD encrypt operation */ - psa_drv_aead_opaque_encrypt_t *p_encrypt; + psa_drv_se_aead_encrypt_t *p_encrypt; /** Function that performs the AEAD decrypt operation */ - psa_drv_aead_opaque_decrypt_t *p_decrypt; -} psa_drv_aead_opaque_t; + psa_drv_se_aead_decrypt_t *p_decrypt; +} psa_drv_se_aead_t; /**@}*/ /** \defgroup driver_key_management Key Management @@ -696,12 +696,12 @@ typedef struct { * \retval #PSA_SUCCESS * Success. */ -typedef psa_status_t (*psa_drv_opaque_import_key_t)(psa_key_slot_t key_slot, - psa_key_type_t type, - psa_algorithm_t algorithm, - psa_key_usage_t usage, - const uint8_t *p_data, - size_t data_length); +typedef psa_status_t (*psa_drv_se_import_key_t)(psa_key_slot_t key_slot, + psa_key_type_t type, + psa_algorithm_t algorithm, + psa_key_usage_t usage, + const uint8_t *p_data, + size_t data_length); /** * \brief Destroy a key and restore the slot to its default state @@ -719,7 +719,7 @@ typedef psa_status_t (*psa_drv_opaque_import_key_t)(psa_key_slot_t key_slot, * \retval #PSA_SUCCESS * The slot's content, if any, has been erased. */ -typedef psa_status_t (*psa_drv_destroy_key_t)(psa_key_slot_t key); +typedef psa_status_t (*psa_drv_se_destroy_key_t)(psa_key_slot_t key); /** * \brief Export a key in binary format @@ -761,10 +761,10 @@ typedef psa_status_t (*psa_drv_destroy_key_t)(psa_key_slot_t key); * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_TAMPERING_DETECTED */ -typedef psa_status_t (*psa_drv_export_key_t)(psa_key_slot_t key, - uint8_t *p_data, - size_t data_size, - size_t *p_data_length); +typedef psa_status_t (*psa_drv_se_export_key_t)(psa_key_slot_t key, + uint8_t *p_data, + size_t data_size, + size_t *p_data_length); /** * \brief Export a public key or the public part of a key pair in binary format @@ -787,7 +787,7 @@ typedef psa_status_t (*psa_drv_export_key_t)(psa_key_slot_t key, * * \retval #PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_export_public_key_t)(psa_key_slot_t key, +typedef psa_status_t (*psa_drv_se_export_public_key_t)(psa_key_slot_t key, uint8_t *p_data, size_t data_size, size_t *p_data_length); @@ -803,14 +803,14 @@ typedef psa_status_t (*psa_drv_export_public_key_t)(psa_key_slot_t key, */ typedef struct { /** Function that performs the key import operation */ - psa_drv_opaque_import_key_t *p_import; + psa_drv_se_import_key_t *p_import; /** Function that performs the key destroy operation */ - psa_drv_destroy_key_t *p_destroy; + psa_drv_se_destroy_key_t *p_destroy; /** Function that performs the key export operation */ - psa_drv_export_key_t *p_export; + psa_drv_se_export_key_t *p_export; /** Function that perforsm the public key export operation */ - psa_drv_export_public_key_t *p_export_public; -} psa_drv_key_management_t; + psa_drv_se_export_public_key_t *p_export_public; +} psa_drv_se_key_management_t; /**@}*/ @@ -881,9 +881,9 @@ typedef struct psa_drv_key_derivation_context_s psa_drv_key_derivation_context_t * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_key_derivation_setup_t)(psa_drv_key_derivation_context_t *p_context, - psa_algorithm_t kdf_alg, - psa_key_slot_t source_key); +typedef psa_status_t (*psa_drv_se_key_derivation_setup_t)(psa_drv_key_derivation_context_t *p_context, + psa_algorithm_t kdf_alg, + psa_key_slot_t source_key); /** \brief Provide collateral (parameters) needed for a key derivation or key * agreement operation @@ -900,10 +900,10 @@ typedef psa_status_t (*psa_drv_key_derivation_setup_t)(psa_drv_key_derivation_co * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_key_derivation_collateral_t)(psa_drv_key_derivation_context_t *p_context, - uint32_t collateral_id, - const uint8_t *p_collateral, - size_t collateral_size); +typedef psa_status_t (*psa_drv_se_key_derivation_collateral_t)(psa_drv_key_derivation_context_t *p_context, + uint32_t collateral_id, + const uint8_t *p_collateral, + size_t collateral_size); /** \brief Perform the final key derivation step and place the generated key * material in a slot @@ -914,7 +914,7 @@ typedef psa_status_t (*psa_drv_key_derivation_collateral_t)(psa_drv_key_derivati * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_key_derivation_derive_t)(psa_drv_key_derivation_context_t *p_context, +typedef psa_status_t (*psa_drv_se_key_derivation_derive_t)(psa_drv_key_derivation_context_t *p_context, psa_key_slot_t dest_key); /** \brief Perform the final step of a key agreement and place the generated @@ -928,7 +928,7 @@ typedef psa_status_t (*psa_drv_key_derivation_derive_t)(psa_drv_key_derivation_c * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_key_derivation_export_t)(uint8_t *p_output, +typedef psa_status_t (*psa_drv_se_key_derivation_export_t)(uint8_t *p_output, size_t output_size, size_t *p_output_length); @@ -943,15 +943,15 @@ typedef psa_status_t (*psa_drv_key_derivation_export_t)(uint8_t *p_output, */ typedef struct { /** Function that performs the key derivation setup */ - psa_drv_key_derivation_setup_t *p_setup; + psa_drv_se_key_derivation_setup_t *p_setup; /** Function that sets the key derivation collateral */ - psa_drv_key_derivation_collateral_t *p_collateral; + psa_drv_se_key_derivation_collateral_t *p_collateral; /** Function that performs the final key derivation step */ - psa_drv_key_derivation_derive_t *p_derive; + psa_drv_se_key_derivation_derive_t *p_derive; /** Function that perforsm the final key derivation or agreement and * exports the key */ - psa_drv_key_derivation_export_t *p_export; -} psa_drv_key_derivation_t; + psa_drv_se_key_derivation_export_t *p_export; +} psa_drv_se_key_derivation_t; /**@}*/ From b2a1cceaf7342f628382d8a6d088e3a6c4e14fde Mon Sep 17 00:00:00 2001 From: Derek Miller Date: Fri, 15 Feb 2019 17:03:42 -0600 Subject: [PATCH 02/15] temporarily changed psa_key_slot_t to psa_key_slot_number_t to avoid naming collision --- include/psa/crypto_se_driver.h | 36 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/include/psa/crypto_se_driver.h b/include/psa/crypto_se_driver.h index 7ca6d605a..5214c62d6 100644 --- a/include/psa/crypto_se_driver.h +++ b/include/psa/crypto_se_driver.h @@ -43,7 +43,7 @@ extern "C" { /** An internal designation of a key slot between the core part of the * PSA Crypto implementation and the driver. The meaning of this value * is driver-dependent. */ -typedef uint32_t psa_key_slot_t; +typedef uint32_t psa_key_slot_number_t; // TODO: Change this to psa_key_slot_t after psa_key_slot_t is removed from Mbed crypto /** \defgroup opaque_mac Opaque Message Authentication Code * Generation and authentication of Message Authentication Codes (MACs) using @@ -76,7 +76,7 @@ typedef uint32_t psa_key_slot_t; * Success. */ typedef psa_status_t (*psa_drv_se_mac_setup_t)(void *p_context, - psa_key_slot_t key_slot, + psa_key_slot_number_t key_slot, psa_algorithm_t algorithm); /** \brief A function that continues a previously started MAC operation using @@ -160,7 +160,7 @@ typedef psa_status_t (*psa_drv_se_mac_abort_t)(void *p_context); */ typedef psa_status_t (*psa_drv_se_mac_generate_t)(const uint8_t *p_input, size_t input_length, - psa_key_slot_t key_slot, + psa_key_slot_number_t key_slot, psa_algorithm_t alg, uint8_t *p_mac, size_t mac_size, @@ -187,7 +187,7 @@ typedef psa_status_t (*psa_drv_se_mac_generate_t)(const uint8_t *p_input, */ typedef psa_status_t (*psa_drv_se_mac_verify_t)(const uint8_t *p_input, size_t input_length, - psa_key_slot_t key_slot, + psa_key_slot_number_t key_slot, psa_algorithm_t alg, const uint8_t *p_mac, size_t mac_length); @@ -273,7 +273,7 @@ typedef struct { * \retval PSA_ERROR_NOT_SUPPORTED */ typedef psa_status_t (*psa_drv_se_cipher_setup_t)(void *p_context, - psa_key_slot_t key_slot, + psa_key_slot_number_t key_slot, psa_algorithm_t algorithm, psa_encrypt_or_decrypt_t direction); @@ -370,7 +370,7 @@ typedef psa_status_t (*psa_drv_se_cipher_abort_t)(void *p_context); * \retval PSA_SUCCESS * \retval PSA_ERROR_NOT_SUPPORTED */ -typedef psa_status_t (*psa_drv_se_cipher_ecb_t)(psa_key_slot_t key_slot, +typedef psa_status_t (*psa_drv_se_cipher_ecb_t)(psa_key_slot_number_t key_slot, psa_algorithm_t algorithm, psa_encrypt_or_decrypt_t direction, const uint8_t *p_input, @@ -435,7 +435,7 @@ typedef struct { * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_se_asymmetric_sign_t)(psa_key_slot_t key_slot, +typedef psa_status_t (*psa_drv_se_asymmetric_sign_t)(psa_key_slot_number_t key_slot, psa_algorithm_t alg, const uint8_t *p_hash, size_t hash_length, @@ -459,7 +459,7 @@ typedef psa_status_t (*psa_drv_se_asymmetric_sign_t)(psa_key_slot_t key_slot, * \retval PSA_SUCCESS * The signature is valid. */ -typedef psa_status_t (*psa_drv_se_asymmetric_verify_t)(psa_key_slot_t key_slot, +typedef psa_status_t (*psa_drv_se_asymmetric_verify_t)(psa_key_slot_number_t key_slot, psa_algorithm_t alg, const uint8_t *p_hash, size_t hash_length, @@ -495,7 +495,7 @@ typedef psa_status_t (*psa_drv_se_asymmetric_verify_t)(psa_key_slot_t key_slot, * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_se_asymmetric_encrypt_t)(psa_key_slot_t key_slot, +typedef psa_status_t (*psa_drv_se_asymmetric_encrypt_t)(psa_key_slot_number_t key_slot, psa_algorithm_t alg, const uint8_t *p_input, size_t input_length, @@ -532,7 +532,7 @@ typedef psa_status_t (*psa_drv_se_asymmetric_encrypt_t)(psa_key_slot_t key_slot, * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_se_asymmetric_decrypt_t)(psa_key_slot_t key_slot, +typedef psa_status_t (*psa_drv_se_asymmetric_decrypt_t)(psa_key_slot_number_t key_slot, psa_algorithm_t alg, const uint8_t *p_input, size_t input_length, @@ -602,7 +602,7 @@ typedef struct { * \retval #PSA_SUCCESS * Success. */ -typedef psa_status_t (*psa_drv_se_aead_encrypt_t)(psa_key_slot_t key_slot, +typedef psa_status_t (*psa_drv_se_aead_encrypt_t)(psa_key_slot_number_t key_slot, psa_algorithm_t algorithm, const uint8_t *p_nonce, size_t nonce_length, @@ -642,7 +642,7 @@ typedef psa_status_t (*psa_drv_se_aead_encrypt_t)(psa_key_slot_t key_slot, * \retval #PSA_SUCCESS * Success. */ -typedef psa_status_t (*psa_drv_se_aead_decrypt_t)(psa_key_slot_t key_slot, +typedef psa_status_t (*psa_drv_se_aead_decrypt_t)(psa_key_slot_number_t key_slot, psa_algorithm_t algorithm, const uint8_t *p_nonce, size_t nonce_length, @@ -696,7 +696,7 @@ typedef struct { * \retval #PSA_SUCCESS * Success. */ -typedef psa_status_t (*psa_drv_se_import_key_t)(psa_key_slot_t key_slot, +typedef psa_status_t (*psa_drv_se_import_key_t)(psa_key_slot_number_t key_slot, psa_key_type_t type, psa_algorithm_t algorithm, psa_key_usage_t usage, @@ -719,7 +719,7 @@ typedef psa_status_t (*psa_drv_se_import_key_t)(psa_key_slot_t key_slot, * \retval #PSA_SUCCESS * The slot's content, if any, has been erased. */ -typedef psa_status_t (*psa_drv_se_destroy_key_t)(psa_key_slot_t key); +typedef psa_status_t (*psa_drv_se_destroy_key_t)(psa_key_slot_number_t key); /** * \brief Export a key in binary format @@ -761,7 +761,7 @@ typedef psa_status_t (*psa_drv_se_destroy_key_t)(psa_key_slot_t key); * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_TAMPERING_DETECTED */ -typedef psa_status_t (*psa_drv_se_export_key_t)(psa_key_slot_t key, +typedef psa_status_t (*psa_drv_se_export_key_t)(psa_key_slot_number_t key, uint8_t *p_data, size_t data_size, size_t *p_data_length); @@ -787,7 +787,7 @@ typedef psa_status_t (*psa_drv_se_export_key_t)(psa_key_slot_t key, * * \retval #PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_se_export_public_key_t)(psa_key_slot_t key, +typedef psa_status_t (*psa_drv_se_export_public_key_t)(psa_key_slot_number_t key, uint8_t *p_data, size_t data_size, size_t *p_data_length); @@ -883,7 +883,7 @@ typedef struct psa_drv_key_derivation_context_s psa_drv_key_derivation_context_t */ typedef psa_status_t (*psa_drv_se_key_derivation_setup_t)(psa_drv_key_derivation_context_t *p_context, psa_algorithm_t kdf_alg, - psa_key_slot_t source_key); + psa_key_slot_number_t source_key); /** \brief Provide collateral (parameters) needed for a key derivation or key * agreement operation @@ -915,7 +915,7 @@ typedef psa_status_t (*psa_drv_se_key_derivation_collateral_t)(psa_drv_key_deriv * \retval PSA_SUCCESS */ typedef psa_status_t (*psa_drv_se_key_derivation_derive_t)(psa_drv_key_derivation_context_t *p_context, - psa_key_slot_t dest_key); + psa_key_slot_number_t dest_key); /** \brief Perform the final step of a key agreement and place the generated * key material in a buffer From ea743cf6b00617b461a091510a774b55f996358c Mon Sep 17 00:00:00 2001 From: Derek Miller Date: Fri, 15 Feb 2019 17:06:29 -0600 Subject: [PATCH 03/15] Removed * from function pointers (as they were already pointers) --- include/psa/crypto_se_driver.h | 54 +++++++++++++++++----------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/include/psa/crypto_se_driver.h b/include/psa/crypto_se_driver.h index 5214c62d6..f94b2f854 100644 --- a/include/psa/crypto_se_driver.h +++ b/include/psa/crypto_se_driver.h @@ -213,25 +213,25 @@ typedef struct { size_t context_size; /** Function that performs the setup operation */ - psa_drv_se_mac_setup_t *p_setup; + psa_drv_se_mac_setup_t p_setup; /** Function that performs the update operation */ - psa_drv_se_mac_update_t *p_update; + psa_drv_se_mac_update_t p_update; /** Function that completes the operation */ - psa_drv_se_mac_finish_t *p_finish; + psa_drv_se_mac_finish_t p_finish; /** Function that completed a MAC operation with a verify check */ - psa_drv_se_mac_finish_verify_t *p_finish_verify; + psa_drv_se_mac_finish_verify_t p_finish_verify; /** Function that aborts a previoustly started operation */ - psa_drv_se_mac_abort_t *p_abort; + psa_drv_se_mac_abort_t p_abort; /** Function that performs the MAC operation in one call */ - psa_drv_se_mac_generate_t *p_mac; + psa_drv_se_mac_generate_t p_mac; /** Function that performs the MAC and verify operation in one call */ - psa_drv_se_mac_verify_t *p_mac_verify; + psa_drv_se_mac_verify_t p_mac_verify; } psa_drv_se_mac_t; /**@}*/ @@ -394,20 +394,20 @@ typedef struct { */ size_t size; /** Function that performs the setup operation */ - psa_drv_se_cipher_setup_t *p_setup; + psa_drv_se_cipher_setup_t p_setup; /** Function that sets the IV (if necessary) */ - psa_drv_se_cipher_set_iv_t *p_set_iv; + psa_drv_se_cipher_set_iv_t p_set_iv; /** Function that performs the update operation */ - psa_drv_se_cipher_update_t *p_update; + psa_drv_se_cipher_update_t p_update; /** Function that completes the operation */ - psa_drv_se_cipher_finish_t *p_finish; + psa_drv_se_cipher_finish_t p_finish; /** Function that aborts the operation */ - psa_drv_se_cipher_abort_t *p_abort; + psa_drv_se_cipher_abort_t p_abort; /** Function that performs ECB mode for the cipher * (Danger: ECB mode should not be used directly by clients of the PSA * Crypto Client API) */ - psa_drv_se_cipher_ecb_t *p_ecb; + psa_drv_se_cipher_ecb_t p_ecb; } psa_drv_se_cipher_t; /**@}*/ @@ -553,13 +553,13 @@ typedef psa_status_t (*psa_drv_se_asymmetric_decrypt_t)(psa_key_slot_number_t ke */ typedef struct { /** Function that performs the asymmetric sign operation */ - psa_drv_se_asymmetric_sign_t *p_sign; + psa_drv_se_asymmetric_sign_t p_sign; /** Function that performs the asymmetric verify operation */ - psa_drv_se_asymmetric_verify_t *p_verify; + psa_drv_se_asymmetric_verify_t p_verify; /** Function that performs the asymmetric encrypt operation */ - psa_drv_se_asymmetric_encrypt_t *p_encrypt; + psa_drv_se_asymmetric_encrypt_t p_encrypt; /** Function that performs the asymmetric decrypt operation */ - psa_drv_se_asymmetric_decrypt_t *p_decrypt; + psa_drv_se_asymmetric_decrypt_t p_decrypt; } psa_drv_se_asymmetric_t; /**@}*/ @@ -665,9 +665,9 @@ typedef psa_status_t (*psa_drv_se_aead_decrypt_t)(psa_key_slot_number_t key_slot */ typedef struct { /** Function that performs the AEAD encrypt operation */ - psa_drv_se_aead_encrypt_t *p_encrypt; + psa_drv_se_aead_encrypt_t p_encrypt; /** Function that performs the AEAD decrypt operation */ - psa_drv_se_aead_decrypt_t *p_decrypt; + psa_drv_se_aead_decrypt_t p_decrypt; } psa_drv_se_aead_t; /**@}*/ @@ -803,13 +803,13 @@ typedef psa_status_t (*psa_drv_se_export_public_key_t)(psa_key_slot_number_t key */ typedef struct { /** Function that performs the key import operation */ - psa_drv_se_import_key_t *p_import; + psa_drv_se_import_key_t p_import; /** Function that performs the key destroy operation */ - psa_drv_se_destroy_key_t *p_destroy; + psa_drv_se_destroy_key_t p_destroy; /** Function that performs the key export operation */ - psa_drv_se_export_key_t *p_export; + psa_drv_se_export_key_t p_export; /** Function that perforsm the public key export operation */ - psa_drv_se_export_public_key_t *p_export_public; + psa_drv_se_export_public_key_t p_export_public; } psa_drv_se_key_management_t; /**@}*/ @@ -943,14 +943,14 @@ typedef psa_status_t (*psa_drv_se_key_derivation_export_t)(uint8_t *p_output, */ typedef struct { /** Function that performs the key derivation setup */ - psa_drv_se_key_derivation_setup_t *p_setup; + psa_drv_se_key_derivation_setup_t p_setup; /** Function that sets the key derivation collateral */ - psa_drv_se_key_derivation_collateral_t *p_collateral; + psa_drv_se_key_derivation_collateral_t p_collateral; /** Function that performs the final key derivation step */ - psa_drv_se_key_derivation_derive_t *p_derive; + psa_drv_se_key_derivation_derive_t p_derive; /** Function that perforsm the final key derivation or agreement and * exports the key */ - psa_drv_se_key_derivation_export_t *p_export; + psa_drv_se_key_derivation_export_t p_export; } psa_drv_se_key_derivation_t; /**@}*/ From 0972fe548ce80de5f6d8896ebf2bc03c960b2450 Mon Sep 17 00:00:00 2001 From: Derek Miller Date: Fri, 15 Feb 2019 17:08:27 -0600 Subject: [PATCH 04/15] added lifetime paramter to psa_drv_se_import_key_t as the SE needs to know this --- include/psa/crypto_se_driver.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/psa/crypto_se_driver.h b/include/psa/crypto_se_driver.h index f94b2f854..fdeb2b150 100644 --- a/include/psa/crypto_se_driver.h +++ b/include/psa/crypto_se_driver.h @@ -697,6 +697,7 @@ typedef struct { * Success. */ typedef psa_status_t (*psa_drv_se_import_key_t)(psa_key_slot_number_t key_slot, + psa_key_lifetime_t lifetime, psa_key_type_t type, psa_algorithm_t algorithm, psa_key_usage_t usage, From 0b3098a48609c797ebbf07a552071e5c96e7947a Mon Sep 17 00:00:00 2001 From: Derek Miller Date: Fri, 15 Feb 2019 17:10:49 -0600 Subject: [PATCH 05/15] added generate key. Removed pubkey export --- include/psa/crypto_se_driver.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/include/psa/crypto_se_driver.h b/include/psa/crypto_se_driver.h index fdeb2b150..aea9ec09d 100644 --- a/include/psa/crypto_se_driver.h +++ b/include/psa/crypto_se_driver.h @@ -788,10 +788,15 @@ typedef psa_status_t (*psa_drv_se_export_key_t)(psa_key_slot_number_t key, * * \retval #PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_se_export_public_key_t)(psa_key_slot_number_t key, - uint8_t *p_data, - size_t data_size, - size_t *p_data_length); +typedef psa_status_t (*psa_drv_se_generate_key_t) (psa_key_slot_number_t key_slot, + psa_key_type_t type, + psa_key_usage_t usage, + size_t bits, + const void *extra, + size_t extra_size, + uint8_t *p_pubkey_out, + size_t pubkey_out_size, + size_t *p_pubkey_length); /** * \brief A struct containing all of the function pointers needed to for key @@ -806,11 +811,11 @@ typedef struct { /** Function that performs the key import operation */ psa_drv_se_import_key_t p_import; /** Function that performs the key destroy operation */ - psa_drv_se_destroy_key_t p_destroy; + psa_drv_se_generate_key_t p_generate; /** Function that performs the key export operation */ - psa_drv_se_export_key_t p_export; + psa_drv_se_destroy_key_t p_destroy; /** Function that perforsm the public key export operation */ - psa_drv_se_export_public_key_t p_export_public; + psa_drv_se_export_key_t p_export; } psa_drv_se_key_management_t; /**@}*/ From 6211726c6125344caa9bc509d90f1f7add0b3765 Mon Sep 17 00:00:00 2001 From: Derek Miller Date: Fri, 15 Feb 2019 17:12:26 -0600 Subject: [PATCH 06/15] Removed key deriv. context struct, replaced with void* and a context_size --- include/psa/crypto_se_driver.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/include/psa/crypto_se_driver.h b/include/psa/crypto_se_driver.h index aea9ec09d..98d4767b1 100644 --- a/include/psa/crypto_se_driver.h +++ b/include/psa/crypto_se_driver.h @@ -874,7 +874,6 @@ typedef struct { * The contents of this structure are implementation dependent and are * therefore not described here */ -typedef struct psa_drv_key_derivation_context_s psa_drv_key_derivation_context_t; /** \brief Set up a key derivation operation by specifying the algorithm and * the source key sot @@ -887,7 +886,7 @@ typedef struct psa_drv_key_derivation_context_s psa_drv_key_derivation_context_t * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_se_key_derivation_setup_t)(psa_drv_key_derivation_context_t *p_context, +typedef psa_status_t (*psa_drv_se_key_derivation_setup_t)(void *p_context, psa_algorithm_t kdf_alg, psa_key_slot_number_t source_key); @@ -906,7 +905,7 @@ typedef psa_status_t (*psa_drv_se_key_derivation_setup_t)(psa_drv_key_derivation * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_se_key_derivation_collateral_t)(psa_drv_key_derivation_context_t *p_context, +typedef psa_status_t (*psa_drv_se_key_derivation_collateral_t)(void *p_context, uint32_t collateral_id, const uint8_t *p_collateral, size_t collateral_size); @@ -920,8 +919,8 @@ typedef psa_status_t (*psa_drv_se_key_derivation_collateral_t)(psa_drv_key_deriv * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_se_key_derivation_derive_t)(psa_drv_key_derivation_context_t *p_context, - psa_key_slot_number_t dest_key); +typedef psa_status_t (*psa_drv_se_key_derivation_derive_t)(void *p_context, + psa_key_slot_number_t dest_key); /** \brief Perform the final step of a key agreement and place the generated * key material in a buffer @@ -934,9 +933,10 @@ typedef psa_status_t (*psa_drv_se_key_derivation_derive_t)(psa_drv_key_derivatio * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_se_key_derivation_export_t)(uint8_t *p_output, - size_t output_size, - size_t *p_output_length); +typedef psa_status_t (*psa_drv_se_key_derivation_export_t)(void *p_context, + uint8_t *p_output, + size_t output_size, + size_t *p_output_length); /** * \brief A struct containing all of the function pointers needed to for key @@ -948,6 +948,8 @@ typedef psa_status_t (*psa_drv_se_key_derivation_export_t)(uint8_t *p_output, * If one of the functions is not implemented, it should be set to NULL. */ typedef struct { + /** The driver-specific size of the key derivation context */ + size_t context_size; /** Function that performs the key derivation setup */ psa_drv_se_key_derivation_setup_t p_setup; /** Function that sets the key derivation collateral */ From 34b33f198bbf3285a1fe2a36a899b14215649f07 Mon Sep 17 00:00:00 2001 From: Derek Miller Date: Fri, 15 Feb 2019 17:13:54 -0600 Subject: [PATCH 07/15] Changed psa_drv_se_cipher_t.size to context_size to be consistent --- include/psa/crypto_se_driver.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/psa/crypto_se_driver.h b/include/psa/crypto_se_driver.h index 98d4767b1..438067f26 100644 --- a/include/psa/crypto_se_driver.h +++ b/include/psa/crypto_se_driver.h @@ -392,8 +392,8 @@ typedef struct { /** The size in bytes of the hardware-specific Opaque Cipher context * structure */ - size_t size; - /** Function that performs the setup operation */ + size_t context_size; + /** Function that performs a cipher setup operation */ psa_drv_se_cipher_setup_t p_setup; /** Function that sets the IV (if necessary) */ psa_drv_se_cipher_set_iv_t p_set_iv; From 6aaa4fd73bae6e255a8973c740cb34f40f759c33 Mon Sep 17 00:00:00 2001 From: Derek Miller Date: Fri, 15 Feb 2019 17:15:54 -0600 Subject: [PATCH 08/15] added key_type parameter to asymmetric operations because the accelerator need this info --- include/psa/crypto_accel_driver.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/psa/crypto_accel_driver.h b/include/psa/crypto_accel_driver.h index 72187152b..dd603fe91 100644 --- a/include/psa/crypto_accel_driver.h +++ b/include/psa/crypto_accel_driver.h @@ -656,6 +656,7 @@ typedef psa_status_t (*psa_drv_accel_aead_decrypt_t)(const uint8_t *p_key, typedef psa_status_t (*psa_drv_accel_asymmetric_sign_t)(const uint8_t *p_key, size_t key_size, psa_algorithm_t alg, + psa_key_type_t key_type, const uint8_t *p_hash, size_t hash_length, uint8_t *p_signature, @@ -689,6 +690,7 @@ typedef psa_status_t (*psa_drv_accel_asymmetric_sign_t)(const uint8_t *p_key, typedef psa_status_t (*psa_drv_accel_asymmetric_verify_t)(const uint8_t *p_key, size_t key_size, psa_algorithm_t alg, + psa_key_type_t key_type, const uint8_t *p_hash, size_t hash_length, const uint8_t *p_signature, @@ -733,6 +735,7 @@ typedef psa_status_t (*psa_drv_accel_asymmetric_verify_t)(const uint8_t *p_key, typedef psa_status_t (*psa_drv_accel_asymmetric_encrypt_t)(const uint8_t *p_key, size_t key_size, psa_algorithm_t alg, + psa_key_type_t key_type, const uint8_t *p_input, size_t input_length, const uint8_t *p_salt, @@ -779,6 +782,7 @@ typedef psa_status_t (*psa_drv_accel_asymmetric_encrypt_t)(const uint8_t *p_key, typedef psa_status_t (*psa_drv_accel_asymmetric_decrypt_t)(const uint8_t *p_key, size_t key_size, psa_algorithm_t alg, + psa_key_type_t key_type, const uint8_t *p_input, size_t input_length, const uint8_t *p_salt, From 8a241a57791cb3918c503a5f45f64e82836034c8 Mon Sep 17 00:00:00 2001 From: Derek Miller Date: Fri, 15 Feb 2019 17:17:25 -0600 Subject: [PATCH 09/15] Replaced entropy driver context with void * to support multiple entropy drivers --- include/psa/crypto_entropy_driver.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/psa/crypto_entropy_driver.h b/include/psa/crypto_entropy_driver.h index f5e383e6c..79b7f7fd5 100644 --- a/include/psa/crypto_entropy_driver.h +++ b/include/psa/crypto_entropy_driver.h @@ -40,10 +40,6 @@ extern "C" { */ /**@{*/ -/** \brief A hardware-specific structure for a entropy providing hardware - */ -typedef struct psa_drv_entropy_context_s psa_drv_entropy_context_t; - /** \brief Initialize an entropy driver * * @@ -53,7 +49,7 @@ typedef struct psa_drv_entropy_context_s psa_drv_entropy_context_t; * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_entropy_init_t)(psa_drv_entropy_context_t *p_context); +typedef psa_status_t (*psa_drv_entropy_init_t)(void *p_context); /** \brief Get a specified number of bits from the entropy source * @@ -81,7 +77,7 @@ typedef psa_status_t (*psa_drv_entropy_init_t)(psa_drv_entropy_context_t *p_cont * * \retval PSA_SUCCESS */ -typedef psa_status_t (*psa_drv_entropy_get_bits_t)(psa_drv_entropy_context_t *p_context, +typedef psa_status_t (*psa_drv_entropy_get_bits_t)(void *p_context, uint8_t *p_buffer, uint32_t buffer_size, uint32_t *p_received_entropy_bits); @@ -96,6 +92,8 @@ typedef psa_status_t (*psa_drv_entropy_get_bits_t)(psa_drv_entropy_context_t *p_ * If one of the functions is not implemented, it should be set to NULL. */ typedef struct { + /** The driver-specific size of the entropy context */ + const size_t context_size; /** Function that performs initialization for the entropy source */ psa_drv_entropy_init_t *p_init; /** Function that performs the get_bits operation for the entropy source From 28d483ef2fa0ed6b24bd5f942ccaa3c9c1b72b58 Mon Sep 17 00:00:00 2001 From: Derek Miller Date: Fri, 15 Feb 2019 17:18:03 -0600 Subject: [PATCH 10/15] removed * from entropy function pointers as they are already pointers --- include/psa/crypto_entropy_driver.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/psa/crypto_entropy_driver.h b/include/psa/crypto_entropy_driver.h index 79b7f7fd5..1d94432ef 100644 --- a/include/psa/crypto_entropy_driver.h +++ b/include/psa/crypto_entropy_driver.h @@ -95,10 +95,10 @@ typedef struct { /** The driver-specific size of the entropy context */ const size_t context_size; /** Function that performs initialization for the entropy source */ - psa_drv_entropy_init_t *p_init; + psa_drv_entropy_init_t p_init; /** Function that performs the get_bits operation for the entropy source */ - psa_drv_entropy_get_bits_t *p_get_bits; + psa_drv_entropy_get_bits_t p_get_bits; } psa_drv_entropy_t; /**@}*/ From f0c1d0d375fbc78f9d4a54d31ce71d001fdc7253 Mon Sep 17 00:00:00 2001 From: Derek Miller Date: Fri, 15 Feb 2019 17:23:42 -0600 Subject: [PATCH 11/15] Doxygen changes to match the code changes. clarifications. --- include/psa/crypto_accel_driver.h | 229 +++++++++-------- include/psa/crypto_entropy_driver.h | 7 +- include/psa/crypto_se_driver.h | 364 ++++++++++++++-------------- 3 files changed, 310 insertions(+), 290 deletions(-) diff --git a/include/psa/crypto_accel_driver.h b/include/psa/crypto_accel_driver.h index dd603fe91..57bc18dad 100644 --- a/include/psa/crypto_accel_driver.h +++ b/include/psa/crypto_accel_driver.h @@ -38,12 +38,13 @@ extern "C" { #endif -/** \defgroup driver_digest Message Digests +/** \defgroup driver_digest Hardware-Accelerated Message Digests * * Generation and authentication of Message Digests (aka hashes) must be done * in parts using the following sequence: * - `psa_drv_hash_setup_t` * - `psa_drv_hash_update_t` + * - `psa_drv_hash_update_t` * - ... * - `psa_drv_hash_finish_t` * @@ -64,7 +65,7 @@ typedef struct psa_drv_hash_context_s psa_drv_hash_context_t; /** \brief The function prototype for the start operation of a hash (message * digest) operation * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} * psa_drv_hash__setup @@ -81,7 +82,7 @@ typedef psa_status_t (*psa_drv_hash_setup_t)(psa_drv_hash_context_t *p_context); /** \brief The function prototype for the update operation of a hash (message * digest) operation * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} * psa_drv_hash__update @@ -99,10 +100,10 @@ typedef psa_status_t (*psa_drv_hash_update_t)(psa_drv_hash_context_t *p_context, const uint8_t *p_input, size_t input_length); -/** \brief The prototype for the finish operation of a hash (message digest) - * operation +/** \brief The function prototype for the finish operation of a hash (message + * digest) operation * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} * psa_drv_hash__finish @@ -130,7 +131,7 @@ typedef psa_status_t (*psa_drv_hash_finish_t)(psa_drv_hash_context_t *p_context, /** \brief The function prototype for the abort operation of a hash (message * digest) operation * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} * psa_drv_hash__abort @@ -144,26 +145,26 @@ typedef void (*psa_drv_hash_abort_t)(psa_drv_hash_context_t *p_context); /**@}*/ -/** \defgroup transparent_mac Transparent Message Authentication Code +/** \defgroup accel_mac Hardware-Accelerated Message Authentication Code * Generation and authentication of Message Authentication Codes (MACs) using - * transparent keys can be done either as a single function call (via the - * `psa_drv_mac_transparent_generate_t` or `psa_drv_mac_transparent_verify_t` + * cryptographic accelerators can be done either as a single function call (via the + * `psa_drv_accel_mac_generate_t` or `psa_drv_accel_mac_verify_t` * functions), or in parts using the following sequence: - * - `psa_drv_mac_transparent_setup_t` - * - `psa_drv_mac_transparent_update_t` - * - `psa_drv_mac_transparent_update_t` + * - `psa_drv_accel_mac_setup_t` + * - `psa_drv_accel_mac_update_t` + * - `psa_drv_accel_mac_update_t` * - ... - * - `psa_drv_mac_transparent_finish_t` or `psa_drv_mac_transparent_finish_verify_t` + * - `psa_drv_accel_mac_finish_t` or `psa_drv_accel_mac_finish_verify_t` * - * If a previously started Transparent MAC operation needs to be terminated, it - * should be done so by the `psa_drv_mac_transparent_abort_t`. Failure to do so may + * If a previously started MAC operation needs to be terminated, it + * should be done so by the `psa_drv_accel_mac_abort_t`. Failure to do so may * result in allocated resources not being freed or in other undefined * behavior. * */ /**@{*/ -/** \brief The hardware-specific transparent-key MAC context structure +/** \brief The hardware-accelerator-specific MAC context structure * * The contents of this structure are implementation dependent and are * therefore not described here. @@ -171,12 +172,12 @@ typedef void (*psa_drv_hash_abort_t)(psa_drv_hash_context_t *p_context); typedef struct psa_drv_accel_mac_context_s psa_drv_accel_mac_context_t; /** \brief The function prototype for the setup operation of a - * transparent-key MAC operation + * hardware-accelerated MAC operation * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} - * psa_drv_mac_transparent___setup + * psa_drv_accel_mac___setup * ~~~~~~~~~~~~~ * Where `ALGO` is the name of the underlying primitive, and `MAC_VARIANT` * is the specific variant of a MAC operation (such as HMAC or CMAC) @@ -195,12 +196,12 @@ typedef psa_status_t (*psa_drv_accel_mac_setup_t)(psa_drv_accel_mac_context_t *p size_t key_length); /** \brief The function prototype for the update operation of a - * transparent-key MAC operation + * hardware-accelerated MAC operation * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} - * psa_drv_mac_transparent___update + * psa_drv_accel_mac___update * ~~~~~~~~~~~~~ * Where `ALGO` is the name of the underlying algorithm, and `MAC_VARIANT` * is the specific variant of a MAC operation (such as HMAC or CMAC) @@ -217,12 +218,12 @@ typedef psa_status_t (*psa_drv_accel_mac_update_t)(psa_drv_accel_mac_context_t * size_t input_length); /** \brief The function prototype for the finish operation of a - * transparent-key MAC operation + * hardware-accelerated MAC operation * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} - * psa_drv_mac_transparent___finish + * psa_drv_accel_mac___finish * ~~~~~~~~~~~~~ * Where `ALGO` is the name of the underlying algorithm, and `MAC_VARIANT` is * the specific variant of a MAC operation (such as HMAC or CMAC) @@ -242,12 +243,12 @@ typedef psa_status_t (*psa_drv_accel_mac_finish_t)(psa_drv_accel_mac_context_t * size_t mac_length); /** \brief The function prototype for the finish and verify operation of a - * transparent-key MAC operation + * hardware-accelerated MAC operation * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} - * psa_drv_mac_transparent___finish_verify + * psa_drv_accel_mac___finish_verify * ~~~~~~~~~~~~~ * Where `ALGO` is the name of the underlying algorithm, and `MAC_VARIANT` is * the specific variant of a MAC operation (such as HMAC or CMAC) @@ -268,12 +269,12 @@ typedef psa_status_t (*psa_drv_accel_mac_finish_verify_t)(psa_drv_accel_mac_cont size_t mac_length); /** \brief The function prototype for the abort operation for a previously - * started transparent-key MAC operation + * started hardware-accelerated MAC operation * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} - * psa_drv_mac_transparent___abort + * psa_drv_accel_mac___abort * ~~~~~~~~~~~~~ * Where `ALGO` is the name of the underlying algorithm, and `MAC_VARIANT` is * the specific variant of a MAC operation (such as HMAC or CMAC) @@ -285,13 +286,13 @@ typedef psa_status_t (*psa_drv_accel_mac_finish_verify_t)(psa_drv_accel_mac_cont */ typedef psa_status_t (*psa_drv_accel_mac_abort_t)(psa_drv_accel_mac_context_t *p_context); -/** \brief The function prototype for a one-shot operation of a transparent-key - * MAC operation +/** \brief The function prototype for the one-shot operation of a + * hardware-accelerated MAC operation * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} - * psa_drv_mac_transparent__ + * psa_drv_accel_mac__ * ~~~~~~~~~~~~~ * Where `ALGO` is the name of the underlying algorithm, and `MAC_VARIANT` is * the specific variant of a MAC operation (such as HMAC or CMAC) @@ -314,13 +315,13 @@ typedef psa_status_t (*psa_drv_accel_mac_t)(const uint8_t *p_input, uint8_t *p_mac, size_t mac_length); -/** \brief The function prototype for a one-shot operation of a transparent-key - * MAC Verify operation +/** \brief The function prototype for the one-shot hardware-accelerated MAC + * Verify operation * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} - * psa_drv_mac_transparent___verify + * psa_drv_accel_mac___verify * ~~~~~~~~~~~~~ * Where `ALGO` is the name of the underlying algorithm, and `MAC_VARIANT` is * the specific variant of a MAC operation (such as HMAC or CMAC) @@ -346,42 +347,44 @@ typedef psa_status_t (*psa_drv_accel_mac_verify_t)(const uint8_t *p_input, size_t mac_length); /**@}*/ -/** \defgroup transparent_cipher Transparent Block Cipher - * Encryption and Decryption using transparent keys in block modes other than - * ECB must be done in multiple parts, using the following flow: - * - `psa_drv_cipher_transparent_setup_t` - * - `psa_drv_cipher_transparent_set_iv_t` (optional depending upon block mode) - * - `psa_drv_cipher_transparent_update_t` +/** \defgroup accel_cipher Hardware-Accelerated Block Ciphers + * Encryption and Decryption using hardware-acceleration in block modes other + * than ECB must be done in multiple parts, using the following flow: + * - `psa_drv_accel_ciphersetup_t` + * - `psa_drv_accel_cipher_set_iv_t` (optional depending upon block mode) + * - `psa_drv_accel_cipher_update_t` + * - `psa_drv_accel_cipher_update_t` * - ... - * - `psa_drv_cipher_transparent_finish_t` + * - `psa_drv_accel_cipher_finish_t` - * If a previously started Transparent Cipher operation needs to be terminated, - * it should be done so by the `psa_drv_cipher_transparent_abort_t`. Failure to do - * so may result in allocated resources not being freed or in other undefined - * behavior. + * If a previously started hardware-accelerated Cipher operation needs to be + * terminated, it should be done so by the `psa_drv_accel_cipher_abort_t`. + * Failure to do so may result in allocated resources not being freed or in + * other undefined behavior. */ /**@{*/ -/** \brief The hardware-specific transparent-key Cipher context structure +/** \brief The hardware-accelerator-specific cipher context structure * * The contents of this structure are implementation dependent and are * therefore not described here. */ typedef struct psa_drv_accel_cipher_context_s psa_drv_accel_cipher_context_t; -/** \brief The function prototype for the setup operation of transparent-key - * block cipher operations. - * Functions that implement the prototype should be named in the following +/** \brief The function prototype for the setup operation of + * hardware-accelerated block cipher operations. + * Functions that implement this prototype should be named in the following * conventions: * ~~~~~~~~~~~~~{.c} - * psa_drv_cipher_transparent_setup__ + * psa_drv_accel_cipher_setup__ * ~~~~~~~~~~~~~ * Where * - `CIPHER_NAME` is the name of the underlying block cipher (i.e. AES or DES) * - `MODE` is the block mode of the cipher operation (i.e. CBC or CTR) - * or for stream ciphers: + * + * For stream ciphers: * ~~~~~~~~~~~~~{.c} - * psa_drv_cipher_transparent_setup_ + * psa_drv_accel_cipher_setup_ * ~~~~~~~~~~~~~ * Where `CIPHER_NAME` is the name of a stream cipher (i.e. RC4) * @@ -401,11 +404,11 @@ typedef psa_status_t (*psa_drv_accel_cipher_setup_t)(psa_drv_accel_cipher_contex size_t key_data_size); /** \brief The function prototype for the set initialization vector operation - * of transparent-key block cipher operations - * Functions that implement the prototype should be named in the following + * of hardware-accelerated block cipher operations + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} - * psa_drv_cipher_transparent_set_iv__ + * psa_drv_accel_cipher_set_iv__ * ~~~~~~~~~~~~~ * Where * - `CIPHER_NAME` is the name of the underlying block cipher (i.e. AES or DES) @@ -422,13 +425,13 @@ typedef psa_status_t (*psa_drv_accel_cipher_set_iv_t)(psa_drv_accel_cipher_conte const uint8_t *p_iv, size_t iv_length); -/** \brief The function prototype for the update operation of transparent-key - * block cipher operations. +/** \brief The function prototype for the update operation of + * hardware-accelerated block cipher operations. * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} - * psa_drv_cipher_transparent_update__ + * psa_drv_accel_cipher_update__ * ~~~~~~~~~~~~~ * Where * - `CIPHER_NAME` is the name of the underlying block cipher (i.e. AES or DES) @@ -454,13 +457,13 @@ typedef psa_status_t (*psa_drv_accel_cipher_update_t)(psa_drv_accel_cipher_conte size_t output_size, size_t *p_output_length); -/** \brief The function prototype for the finish operation of transparent-key - * block cipher operations. +/** \brief The function prototype for the finish operation of + * hardware-accelerated block cipher operations. * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} - * psa_drv_cipher_transparent_finish__ + * psa_drv_accel_cipher_finish__ * ~~~~~~~~~~~~~ * Where * - `CIPHER_NAME` is the name of the underlying block cipher (i.e. AES or DES) @@ -481,13 +484,13 @@ typedef psa_status_t (*psa_drv_accel_cipher_finish_t)(psa_drv_accel_cipher_conte size_t output_size, size_t *p_output_length); -/** \brief The function prototype for the abort operation of transparent-key - * block cipher operations. +/** \brief The function prototype for the abort operation of + * hardware-accelerated block cipher operations. * * Functions that implement the following prototype should be named in the * following convention: * ~~~~~~~~~~~~~{.c} - * psa_drv_cipher_transparent_abort__ + * psa_drv_accel_cipher_abort__ * ~~~~~~~~~~~~~ * Where * - `CIPHER_NAME` is the name of the underlying block cipher (i.e. AES or DES) @@ -502,23 +505,23 @@ typedef psa_status_t (*psa_drv_accel_cipher_abort_t)(psa_drv_accel_cipher_contex /**@}*/ -/** \defgroup aead_transparent AEAD Transparent +/** \defgroup accel_aead Hardware-Accelerated Authenticated Encryption with Additional Data * - * Authenticated Encryption with Additional Data (AEAD) operations with - * transparent keys must be done in one function call. While this creates a - * burden for implementers as there must be sufficient space in memory for the - * entire message, it prevents decrypted data from being made available before - * the authentication operation is complete and the data is known to be - * authentic. + * Hardware-accelerated Authenticated Encryption with Additional Data (AEAD) + * operations must be done in one function call. While this creates a burden + * for implementers as there must be sufficient space in memory for the entire + * message, it prevents decrypted data from being made available before the + * authentication operation is complete and the data is known to be authentic. */ /**@{*/ -/** Process an authenticated encryption operation using an opaque key. +/** \brief The function prototype for the hardware-accelerated authenticated + * encryption operation. * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} - * psa_drv_aead__encrypt + * psa_drv_accel_aead__encrypt * ~~~~~~~~~~~~~ * Where `ALGO` is the name of the AEAD algorithm * @@ -566,12 +569,13 @@ typedef psa_status_t (*psa_drv_accel_aead_encrypt_t)(const uint8_t *p_key, size_t ciphertext_size, size_t *ciphertext_length); -/** Process an authenticated decryption operation using an opaque key. +/** \brief The function prototype for the hardware-accelerated authenticated + * decryption operation. * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} - * psa_drv_aead__decrypt + * psa_drv_accel_aead__decrypt * ~~~~~~~~~~~~~ * Where `ALGO` is the name of the AEAD algorithm * \param[in] p_key A pointer to the key material @@ -619,26 +623,30 @@ typedef psa_status_t (*psa_drv_accel_aead_decrypt_t)(const uint8_t *p_key, /**@}*/ -/** \defgroup transparent_asymmetric Transparent Asymmetric Cryptography +/** \defgroup accel_asymmetric Hardware-Accelerated Asymmetric Cryptography * * Since the amount of data that can (or should) be encrypted or signed using - * asymmetric keys is limited by the key size, asymmetric key operations using - * transparent keys must be done in single function calls. + * asymmetric keys is limited by the key size, hardware-accelerated asymmetric + * key operations must be done in single function calls. */ /**@{*/ /** - * \brief A function that signs a hash or short message with a transparent - * asymmetric private key + * \brief The function prototype for the hardware-accelerated asymmetric sign + * operation. * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} - * psa_drv_asymmetric__sign + * psa_drv_accel_asymmetric__sign * ~~~~~~~~~~~~~ * Where `ALGO` is the name of the signing algorithm * + * This function supports any asymmetric-key output from psa_export_key() as + * the buffer in \ref p_key. Refer to the documentation of \ref + * psa_export_key() for the formats. + * * \param[in] p_key A buffer containing the private key * material * \param[in] key_size The size in bytes of the `p_key` data @@ -664,16 +672,21 @@ typedef psa_status_t (*psa_drv_accel_asymmetric_sign_t)(const uint8_t *p_key, size_t *p_signature_length); /** - * \brief A function that verifies the signature a hash or short message using - * a transparent asymmetric public key + * \brief The function prototype for the hardware-accelerated signature verify + * operation * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} - * psa_drv_asymmetric__verify + * psa_drv_accel_asymmetric__verify * ~~~~~~~~~~~~~ * Where `ALGO` is the name of the signing algorithm * + * This function supports any output from \ref psa_export_public_key() as the + * buffer in \ref p_key. Refer to the documentation of \ref + * psa_export_public_key() for the format of public keys and to the + * documentation of \ref psa_export_key() for the format for other key types. + * * \param[in] p_key A buffer containing the public key material * \param[in] key_size The size in bytes of the `p_key` data * \param[in] alg A signature algorithm that is compatible with @@ -697,15 +710,20 @@ typedef psa_status_t (*psa_drv_accel_asymmetric_verify_t)(const uint8_t *p_key, size_t signature_length); /** - * \brief A function that encrypts a short message with a transparent - * asymmetric public key + * \brief The function prototype for the hardware-accelerated asymmetric + * encrypt operation * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} - * psa_drv_asymmetric__encrypt + * psa_drv_accel_asymmetric__encrypt * ~~~~~~~~~~~~~ * Where `ALGO` is the name of the encryption algorithm + * + * This function supports any output from \ref psa_export_public_key() as the + * buffer in \ref p_key. Refer to the documentation of \ref + * psa_export_public_key() for the format of public keys and to the + * documentation of \ref psa_export_key() for the format for other key types. * * \param[in] p_key A buffer containing the public key material * \param[in] key_size The size in bytes of the `p_key` data @@ -745,14 +763,19 @@ typedef psa_status_t (*psa_drv_accel_asymmetric_encrypt_t)(const uint8_t *p_key, size_t *p_output_length); /** - * \brief Decrypt a short message with a transparent asymmetric private key + * \brief The function prototype for the hardware=acce;erated asymmetric + * decrypt operation * - * Functions that implement the prototype should be named in the following + * Functions that implement this prototype should be named in the following * convention: * ~~~~~~~~~~~~~{.c} - * psa_drv_asymmetric__decrypt + * psa_drv_accel_asymmetric__decrypt * ~~~~~~~~~~~~~ * Where `ALGO` is the name of the encryption algorithm + * + * This function supports any asymmetric-key output from psa_export_key() as + * the buffer in \ref p_key. Refer to the documentation of \ref + * psa_export_key() for the formats. * * \param[in] p_key A buffer containing the private key material * \param[in] key_size The size in bytes of the `p_key` data diff --git a/include/psa/crypto_entropy_driver.h b/include/psa/crypto_entropy_driver.h index 1d94432ef..f596b6bd4 100644 --- a/include/psa/crypto_entropy_driver.h +++ b/include/psa/crypto_entropy_driver.h @@ -95,10 +95,9 @@ typedef struct { /** The driver-specific size of the entropy context */ const size_t context_size; /** Function that performs initialization for the entropy source */ - psa_drv_entropy_init_t p_init; - /** Function that performs the get_bits operation for the entropy source - */ - psa_drv_entropy_get_bits_t p_get_bits; + psa_drv_entropy_init_t p_init; + /** Function that performs the get_bits operation for the entropy source */ + psa_drv_entropy_get_bits_t p_get_bits; } psa_drv_entropy_t; /**@}*/ diff --git a/include/psa/crypto_se_driver.h b/include/psa/crypto_se_driver.h index 438067f26..18ef1c47b 100644 --- a/include/psa/crypto_se_driver.h +++ b/include/psa/crypto_se_driver.h @@ -3,10 +3,10 @@ * \brief PSA external cryptoprocessor driver module * * This header declares types and function signatures for cryptography - * drivers that access key material via opaque references. This is - * meant for cryptoprocessors that have a separate key storage from the + * drivers that access key material via opaque references. + * This is meant for cryptoprocessors that have a separate key storage from the * space in which the PSA Crypto implementation runs, typically secure - * elements. + * elements (SEs). * * This file is part of the PSA Crypto Driver Model, containing functions for * driver developers to implement to enable hardware to be called in a @@ -45,25 +45,25 @@ extern "C" { * is driver-dependent. */ typedef uint32_t psa_key_slot_number_t; // TODO: Change this to psa_key_slot_t after psa_key_slot_t is removed from Mbed crypto -/** \defgroup opaque_mac Opaque Message Authentication Code +/** \defgroup se_mac Secure Element Message Authentication Codes * Generation and authentication of Message Authentication Codes (MACs) using - * opaque keys can be done either as a single function call (via the - * `psa_drv_mac_opaque_generate_t` or `psa_drv_mac_opaque_verify_t` functions), or in + * a secure element can be done either as a single function call (via the + * `psa_drv_se_mac_generate_t` or `psa_drv_se_mac_verify_t` functions), or in * parts using the following sequence: - * - `psa_drv_mac_opaque_setup_t` - * - `psa_drv_mac_opaque_update_t` - * - `psa_drv_mac_opaque_update_t` + * - `psa_drv_se_mac_setup_t` + * - `psa_drv_se_mac_update_t` + * - `psa_drv_se_mac_update_t` * - ... - * - `psa_drv_mac_opaque_finish_t` or `psa_drv_mac_opaque_finish_verify_t` + * - `psa_drv_se_mac_finish_t` or `psa_drv_se_mac_finish_verify_t` * - * If a previously started Opaque MAC operation needs to be terminated, it - * should be done so by the `psa_drv_mac_opaque_abort_t`. Failure to do so may + * If a previously started secure element MAC operation needs to be terminated, + * it should be done so by the `psa_drv_se_mac_abort_t`. Failure to do so may * result in allocated resources not being freed or in other undefined * behavior. */ /**@{*/ -/** \brief A function that starts a MAC operation for a PSA Crypto Driver - * implementation using an opaque key +/** \brief A function that starts a secure element MAC operation for a PSA + * Crypto Driver implementation * * \param[in,out] p_context A structure that will contain the * hardware-specific MAC context @@ -79,12 +79,12 @@ typedef psa_status_t (*psa_drv_se_mac_setup_t)(void *p_context, psa_key_slot_number_t key_slot, psa_algorithm_t algorithm); -/** \brief A function that continues a previously started MAC operation using - * an opaque key +/** \brief A function that continues a previously started secure element MAC + * operation * * \param[in,out] p_context A hardware-specific structure for the * previously-established MAC operation to be - * continued + * updated * \param[in] p_input A buffer containing the message to be appended * to the MAC operation * \param[in] input_length The size in bytes of the input message buffer @@ -93,8 +93,8 @@ typedef psa_status_t (*psa_drv_se_mac_update_t)(void *p_context, const uint8_t *p_input, size_t input_length); -/** \brief a function that completes a previously started MAC operation by - * returning the resulting MAC using an opaque key +/** \brief a function that completes a previously started secure element MAC + * operation by returning the resulting MAC. * * \param[in,out] p_context A hardware-specific structure for the * previously started MAC operation to be @@ -114,8 +114,8 @@ typedef psa_status_t (*psa_drv_se_mac_finish_t)(void *p_context, size_t mac_size, size_t *p_mac_length); -/** \brief A function that completes a previously started MAC operation by - * comparing the resulting MAC against a known value using an opaque key +/** \brief A function that completes a previously started secure element MAC + * operation by comparing the resulting MAC against a provided value * * \param[in,out] p_context A hardware-specific structure for the previously * started MAC operation to be fiinished @@ -134,15 +134,16 @@ typedef psa_status_t (*psa_drv_se_mac_finish_verify_t)(void *p_context, const uint8_t *p_mac, size_t mac_length); -/** \brief A function that aborts a previous started opaque-key MAC operation +/** \brief A function that aborts a previous started secure element MAC + * operation * \param[in,out] p_context A hardware-specific structure for the previously * started MAC operation to be aborted */ typedef psa_status_t (*psa_drv_se_mac_abort_t)(void *p_context); -/** \brief A function that performs a MAC operation in one command and returns - * the calculated MAC using an opaque key +/** \brief A function that performs a secure element MAC operation in one + * command and returns the calculated MAC * * \param[in] p_input A buffer containing the message to be MACed * \param[in] input_length The size in bytes of `p_input` @@ -166,8 +167,8 @@ typedef psa_status_t (*psa_drv_se_mac_generate_t)(const uint8_t *p_input, size_t mac_size, size_t *p_mac_length); -/** \brief A function that performs an MAC operation in one command and - * compare the resulting MAC against a known value using an opaque key +/** \brief A function that performs a secure element MAC operation in one + * command and compares the resulting MAC against a provided value * * \param[in] p_input A buffer containing the message to be MACed * \param[in] input_length The size in bytes of `input` @@ -193,13 +194,13 @@ typedef psa_status_t (*psa_drv_se_mac_verify_t)(const uint8_t *p_input, size_t mac_length); /** \brief A struct containing all of the function pointers needed to - * implement MAC operations using opaque keys. + * perform secure element MAC operations * * PSA Crypto API implementations should populate the table as appropriate * upon startup. * * If one of the functions is not implemented (such as - * `psa_drv_mac_opaque_generate_t`), it should be set to NULL. + * `psa_drv_se_mac_generate_t`), it should be set to NULL. * * Driver implementers should ensure that they implement all of the functions * that make sense for their hardware, and that they provide a full solution @@ -208,57 +209,59 @@ typedef psa_status_t (*psa_drv_se_mac_verify_t)(const uint8_t *p_input, * */ typedef struct { - /**The size in bytes of the hardware-specific Opaque-MAC Context structure + /**The size in bytes of the hardware-specific secure element MAC context + * structure */ - size_t context_size; - /** Function that performs the setup operation + size_t context_size; + /** Function that performs a MAC setup operation */ psa_drv_se_mac_setup_t p_setup; - /** Function that performs the update operation + /** Function that performs a MAC update operation */ psa_drv_se_mac_update_t p_update; - /** Function that completes the operation + /** Function that completes a MAC operation */ psa_drv_se_mac_finish_t p_finish; - /** Function that completed a MAC operation with a verify check + /** Function that completes a MAC operation with a verify check */ psa_drv_se_mac_finish_verify_t p_finish_verify; - /** Function that aborts a previoustly started operation + /** Function that aborts a previoustly started MAC operation */ psa_drv_se_mac_abort_t p_abort; - /** Function that performs the MAC operation in one call + /** Function that performs a MAC operation in one call */ psa_drv_se_mac_generate_t p_mac; - /** Function that performs the MAC and verify operation in one call + /** Function that performs a MAC and verify operation in one call */ psa_drv_se_mac_verify_t p_mac_verify; } psa_drv_se_mac_t; /**@}*/ -/** \defgroup opaque_cipher Opaque Symmetric Ciphers +/** \defgroup se_cipher Secure Element Symmetric Ciphers * - * Encryption and Decryption using opaque keys in block modes other than ECB - * must be done in multiple parts, using the following flow: - * - `psa_drv_cipher_opaque_setup_t` - * - `psa_drv_cipher_opaque_set_iv_t` (optional depending upon block mode) - * - `psa_drv_cipher_opaque_update_t` + * Encryption and Decryption using secure element keys in block modes other + * than ECB must be done in multiple parts, using the following flow: + * - `psa_drv_se_cipher_setup_t` + * - `psa_drv_se_cipher_set_iv_t` (optional depending upon block mode) + * - `psa_drv_se_cipher_update_t` + * - `psa_drv_se_cipher_update_t` * - ... - * - `psa_drv_cipher_opaque_finish_t` + * - `psa_drv_se_cipher_finish_t` - * If a previously started Opaque Cipher operation needs to be terminated, it - * should be done so by the `psa_drv_cipher_opaque_abort_t`. Failure to do so may - * result in allocated resources not being freed or in other undefined - * behavior. + * If a previously started secure element Cipher operation needs to be + * terminated, it should be done so by the `psa_drv_se_cipher_abort_t`. Failure + * to do so may result in allocated resources not being freed or in other + * undefined behavior. * * In situations where a PSA Cryptographic API implementation is using a block * mode not-supported by the underlying hardware or driver, it can construct - * the block mode itself, while calling the `psa_drv_cipher_opaque_ecb_t` function - * pointer for the cipher operations. + * the block mode itself, while calling the `psa_drv_se_cipher_ecb_t` function + * for the cipher operations. */ /**@{*/ -/** \brief A function pointer that provides the cipher setup function for - * opaque-key operations +/** \brief A function that provides the cipher setup function for a + * secure element driver * * \param[in,out] p_context A structure that will contain the * hardware-specific cipher context. @@ -277,11 +280,11 @@ typedef psa_status_t (*psa_drv_se_cipher_setup_t)(void *p_context, psa_algorithm_t algorithm, psa_encrypt_or_decrypt_t direction); -/** \brief A function pointer that sets the initialization vector (if - * necessary) for an opaque cipher operation +/** \brief A function that sets the initialization vector (if + * necessary) for an secure element cipher operation * - * Rationale: The `psa_cipher_*` function in the PSA Cryptographic API has two - * IV functions: one to set the IV, and one to generate it internally. The + * Rationale: The `psa_se_cipher_*` operation in the PSA Cryptographic API has + * two IV functions: one to set the IV, and one to generate it internally. The * generate function is not necessary for the drivers to implement as the PSA * Crypto implementation can do the generation using its RNG features. * @@ -296,7 +299,7 @@ typedef psa_status_t (*psa_drv_se_cipher_set_iv_t)(void *p_context, const uint8_t *p_iv, size_t iv_length); -/** \brief A function that continues a previously started opaque-key cipher +/** \brief A function that continues a previously started secure element cipher * operation * * \param[in,out] p_context A hardware-specific structure for the @@ -321,7 +324,7 @@ typedef psa_status_t (*psa_drv_se_cipher_update_t)(void *p_context, size_t output_size, size_t *p_output_length); -/** \brief A function that completes a previously started opaque-key cipher +/** \brief A function that completes a previously started secure element cipher * operation * * \param[in,out] p_context A hardware-specific structure for the @@ -340,7 +343,7 @@ typedef psa_status_t (*psa_drv_se_cipher_finish_t)(void *p_context, size_t output_size, size_t *p_output_length); -/** \brief A function that aborts a previously started opaque-key cipher +/** \brief A function that aborts a previously started secure element cipher * operation * * \param[in,out] p_context A hardware-specific structure for the @@ -348,8 +351,8 @@ typedef psa_status_t (*psa_drv_se_cipher_finish_t)(void *p_context, */ typedef psa_status_t (*psa_drv_se_cipher_abort_t)(void *p_context); -/** \brief A function that performs the ECB block mode for opaque-key cipher - * operations +/** \brief A function that performs the ECB block mode for secure element + * cipher operations * * Note: this function should only be used with implementations that do not * provide a needed higher-level operation. @@ -380,30 +383,30 @@ typedef psa_status_t (*psa_drv_se_cipher_ecb_t)(psa_key_slot_number_t key_slot, /** * \brief A struct containing all of the function pointers needed to implement - * cipher operations using opaque keys. + * cipher operations using secure elements. * * PSA Crypto API implementations should populate instances of the table as - * appropriate upon startup. + * appropriate upon startup or at build time. * * If one of the functions is not implemented (such as - * `psa_drv_cipher_opaque_ecb_t`), it should be set to NULL. + * `psa_drv_se_cipher_ecb_t`), it should be set to NULL. */ typedef struct { - /** The size in bytes of the hardware-specific Opaque Cipher context - * structure + /** The size in bytes of the hardware-specific secure element cipher + * context structure */ size_t context_size; /** Function that performs a cipher setup operation */ psa_drv_se_cipher_setup_t p_setup; - /** Function that sets the IV (if necessary) */ + /** Function that sets a cipher IV (if necessary) */ psa_drv_se_cipher_set_iv_t p_set_iv; - /** Function that performs the update operation */ + /** Function that performs a cipher update operation */ psa_drv_se_cipher_update_t p_update; - /** Function that completes the operation */ + /** Function that completes a cipher operation */ psa_drv_se_cipher_finish_t p_finish; - /** Function that aborts the operation */ + /** Function that aborts a cipher operation */ psa_drv_se_cipher_abort_t p_abort; - /** Function that performs ECB mode for the cipher + /** Function that performs ECB mode for a cipher operation * (Danger: ECB mode should not be used directly by clients of the PSA * Crypto Client API) */ @@ -412,16 +415,17 @@ typedef struct { /**@}*/ -/** \defgroup opaque_asymmetric Opaque Asymmetric Cryptography +/** \defgroup se_asymmetric Secure Element Asymmetric Cryptography * * Since the amount of data that can (or should) be encrypted or signed using * asymmetric keys is limited by the key size, asymmetric key operations using - * opaque keys must be done in single function calls. + * keys in a secure element must be done in single function calls. */ /**@{*/ /** - * \brief A function that signs a hash or short message with a private key + * \brief A function that signs a hash or short message with a private key in + * a secure element * * \param[in] key_slot Key slot of an asymmetric key pair * \param[in] alg A signature algorithm that is compatible @@ -445,7 +449,7 @@ typedef psa_status_t (*psa_drv_se_asymmetric_sign_t)(psa_key_slot_number_t key_s /** * \brief A function that verifies the signature a hash or short message using - * an asymmetric public key + * an asymmetric public key in a secure element * * \param[in] key_slot Key slot of a public key or an asymmetric key * pair @@ -468,7 +472,7 @@ typedef psa_status_t (*psa_drv_se_asymmetric_verify_t)(psa_key_slot_number_t key /** * \brief A function that encrypts a short message with an asymmetric public - * key + * key in a secure element * * \param[in] key_slot Key slot of a public key or an asymmetric key * pair @@ -506,7 +510,8 @@ typedef psa_status_t (*psa_drv_se_asymmetric_encrypt_t)(psa_key_slot_number_t ke size_t *p_output_length); /** - * \brief Decrypt a short message with an asymmetric private key. + * \brief A function that decrypts a short message with an asymmetric private + * key in a secure element. * * \param[in] key_slot Key slot of an asymmetric key pair * \param[in] alg An asymmetric encryption algorithm that is @@ -544,36 +549,37 @@ typedef psa_status_t (*psa_drv_se_asymmetric_decrypt_t)(psa_key_slot_number_t ke /** * \brief A struct containing all of the function pointers needed to implement - * asymmetric cryptographic operations using opaque keys. + * asymmetric cryptographic operations using secure elements. * * PSA Crypto API implementations should populate instances of the table as - * appropriate upon startup. + * appropriate upon startup or at build time. * * If one of the functions is not implemented, it should be set to NULL. */ typedef struct { - /** Function that performs the asymmetric sign operation */ + /** Function that performs an asymmetric sign operation */ psa_drv_se_asymmetric_sign_t p_sign; - /** Function that performs the asymmetric verify operation */ + /** Function that performs an asymmetric verify operation */ psa_drv_se_asymmetric_verify_t p_verify; - /** Function that performs the asymmetric encrypt operation */ + /** Function that performs an asymmetric encrypt operation */ psa_drv_se_asymmetric_encrypt_t p_encrypt; - /** Function that performs the asymmetric decrypt operation */ + /** Function that performs an asymmetric decrypt operation */ psa_drv_se_asymmetric_decrypt_t p_decrypt; } psa_drv_se_asymmetric_t; /**@}*/ -/** \defgroup aead_opaque AEAD Opaque - * Authenticated Encryption with Additional Data (AEAD) operations with opaque - * keys must be done in one function call. While this creates a burden for +/** \defgroup se_aead Secure Element Authenticated Encryption with Additional Data + * Authenticated Encryption with Additional Data (AEAD) operations with secure + * elements must be done in one function call. While this creates a burden for * implementers as there must be sufficient space in memory for the entire * message, it prevents decrypted data from being made available before the * authentication operation is complete and the data is known to be authentic. */ /**@{*/ -/** \brief Process an authenticated encryption operation using an opaque key +/** \brief A function that performs a secure element authenticated encryption + * operation * * \param[in] key_slot Slot containing the key to use. * \param[in] algorithm The AEAD algorithm to compute @@ -614,7 +620,7 @@ typedef psa_status_t (*psa_drv_se_aead_encrypt_t)(psa_key_slot_number_t key_slot size_t ciphertext_size, size_t *p_ciphertext_length); -/** Process an authenticated decryption operation using an opaque key +/** A function that peforms a secure element authenticated decryption operation * * \param[in] key_slot Slot containing the key to use * \param[in] algorithm The AEAD algorithm to compute @@ -656,7 +662,7 @@ typedef psa_status_t (*psa_drv_se_aead_decrypt_t)(psa_key_slot_number_t key_slot /** * \brief A struct containing all of the function pointers needed to implement - * Authenticated Encryption with Additional Data operations using opaque keys + * secure element Authenticated Encryption with Additional Data operations * * PSA Crypto API implementations should populate instances of the table as * appropriate upon startup. @@ -671,7 +677,7 @@ typedef struct { } psa_drv_se_aead_t; /**@}*/ -/** \defgroup driver_key_management Key Management +/** \defgroup se_key_management Secure Element Key Management * Currently, key management is limited to importing keys in the clear, * destroying keys, and exporting keys in the clear. * Whether a key may be exported is determined by the key policies in place @@ -679,7 +685,7 @@ typedef struct { */ /**@{*/ -/** \brief Import a key in binary format +/** \brief A function that imports a key into a secure element in binary format * * This function can support any output from psa_export_key(). Refer to the * documentation of psa_export_key() for the format for each key type. @@ -687,6 +693,7 @@ typedef struct { * \param[in] key_slot Slot where the key will be stored * This must be a valid slot for a key of the chosen * type. It must be unoccupied. + * \param[in] lifetime The required lifetime of the key storage * \param[in] type Key type (a \c PSA_KEY_TYPE_XXX value) * \param[in] algorithm Key algorithm (a \c PSA_ALG_XXX value) * \param[in] usage The allowed uses of the key @@ -705,15 +712,14 @@ typedef psa_status_t (*psa_drv_se_import_key_t)(psa_key_slot_number_t key_slot, size_t data_length); /** - * \brief Destroy a key and restore the slot to its default state + * \brief A function that destroys a secure element key and restore the slot to + * its default state * - * This function destroys the content of the key slot from both volatile - * memory and, if applicable, non-volatile storage. Implementations shall - * make a best effort to ensure that any previous content of the slot is - * unrecoverable. + * This function destroys the content of the key from a secure element. + * Implementations shall make a best effort to ensure that any previous content + * of the slot is unrecoverable. * - * This function also erases any metadata such as policies. It returns the - * specified slot to its default state. + * This function returns the specified slot to its default state. * * \param[in] key_slot The key slot to erase. * @@ -723,7 +729,7 @@ typedef psa_status_t (*psa_drv_se_import_key_t)(psa_key_slot_number_t key_slot, typedef psa_status_t (*psa_drv_se_destroy_key_t)(psa_key_slot_number_t key); /** - * \brief Export a key in binary format + * \brief A function that exports a secure element key in binary format * * The output of this function can be passed to psa_import_key() to * create an equivalent object. @@ -733,19 +739,9 @@ typedef psa_status_t (*psa_drv_se_destroy_key_t)(psa_key_slot_number_t key); * identical: the implementation may choose a different representation * of the same key if the format permits it. * - * For standard key types, the output format is as follows: - * - * - For symmetric keys (including MAC keys), the format is the - * raw bytes of the key. - * - For DES, the key data consists of 8 bytes. The parity bits must be - * correct. - * - For Triple-DES, the format is the concatenation of the - * two or three DES keys. - * - For RSA key pairs (#PSA_KEY_TYPE_RSA_KEYPAIR), the format - * is the non-encrypted DER representation defined by PKCS\#1 (RFC 8017) - * as RSAPrivateKey. - * - For RSA public keys (#PSA_KEY_TYPE_RSA_PUBLIC_KEY), the format - * is the DER representation defined by RFC 5280 as SubjectPublicKeyInfo. + * This function should generate output in the same format that + * `psa_export_key()` does. Refer to the + * documentation of `psa_export_key()` for the format for each key type. * * \param[in] key Slot whose content is to be exported. This must * be an occupied key slot. @@ -768,25 +764,32 @@ typedef psa_status_t (*psa_drv_se_export_key_t)(psa_key_slot_number_t key, size_t *p_data_length); /** - * \brief Export a public key or the public part of a key pair in binary format - * - * The output of this function can be passed to psa_import_key() to - * create an object that is equivalent to the public key. - * - * For standard key types, the output format is as follows: - * - * - For RSA keys (#PSA_KEY_TYPE_RSA_KEYPAIR or #PSA_KEY_TYPE_RSA_PUBLIC_KEY), - * the format is the DER representation of the public key defined by RFC 5280 - * as SubjectPublicKeyInfo. - * - * \param[in] key_slot Slot whose content is to be exported. This must - * be an occupied key slot. - * \param[out] p_data Buffer where the key data is to be written. - * \param[in] data_size Size of the `data` buffer in bytes. - * \param[out] p_data_length On success, the number of bytes - * that make up the key data. - * - * \retval #PSA_SUCCESS + * \brief A function that generates a symmetric or asymmetric key on a secure + * element + * + * If `type` is asymmetric (`#define PSA_KEY_TYPE_IS_ASYMMETRIC(type) == 1`), + * the public component of the generated key will be placed in `p_pubkey_out`. + * The format of the public key information will match the format specified for + * the `psa_export_key()` function for the key type. + * + * \param[in] key_slot Slot where the generated key will be placed + * \param[in] type The type of the key to be generated + * \param[in] usage The prescribed usage of the generated key + * Note: Not all Secure Elements support the same + * restrictions that PSA Crypto does (and vice versa). + * Driver developers should endeavor to match the + * usages as close as possible. + * \param[in] bits The size in bits of the key to be generated. + * \param[in] extra Extra parameters for key generation. The + * interpretation of this parameter should match the + * interpretation in the `extra` parameter is the + * `psa_generate_key` function + * \param[in] extra_size The size in bytes of the \ref extra buffer + * \param[out] p_pubkey_out The buffer where the public key information will + * be placed + * \param[in] pubkey_out_size The size in bytes of the `p_pubkey_out` buffer + * \param[out] p_pubkey_length Upon successful completion, will contain the + * size of the data placed in `p_pubkey_out`. */ typedef psa_status_t (*psa_drv_se_generate_key_t) (psa_key_slot_number_t key_slot, psa_key_type_t type, @@ -799,28 +802,28 @@ typedef psa_status_t (*psa_drv_se_generate_key_t) (psa_key_slot_number_t key_slo size_t *p_pubkey_length); /** - * \brief A struct containing all of the function pointers needed to for key - * management using opaque keys + * \brief A struct containing all of the function pointers needed to for secure + * element key management * * PSA Crypto API implementations should populate instances of the table as - * appropriate upon startup. + * appropriate upon startup or at build time. * * If one of the functions is not implemented, it should be set to NULL. */ typedef struct { - /** Function that performs the key import operation */ - psa_drv_se_import_key_t p_import; - /** Function that performs the key destroy operation */ + /** Function that performs a key import operation */ + psa_drv_se_import_key_t p_import; + /** Function that performs a generation */ psa_drv_se_generate_key_t p_generate; - /** Function that performs the key export operation */ + /** Function that performs a key destroy operation */ psa_drv_se_destroy_key_t p_destroy; - /** Function that perforsm the public key export operation */ + /** Function that performs a key export operation */ psa_drv_se_export_key_t p_export; } psa_drv_se_key_management_t; /**@}*/ -/** \defgroup driver_derivation Key Derivation and Agreement +/** \defgroup driver_derivation Secure Element Key Derivation and Agreement * Key derivation is the process of generating new key material using an * existing key and additional parameters, iterating through a basic * cryptographic function, such as a hash. @@ -831,52 +834,46 @@ typedef struct { * for both of the flows. * * There are two different final functions for the flows, - * `psa_drv_key_derivation_derive` and `psa_drv_key_derivation_export`. - * `psa_drv_key_derivation_derive` is used when the key material should be placed - * in a slot on the hardware and not exposed to the caller. - * `psa_drv_key_derivation_export` is used when the key material should be returned - * to the PSA Cryptographic API implementation. + * `psa_drv_se_key_derivation_derive` and `psa_drv_se_key_derivation_export`. + * `psa_drv_se_key_derivation_derive` is used when the key material should be + * placed in a slot on the hardware and not exposed to the caller. + * `psa_drv_se_key_derivation_export` is used when the key material should be + * returned to the PSA Cryptographic API implementation. * * Different key derivation algorithms require a different number of inputs. * Instead of having an API that takes as input variable length arrays, which * can be problemmatic to manage on embedded platforms, the inputs are passed - * to the driver via a function, `psa_drv_key_derivation_collateral`, that is - * called multiple times with different `collateral_id`s. Thus, for a key + * to the driver via a function, `psa_drv_se_key_derivation_collateral`, that + * is called multiple times with different `collateral_id`s. Thus, for a key * derivation algorithm that required 3 paramter inputs, the flow would look * something like: * ~~~~~~~~~~~~~{.c} - * psa_drv_key_derivation_setup(kdf_algorithm, source_key, dest_key_size_bytes); - * psa_drv_key_derivation_collateral(kdf_algorithm_collateral_id_0, - * p_collateral_0, - * collateral_0_size); - * psa_drv_key_derivation_collateral(kdf_algorithm_collateral_id_1, - * p_collateral_1, - * collateral_1_size); - * psa_drv_key_derivation_collateral(kdf_algorithm_collateral_id_2, - * p_collateral_2, - * collateral_2_size); - * psa_drv_key_derivation_derive(); + * psa_drv_se_key_derivation_setup(kdf_algorithm, source_key, dest_key_size_bytes); + * psa_drv_se_key_derivation_collateral(kdf_algorithm_collateral_id_0, + * p_collateral_0, + * collateral_0_size); + * psa_drv_se_key_derivation_collateral(kdf_algorithm_collateral_id_1, + * p_collateral_1, + * collateral_1_size); + * psa_drv_se_key_derivation_collateral(kdf_algorithm_collateral_id_2, + * p_collateral_2, + * collateral_2_size); + * psa_drv_se_key_derivation_derive(); * ~~~~~~~~~~~~~ * * key agreement example: * ~~~~~~~~~~~~~{.c} - * psa_drv_key_derivation_setup(alg, source_key. dest_key_size_bytes); - * psa_drv_key_derivation_collateral(DHE_PUBKEY, p_pubkey, pubkey_size); - * psa_drv_key_derivation_export(p_session_key, - * session_key_size, - * &session_key_length); + * psa_drv_se_key_derivation_setup(alg, source_key. dest_key_size_bytes); + * psa_drv_se_key_derivation_collateral(DHE_PUBKEY, p_pubkey, pubkey_size); + * psa_drv_se_key_derivation_export(p_session_key, + * session_key_size, + * &session_key_length); * ~~~~~~~~~~~~~ */ /**@{*/ -/** \brief The hardware-specific key derivation context structure - * - * The contents of this structure are implementation dependent and are - * therefore not described here - */ - -/** \brief Set up a key derivation operation by specifying the algorithm and - * the source key sot +/** \brief A function that Sets up a secure element key derivation operation by + * specifying the algorithm and the source key sot * * \param[in,out] p_context A hardware-specific structure containing any * context information for the implementation @@ -890,8 +887,8 @@ typedef psa_status_t (*psa_drv_se_key_derivation_setup_t)(void *p_context, psa_algorithm_t kdf_alg, psa_key_slot_number_t source_key); -/** \brief Provide collateral (parameters) needed for a key derivation or key - * agreement operation +/** \brief A function that provides collateral (parameters) needed for a secure + * element key derivation or key agreement operation * * Since many key derivation algorithms require multiple parameters, it is * expeced that this function may be called multiple times for the same @@ -910,8 +907,9 @@ typedef psa_status_t (*psa_drv_se_key_derivation_collateral_t)(void *p_context, const uint8_t *p_collateral, size_t collateral_size); -/** \brief Perform the final key derivation step and place the generated key - * material in a slot +/** \brief A function that performs the final secure element key derivation + * step and place the generated key material in a slot + * * \param[in,out] p_context A hardware-specific structure containing any * context information for the implementation * \param[in] dest_key The slot where the generated key material @@ -922,8 +920,8 @@ typedef psa_status_t (*psa_drv_se_key_derivation_collateral_t)(void *p_context, typedef psa_status_t (*psa_drv_se_key_derivation_derive_t)(void *p_context, psa_key_slot_number_t dest_key); -/** \brief Perform the final step of a key agreement and place the generated - * key material in a buffer +/** \brief A function that performs the final step of a secure element key + * agreement and place the generated key material in a buffer * * \param[out] p_output Buffer in which to place the generated key * material @@ -939,8 +937,8 @@ typedef psa_status_t (*psa_drv_se_key_derivation_export_t)(void *p_context, size_t *p_output_length); /** - * \brief A struct containing all of the function pointers needed to for key - * derivation and agreement + * \brief A struct containing all of the function pointers needed to for secure + * element key derivation and agreement * * PSA Crypto API implementations should populate instances of the table as * appropriate upon startup. @@ -950,13 +948,13 @@ typedef psa_status_t (*psa_drv_se_key_derivation_export_t)(void *p_context, typedef struct { /** The driver-specific size of the key derivation context */ size_t context_size; - /** Function that performs the key derivation setup */ + /** Function that performs a key derivation setup */ psa_drv_se_key_derivation_setup_t p_setup; - /** Function that sets the key derivation collateral */ + /** Function that sets key derivation collateral */ psa_drv_se_key_derivation_collateral_t p_collateral; - /** Function that performs the final key derivation step */ + /** Function that performs a final key derivation step */ psa_drv_se_key_derivation_derive_t p_derive; - /** Function that perforsm the final key derivation or agreement and + /** Function that perforsm a final key derivation or agreement and * exports the key */ psa_drv_se_key_derivation_export_t p_export; } psa_drv_se_key_derivation_t; From c3044a6a367df834342e4ce48485bcbe6e46fbb8 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 6 Mar 2019 17:56:28 +0100 Subject: [PATCH 12/15] Remove trailing whitespace check-files.py doesn't like trailing whitespace. --- include/psa/crypto_accel_driver.h | 14 +++++++------- include/psa/crypto_se_driver.h | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/psa/crypto_accel_driver.h b/include/psa/crypto_accel_driver.h index 57bc18dad..125d4c246 100644 --- a/include/psa/crypto_accel_driver.h +++ b/include/psa/crypto_accel_driver.h @@ -381,7 +381,7 @@ typedef struct psa_drv_accel_cipher_context_s psa_drv_accel_cipher_context_t; * Where * - `CIPHER_NAME` is the name of the underlying block cipher (i.e. AES or DES) * - `MODE` is the block mode of the cipher operation (i.e. CBC or CTR) - * + * * For stream ciphers: * ~~~~~~~~~~~~~{.c} * psa_drv_accel_cipher_setup_ @@ -643,10 +643,10 @@ typedef psa_status_t (*psa_drv_accel_aead_decrypt_t)(const uint8_t *p_key, * ~~~~~~~~~~~~~ * Where `ALGO` is the name of the signing algorithm * - * This function supports any asymmetric-key output from psa_export_key() as + * This function supports any asymmetric-key output from psa_export_key() as * the buffer in \ref p_key. Refer to the documentation of \ref * psa_export_key() for the formats. - * + * * \param[in] p_key A buffer containing the private key * material * \param[in] key_size The size in bytes of the `p_key` data @@ -686,7 +686,7 @@ typedef psa_status_t (*psa_drv_accel_asymmetric_sign_t)(const uint8_t *p_key, * buffer in \ref p_key. Refer to the documentation of \ref * psa_export_public_key() for the format of public keys and to the * documentation of \ref psa_export_key() for the format for other key types. - * + * * \param[in] p_key A buffer containing the public key material * \param[in] key_size The size in bytes of the `p_key` data * \param[in] alg A signature algorithm that is compatible with @@ -719,7 +719,7 @@ typedef psa_status_t (*psa_drv_accel_asymmetric_verify_t)(const uint8_t *p_key, * psa_drv_accel_asymmetric__encrypt * ~~~~~~~~~~~~~ * Where `ALGO` is the name of the encryption algorithm - * + * * This function supports any output from \ref psa_export_public_key() as the * buffer in \ref p_key. Refer to the documentation of \ref * psa_export_public_key() for the format of public keys and to the @@ -772,8 +772,8 @@ typedef psa_status_t (*psa_drv_accel_asymmetric_encrypt_t)(const uint8_t *p_key, * psa_drv_accel_asymmetric__decrypt * ~~~~~~~~~~~~~ * Where `ALGO` is the name of the encryption algorithm - * - * This function supports any asymmetric-key output from psa_export_key() as + * + * This function supports any asymmetric-key output from psa_export_key() as * the buffer in \ref p_key. Refer to the documentation of \ref * psa_export_key() for the formats. * diff --git a/include/psa/crypto_se_driver.h b/include/psa/crypto_se_driver.h index 18ef1c47b..870f69d06 100644 --- a/include/psa/crypto_se_driver.h +++ b/include/psa/crypto_se_driver.h @@ -766,16 +766,16 @@ typedef psa_status_t (*psa_drv_se_export_key_t)(psa_key_slot_number_t key, /** * \brief A function that generates a symmetric or asymmetric key on a secure * element - * - * If `type` is asymmetric (`#define PSA_KEY_TYPE_IS_ASYMMETRIC(type) == 1`), + * + * If `type` is asymmetric (`#define PSA_KEY_TYPE_IS_ASYMMETRIC(type) == 1`), * the public component of the generated key will be placed in `p_pubkey_out`. * The format of the public key information will match the format specified for * the `psa_export_key()` function for the key type. - * + * * \param[in] key_slot Slot where the generated key will be placed * \param[in] type The type of the key to be generated * \param[in] usage The prescribed usage of the generated key - * Note: Not all Secure Elements support the same + * Note: Not all Secure Elements support the same * restrictions that PSA Crypto does (and vice versa). * Driver developers should endeavor to match the * usages as close as possible. @@ -785,7 +785,7 @@ typedef psa_status_t (*psa_drv_se_export_key_t)(psa_key_slot_number_t key, * interpretation in the `extra` parameter is the * `psa_generate_key` function * \param[in] extra_size The size in bytes of the \ref extra buffer - * \param[out] p_pubkey_out The buffer where the public key information will + * \param[out] p_pubkey_out The buffer where the public key information will * be placed * \param[in] pubkey_out_size The size in bytes of the `p_pubkey_out` buffer * \param[out] p_pubkey_length Upon successful completion, will contain the @@ -909,7 +909,7 @@ typedef psa_status_t (*psa_drv_se_key_derivation_collateral_t)(void *p_context, /** \brief A function that performs the final secure element key derivation * step and place the generated key material in a slot - * + * * \param[in,out] p_context A hardware-specific structure containing any * context information for the implementation * \param[in] dest_key The slot where the generated key material From e5c025c7ab19953db723da0f8f63da9d849cd023 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 6 Mar 2019 18:01:43 +0100 Subject: [PATCH 13/15] Fix Doxygen warnings --- include/psa/crypto_accel_driver.h | 8 ++++---- include/psa/crypto_se_driver.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/psa/crypto_accel_driver.h b/include/psa/crypto_accel_driver.h index 125d4c246..1e1940c80 100644 --- a/include/psa/crypto_accel_driver.h +++ b/include/psa/crypto_accel_driver.h @@ -644,7 +644,7 @@ typedef psa_status_t (*psa_drv_accel_aead_decrypt_t)(const uint8_t *p_key, * Where `ALGO` is the name of the signing algorithm * * This function supports any asymmetric-key output from psa_export_key() as - * the buffer in \ref p_key. Refer to the documentation of \ref + * the buffer in \p p_key. Refer to the documentation of \ref * psa_export_key() for the formats. * * \param[in] p_key A buffer containing the private key @@ -683,7 +683,7 @@ typedef psa_status_t (*psa_drv_accel_asymmetric_sign_t)(const uint8_t *p_key, * Where `ALGO` is the name of the signing algorithm * * This function supports any output from \ref psa_export_public_key() as the - * buffer in \ref p_key. Refer to the documentation of \ref + * buffer in \p p_key. Refer to the documentation of \ref * psa_export_public_key() for the format of public keys and to the * documentation of \ref psa_export_key() for the format for other key types. * @@ -721,7 +721,7 @@ typedef psa_status_t (*psa_drv_accel_asymmetric_verify_t)(const uint8_t *p_key, * Where `ALGO` is the name of the encryption algorithm * * This function supports any output from \ref psa_export_public_key() as the - * buffer in \ref p_key. Refer to the documentation of \ref + * buffer in \p p_key. Refer to the documentation of \ref * psa_export_public_key() for the format of public keys and to the * documentation of \ref psa_export_key() for the format for other key types. * @@ -774,7 +774,7 @@ typedef psa_status_t (*psa_drv_accel_asymmetric_encrypt_t)(const uint8_t *p_key, * Where `ALGO` is the name of the encryption algorithm * * This function supports any asymmetric-key output from psa_export_key() as - * the buffer in \ref p_key. Refer to the documentation of \ref + * the buffer in \p p_key. Refer to the documentation of \ref * psa_export_key() for the formats. * * \param[in] p_key A buffer containing the private key material diff --git a/include/psa/crypto_se_driver.h b/include/psa/crypto_se_driver.h index 870f69d06..4772f306e 100644 --- a/include/psa/crypto_se_driver.h +++ b/include/psa/crypto_se_driver.h @@ -767,10 +767,10 @@ typedef psa_status_t (*psa_drv_se_export_key_t)(psa_key_slot_number_t key, * \brief A function that generates a symmetric or asymmetric key on a secure * element * - * If `type` is asymmetric (`#define PSA_KEY_TYPE_IS_ASYMMETRIC(type) == 1`), + * If \p type is asymmetric (`#PSA_KEY_TYPE_IS_ASYMMETRIC(\p type) == 1`), * the public component of the generated key will be placed in `p_pubkey_out`. * The format of the public key information will match the format specified for - * the `psa_export_key()` function for the key type. + * the psa_export_key() function for the key type. * * \param[in] key_slot Slot where the generated key will be placed * \param[in] type The type of the key to be generated @@ -784,7 +784,7 @@ typedef psa_status_t (*psa_drv_se_export_key_t)(psa_key_slot_number_t key, * interpretation of this parameter should match the * interpretation in the `extra` parameter is the * `psa_generate_key` function - * \param[in] extra_size The size in bytes of the \ref extra buffer + * \param[in] extra_size The size in bytes of the \p extra buffer * \param[out] p_pubkey_out The buffer where the public key information will * be placed * \param[in] pubkey_out_size The size in bytes of the `p_pubkey_out` buffer From c079f5692dbd184e755e3486428deb0bfe0618cb Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 6 Mar 2019 18:01:52 +0100 Subject: [PATCH 14/15] Pass check-files.py --- include/psa/crypto_se_driver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/psa/crypto_se_driver.h b/include/psa/crypto_se_driver.h index 4772f306e..7ba7cf5c9 100644 --- a/include/psa/crypto_se_driver.h +++ b/include/psa/crypto_se_driver.h @@ -43,7 +43,7 @@ extern "C" { /** An internal designation of a key slot between the core part of the * PSA Crypto implementation and the driver. The meaning of this value * is driver-dependent. */ -typedef uint32_t psa_key_slot_number_t; // TODO: Change this to psa_key_slot_t after psa_key_slot_t is removed from Mbed crypto +typedef uint32_t psa_key_slot_number_t; // Change this to psa_key_slot_t after psa_key_slot_t is removed from Mbed crypto /** \defgroup se_mac Secure Element Message Authentication Codes * Generation and authentication of Message Authentication Codes (MACs) using From 32668ce2685787f04ae74f40e086f54cd2d3a0eb Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 6 Mar 2019 18:29:57 +0100 Subject: [PATCH 15/15] Pacify check-names.sh --- include/psa/crypto_accel_driver.h | 4 ++-- include/psa/crypto_se_driver.h | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/psa/crypto_accel_driver.h b/include/psa/crypto_accel_driver.h index 1e1940c80..4a540f0fa 100644 --- a/include/psa/crypto_accel_driver.h +++ b/include/psa/crypto_accel_driver.h @@ -356,7 +356,7 @@ typedef psa_status_t (*psa_drv_accel_mac_verify_t)(const uint8_t *p_input, * - `psa_drv_accel_cipher_update_t` * - ... * - `psa_drv_accel_cipher_finish_t` - + * * If a previously started hardware-accelerated Cipher operation needs to be * terminated, it should be done so by the `psa_drv_accel_cipher_abort_t`. * Failure to do so may result in allocated resources not being freed or in @@ -554,7 +554,7 @@ typedef psa_status_t (*psa_drv_accel_cipher_abort_t)(psa_drv_accel_cipher_contex * the `ciphertext` buffer * * \retval #PSA_SUCCESS - + * */ typedef psa_status_t (*psa_drv_accel_aead_encrypt_t)(const uint8_t *p_key, size_t key_length, diff --git a/include/psa/crypto_se_driver.h b/include/psa/crypto_se_driver.h index 7ba7cf5c9..01f378c7b 100644 --- a/include/psa/crypto_se_driver.h +++ b/include/psa/crypto_se_driver.h @@ -136,7 +136,7 @@ typedef psa_status_t (*psa_drv_se_mac_finish_verify_t)(void *p_context, /** \brief A function that aborts a previous started secure element MAC * operation - + * * \param[in,out] p_context A hardware-specific structure for the previously * started MAC operation to be aborted */ @@ -247,7 +247,7 @@ typedef struct { * - `psa_drv_se_cipher_update_t` * - ... * - `psa_drv_se_cipher_finish_t` - + * * If a previously started secure element Cipher operation needs to be * terminated, it should be done so by the `psa_drv_se_cipher_abort_t`. Failure * to do so may result in allocated resources not being freed or in other @@ -791,15 +791,15 @@ typedef psa_status_t (*psa_drv_se_export_key_t)(psa_key_slot_number_t key, * \param[out] p_pubkey_length Upon successful completion, will contain the * size of the data placed in `p_pubkey_out`. */ -typedef psa_status_t (*psa_drv_se_generate_key_t) (psa_key_slot_number_t key_slot, - psa_key_type_t type, - psa_key_usage_t usage, - size_t bits, - const void *extra, - size_t extra_size, - uint8_t *p_pubkey_out, - size_t pubkey_out_size, - size_t *p_pubkey_length); +typedef psa_status_t (*psa_drv_se_generate_key_t)(psa_key_slot_number_t key_slot, + psa_key_type_t type, + psa_key_usage_t usage, + size_t bits, + const void *extra, + size_t extra_size, + uint8_t *p_pubkey_out, + size_t pubkey_out_size, + size_t *p_pubkey_length); /** * \brief A struct containing all of the function pointers needed to for secure