mirror of https://github.com/ARMmbed/mbed-os.git
"Update directory platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST"
parent
eff8fda16c
commit
c48361b841
|
@ -5,11 +5,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "os_wrapper/mutex.h"
|
#include "os_wrapper/mutex.h"
|
||||||
|
|
||||||
#include "tfm_api.h"
|
|
||||||
#include "tfm_ns_interface.h"
|
#include "tfm_ns_interface.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,7 +15,6 @@
|
||||||
*/
|
*/
|
||||||
static void *ns_lock_handle = NULL;
|
static void *ns_lock_handle = NULL;
|
||||||
|
|
||||||
__attribute__((weak))
|
|
||||||
int32_t tfm_ns_interface_dispatch(veneer_fn fn,
|
int32_t tfm_ns_interface_dispatch(veneer_fn fn,
|
||||||
uint32_t arg0, uint32_t arg1,
|
uint32_t arg0, uint32_t arg1,
|
||||||
uint32_t arg2, uint32_t arg3)
|
uint32_t arg2, uint32_t arg3)
|
||||||
|
@ -35,16 +32,15 @@ int32_t tfm_ns_interface_dispatch(veneer_fn fn,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((weak))
|
uint32_t tfm_ns_interface_init(void)
|
||||||
enum tfm_status_e tfm_ns_interface_init(void)
|
|
||||||
{
|
{
|
||||||
void *handle;
|
void *handle;
|
||||||
|
|
||||||
handle = os_wrapper_mutex_create();
|
handle = os_wrapper_mutex_create();
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
return TFM_ERROR_GENERIC;
|
return OS_WRAPPER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ns_lock_handle = handle;
|
ns_lock_handle = handle;
|
||||||
return TFM_SUCCESS;
|
return OS_WRAPPER_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2019, Arm Limited. All rights reserved.
|
* Copyright (c) 2018-2021, Arm Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*
|
*
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
#include "psa/client.h"
|
#include "psa/client.h"
|
||||||
#include "tfm_ns_interface.h"
|
#include "tfm_ns_interface.h"
|
||||||
#include "tfm_api.h"
|
#include "tfm_api.h"
|
||||||
|
#include "tfm_psa_call_param.h"
|
||||||
|
|
||||||
/**** API functions ****/
|
/**** API functions ****/
|
||||||
|
|
||||||
|
@ -47,23 +48,17 @@ psa_status_t psa_call(psa_handle_t handle, int32_t type,
|
||||||
psa_outvec *out_vec,
|
psa_outvec *out_vec,
|
||||||
size_t out_len)
|
size_t out_len)
|
||||||
{
|
{
|
||||||
/* FixMe: sanity check can be added to offload some NS thread checks from
|
if ((type > INT16_MAX) ||
|
||||||
* TFM secure API
|
(type < INT16_MIN) ||
|
||||||
*/
|
(in_len > UINT8_MAX) ||
|
||||||
|
(out_len > UINT8_MAX)) {
|
||||||
/* Due to v8M restrictions, TF-M NS API needs to add another layer of
|
return PSA_ERROR_PROGRAMMER_ERROR;
|
||||||
* serialization in order for NS to pass arguments to S
|
}
|
||||||
*/
|
|
||||||
const struct tfm_control_parameter_t ctrl_param = {
|
|
||||||
.type = type,
|
|
||||||
.in_len = in_len,
|
|
||||||
.out_len = out_len,
|
|
||||||
};
|
|
||||||
|
|
||||||
return tfm_ns_interface_dispatch(
|
return tfm_ns_interface_dispatch(
|
||||||
(veneer_fn)tfm_psa_call_veneer,
|
(veneer_fn)tfm_psa_call_veneer,
|
||||||
(uint32_t)handle,
|
(uint32_t)handle,
|
||||||
(uint32_t)&ctrl_param,
|
PARAM_PACK(type, in_len, out_len),
|
||||||
(uint32_t)in_vec,
|
(uint32_t)in_vec,
|
||||||
(uint32_t)out_vec);
|
(uint32_t)out_vec);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
TF-Mv1.3.0
|
TF-Mv1.4.0
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef IOVEC_LEN
|
||||||
|
#define IOVEC_LEN(arr) ((uint32_t)(sizeof(arr)/sizeof(arr[0])))
|
||||||
|
#endif
|
||||||
|
|
||||||
/*********************** PSA Client Macros and Types *************************/
|
/*********************** PSA Client Macros and Types *************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,6 +130,14 @@ psa_handle_t psa_connect(uint32_t sid, uint32_t version);
|
||||||
/**
|
/**
|
||||||
* \brief Call an RoT Service on an established connection.
|
* \brief Call an RoT Service on an established connection.
|
||||||
*
|
*
|
||||||
|
* \note FF-M 1.0 proposes 6 parameters for psa_call but the secure gateway ABI
|
||||||
|
* support at most 4 parameters. TF-M chooses to encode 'in_len',
|
||||||
|
* 'out_len', and 'type' into a 32-bit integer to improve efficiency.
|
||||||
|
* Compared with struct-based encoding, this method saves extra memory
|
||||||
|
* check and memory copy operation. The disadvantage is that the 'type'
|
||||||
|
* range has to be reduced into a 16-bit integer. So with this encoding,
|
||||||
|
* the valid range for 'type' is 0-32767.
|
||||||
|
*
|
||||||
* \param[in] handle A handle to an established connection.
|
* \param[in] handle A handle to an established connection.
|
||||||
* \param[in] type The request type.
|
* \param[in] type The request type.
|
||||||
* Must be zero( \ref PSA_IPC_CALL) or positive.
|
* Must be zero( \ref PSA_IPC_CALL) or positive.
|
||||||
|
|
|
@ -78,10 +78,14 @@ extern "C" {
|
||||||
*
|
*
|
||||||
* \retval #PSA_SUCCESS
|
* \retval #PSA_SUCCESS
|
||||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||||
|
* \retval #PSA_ERROR_INSUFFICIENT_STORAGE
|
||||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||||
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
||||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||||
* \retval #PSA_ERROR_INSUFFICIENT_ENTROPY
|
* \retval #PSA_ERROR_INSUFFICIENT_ENTROPY
|
||||||
|
* \retval #PSA_ERROR_STORAGE_FAILURE
|
||||||
|
* \retval #PSA_ERROR_DATA_INVALID
|
||||||
|
* \retval #PSA_ERROR_DATA_CORRUPT
|
||||||
*/
|
*/
|
||||||
psa_status_t psa_crypto_init(void);
|
psa_status_t psa_crypto_init(void);
|
||||||
|
|
||||||
|
@ -91,18 +95,6 @@ psa_status_t psa_crypto_init(void);
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \def PSA_KEY_ATTRIBUTES_INIT
|
|
||||||
*
|
|
||||||
* This macro returns a suitable initializer for a key attribute structure
|
|
||||||
* of type #psa_key_attributes_t.
|
|
||||||
*/
|
|
||||||
#ifdef __DOXYGEN_ONLY__
|
|
||||||
/* This is an example definition for documentation purposes.
|
|
||||||
* Implementations should define a suitable value in `crypto_struct.h`.
|
|
||||||
*/
|
|
||||||
#define PSA_KEY_ATTRIBUTES_INIT {0}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Return an initial value for a key attributes structure.
|
/** Return an initial value for a key attributes structure.
|
||||||
*/
|
*/
|
||||||
static psa_key_attributes_t psa_key_attributes_init(void);
|
static psa_key_attributes_t psa_key_attributes_init(void);
|
||||||
|
@ -228,6 +220,14 @@ static psa_key_usage_t psa_get_key_usage_flags(
|
||||||
* - An algorithm value permits this particular algorithm.
|
* - An algorithm value permits this particular algorithm.
|
||||||
* - An algorithm wildcard built from #PSA_ALG_ANY_HASH allows the specified
|
* - An algorithm wildcard built from #PSA_ALG_ANY_HASH allows the specified
|
||||||
* signature scheme with any hash algorithm.
|
* signature scheme with any hash algorithm.
|
||||||
|
* - An algorithm built from #PSA_ALG_AT_LEAST_THIS_LENGTH_MAC allows
|
||||||
|
* any MAC algorithm from the same base class (e.g. CMAC) which
|
||||||
|
* generates/verifies a MAC length greater than or equal to the length
|
||||||
|
* encoded in the wildcard algorithm.
|
||||||
|
* - An algorithm built from #PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG
|
||||||
|
* allows any AEAD algorithm from the same base class (e.g. CCM) which
|
||||||
|
* generates/verifies a tag length greater than or equal to the length
|
||||||
|
* encoded in the wildcard algorithm.
|
||||||
*
|
*
|
||||||
* This function overwrites any algorithm policy
|
* This function overwrites any algorithm policy
|
||||||
* previously set in \p attributes.
|
* previously set in \p attributes.
|
||||||
|
@ -336,6 +336,8 @@ static size_t psa_get_key_bits(const psa_key_attributes_t *attributes);
|
||||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||||
* \retval #PSA_ERROR_STORAGE_FAILURE
|
* \retval #PSA_ERROR_STORAGE_FAILURE
|
||||||
|
* \retval #PSA_ERROR_DATA_CORRUPT
|
||||||
|
* \retval #PSA_ERROR_DATA_INVALID
|
||||||
* \retval #PSA_ERROR_BAD_STATE
|
* \retval #PSA_ERROR_BAD_STATE
|
||||||
* The library has not been previously initialized by psa_crypto_init().
|
* The library has not been previously initialized by psa_crypto_init().
|
||||||
* It is implementation-dependent whether a failure to initialize
|
* It is implementation-dependent whether a failure to initialize
|
||||||
|
@ -469,6 +471,8 @@ psa_status_t psa_purge_key(psa_key_id_t key);
|
||||||
* \retval #PSA_ERROR_INSUFFICIENT_STORAGE
|
* \retval #PSA_ERROR_INSUFFICIENT_STORAGE
|
||||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||||
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
||||||
|
* \retval #PSA_ERROR_DATA_INVALID
|
||||||
|
* \retval #PSA_ERROR_DATA_CORRUPT
|
||||||
* \retval #PSA_ERROR_STORAGE_FAILURE
|
* \retval #PSA_ERROR_STORAGE_FAILURE
|
||||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||||
* \retval #PSA_ERROR_BAD_STATE
|
* \retval #PSA_ERROR_BAD_STATE
|
||||||
|
@ -508,6 +512,10 @@ psa_status_t psa_copy_key(psa_key_id_t source_key,
|
||||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||||
* There was an failure in communication with the cryptoprocessor.
|
* There was an failure in communication with the cryptoprocessor.
|
||||||
* The key material may still be present in the cryptoprocessor.
|
* The key material may still be present in the cryptoprocessor.
|
||||||
|
* \retval #PSA_ERROR_DATA_INVALID
|
||||||
|
* This error is typically a result of either storage corruption on a
|
||||||
|
* cleartext storage backend, or an attempt to read data that was
|
||||||
|
* written by an incompatible version of the library.
|
||||||
* \retval #PSA_ERROR_STORAGE_FAILURE
|
* \retval #PSA_ERROR_STORAGE_FAILURE
|
||||||
* The storage is corrupted. Implementations shall make a best effort
|
* The storage is corrupted. Implementations shall make a best effort
|
||||||
* to erase key material even in this stage, however applications
|
* to erase key material even in this stage, however applications
|
||||||
|
@ -593,6 +601,8 @@ psa_status_t psa_destroy_key(psa_key_id_t key);
|
||||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||||
* \retval #PSA_ERROR_INSUFFICIENT_STORAGE
|
* \retval #PSA_ERROR_INSUFFICIENT_STORAGE
|
||||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||||
|
* \retval #PSA_ERROR_DATA_CORRUPT
|
||||||
|
* \retval #PSA_ERROR_DATA_INVALID
|
||||||
* \retval #PSA_ERROR_STORAGE_FAILURE
|
* \retval #PSA_ERROR_STORAGE_FAILURE
|
||||||
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
||||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||||
|
@ -655,6 +665,8 @@ psa_status_t psa_import_key(const psa_key_attributes_t *attributes,
|
||||||
* For Weierstrass curves, this is the content of the `privateKey` field of
|
* For Weierstrass curves, this is the content of the `privateKey` field of
|
||||||
* the `ECPrivateKey` format defined by RFC 5915. For Montgomery curves,
|
* the `ECPrivateKey` format defined by RFC 5915. For Montgomery curves,
|
||||||
* the format is defined by RFC 7748, and output is masked according to §5.
|
* the format is defined by RFC 7748, and output is masked according to §5.
|
||||||
|
* For twisted Edwards curves, the private key is as defined by RFC 8032
|
||||||
|
* (a 32-byte string for Edwards25519, a 57-byte string for Edwards448).
|
||||||
* - For Diffie-Hellman key exchange key pairs (key types for which
|
* - For Diffie-Hellman key exchange key pairs (key types for which
|
||||||
* #PSA_KEY_TYPE_IS_DH_KEY_PAIR is true), the
|
* #PSA_KEY_TYPE_IS_DH_KEY_PAIR is true), the
|
||||||
* format is the representation of the private key `x` as a big-endian byte
|
* format is the representation of the private key `x` as a big-endian byte
|
||||||
|
@ -681,7 +693,7 @@ psa_status_t psa_import_key(const psa_key_attributes_t *attributes,
|
||||||
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
||||||
* The size of the \p data buffer is too small. You can determine a
|
* The size of the \p data buffer is too small. You can determine a
|
||||||
* sufficient buffer size by calling
|
* sufficient buffer size by calling
|
||||||
* #PSA_KEY_EXPORT_MAX_SIZE(\c type, \c bits)
|
* #PSA_EXPORT_KEY_OUTPUT_SIZE(\c type, \c bits)
|
||||||
* where \c type is the key type
|
* where \c type is the key type
|
||||||
* and \c bits is the key size in bits.
|
* and \c bits is the key size in bits.
|
||||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||||
|
@ -720,7 +732,12 @@ psa_status_t psa_export_key(psa_key_id_t key,
|
||||||
* modulus INTEGER, -- n
|
* modulus INTEGER, -- n
|
||||||
* publicExponent INTEGER } -- e
|
* publicExponent INTEGER } -- e
|
||||||
* ```
|
* ```
|
||||||
* - For elliptic curve public keys (key types for which
|
* - For elliptic curve keys on a twisted Edwards curve (key types for which
|
||||||
|
* #PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY is true and #PSA_KEY_TYPE_ECC_GET_FAMILY
|
||||||
|
* returns #PSA_ECC_FAMILY_TWISTED_EDWARDS), the public key is as defined
|
||||||
|
* by RFC 8032
|
||||||
|
* (a 32-byte string for Edwards25519, a 57-byte string for Edwards448).
|
||||||
|
* - For other elliptic curve public keys (key types for which
|
||||||
* #PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY is true), the format is the uncompressed
|
* #PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY is true), the format is the uncompressed
|
||||||
* representation defined by SEC1 §2.3.3 as the content of an ECPoint.
|
* representation defined by SEC1 §2.3.3 as the content of an ECPoint.
|
||||||
* Let `m` be the bit size associated with the curve, i.e. the bit size of
|
* Let `m` be the bit size associated with the curve, i.e. the bit size of
|
||||||
|
@ -751,7 +768,7 @@ psa_status_t psa_export_key(psa_key_id_t key,
|
||||||
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
||||||
* The size of the \p data buffer is too small. You can determine a
|
* The size of the \p data buffer is too small. You can determine a
|
||||||
* sufficient buffer size by calling
|
* sufficient buffer size by calling
|
||||||
* #PSA_KEY_EXPORT_MAX_SIZE(#PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(\c type), \c bits)
|
* #PSA_EXPORT_KEY_OUTPUT_SIZE(#PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(\c type), \c bits)
|
||||||
* where \c type is the key type
|
* where \c type is the key type
|
||||||
* and \c bits is the key size in bits.
|
* and \c bits is the key size in bits.
|
||||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||||
|
@ -790,7 +807,7 @@ psa_status_t psa_export_public_key(psa_key_id_t key,
|
||||||
* \param hash_size Size of the \p hash buffer in bytes.
|
* \param hash_size Size of the \p hash buffer in bytes.
|
||||||
* \param[out] hash_length On success, the number of bytes
|
* \param[out] hash_length On success, the number of bytes
|
||||||
* that make up the hash value. This is always
|
* that make up the hash value. This is always
|
||||||
* #PSA_HASH_SIZE(\p alg).
|
* #PSA_HASH_LENGTH(\p alg).
|
||||||
*
|
*
|
||||||
* \retval #PSA_SUCCESS
|
* \retval #PSA_SUCCESS
|
||||||
* Success.
|
* Success.
|
||||||
|
@ -877,22 +894,10 @@ psa_status_t psa_hash_compare(psa_algorithm_t alg,
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* This is an implementation-defined \c struct. Applications should not
|
* This is an implementation-defined \c struct. Applications should not
|
||||||
* make any assumptions about the content of this structure except
|
* make any assumptions about the content of this structure.
|
||||||
* as directed by the documentation of a specific implementation. */
|
* Implementation details can change in future versions without notice. */
|
||||||
typedef struct psa_hash_operation_s psa_hash_operation_t;
|
typedef struct psa_hash_operation_s psa_hash_operation_t;
|
||||||
|
|
||||||
/** \def PSA_HASH_OPERATION_INIT
|
|
||||||
*
|
|
||||||
* This macro returns a suitable initializer for a hash operation object
|
|
||||||
* of type #psa_hash_operation_t.
|
|
||||||
*/
|
|
||||||
#ifdef __DOXYGEN_ONLY__
|
|
||||||
/* This is an example definition for documentation purposes.
|
|
||||||
* Implementations should define a suitable value in `crypto_struct.h`.
|
|
||||||
*/
|
|
||||||
#define PSA_HASH_OPERATION_INIT {0}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Return an initial value for a hash operation object.
|
/** Return an initial value for a hash operation object.
|
||||||
*/
|
*/
|
||||||
static psa_hash_operation_t psa_hash_operation_init(void);
|
static psa_hash_operation_t psa_hash_operation_init(void);
|
||||||
|
@ -1000,7 +1005,7 @@ psa_status_t psa_hash_update(psa_hash_operation_t *operation,
|
||||||
* \param hash_size Size of the \p hash buffer in bytes.
|
* \param hash_size Size of the \p hash buffer in bytes.
|
||||||
* \param[out] hash_length On success, the number of bytes
|
* \param[out] hash_length On success, the number of bytes
|
||||||
* that make up the hash value. This is always
|
* that make up the hash value. This is always
|
||||||
* #PSA_HASH_SIZE(\c alg) where \c alg is the
|
* #PSA_HASH_LENGTH(\c alg) where \c alg is the
|
||||||
* hash algorithm that is calculated.
|
* hash algorithm that is calculated.
|
||||||
*
|
*
|
||||||
* \retval #PSA_SUCCESS
|
* \retval #PSA_SUCCESS
|
||||||
|
@ -1009,7 +1014,7 @@ psa_status_t psa_hash_update(psa_hash_operation_t *operation,
|
||||||
* The operation state is not valid (it must be active).
|
* The operation state is not valid (it must be active).
|
||||||
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
||||||
* The size of the \p hash buffer is too small. You can determine a
|
* The size of the \p hash buffer is too small. You can determine a
|
||||||
* sufficient buffer size by calling #PSA_HASH_SIZE(\c alg)
|
* sufficient buffer size by calling #PSA_HASH_LENGTH(\c alg)
|
||||||
* where \c alg is the hash algorithm that is calculated.
|
* where \c alg is the hash algorithm that is calculated.
|
||||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||||
|
@ -1246,22 +1251,11 @@ psa_status_t psa_mac_verify(psa_key_id_t key,
|
||||||
* operation = psa_mac_operation_init();
|
* operation = psa_mac_operation_init();
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* This is an implementation-defined \c struct. Applications should not
|
|
||||||
* make any assumptions about the content of this structure except
|
|
||||||
* as directed by the documentation of a specific implementation. */
|
|
||||||
typedef struct psa_mac_operation_s psa_mac_operation_t;
|
|
||||||
|
|
||||||
/** \def PSA_MAC_OPERATION_INIT
|
|
||||||
*
|
*
|
||||||
* This macro returns a suitable initializer for a MAC operation object of type
|
* This is an implementation-defined \c struct. Applications should not
|
||||||
* #psa_mac_operation_t.
|
* make any assumptions about the content of this structure.
|
||||||
*/
|
* Implementation details can change in future versions without notice. */
|
||||||
#ifdef __DOXYGEN_ONLY__
|
typedef struct psa_mac_operation_s psa_mac_operation_t;
|
||||||
/* This is an example definition for documentation purposes.
|
|
||||||
* Implementations should define a suitable value in `crypto_struct.h`.
|
|
||||||
*/
|
|
||||||
#define PSA_MAC_OPERATION_INIT {0}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Return an initial value for a MAC operation object.
|
/** Return an initial value for a MAC operation object.
|
||||||
*/
|
*/
|
||||||
|
@ -1447,7 +1441,7 @@ psa_status_t psa_mac_update(psa_mac_operation_t *operation,
|
||||||
* \param mac_size Size of the \p mac buffer in bytes.
|
* \param mac_size Size of the \p mac buffer in bytes.
|
||||||
* \param[out] mac_length On success, the number of bytes
|
* \param[out] mac_length On success, the number of bytes
|
||||||
* that make up the MAC value. This is always
|
* that make up the MAC value. This is always
|
||||||
* #PSA_MAC_FINAL_SIZE(\c key_type, \c key_bits, \c alg)
|
* #PSA_MAC_LENGTH(\c key_type, \c key_bits, \c alg)
|
||||||
* where \c key_type and \c key_bits are the type and
|
* where \c key_type and \c key_bits are the type and
|
||||||
* bit-size respectively of the key and \c alg is the
|
* bit-size respectively of the key and \c alg is the
|
||||||
* MAC algorithm that is calculated.
|
* MAC algorithm that is calculated.
|
||||||
|
@ -1459,7 +1453,7 @@ psa_status_t psa_mac_update(psa_mac_operation_t *operation,
|
||||||
* operation).
|
* operation).
|
||||||
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
||||||
* The size of the \p mac buffer is too small. You can determine a
|
* The size of the \p mac buffer is too small. You can determine a
|
||||||
* sufficient buffer size by calling PSA_MAC_FINAL_SIZE().
|
* sufficient buffer size by calling PSA_MAC_LENGTH().
|
||||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||||
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
||||||
|
@ -1671,22 +1665,10 @@ psa_status_t psa_cipher_decrypt(psa_key_id_t key,
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* This is an implementation-defined \c struct. Applications should not
|
* This is an implementation-defined \c struct. Applications should not
|
||||||
* make any assumptions about the content of this structure except
|
* make any assumptions about the content of this structure.
|
||||||
* as directed by the documentation of a specific implementation. */
|
* Implementation details can change in future versions without notice. */
|
||||||
typedef struct psa_cipher_operation_s psa_cipher_operation_t;
|
typedef struct psa_cipher_operation_s psa_cipher_operation_t;
|
||||||
|
|
||||||
/** \def PSA_CIPHER_OPERATION_INIT
|
|
||||||
*
|
|
||||||
* This macro returns a suitable initializer for a cipher operation object of
|
|
||||||
* type #psa_cipher_operation_t.
|
|
||||||
*/
|
|
||||||
#ifdef __DOXYGEN_ONLY__
|
|
||||||
/* This is an example definition for documentation purposes.
|
|
||||||
* Implementations should define a suitable value in `crypto_struct.h`.
|
|
||||||
*/
|
|
||||||
#define PSA_CIPHER_OPERATION_INIT {0}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Return an initial value for a cipher operation object.
|
/** Return an initial value for a cipher operation object.
|
||||||
*/
|
*/
|
||||||
static psa_cipher_operation_t psa_cipher_operation_init(void);
|
static psa_cipher_operation_t psa_cipher_operation_init(void);
|
||||||
|
@ -2052,9 +2034,16 @@ psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation);
|
||||||
* authentication tag is appended to the
|
* authentication tag is appended to the
|
||||||
* encrypted data.
|
* encrypted data.
|
||||||
* \param ciphertext_size Size of the \p ciphertext buffer in bytes.
|
* \param ciphertext_size Size of the \p ciphertext buffer in bytes.
|
||||||
* This must be at least
|
* This must be appropriate for the selected
|
||||||
* #PSA_AEAD_ENCRYPT_OUTPUT_SIZE(\p alg,
|
* algorithm and key:
|
||||||
* \p plaintext_length).
|
* - A sufficient output size is
|
||||||
|
* #PSA_AEAD_ENCRYPT_OUTPUT_SIZE(\c key_type,
|
||||||
|
* \p alg, \p plaintext_length) where
|
||||||
|
* \c key_type is the type of \p key.
|
||||||
|
* - #PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE(\p
|
||||||
|
* plaintext_length) evaluates to the maximum
|
||||||
|
* ciphertext size of any supported AEAD
|
||||||
|
* encryption.
|
||||||
* \param[out] ciphertext_length On success, the size of the output
|
* \param[out] ciphertext_length On success, the size of the output
|
||||||
* in the \p ciphertext buffer.
|
* in the \p ciphertext buffer.
|
||||||
*
|
*
|
||||||
|
@ -2068,7 +2057,11 @@ psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation);
|
||||||
* \p alg is not supported or is not an AEAD algorithm.
|
* \p alg is not supported or is not an AEAD algorithm.
|
||||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||||
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
||||||
* \p ciphertext_size is too small
|
* \p ciphertext_size is too small.
|
||||||
|
* #PSA_AEAD_ENCRYPT_OUTPUT_SIZE(\c key_type, \p alg,
|
||||||
|
* \p plaintext_length) or
|
||||||
|
* #PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE(\p plaintext_length) can be used to
|
||||||
|
* determine the required buffer size.
|
||||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||||
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
||||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||||
|
@ -2112,9 +2105,16 @@ psa_status_t psa_aead_encrypt(psa_key_id_t key,
|
||||||
* \param ciphertext_length Size of \p ciphertext in bytes.
|
* \param ciphertext_length Size of \p ciphertext in bytes.
|
||||||
* \param[out] plaintext Output buffer for the decrypted data.
|
* \param[out] plaintext Output buffer for the decrypted data.
|
||||||
* \param plaintext_size Size of the \p plaintext buffer in bytes.
|
* \param plaintext_size Size of the \p plaintext buffer in bytes.
|
||||||
* This must be at least
|
* This must be appropriate for the selected
|
||||||
* #PSA_AEAD_DECRYPT_OUTPUT_SIZE(\p alg,
|
* algorithm and key:
|
||||||
* \p ciphertext_length).
|
* - A sufficient output size is
|
||||||
|
* #PSA_AEAD_DECRYPT_OUTPUT_SIZE(\c key_type,
|
||||||
|
* \p alg, \p ciphertext_length) where
|
||||||
|
* \c key_type is the type of \p key.
|
||||||
|
* - #PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE(\p
|
||||||
|
* ciphertext_length) evaluates to the maximum
|
||||||
|
* plaintext size of any supported AEAD
|
||||||
|
* decryption.
|
||||||
* \param[out] plaintext_length On success, the size of the output
|
* \param[out] plaintext_length On success, the size of the output
|
||||||
* in the \p plaintext buffer.
|
* in the \p plaintext buffer.
|
||||||
*
|
*
|
||||||
|
@ -2130,7 +2130,11 @@ psa_status_t psa_aead_encrypt(psa_key_id_t key,
|
||||||
* \p alg is not supported or is not an AEAD algorithm.
|
* \p alg is not supported or is not an AEAD algorithm.
|
||||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||||
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
||||||
* \p plaintext_size or \p nonce_length is too small
|
* \p plaintext_size is too small.
|
||||||
|
* #PSA_AEAD_DECRYPT_OUTPUT_SIZE(\c key_type, \p alg,
|
||||||
|
* \p ciphertext_length) or
|
||||||
|
* #PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE(\p ciphertext_length) can be used
|
||||||
|
* to determine the required buffer size.
|
||||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||||
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
||||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||||
|
@ -2178,22 +2182,10 @@ psa_status_t psa_aead_decrypt(psa_key_id_t key,
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* This is an implementation-defined \c struct. Applications should not
|
* This is an implementation-defined \c struct. Applications should not
|
||||||
* make any assumptions about the content of this structure except
|
* make any assumptions about the content of this structure.
|
||||||
* as directed by the documentation of a specific implementation. */
|
* Implementation details can change in future versions without notice. */
|
||||||
typedef struct psa_aead_operation_s psa_aead_operation_t;
|
typedef struct psa_aead_operation_s psa_aead_operation_t;
|
||||||
|
|
||||||
/** \def PSA_AEAD_OPERATION_INIT
|
|
||||||
*
|
|
||||||
* This macro returns a suitable initializer for an AEAD operation object of
|
|
||||||
* type #psa_aead_operation_t.
|
|
||||||
*/
|
|
||||||
#ifdef __DOXYGEN_ONLY__
|
|
||||||
/* This is an example definition for documentation purposes.
|
|
||||||
* Implementations should define a suitable value in `crypto_struct.h`.
|
|
||||||
*/
|
|
||||||
#define PSA_AEAD_OPERATION_INIT {0}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Return an initial value for an AEAD operation object.
|
/** Return an initial value for an AEAD operation object.
|
||||||
*/
|
*/
|
||||||
static psa_aead_operation_t psa_aead_operation_init(void);
|
static psa_aead_operation_t psa_aead_operation_init(void);
|
||||||
|
@ -2551,10 +2543,18 @@ psa_status_t psa_aead_update_ad(psa_aead_operation_t *operation,
|
||||||
* \param input_length Size of the \p input buffer in bytes.
|
* \param input_length Size of the \p input buffer in bytes.
|
||||||
* \param[out] output Buffer where the output is to be written.
|
* \param[out] output Buffer where the output is to be written.
|
||||||
* \param output_size Size of the \p output buffer in bytes.
|
* \param output_size Size of the \p output buffer in bytes.
|
||||||
* This must be at least
|
* This must be appropriate for the selected
|
||||||
* #PSA_AEAD_UPDATE_OUTPUT_SIZE(\c alg,
|
* algorithm and key:
|
||||||
* \p input_length) where \c alg is the
|
* - A sufficient output size is
|
||||||
* algorithm that is being calculated.
|
* #PSA_AEAD_UPDATE_OUTPUT_SIZE(\c key_type,
|
||||||
|
* \c alg, \p input_length) where
|
||||||
|
* \c key_type is the type of key and \c alg is
|
||||||
|
* the algorithm that were used to set up the
|
||||||
|
* operation.
|
||||||
|
* - #PSA_AEAD_UPDATE_OUTPUT_MAX_SIZE(\p
|
||||||
|
* input_length) evaluates to the maximum
|
||||||
|
* output size of any supported AEAD
|
||||||
|
* algorithm.
|
||||||
* \param[out] output_length On success, the number of bytes
|
* \param[out] output_length On success, the number of bytes
|
||||||
* that make up the returned output.
|
* that make up the returned output.
|
||||||
*
|
*
|
||||||
|
@ -2565,9 +2565,9 @@ psa_status_t psa_aead_update_ad(psa_aead_operation_t *operation,
|
||||||
* set, and have lengths set if required by the algorithm).
|
* set, and have lengths set if required by the algorithm).
|
||||||
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
||||||
* The size of the \p output buffer is too small.
|
* The size of the \p output buffer is too small.
|
||||||
* You can determine a sufficient buffer size by calling
|
* #PSA_AEAD_UPDATE_OUTPUT_SIZE(\c key_type, \c alg, \p input_length) or
|
||||||
* #PSA_AEAD_UPDATE_OUTPUT_SIZE(\c alg, \p input_length)
|
* #PSA_AEAD_UPDATE_OUTPUT_MAX_SIZE(\p input_length) can be used to
|
||||||
* where \c alg is the algorithm that is being calculated.
|
* determine the required buffer size.
|
||||||
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
||||||
* The total length of input to psa_aead_update_ad() so far is
|
* The total length of input to psa_aead_update_ad() so far is
|
||||||
* less than the additional data length that was previously
|
* less than the additional data length that was previously
|
||||||
|
@ -2604,9 +2604,7 @@ psa_status_t psa_aead_update(psa_aead_operation_t *operation,
|
||||||
* This function has two output buffers:
|
* This function has two output buffers:
|
||||||
* - \p ciphertext contains trailing ciphertext that was buffered from
|
* - \p ciphertext contains trailing ciphertext that was buffered from
|
||||||
* preceding calls to psa_aead_update().
|
* preceding calls to psa_aead_update().
|
||||||
* - \p tag contains the authentication tag. Its length is always
|
* - \p tag contains the authentication tag.
|
||||||
* #PSA_AEAD_TAG_LENGTH(\c alg) where \c alg is the AEAD algorithm
|
|
||||||
* that the operation performs.
|
|
||||||
*
|
*
|
||||||
* When this function returns successfuly, the operation becomes inactive.
|
* When this function returns successfuly, the operation becomes inactive.
|
||||||
* If this function returns an error status, the operation enters an error
|
* If this function returns an error status, the operation enters an error
|
||||||
|
@ -2616,18 +2614,32 @@ psa_status_t psa_aead_update(psa_aead_operation_t *operation,
|
||||||
* \param[out] ciphertext Buffer where the last part of the ciphertext
|
* \param[out] ciphertext Buffer where the last part of the ciphertext
|
||||||
* is to be written.
|
* is to be written.
|
||||||
* \param ciphertext_size Size of the \p ciphertext buffer in bytes.
|
* \param ciphertext_size Size of the \p ciphertext buffer in bytes.
|
||||||
* This must be at least
|
* This must be appropriate for the selected
|
||||||
* #PSA_AEAD_FINISH_OUTPUT_SIZE(\c alg) where
|
* algorithm and key:
|
||||||
* \c alg is the algorithm that is being
|
* - A sufficient output size is
|
||||||
* calculated.
|
* #PSA_AEAD_FINISH_OUTPUT_SIZE(\c key_type,
|
||||||
|
* \c alg) where \c key_type is the type of key
|
||||||
|
* and \c alg is the algorithm that were used to
|
||||||
|
* set up the operation.
|
||||||
|
* - #PSA_AEAD_FINISH_OUTPUT_MAX_SIZE evaluates to
|
||||||
|
* the maximum output size of any supported AEAD
|
||||||
|
* algorithm.
|
||||||
* \param[out] ciphertext_length On success, the number of bytes of
|
* \param[out] ciphertext_length On success, the number of bytes of
|
||||||
* returned ciphertext.
|
* returned ciphertext.
|
||||||
* \param[out] tag Buffer where the authentication tag is
|
* \param[out] tag Buffer where the authentication tag is
|
||||||
* to be written.
|
* to be written.
|
||||||
* \param tag_size Size of the \p tag buffer in bytes.
|
* \param tag_size Size of the \p tag buffer in bytes.
|
||||||
* This must be at least
|
* This must be appropriate for the selected
|
||||||
* #PSA_AEAD_TAG_LENGTH(\c alg) where \c alg is
|
* algorithm and key:
|
||||||
* the algorithm that is being calculated.
|
* - The exact tag size is #PSA_AEAD_TAG_LENGTH(\c
|
||||||
|
* key_type, \c key_bits, \c alg) where
|
||||||
|
* \c key_type and \c key_bits are the type and
|
||||||
|
* bit-size of the key, and \c alg is the
|
||||||
|
* algorithm that were used in the call to
|
||||||
|
* psa_aead_encrypt_setup().
|
||||||
|
* - #PSA_AEAD_TAG_MAX_SIZE evaluates to the
|
||||||
|
* maximum tag size of any supported AEAD
|
||||||
|
* algorithm.
|
||||||
* \param[out] tag_length On success, the number of bytes
|
* \param[out] tag_length On success, the number of bytes
|
||||||
* that make up the returned tag.
|
* that make up the returned tag.
|
||||||
*
|
*
|
||||||
|
@ -2638,11 +2650,11 @@ psa_status_t psa_aead_update(psa_aead_operation_t *operation,
|
||||||
* operation with a nonce set).
|
* operation with a nonce set).
|
||||||
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
||||||
* The size of the \p ciphertext or \p tag buffer is too small.
|
* The size of the \p ciphertext or \p tag buffer is too small.
|
||||||
* You can determine a sufficient buffer size for \p ciphertext by
|
* #PSA_AEAD_FINISH_OUTPUT_SIZE(\c key_type, \c alg) or
|
||||||
* calling #PSA_AEAD_FINISH_OUTPUT_SIZE(\c alg)
|
* #PSA_AEAD_FINISH_OUTPUT_MAX_SIZE can be used to determine the
|
||||||
* where \c alg is the algorithm that is being calculated.
|
* required \p ciphertext buffer size. #PSA_AEAD_TAG_LENGTH(\c key_type,
|
||||||
* You can determine a sufficient buffer size for \p tag by
|
* \c key_bits, \c alg) or #PSA_AEAD_TAG_MAX_SIZE can be used to
|
||||||
* calling #PSA_AEAD_TAG_LENGTH(\c alg).
|
* determine the required \p tag buffer size.
|
||||||
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
||||||
* The total length of input to psa_aead_update_ad() so far is
|
* The total length of input to psa_aead_update_ad() so far is
|
||||||
* less than the additional data length that was previously
|
* less than the additional data length that was previously
|
||||||
|
@ -2701,10 +2713,15 @@ psa_status_t psa_aead_finish(psa_aead_operation_t *operation,
|
||||||
* that could not be processed until the end
|
* that could not be processed until the end
|
||||||
* of the input.
|
* of the input.
|
||||||
* \param plaintext_size Size of the \p plaintext buffer in bytes.
|
* \param plaintext_size Size of the \p plaintext buffer in bytes.
|
||||||
* This must be at least
|
* This must be appropriate for the selected algorithm and key:
|
||||||
* #PSA_AEAD_VERIFY_OUTPUT_SIZE(\c alg) where
|
* - A sufficient output size is
|
||||||
* \c alg is the algorithm that is being
|
* #PSA_AEAD_VERIFY_OUTPUT_SIZE(\c key_type,
|
||||||
* calculated.
|
* \c alg) where \c key_type is the type of key
|
||||||
|
* and \c alg is the algorithm that were used to
|
||||||
|
* set up the operation.
|
||||||
|
* - #PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE evaluates to
|
||||||
|
* the maximum output size of any supported AEAD
|
||||||
|
* algorithm.
|
||||||
* \param[out] plaintext_length On success, the number of bytes of
|
* \param[out] plaintext_length On success, the number of bytes of
|
||||||
* returned plaintext.
|
* returned plaintext.
|
||||||
* \param[in] tag Buffer containing the authentication tag.
|
* \param[in] tag Buffer containing the authentication tag.
|
||||||
|
@ -2720,9 +2737,9 @@ psa_status_t psa_aead_finish(psa_aead_operation_t *operation,
|
||||||
* operation with a nonce set).
|
* operation with a nonce set).
|
||||||
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
||||||
* The size of the \p plaintext buffer is too small.
|
* The size of the \p plaintext buffer is too small.
|
||||||
* You can determine a sufficient buffer size for \p plaintext by
|
* #PSA_AEAD_VERIFY_OUTPUT_SIZE(\c key_type, \c alg) or
|
||||||
* calling #PSA_AEAD_VERIFY_OUTPUT_SIZE(\c alg)
|
* #PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE can be used to determine the
|
||||||
* where \c alg is the algorithm that is being calculated.
|
* required buffer size.
|
||||||
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
||||||
* The total length of input to psa_aead_update_ad() so far is
|
* The total length of input to psa_aead_update_ad() so far is
|
||||||
* less than the additional data length that was previously
|
* less than the additional data length that was previously
|
||||||
|
@ -2781,12 +2798,130 @@ psa_status_t psa_aead_abort(psa_aead_operation_t *operation);
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Sign a message with a private key. For hash-and-sign algorithms,
|
||||||
|
* this includes the hashing step.
|
||||||
|
*
|
||||||
|
* \note To perform a multi-part hash-and-sign signature algorithm, first use
|
||||||
|
* a multi-part hash operation and then pass the resulting hash to
|
||||||
|
* psa_sign_hash(). PSA_ALG_GET_HASH(\p alg) can be used to determine the
|
||||||
|
* hash algorithm to use.
|
||||||
|
*
|
||||||
|
* \param[in] key Identifier of the key to use for the operation.
|
||||||
|
* It must be an asymmetric key pair. The key must
|
||||||
|
* allow the usage #PSA_KEY_USAGE_SIGN_MESSAGE.
|
||||||
|
* \param[in] alg An asymmetric signature algorithm (PSA_ALG_XXX
|
||||||
|
* value such that #PSA_ALG_IS_SIGN_MESSAGE(\p alg)
|
||||||
|
* is true), that is compatible with the type of
|
||||||
|
* \p key.
|
||||||
|
* \param[in] input The input message to sign.
|
||||||
|
* \param[in] input_length Size of the \p input buffer in bytes.
|
||||||
|
* \param[out] signature Buffer where the signature is to be written.
|
||||||
|
* \param[in] signature_size Size of the \p signature buffer in bytes. This
|
||||||
|
* must be appropriate for the selected
|
||||||
|
* algorithm and key:
|
||||||
|
* - The required signature size is
|
||||||
|
* #PSA_SIGN_OUTPUT_SIZE(\c key_type, \c key_bits, \p alg)
|
||||||
|
* where \c key_type and \c key_bits are the type and
|
||||||
|
* bit-size respectively of key.
|
||||||
|
* - #PSA_SIGNATURE_MAX_SIZE evaluates to the
|
||||||
|
* maximum signature size of any supported
|
||||||
|
* signature algorithm.
|
||||||
|
* \param[out] signature_length On success, the number of bytes that make up
|
||||||
|
* the returned signature value.
|
||||||
|
*
|
||||||
|
* \retval #PSA_SUCCESS
|
||||||
|
* \retval #PSA_ERROR_INVALID_HANDLE
|
||||||
|
* \retval #PSA_ERROR_NOT_PERMITTED
|
||||||
|
* The key does not have the #PSA_KEY_USAGE_SIGN_MESSAGE flag,
|
||||||
|
* or it does not permit the requested algorithm.
|
||||||
|
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
||||||
|
* The size of the \p signature buffer is too small. You can
|
||||||
|
* determine a sufficient buffer size by calling
|
||||||
|
* #PSA_SIGN_OUTPUT_SIZE(\c key_type, \c key_bits, \p alg)
|
||||||
|
* where \c key_type and \c key_bits are the type and bit-size
|
||||||
|
* respectively of \p key.
|
||||||
|
* \retval #PSA_ERROR_NOT_SUPPORTED
|
||||||
|
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
||||||
|
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||||
|
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||||
|
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
||||||
|
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||||
|
* \retval #PSA_ERROR_STORAGE_FAILURE
|
||||||
|
* \retval #PSA_ERROR_DATA_CORRUPT
|
||||||
|
* \retval #PSA_ERROR_DATA_INVALID
|
||||||
|
* \retval #PSA_ERROR_INSUFFICIENT_ENTROPY
|
||||||
|
* \retval #PSA_ERROR_BAD_STATE
|
||||||
|
* The library has not been previously initialized by psa_crypto_init().
|
||||||
|
* It is implementation-dependent whether a failure to initialize
|
||||||
|
* results in this error code.
|
||||||
|
*/
|
||||||
|
psa_status_t psa_sign_message( psa_key_id_t key,
|
||||||
|
psa_algorithm_t alg,
|
||||||
|
const uint8_t * input,
|
||||||
|
size_t input_length,
|
||||||
|
uint8_t * signature,
|
||||||
|
size_t signature_size,
|
||||||
|
size_t * signature_length );
|
||||||
|
|
||||||
|
/** \brief Verify the signature of a message with a public key, using
|
||||||
|
* a hash-and-sign verification algorithm.
|
||||||
|
*
|
||||||
|
* \note To perform a multi-part hash-and-sign signature verification
|
||||||
|
* algorithm, first use a multi-part hash operation to hash the message
|
||||||
|
* and then pass the resulting hash to psa_verify_hash().
|
||||||
|
* PSA_ALG_GET_HASH(\p alg) can be used to determine the hash algorithm
|
||||||
|
* to use.
|
||||||
|
*
|
||||||
|
* \param[in] key Identifier of the key to use for the operation.
|
||||||
|
* It must be a public key or an asymmetric key
|
||||||
|
* pair. The key must allow the usage
|
||||||
|
* #PSA_KEY_USAGE_VERIFY_MESSAGE.
|
||||||
|
* \param[in] alg An asymmetric signature algorithm (PSA_ALG_XXX
|
||||||
|
* value such that #PSA_ALG_IS_SIGN_MESSAGE(\p alg)
|
||||||
|
* is true), that is compatible with the type of
|
||||||
|
* \p key.
|
||||||
|
* \param[in] input The message whose signature is to be verified.
|
||||||
|
* \param[in] input_length Size of the \p input buffer in bytes.
|
||||||
|
* \param[out] signature Buffer containing the signature to verify.
|
||||||
|
* \param[in] signature_length Size of the \p signature buffer in bytes.
|
||||||
|
*
|
||||||
|
* \retval #PSA_SUCCESS
|
||||||
|
* \retval #PSA_ERROR_INVALID_HANDLE
|
||||||
|
* \retval #PSA_ERROR_NOT_PERMITTED
|
||||||
|
* The key does not have the #PSA_KEY_USAGE_SIGN_MESSAGE flag,
|
||||||
|
* or it does not permit the requested algorithm.
|
||||||
|
* \retval #PSA_ERROR_INVALID_SIGNATURE
|
||||||
|
* The calculation was performed successfully, but the passed signature
|
||||||
|
* is not a valid signature.
|
||||||
|
* \retval #PSA_ERROR_NOT_SUPPORTED
|
||||||
|
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
||||||
|
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||||
|
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||||
|
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
||||||
|
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||||
|
* \retval #PSA_ERROR_STORAGE_FAILURE
|
||||||
|
* \retval #PSA_ERROR_DATA_CORRUPT
|
||||||
|
* \retval #PSA_ERROR_DATA_INVALID
|
||||||
|
* \retval #PSA_ERROR_BAD_STATE
|
||||||
|
* The library has not been previously initialized by psa_crypto_init().
|
||||||
|
* It is implementation-dependent whether a failure to initialize
|
||||||
|
* results in this error code.
|
||||||
|
*/
|
||||||
|
psa_status_t psa_verify_message( psa_key_id_t key,
|
||||||
|
psa_algorithm_t alg,
|
||||||
|
const uint8_t * input,
|
||||||
|
size_t input_length,
|
||||||
|
const uint8_t * signature,
|
||||||
|
size_t signature_length );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Sign a hash or short message with a private key.
|
* \brief Sign a hash or short message with a private key.
|
||||||
*
|
*
|
||||||
* Note that to perform a hash-and-sign signature algorithm, you must
|
* Note that to perform a hash-and-sign signature algorithm, you must
|
||||||
* first calculate the hash by calling psa_hash_setup(), psa_hash_update()
|
* first calculate the hash by calling psa_hash_setup(), psa_hash_update()
|
||||||
* and psa_hash_finish(). Then pass the resulting hash as the \p hash
|
* and psa_hash_finish(), or alternatively by calling psa_hash_compute().
|
||||||
|
* Then pass the resulting hash as the \p hash
|
||||||
* parameter to this function. You can use #PSA_ALG_SIGN_GET_HASH(\p alg)
|
* parameter to this function. You can use #PSA_ALG_SIGN_GET_HASH(\p alg)
|
||||||
* to determine the hash algorithm to use.
|
* to determine the hash algorithm to use.
|
||||||
*
|
*
|
||||||
|
@ -2833,11 +2968,12 @@ psa_status_t psa_sign_hash(psa_key_id_t key,
|
||||||
size_t *signature_length);
|
size_t *signature_length);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Verify the signature a hash or short message using a public key.
|
* \brief Verify the signature of a hash or short message using a public key.
|
||||||
*
|
*
|
||||||
* Note that to perform a hash-and-sign signature algorithm, you must
|
* Note that to perform a hash-and-sign signature algorithm, you must
|
||||||
* first calculate the hash by calling psa_hash_setup(), psa_hash_update()
|
* first calculate the hash by calling psa_hash_setup(), psa_hash_update()
|
||||||
* and psa_hash_finish(). Then pass the resulting hash as the \p hash
|
* and psa_hash_finish(), or alternatively by calling psa_hash_compute().
|
||||||
|
* Then pass the resulting hash as the \p hash
|
||||||
* parameter to this function. You can use #PSA_ALG_SIGN_GET_HASH(\p alg)
|
* parameter to this function. You can use #PSA_ALG_SIGN_GET_HASH(\p alg)
|
||||||
* to determine the hash algorithm to use.
|
* to determine the hash algorithm to use.
|
||||||
*
|
*
|
||||||
|
@ -3033,23 +3169,11 @@ psa_status_t psa_asymmetric_decrypt(psa_key_id_t key,
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* This is an implementation-defined \c struct. Applications should not
|
* This is an implementation-defined \c struct. Applications should not
|
||||||
* make any assumptions about the content of this structure except
|
* make any assumptions about the content of this structure.
|
||||||
* as directed by the documentation of a specific implementation.
|
* Implementation details can change in future versions without notice.
|
||||||
*/
|
*/
|
||||||
typedef struct psa_key_derivation_s psa_key_derivation_operation_t;
|
typedef struct psa_key_derivation_s psa_key_derivation_operation_t;
|
||||||
|
|
||||||
/** \def PSA_KEY_DERIVATION_OPERATION_INIT
|
|
||||||
*
|
|
||||||
* This macro returns a suitable initializer for a key derivation operation
|
|
||||||
* object of type #psa_key_derivation_operation_t.
|
|
||||||
*/
|
|
||||||
#ifdef __DOXYGEN_ONLY__
|
|
||||||
/* This is an example definition for documentation purposes.
|
|
||||||
* Implementations should define a suitable value in `crypto_struct.h`.
|
|
||||||
*/
|
|
||||||
#define PSA_KEY_DERIVATION_OPERATION_INIT {0}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Return an initial value for a key derivation operation object.
|
/** Return an initial value for a key derivation operation object.
|
||||||
*/
|
*/
|
||||||
static psa_key_derivation_operation_t psa_key_derivation_operation_init(void);
|
static psa_key_derivation_operation_t psa_key_derivation_operation_init(void);
|
||||||
|
@ -3227,6 +3351,50 @@ psa_status_t psa_key_derivation_input_bytes(
|
||||||
const uint8_t *data,
|
const uint8_t *data,
|
||||||
size_t data_length);
|
size_t data_length);
|
||||||
|
|
||||||
|
/** Provide a numeric input for key derivation or key agreement.
|
||||||
|
*
|
||||||
|
* Which inputs are required and in what order depends on the algorithm.
|
||||||
|
* However, when an algorithm requires a particular order, numeric inputs
|
||||||
|
* usually come first as they tend to be configuration parameters.
|
||||||
|
* Refer to the documentation of each key derivation or key agreement
|
||||||
|
* algorithm for information.
|
||||||
|
*
|
||||||
|
* This function is used for inputs which are fixed-size non-negative
|
||||||
|
* integers.
|
||||||
|
*
|
||||||
|
* If this function returns an error status, the operation enters an error
|
||||||
|
* state and must be aborted by calling psa_key_derivation_abort().
|
||||||
|
*
|
||||||
|
* \param[in,out] operation The key derivation operation object to use.
|
||||||
|
* It must have been set up with
|
||||||
|
* psa_key_derivation_setup() and must not
|
||||||
|
* have produced any output yet.
|
||||||
|
* \param step Which step the input data is for.
|
||||||
|
* \param[in] value The value of the numeric input.
|
||||||
|
*
|
||||||
|
* \retval #PSA_SUCCESS
|
||||||
|
* Success.
|
||||||
|
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
||||||
|
* \c step is not compatible with the operation's algorithm.
|
||||||
|
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
||||||
|
* \c step does not allow numeric inputs.
|
||||||
|
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||||
|
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||||
|
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
||||||
|
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||||
|
* \retval #PSA_ERROR_STORAGE_FAILURE
|
||||||
|
* \retval #PSA_ERROR_BAD_STATE
|
||||||
|
* The operation state is not valid for this input \p step.
|
||||||
|
* \retval #PSA_ERROR_BAD_STATE
|
||||||
|
* The library has not been previously initialized by psa_crypto_init().
|
||||||
|
* It is implementation-dependent whether a failure to initialize
|
||||||
|
* results in this error code.
|
||||||
|
*/
|
||||||
|
psa_status_t psa_key_derivation_input_integer(
|
||||||
|
psa_key_derivation_operation_t *operation,
|
||||||
|
psa_key_derivation_step_t step,
|
||||||
|
uint64_t value);
|
||||||
|
|
||||||
/** Provide an input for key derivation in the form of a key.
|
/** Provide an input for key derivation in the form of a key.
|
||||||
*
|
*
|
||||||
* Which inputs are required and in what order depends on the algorithm.
|
* Which inputs are required and in what order depends on the algorithm.
|
||||||
|
@ -3251,12 +3419,29 @@ psa_status_t psa_key_derivation_input_bytes(
|
||||||
* \param step Which step the input data is for.
|
* \param step Which step the input data is for.
|
||||||
* \param key Identifier of the key. It must have an
|
* \param key Identifier of the key. It must have an
|
||||||
* appropriate type for step and must allow the
|
* appropriate type for step and must allow the
|
||||||
* usage #PSA_KEY_USAGE_DERIVE.
|
* usage #PSA_KEY_USAGE_DERIVE or
|
||||||
|
* #PSA_KEY_USAGE_VERIFY_DERIVATION (see note)
|
||||||
|
* and the algorithm used by the operation.
|
||||||
|
*
|
||||||
|
* \note Once all inputs steps are completed, the operations will allow:
|
||||||
|
* - psa_key_derivation_output_bytes() if each input was either a direct input
|
||||||
|
* or a key with #PSA_KEY_USAGE_DERIVE set;
|
||||||
|
* - psa_key_derivation_output_key() if the input for step
|
||||||
|
* #PSA_KEY_DERIVATION_INPUT_SECRET or #PSA_KEY_DERIVATION_INPUT_PASSWORD
|
||||||
|
* was from a key slot with #PSA_KEY_USAGE_DERIVE and each other input was
|
||||||
|
* either a direct input or a key with #PSA_KEY_USAGE_DERIVE set;
|
||||||
|
* - psa_key_derivation_verify_bytes() if each input was either a direct input
|
||||||
|
* or a key with #PSA_KEY_USAGE_VERIFY_DERIVATION set;
|
||||||
|
* - psa_key_derivation_verify_key() under the same conditions as
|
||||||
|
* psa_key_derivation_verify_bytes().
|
||||||
*
|
*
|
||||||
* \retval #PSA_SUCCESS
|
* \retval #PSA_SUCCESS
|
||||||
* Success.
|
* Success.
|
||||||
* \retval #PSA_ERROR_INVALID_HANDLE
|
* \retval #PSA_ERROR_INVALID_HANDLE
|
||||||
* \retval #PSA_ERROR_NOT_PERMITTED
|
* \retval #PSA_ERROR_NOT_PERMITTED
|
||||||
|
* The key allows neither #PSA_KEY_USAGE_DERIVE nor
|
||||||
|
* #PSA_KEY_USAGE_VERIFY_DERIVATION, or it doesn't allow this
|
||||||
|
* algorithm.
|
||||||
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
||||||
* \c step is not compatible with the operation's algorithm.
|
* \c step is not compatible with the operation's algorithm.
|
||||||
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
||||||
|
@ -3369,6 +3554,9 @@ psa_status_t psa_key_derivation_key_agreement(
|
||||||
* \param output_length Number of bytes to output.
|
* \param output_length Number of bytes to output.
|
||||||
*
|
*
|
||||||
* \retval #PSA_SUCCESS
|
* \retval #PSA_SUCCESS
|
||||||
|
* \retval #PSA_ERROR_NOT_PERMITTED
|
||||||
|
* One of the inputs was a key whose policy didn't allow
|
||||||
|
* #PSA_KEY_USAGE_DERIVE.
|
||||||
* \retval #PSA_ERROR_INSUFFICIENT_DATA
|
* \retval #PSA_ERROR_INSUFFICIENT_DATA
|
||||||
* The operation's capacity was less than
|
* The operation's capacity was less than
|
||||||
* \p output_length bytes. Note that in this case,
|
* \p output_length bytes. Note that in this case,
|
||||||
|
@ -3411,7 +3599,8 @@ psa_status_t psa_key_derivation_output_bytes(
|
||||||
* state and must be aborted by calling psa_key_derivation_abort().
|
* state and must be aborted by calling psa_key_derivation_abort().
|
||||||
*
|
*
|
||||||
* How much output is produced and consumed from the operation, and how
|
* How much output is produced and consumed from the operation, and how
|
||||||
* the key is derived, depends on the key type:
|
* the key is derived, depends on the key type and on the key size
|
||||||
|
* (denoted \c bits below):
|
||||||
*
|
*
|
||||||
* - For key types for which the key is an arbitrary sequence of bytes
|
* - For key types for which the key is an arbitrary sequence of bytes
|
||||||
* of a given size, this function is functionally equivalent to
|
* of a given size, this function is functionally equivalent to
|
||||||
|
@ -3421,14 +3610,14 @@ psa_status_t psa_key_derivation_output_bytes(
|
||||||
* if the implementation provides an isolation boundary then
|
* if the implementation provides an isolation boundary then
|
||||||
* the key material is not exposed outside the isolation boundary.
|
* the key material is not exposed outside the isolation boundary.
|
||||||
* As a consequence, for these key types, this function always consumes
|
* As a consequence, for these key types, this function always consumes
|
||||||
* exactly (\p bits / 8) bytes from the operation.
|
* exactly (\c bits / 8) bytes from the operation.
|
||||||
* The following key types defined in this specification follow this scheme:
|
* The following key types defined in this specification follow this scheme:
|
||||||
*
|
*
|
||||||
* - #PSA_KEY_TYPE_AES;
|
* - #PSA_KEY_TYPE_AES;
|
||||||
* - #PSA_KEY_TYPE_ARC4;
|
|
||||||
* - #PSA_KEY_TYPE_CAMELLIA;
|
* - #PSA_KEY_TYPE_CAMELLIA;
|
||||||
* - #PSA_KEY_TYPE_DERIVE;
|
* - #PSA_KEY_TYPE_DERIVE;
|
||||||
* - #PSA_KEY_TYPE_HMAC.
|
* - #PSA_KEY_TYPE_HMAC;
|
||||||
|
* - #PSA_KEY_TYPE_PASSWORD_HASH.
|
||||||
*
|
*
|
||||||
* - For ECC keys on a Montgomery elliptic curve
|
* - For ECC keys on a Montgomery elliptic curve
|
||||||
* (#PSA_KEY_TYPE_ECC_KEY_PAIR(\c curve) where \c curve designates a
|
* (#PSA_KEY_TYPE_ECC_KEY_PAIR(\c curve) where \c curve designates a
|
||||||
|
@ -3442,8 +3631,8 @@ psa_status_t psa_key_derivation_output_bytes(
|
||||||
* string and process it as specified in RFC 7748 §5.
|
* string and process it as specified in RFC 7748 §5.
|
||||||
*
|
*
|
||||||
* - For key types for which the key is represented by a single sequence of
|
* - For key types for which the key is represented by a single sequence of
|
||||||
* \p bits bits with constraints as to which bit sequences are acceptable,
|
* \c bits bits with constraints as to which bit sequences are acceptable,
|
||||||
* this function draws a byte string of length (\p bits / 8) bytes rounded
|
* this function draws a byte string of length (\c bits / 8) bytes rounded
|
||||||
* up to the nearest whole number of bytes. If the resulting byte string
|
* up to the nearest whole number of bytes. If the resulting byte string
|
||||||
* is acceptable, it becomes the key, otherwise the drawn bytes are discarded.
|
* is acceptable, it becomes the key, otherwise the drawn bytes are discarded.
|
||||||
* This process is repeated until an acceptable byte string is drawn.
|
* This process is repeated until an acceptable byte string is drawn.
|
||||||
|
@ -3490,6 +3679,10 @@ psa_status_t psa_key_derivation_output_bytes(
|
||||||
* on the derived key based on the attributes and strength of the secret key.
|
* on the derived key based on the attributes and strength of the secret key.
|
||||||
*
|
*
|
||||||
* \param[in] attributes The attributes for the new key.
|
* \param[in] attributes The attributes for the new key.
|
||||||
|
* If the key type to be created is
|
||||||
|
* #PSA_KEY_TYPE_PASSWORD_HASH then the algorithm in
|
||||||
|
* the policy must be the same as in the current
|
||||||
|
* operation.
|
||||||
* \param[in,out] operation The key derivation operation object to read from.
|
* \param[in,out] operation The key derivation operation object to read from.
|
||||||
* \param[out] key On success, an identifier for the newly created
|
* \param[out] key On success, an identifier for the newly created
|
||||||
* key. For persistent keys, this is the key
|
* key. For persistent keys, this is the key
|
||||||
|
@ -3514,8 +3707,10 @@ psa_status_t psa_key_derivation_output_bytes(
|
||||||
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
||||||
* The provided key attributes are not valid for the operation.
|
* The provided key attributes are not valid for the operation.
|
||||||
* \retval #PSA_ERROR_NOT_PERMITTED
|
* \retval #PSA_ERROR_NOT_PERMITTED
|
||||||
* The #PSA_KEY_DERIVATION_INPUT_SECRET input was not provided through
|
* The #PSA_KEY_DERIVATION_INPUT_SECRET or
|
||||||
* a key.
|
* #PSA_KEY_DERIVATION_INPUT_PASSWORD input was not provided through a
|
||||||
|
* key; or one of the inputs was a key whose policy didn't allow
|
||||||
|
* #PSA_KEY_USAGE_DERIVE.
|
||||||
* \retval #PSA_ERROR_BAD_STATE
|
* \retval #PSA_ERROR_BAD_STATE
|
||||||
* The operation state is not valid (it must be active and completed
|
* The operation state is not valid (it must be active and completed
|
||||||
* all required input steps).
|
* all required input steps).
|
||||||
|
@ -3524,6 +3719,8 @@ psa_status_t psa_key_derivation_output_bytes(
|
||||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||||
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
||||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||||
|
* \retval #PSA_ERROR_DATA_INVALID
|
||||||
|
* \retval #PSA_ERROR_DATA_CORRUPT
|
||||||
* \retval #PSA_ERROR_STORAGE_FAILURE
|
* \retval #PSA_ERROR_STORAGE_FAILURE
|
||||||
* \retval #PSA_ERROR_BAD_STATE
|
* \retval #PSA_ERROR_BAD_STATE
|
||||||
* The library has not been previously initialized by psa_crypto_init().
|
* The library has not been previously initialized by psa_crypto_init().
|
||||||
|
@ -3535,6 +3732,129 @@ psa_status_t psa_key_derivation_output_key(
|
||||||
psa_key_derivation_operation_t *operation,
|
psa_key_derivation_operation_t *operation,
|
||||||
psa_key_id_t *key);
|
psa_key_id_t *key);
|
||||||
|
|
||||||
|
/** Compare output data from a key derivation operation to an expected value.
|
||||||
|
*
|
||||||
|
* This function calculates output bytes from a key derivation algorithm and
|
||||||
|
* compares those bytes to an expected value in constant time.
|
||||||
|
* If you view the key derivation's output as a stream of bytes, this
|
||||||
|
* function destructively reads the expected number of bytes from the
|
||||||
|
* stream before comparing them.
|
||||||
|
* The operation's capacity decreases by the number of bytes read.
|
||||||
|
*
|
||||||
|
* This is functionally equivalent to the following code:
|
||||||
|
* \code
|
||||||
|
* psa_key_derivation_output_bytes(operation, tmp, output_length);
|
||||||
|
* if (memcmp(output, tmp, output_length) != 0)
|
||||||
|
* return PSA_ERROR_INVALID_SIGNATURE;
|
||||||
|
* \endcode
|
||||||
|
* except (1) it works even if the key's policy does not allow outputting the
|
||||||
|
* bytes, and (2) the comparison will be done in constant time.
|
||||||
|
*
|
||||||
|
* If this function returns an error status other than
|
||||||
|
* #PSA_ERROR_INSUFFICIENT_DATA or #PSA_ERROR_INVALID_SIGNATURE,
|
||||||
|
* the operation enters an error state and must be aborted by calling
|
||||||
|
* psa_key_derivation_abort().
|
||||||
|
*
|
||||||
|
* \param[in,out] operation The key derivation operation object to read from.
|
||||||
|
* \param[in] expected_output Buffer containing the expected derivation output.
|
||||||
|
* \param output_length Length ot the expected output; this is also the
|
||||||
|
* number of bytes that will be read.
|
||||||
|
*
|
||||||
|
* \retval #PSA_SUCCESS
|
||||||
|
* \retval #PSA_ERROR_INVALID_SIGNATURE
|
||||||
|
* The output was read successfully, but it differs from the expected
|
||||||
|
* output.
|
||||||
|
* \retval #PSA_ERROR_NOT_PERMITTED
|
||||||
|
* One of the inputs was a key whose policy didn't allow
|
||||||
|
* #PSA_KEY_USAGE_VERIFY_DERIVATION.
|
||||||
|
* \retval #PSA_ERROR_INSUFFICIENT_DATA
|
||||||
|
* The operation's capacity was less than
|
||||||
|
* \p output_length bytes. Note that in this case,
|
||||||
|
* the operation's capacity is set to 0, thus
|
||||||
|
* subsequent calls to this function will not
|
||||||
|
* succeed, even with a smaller expected output.
|
||||||
|
* \retval #PSA_ERROR_BAD_STATE
|
||||||
|
* The operation state is not valid (it must be active and completed
|
||||||
|
* all required input steps).
|
||||||
|
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||||
|
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||||
|
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
||||||
|
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||||
|
* \retval #PSA_ERROR_STORAGE_FAILURE
|
||||||
|
* \retval #PSA_ERROR_BAD_STATE
|
||||||
|
* The library has not been previously initialized by psa_crypto_init().
|
||||||
|
* It is implementation-dependent whether a failure to initialize
|
||||||
|
* results in this error code.
|
||||||
|
*/
|
||||||
|
psa_status_t psa_key_derivation_verify_bytes(
|
||||||
|
psa_key_derivation_operation_t *operation,
|
||||||
|
const uint8_t *expected_output,
|
||||||
|
size_t output_length);
|
||||||
|
|
||||||
|
/** Compare output data from a key derivation operation to an expected value
|
||||||
|
* stored in a key object.
|
||||||
|
*
|
||||||
|
* This function calculates output bytes from a key derivation algorithm and
|
||||||
|
* compares those bytes to an expected value, provided as key of type
|
||||||
|
* #PSA_KEY_TYPE_PASSWORD_HASH.
|
||||||
|
* If you view the key derivation's output as a stream of bytes, this
|
||||||
|
* function destructively reads the number of bytes corresponding the the
|
||||||
|
* length of the expected value from the stream before comparing them.
|
||||||
|
* The operation's capacity decreases by the number of bytes read.
|
||||||
|
*
|
||||||
|
* This is functionally equivalent to exporting the key and calling
|
||||||
|
* psa_key_derivation_verify_bytes() on the result, except that it
|
||||||
|
* works even if the key cannot be exported.
|
||||||
|
*
|
||||||
|
* If this function returns an error status other than
|
||||||
|
* #PSA_ERROR_INSUFFICIENT_DATA or #PSA_ERROR_INVALID_SIGNATURE,
|
||||||
|
* the operation enters an error state and must be aborted by calling
|
||||||
|
* psa_key_derivation_abort().
|
||||||
|
*
|
||||||
|
* \param[in,out] operation The key derivation operation object to read from.
|
||||||
|
* \param[in] expected A key of type #PSA_KEY_TYPE_PASSWORD_HASH
|
||||||
|
* containing the expected output. Its policy must
|
||||||
|
* include the #PSA_KEY_USAGE_VERIFY_DERIVATION flag
|
||||||
|
* and the permitted algorithm must match the
|
||||||
|
* operation. The value of this key was likely
|
||||||
|
* computed by a previous call to
|
||||||
|
* psa_key_derivation_output_key().
|
||||||
|
*
|
||||||
|
* \retval #PSA_SUCCESS
|
||||||
|
* \retval #PSA_ERROR_INVALID_SIGNATURE
|
||||||
|
* The output was read successfully, but if differs from the expected
|
||||||
|
* output.
|
||||||
|
* \retval #PSA_ERROR_INVALID_HANDLE
|
||||||
|
* The key passed as the expected value does not exist.
|
||||||
|
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
||||||
|
* The key passed as the expected value has an invalid type.
|
||||||
|
* \retval #PSA_ERROR_NOT_PERMITTED
|
||||||
|
* The key passed as the expected value does not allow this usage or
|
||||||
|
* this algorithm; or one of the inputs was a key whose policy didn't
|
||||||
|
* allow #PSA_KEY_USAGE_VERIFY_DERIVATION.
|
||||||
|
* \retval #PSA_ERROR_INSUFFICIENT_DATA
|
||||||
|
* The operation's capacity was less than
|
||||||
|
* the length of the expected value. In this case,
|
||||||
|
* the operation's capacity is set to 0, thus
|
||||||
|
* subsequent calls to this function will not
|
||||||
|
* succeed, even with a smaller expected output.
|
||||||
|
* \retval #PSA_ERROR_BAD_STATE
|
||||||
|
* The operation state is not valid (it must be active and completed
|
||||||
|
* all required input steps).
|
||||||
|
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||||
|
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||||
|
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
||||||
|
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||||
|
* \retval #PSA_ERROR_STORAGE_FAILURE
|
||||||
|
* \retval #PSA_ERROR_BAD_STATE
|
||||||
|
* The library has not been previously initialized by psa_crypto_init().
|
||||||
|
* It is implementation-dependent whether a failure to initialize
|
||||||
|
* results in this error code.
|
||||||
|
*/
|
||||||
|
psa_status_t psa_key_derivation_verify_key(
|
||||||
|
psa_key_derivation_operation_t *operation,
|
||||||
|
psa_key_id_t expected);
|
||||||
|
|
||||||
/** Abort a key derivation operation.
|
/** Abort a key derivation operation.
|
||||||
*
|
*
|
||||||
* Aborting an operation frees all associated resources except for the \c
|
* Aborting an operation frees all associated resources except for the \c
|
||||||
|
@ -3689,6 +4009,8 @@ psa_status_t psa_generate_random(uint8_t *output,
|
||||||
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
||||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||||
* \retval #PSA_ERROR_INSUFFICIENT_STORAGE
|
* \retval #PSA_ERROR_INSUFFICIENT_STORAGE
|
||||||
|
* \retval #PSA_ERROR_DATA_INVALID
|
||||||
|
* \retval #PSA_ERROR_DATA_CORRUPT
|
||||||
* \retval #PSA_ERROR_STORAGE_FAILURE
|
* \retval #PSA_ERROR_STORAGE_FAILURE
|
||||||
* \retval #PSA_ERROR_BAD_STATE
|
* \retval #PSA_ERROR_BAD_STATE
|
||||||
* The library has not been previously initialized by psa_crypto_init().
|
* The library has not been previously initialized by psa_crypto_init().
|
||||||
|
|
|
@ -31,12 +31,12 @@ extern "C" {
|
||||||
* data structure internally. */
|
* data structure internally. */
|
||||||
struct psa_client_key_attributes_s
|
struct psa_client_key_attributes_s
|
||||||
{
|
{
|
||||||
|
uint16_t type;
|
||||||
|
uint16_t bits;
|
||||||
uint32_t lifetime;
|
uint32_t lifetime;
|
||||||
psa_key_id_t id;
|
psa_key_id_t id;
|
||||||
uint32_t alg;
|
|
||||||
uint32_t usage;
|
uint32_t usage;
|
||||||
size_t bits;
|
uint32_t alg;
|
||||||
uint16_t type;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PSA_CLIENT_KEY_ATTRIBUTES_INIT {0, 0, 0, 0, 0, 0}
|
#define PSA_CLIENT_KEY_ATTRIBUTES_INIT {0, 0, 0, 0, 0, 0}
|
||||||
|
|
|
@ -43,197 +43,6 @@ static inline int psa_key_handle_is_null(psa_key_handle_t handle)
|
||||||
return(handle == 0);
|
return(handle == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Mechanism for declaring deprecated values
|
|
||||||
*/
|
|
||||||
#if defined(MBEDTLS_DEPRECATED_WARNING) && !defined(MBEDTLS_PSA_DEPRECATED)
|
|
||||||
#define MBEDTLS_PSA_DEPRECATED __attribute__((deprecated))
|
|
||||||
#else
|
|
||||||
#define MBEDTLS_PSA_DEPRECATED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef MBEDTLS_PSA_DEPRECATED size_t mbedtls_deprecated_size_t;
|
|
||||||
typedef MBEDTLS_PSA_DEPRECATED psa_status_t mbedtls_deprecated_psa_status_t;
|
|
||||||
typedef MBEDTLS_PSA_DEPRECATED psa_key_usage_t mbedtls_deprecated_psa_key_usage_t;
|
|
||||||
typedef MBEDTLS_PSA_DEPRECATED psa_ecc_family_t mbedtls_deprecated_psa_ecc_family_t;
|
|
||||||
typedef MBEDTLS_PSA_DEPRECATED psa_dh_family_t mbedtls_deprecated_psa_dh_family_t;
|
|
||||||
typedef MBEDTLS_PSA_DEPRECATED psa_ecc_family_t psa_ecc_curve_t;
|
|
||||||
typedef MBEDTLS_PSA_DEPRECATED psa_dh_family_t psa_dh_group_t;
|
|
||||||
typedef MBEDTLS_PSA_DEPRECATED psa_algorithm_t mbedtls_deprecated_psa_algorithm_t;
|
|
||||||
|
|
||||||
#define PSA_KEY_TYPE_GET_CURVE PSA_KEY_TYPE_ECC_GET_FAMILY
|
|
||||||
#define PSA_KEY_TYPE_GET_GROUP PSA_KEY_TYPE_DH_GET_FAMILY
|
|
||||||
|
|
||||||
#define MBEDTLS_DEPRECATED_CONSTANT( type, value ) \
|
|
||||||
( (mbedtls_deprecated_##type) ( value ) )
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Deprecated PSA Crypto error code definitions (PSA Crypto API <= 1.0 beta2)
|
|
||||||
*/
|
|
||||||
#define PSA_ERROR_UNKNOWN_ERROR \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_GENERIC_ERROR )
|
|
||||||
#define PSA_ERROR_OCCUPIED_SLOT \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_ALREADY_EXISTS )
|
|
||||||
#define PSA_ERROR_EMPTY_SLOT \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_DOES_NOT_EXIST )
|
|
||||||
#define PSA_ERROR_INSUFFICIENT_CAPACITY \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_INSUFFICIENT_DATA )
|
|
||||||
#define PSA_ERROR_TAMPERING_DETECTED \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_CORRUPTION_DETECTED )
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Deprecated PSA Crypto numerical encodings (PSA Crypto API <= 1.0 beta3)
|
|
||||||
*/
|
|
||||||
#define PSA_KEY_USAGE_SIGN \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_key_usage_t, PSA_KEY_USAGE_SIGN_HASH )
|
|
||||||
#define PSA_KEY_USAGE_VERIFY \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_key_usage_t, PSA_KEY_USAGE_VERIFY_HASH )
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Deprecated PSA Crypto size calculation macros (PSA Crypto API <= 1.0 beta3)
|
|
||||||
*/
|
|
||||||
#define PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_SIGNATURE_MAX_SIZE )
|
|
||||||
#define PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE( key_type, key_bits, alg ) \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_SIGN_OUTPUT_SIZE( key_type, key_bits, alg ) )
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Deprecated PSA Crypto function names (PSA Crypto API <= 1.0 beta3)
|
|
||||||
*/
|
|
||||||
MBEDTLS_PSA_DEPRECATED psa_status_t psa_asymmetric_sign( psa_key_handle_t key,
|
|
||||||
psa_algorithm_t alg,
|
|
||||||
const uint8_t *hash,
|
|
||||||
size_t hash_length,
|
|
||||||
uint8_t *signature,
|
|
||||||
size_t signature_size,
|
|
||||||
size_t *signature_length );
|
|
||||||
|
|
||||||
MBEDTLS_PSA_DEPRECATED psa_status_t psa_asymmetric_verify( psa_key_handle_t key,
|
|
||||||
psa_algorithm_t alg,
|
|
||||||
const uint8_t *hash,
|
|
||||||
size_t hash_length,
|
|
||||||
const uint8_t *signature,
|
|
||||||
size_t signature_length );
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Size-specific elliptic curve families.
|
|
||||||
*/
|
|
||||||
#define PSA_ECC_CURVE_SECP160K1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 )
|
|
||||||
#define PSA_ECC_CURVE_SECP192K1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 )
|
|
||||||
#define PSA_ECC_CURVE_SECP224K1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 )
|
|
||||||
#define PSA_ECC_CURVE_SECP256K1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 )
|
|
||||||
#define PSA_ECC_CURVE_SECP160R1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
|
|
||||||
#define PSA_ECC_CURVE_SECP192R1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
|
|
||||||
#define PSA_ECC_CURVE_SECP224R1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
|
|
||||||
#define PSA_ECC_CURVE_SECP256R1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
|
|
||||||
#define PSA_ECC_CURVE_SECP384R1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
|
|
||||||
#define PSA_ECC_CURVE_SECP521R1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
|
|
||||||
#define PSA_ECC_CURVE_SECP160R2 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R2 )
|
|
||||||
#define PSA_ECC_CURVE_SECT163K1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
|
|
||||||
#define PSA_ECC_CURVE_SECT233K1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
|
|
||||||
#define PSA_ECC_CURVE_SECT239K1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
|
|
||||||
#define PSA_ECC_CURVE_SECT283K1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
|
|
||||||
#define PSA_ECC_CURVE_SECT409K1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
|
|
||||||
#define PSA_ECC_CURVE_SECT571K1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
|
|
||||||
#define PSA_ECC_CURVE_SECT163R1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
|
|
||||||
#define PSA_ECC_CURVE_SECT193R1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
|
|
||||||
#define PSA_ECC_CURVE_SECT233R1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
|
|
||||||
#define PSA_ECC_CURVE_SECT283R1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
|
|
||||||
#define PSA_ECC_CURVE_SECT409R1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
|
|
||||||
#define PSA_ECC_CURVE_SECT571R1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
|
|
||||||
#define PSA_ECC_CURVE_SECT163R2 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R2 )
|
|
||||||
#define PSA_ECC_CURVE_SECT193R2 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R2 )
|
|
||||||
#define PSA_ECC_CURVE_BRAINPOOL_P256R1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_BRAINPOOL_P_R1 )
|
|
||||||
#define PSA_ECC_CURVE_BRAINPOOL_P384R1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_BRAINPOOL_P_R1 )
|
|
||||||
#define PSA_ECC_CURVE_BRAINPOOL_P512R1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_BRAINPOOL_P_R1 )
|
|
||||||
#define PSA_ECC_CURVE_CURVE25519 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_MONTGOMERY )
|
|
||||||
#define PSA_ECC_CURVE_CURVE448 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_MONTGOMERY )
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Curves that changed name due to PSA specification.
|
|
||||||
*/
|
|
||||||
#define PSA_ECC_CURVE_SECP_K1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 )
|
|
||||||
#define PSA_ECC_CURVE_SECP_R1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
|
|
||||||
#define PSA_ECC_CURVE_SECP_R2 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R2 )
|
|
||||||
#define PSA_ECC_CURVE_SECT_K1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
|
|
||||||
#define PSA_ECC_CURVE_SECT_R1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
|
|
||||||
#define PSA_ECC_CURVE_SECT_R2 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R2 )
|
|
||||||
#define PSA_ECC_CURVE_BRAINPOOL_P_R1 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_BRAINPOOL_P_R1 )
|
|
||||||
#define PSA_ECC_CURVE_MONTGOMERY \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_MONTGOMERY )
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Finite-field Diffie-Hellman families.
|
|
||||||
*/
|
|
||||||
#define PSA_DH_GROUP_FFDHE2048 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 )
|
|
||||||
#define PSA_DH_GROUP_FFDHE3072 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 )
|
|
||||||
#define PSA_DH_GROUP_FFDHE4096 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 )
|
|
||||||
#define PSA_DH_GROUP_FFDHE6144 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 )
|
|
||||||
#define PSA_DH_GROUP_FFDHE8192 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 )
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Diffie-Hellman families that changed name due to PSA specification.
|
|
||||||
*/
|
|
||||||
#define PSA_DH_GROUP_RFC7919 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 )
|
|
||||||
#define PSA_DH_GROUP_CUSTOM \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_CUSTOM )
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Deprecated PSA Crypto stream cipher algorithms (PSA Crypto API <= 1.0 beta3)
|
|
||||||
*/
|
|
||||||
#define PSA_ALG_ARC4 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT(psa_algorithm_t, PSA_ALG_STREAM_CIPHER)
|
|
||||||
#define PSA_ALG_CHACHA20 \
|
|
||||||
MBEDTLS_DEPRECATED_CONSTANT(psa_algorithm_t, PSA_ALG_STREAM_CIPHER)
|
|
||||||
|
|
||||||
#endif /* MBEDTLS_DEPRECATED_REMOVED */
|
|
||||||
|
|
||||||
/** Open a handle to an existing persistent key.
|
/** Open a handle to an existing persistent key.
|
||||||
*
|
*
|
||||||
* Open a handle to a persistent key. A key is persistent if it was created
|
* Open a handle to a persistent key. A key is persistent if it was created
|
||||||
|
@ -287,6 +96,8 @@ MBEDTLS_PSA_DEPRECATED psa_status_t psa_asymmetric_verify( psa_key_handle_t key,
|
||||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||||
* \retval #PSA_ERROR_STORAGE_FAILURE
|
* \retval #PSA_ERROR_STORAGE_FAILURE
|
||||||
|
* \retval #PSA_ERROR_DATA_INVALID
|
||||||
|
* \retval #PSA_ERROR_DATA_CORRUPT
|
||||||
* \retval #PSA_ERROR_BAD_STATE
|
* \retval #PSA_ERROR_BAD_STATE
|
||||||
* The library has not been previously initialized by psa_crypto_init().
|
* The library has not been previously initialized by psa_crypto_init().
|
||||||
* It is implementation-dependent whether a failure to initialize
|
* It is implementation-dependent whether a failure to initialize
|
||||||
|
|
|
@ -57,8 +57,6 @@ extern "C" {
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
#include "mbedtls_ecc_group_to_psa.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -47,13 +47,9 @@
|
||||||
*
|
*
|
||||||
* \return The hash size for the specified hash algorithm.
|
* \return The hash size for the specified hash algorithm.
|
||||||
* If the hash algorithm is not recognized, return 0.
|
* If the hash algorithm is not recognized, return 0.
|
||||||
* An implementation may return either 0 or the correct size
|
|
||||||
* for a hash algorithm that it recognizes, but does not support.
|
|
||||||
*/
|
*/
|
||||||
#define PSA_HASH_SIZE(alg) \
|
#define PSA_HASH_LENGTH(alg) \
|
||||||
( \
|
( \
|
||||||
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD2 ? 16 : \
|
|
||||||
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD4 ? 16 : \
|
|
||||||
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD5 ? 16 : \
|
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD5 ? 16 : \
|
||||||
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_RIPEMD160 ? 20 : \
|
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_RIPEMD160 ? 20 : \
|
||||||
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_1 ? 20 : \
|
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_1 ? 20 : \
|
||||||
|
@ -73,23 +69,26 @@
|
||||||
*
|
*
|
||||||
* Maximum size of a hash.
|
* Maximum size of a hash.
|
||||||
*
|
*
|
||||||
* This macro must expand to a compile-time constant integer. This value
|
* This macro expands to a compile-time constant integer. This value
|
||||||
* should be the maximum size of a hash supported by the implementation,
|
* is the maximum size of a hash in bytes.
|
||||||
* in bytes, and must be no smaller than this maximum.
|
|
||||||
*/
|
*/
|
||||||
/* Note: for HMAC-SHA-3, the block size is 144 bytes for HMAC-SHA3-226,
|
/* Note: for HMAC-SHA-3, the block size is 144 bytes for HMAC-SHA3-226,
|
||||||
* 136 bytes for HMAC-SHA3-256, 104 bytes for SHA3-384, 72 bytes for
|
* 136 bytes for HMAC-SHA3-256, 104 bytes for SHA3-384, 72 bytes for
|
||||||
* HMAC-SHA3-512. */
|
* HMAC-SHA3-512. */
|
||||||
|
#if defined(MBEDTLS_SHA512_C)
|
||||||
#define PSA_HASH_MAX_SIZE 64
|
#define PSA_HASH_MAX_SIZE 64
|
||||||
#define PSA_HMAC_MAX_HASH_BLOCK_SIZE 128
|
#define PSA_HMAC_MAX_HASH_BLOCK_SIZE 128
|
||||||
|
#else
|
||||||
|
#define PSA_HASH_MAX_SIZE 32
|
||||||
|
#define PSA_HMAC_MAX_HASH_BLOCK_SIZE 64
|
||||||
|
#endif
|
||||||
|
|
||||||
/** \def PSA_MAC_MAX_SIZE
|
/** \def PSA_MAC_MAX_SIZE
|
||||||
*
|
*
|
||||||
* Maximum size of a MAC.
|
* Maximum size of a MAC.
|
||||||
*
|
*
|
||||||
* This macro must expand to a compile-time constant integer. This value
|
* This macro expands to a compile-time constant integer. This value
|
||||||
* should be the maximum size of a MAC supported by the implementation,
|
* is the maximum size of a MAC in bytes.
|
||||||
* in bytes, and must be no smaller than this maximum.
|
|
||||||
*/
|
*/
|
||||||
/* All non-HMAC MACs have a maximum size that's smaller than the
|
/* All non-HMAC MACs have a maximum size that's smaller than the
|
||||||
* minimum possible value of PSA_HASH_MAX_SIZE in this implementation. */
|
* minimum possible value of PSA_HASH_MAX_SIZE in this implementation. */
|
||||||
|
@ -98,25 +97,37 @@
|
||||||
*/
|
*/
|
||||||
#define PSA_MAC_MAX_SIZE PSA_HASH_MAX_SIZE
|
#define PSA_MAC_MAX_SIZE PSA_HASH_MAX_SIZE
|
||||||
|
|
||||||
/** The tag size for an AEAD algorithm, in bytes.
|
/** The length of a tag for an AEAD algorithm, in bytes.
|
||||||
*
|
*
|
||||||
|
* This macro can be used to allocate a buffer of sufficient size to store the
|
||||||
|
* tag output from psa_aead_finish().
|
||||||
|
*
|
||||||
|
* See also #PSA_AEAD_TAG_MAX_SIZE.
|
||||||
|
*
|
||||||
|
* \param key_type The type of the AEAD key.
|
||||||
|
* \param key_bits The size of the AEAD key in bits.
|
||||||
* \param alg An AEAD algorithm
|
* \param alg An AEAD algorithm
|
||||||
* (\c PSA_ALG_XXX value such that
|
* (\c PSA_ALG_XXX value such that
|
||||||
* #PSA_ALG_IS_AEAD(\p alg) is true).
|
* #PSA_ALG_IS_AEAD(\p alg) is true).
|
||||||
*
|
*
|
||||||
* \return The tag size for the specified algorithm.
|
* \return The tag length for the specified algorithm and key.
|
||||||
* If the AEAD algorithm does not have an identified
|
* If the AEAD algorithm does not have an identified
|
||||||
* tag that can be distinguished from the rest of
|
* tag that can be distinguished from the rest of
|
||||||
* the ciphertext, return 0.
|
* the ciphertext, return 0.
|
||||||
* If the AEAD algorithm is not recognized, return 0.
|
* If the key type or AEAD algorithm is not
|
||||||
* An implementation may return either 0 or a
|
* recognized, or the parameters are incompatible,
|
||||||
* correct size for an AEAD algorithm that it
|
* return 0.
|
||||||
* recognizes, but does not support.
|
|
||||||
*/
|
*/
|
||||||
#define PSA_AEAD_TAG_LENGTH(alg) \
|
#define PSA_AEAD_TAG_LENGTH(key_type, key_bits, alg) \
|
||||||
(PSA_ALG_IS_AEAD(alg) ? \
|
(PSA_AEAD_NONCE_LENGTH(key_type, alg) != 0 ? \
|
||||||
(((alg) & PSA_ALG_AEAD_TAG_LENGTH_MASK) >> PSA_AEAD_TAG_LENGTH_OFFSET) : \
|
PSA_ALG_AEAD_GET_TAG_LENGTH(alg) : \
|
||||||
0)
|
((void) (key_bits), 0))
|
||||||
|
|
||||||
|
/** The maximum tag size for all supported AEAD algorithms, in bytes.
|
||||||
|
*
|
||||||
|
* See also #PSA_AEAD_TAG_LENGTH(\p key_type, \p key_bits, \p alg).
|
||||||
|
*/
|
||||||
|
#define PSA_AEAD_TAG_MAX_SIZE 16
|
||||||
|
|
||||||
/* The maximum size of an RSA key on this implementation, in bits.
|
/* The maximum size of an RSA key on this implementation, in bits.
|
||||||
* This is a vendor-specific macro.
|
* This is a vendor-specific macro.
|
||||||
|
@ -136,10 +147,11 @@
|
||||||
/* The maximum size of an ECC key on this implementation, in bits */
|
/* The maximum size of an ECC key on this implementation, in bits */
|
||||||
#define PSA_VENDOR_ECC_MAX_CURVE_BITS 521
|
#define PSA_VENDOR_ECC_MAX_CURVE_BITS 521
|
||||||
|
|
||||||
/** \def PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN
|
/** This macro returns the maximum supported length of the PSK for the
|
||||||
|
* TLS-1.2 PSK-to-MS key derivation
|
||||||
|
* (#PSA_ALG_TLS12_PSK_TO_MS(\c hash_alg)).
|
||||||
*
|
*
|
||||||
* This macro returns the maximum length of the PSK supported
|
* The maximum supported length does not depend on the chosen hash algorithm.
|
||||||
* by the TLS-1.2 PSK-to-MS key derivation.
|
|
||||||
*
|
*
|
||||||
* Quoting RFC 4279, Sect 5.3:
|
* Quoting RFC 4279, Sect 5.3:
|
||||||
* TLS implementations supporting these ciphersuites MUST support
|
* TLS implementations supporting these ciphersuites MUST support
|
||||||
|
@ -148,17 +160,21 @@
|
||||||
* keys is RECOMMENDED.
|
* keys is RECOMMENDED.
|
||||||
*
|
*
|
||||||
* Therefore, no implementation should define a value smaller than 64
|
* Therefore, no implementation should define a value smaller than 64
|
||||||
* for #PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN.
|
* for #PSA_TLS12_PSK_TO_MS_PSK_MAX_SIZE.
|
||||||
*/
|
*/
|
||||||
#define PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN 128
|
#define PSA_TLS12_PSK_TO_MS_PSK_MAX_SIZE 128
|
||||||
|
|
||||||
/** The maximum size of a block cipher supported by the implementation. */
|
/** The maximum size of a block cipher. */
|
||||||
#define PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE 16
|
#define PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE 16
|
||||||
|
|
||||||
/** The size of the output of psa_mac_sign_finish(), in bytes.
|
/** The size of the output of psa_mac_sign_finish(), in bytes.
|
||||||
*
|
*
|
||||||
* This is also the MAC size that psa_mac_verify_finish() expects.
|
* This is also the MAC size that psa_mac_verify_finish() expects.
|
||||||
*
|
*
|
||||||
|
* \warning This macro may evaluate its arguments multiple times or
|
||||||
|
* zero times, so you should not pass arguments that contain
|
||||||
|
* side effects.
|
||||||
|
*
|
||||||
* \param key_type The type of the MAC key.
|
* \param key_type The type of the MAC key.
|
||||||
* \param key_bits The size of the MAC key in bits.
|
* \param key_bits The size of the MAC key in bits.
|
||||||
* \param alg A MAC algorithm (\c PSA_ALG_XXX value such that
|
* \param alg A MAC algorithm (\c PSA_ALG_XXX value such that
|
||||||
|
@ -172,10 +188,10 @@
|
||||||
* \return Unspecified if the key parameters are not consistent
|
* \return Unspecified if the key parameters are not consistent
|
||||||
* with the algorithm.
|
* with the algorithm.
|
||||||
*/
|
*/
|
||||||
#define PSA_MAC_FINAL_SIZE(key_type, key_bits, alg) \
|
#define PSA_MAC_LENGTH(key_type, key_bits, alg) \
|
||||||
((alg) & PSA_ALG_MAC_TRUNCATION_MASK ? PSA_MAC_TRUNCATED_LENGTH(alg) : \
|
((alg) & PSA_ALG_MAC_TRUNCATION_MASK ? PSA_MAC_TRUNCATED_LENGTH(alg) : \
|
||||||
PSA_ALG_IS_HMAC(alg) ? PSA_HASH_SIZE(PSA_ALG_HMAC_GET_HASH(alg)) : \
|
PSA_ALG_IS_HMAC(alg) ? PSA_HASH_LENGTH(PSA_ALG_HMAC_GET_HASH(alg)) : \
|
||||||
PSA_ALG_IS_BLOCK_CIPHER_MAC(alg) ? PSA_BLOCK_CIPHER_BLOCK_SIZE(key_type) : \
|
PSA_ALG_IS_BLOCK_CIPHER_MAC(alg) ? PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
|
||||||
((void)(key_type), (void)(key_bits), 0))
|
((void)(key_type), (void)(key_bits), 0))
|
||||||
|
|
||||||
/** The maximum size of the output of psa_aead_encrypt(), in bytes.
|
/** The maximum size of the output of psa_aead_encrypt(), in bytes.
|
||||||
|
@ -185,6 +201,14 @@
|
||||||
* insufficient buffer size. Depending on the algorithm, the actual size of
|
* insufficient buffer size. Depending on the algorithm, the actual size of
|
||||||
* the ciphertext may be smaller.
|
* the ciphertext may be smaller.
|
||||||
*
|
*
|
||||||
|
* See also #PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE(\p plaintext_length).
|
||||||
|
*
|
||||||
|
* \warning This macro may evaluate its arguments multiple times or
|
||||||
|
* zero times, so you should not pass arguments that contain
|
||||||
|
* side effects.
|
||||||
|
*
|
||||||
|
* \param key_type A symmetric key type that is
|
||||||
|
* compatible with algorithm \p alg.
|
||||||
* \param alg An AEAD algorithm
|
* \param alg An AEAD algorithm
|
||||||
* (\c PSA_ALG_XXX value such that
|
* (\c PSA_ALG_XXX value such that
|
||||||
* #PSA_ALG_IS_AEAD(\p alg) is true).
|
* #PSA_ALG_IS_AEAD(\p alg) is true).
|
||||||
|
@ -192,16 +216,37 @@
|
||||||
*
|
*
|
||||||
* \return The AEAD ciphertext size for the specified
|
* \return The AEAD ciphertext size for the specified
|
||||||
* algorithm.
|
* algorithm.
|
||||||
* If the AEAD algorithm is not recognized, return 0.
|
* If the key type or AEAD algorithm is not
|
||||||
* An implementation may return either 0 or a
|
* recognized, or the parameters are incompatible,
|
||||||
* correct size for an AEAD algorithm that it
|
* return 0.
|
||||||
* recognizes, but does not support.
|
|
||||||
*/
|
*/
|
||||||
#define PSA_AEAD_ENCRYPT_OUTPUT_SIZE(alg, plaintext_length) \
|
#define PSA_AEAD_ENCRYPT_OUTPUT_SIZE(key_type, alg, plaintext_length) \
|
||||||
(PSA_AEAD_TAG_LENGTH(alg) != 0 ? \
|
(PSA_AEAD_NONCE_LENGTH(key_type, alg) != 0 ? \
|
||||||
(plaintext_length) + PSA_AEAD_TAG_LENGTH(alg) : \
|
(plaintext_length) + PSA_ALG_AEAD_GET_TAG_LENGTH(alg) : \
|
||||||
0)
|
0)
|
||||||
|
|
||||||
|
/** A sufficient output buffer size for psa_aead_encrypt(), for any of the
|
||||||
|
* supported key types and AEAD algorithms.
|
||||||
|
*
|
||||||
|
* If the size of the ciphertext buffer is at least this large, it is guaranteed
|
||||||
|
* that psa_aead_encrypt() will not fail due to an insufficient buffer size.
|
||||||
|
*
|
||||||
|
* \note This macro returns a compile-time constant if its arguments are
|
||||||
|
* compile-time constants.
|
||||||
|
*
|
||||||
|
* See also #PSA_AEAD_ENCRYPT_OUTPUT_SIZE(\p key_type, \p alg,
|
||||||
|
* \p plaintext_length).
|
||||||
|
*
|
||||||
|
* \param plaintext_length Size of the plaintext in bytes.
|
||||||
|
*
|
||||||
|
* \return A sufficient output buffer size for any of the
|
||||||
|
* supported key types and AEAD algorithms.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE(plaintext_length) \
|
||||||
|
((plaintext_length) + PSA_AEAD_TAG_MAX_SIZE)
|
||||||
|
|
||||||
|
|
||||||
/** The maximum size of the output of psa_aead_decrypt(), in bytes.
|
/** The maximum size of the output of psa_aead_decrypt(), in bytes.
|
||||||
*
|
*
|
||||||
* If the size of the plaintext buffer is at least this large, it is
|
* If the size of the plaintext buffer is at least this large, it is
|
||||||
|
@ -209,6 +254,14 @@
|
||||||
* insufficient buffer size. Depending on the algorithm, the actual size of
|
* insufficient buffer size. Depending on the algorithm, the actual size of
|
||||||
* the plaintext may be smaller.
|
* the plaintext may be smaller.
|
||||||
*
|
*
|
||||||
|
* See also #PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE(\p ciphertext_length).
|
||||||
|
*
|
||||||
|
* \warning This macro may evaluate its arguments multiple times or
|
||||||
|
* zero times, so you should not pass arguments that contain
|
||||||
|
* side effects.
|
||||||
|
*
|
||||||
|
* \param key_type A symmetric key type that is
|
||||||
|
* compatible with algorithm \p alg.
|
||||||
* \param alg An AEAD algorithm
|
* \param alg An AEAD algorithm
|
||||||
* (\c PSA_ALG_XXX value such that
|
* (\c PSA_ALG_XXX value such that
|
||||||
* #PSA_ALG_IS_AEAD(\p alg) is true).
|
* #PSA_ALG_IS_AEAD(\p alg) is true).
|
||||||
|
@ -216,16 +269,84 @@
|
||||||
*
|
*
|
||||||
* \return The AEAD ciphertext size for the specified
|
* \return The AEAD ciphertext size for the specified
|
||||||
* algorithm.
|
* algorithm.
|
||||||
* If the AEAD algorithm is not recognized, return 0.
|
* If the key type or AEAD algorithm is not
|
||||||
* An implementation may return either 0 or a
|
* recognized, or the parameters are incompatible,
|
||||||
* correct size for an AEAD algorithm that it
|
* return 0.
|
||||||
* recognizes, but does not support.
|
|
||||||
*/
|
*/
|
||||||
#define PSA_AEAD_DECRYPT_OUTPUT_SIZE(alg, ciphertext_length) \
|
#define PSA_AEAD_DECRYPT_OUTPUT_SIZE(key_type, alg, ciphertext_length) \
|
||||||
(PSA_AEAD_TAG_LENGTH(alg) != 0 ? \
|
(PSA_AEAD_NONCE_LENGTH(key_type, alg) != 0 && \
|
||||||
(ciphertext_length) - PSA_AEAD_TAG_LENGTH(alg) : \
|
(ciphertext_length) > PSA_ALG_AEAD_GET_TAG_LENGTH(alg) ? \
|
||||||
|
(ciphertext_length) - PSA_ALG_AEAD_GET_TAG_LENGTH(alg) : \
|
||||||
0)
|
0)
|
||||||
|
|
||||||
|
/** A sufficient output buffer size for psa_aead_decrypt(), for any of the
|
||||||
|
* supported key types and AEAD algorithms.
|
||||||
|
*
|
||||||
|
* If the size of the plaintext buffer is at least this large, it is guaranteed
|
||||||
|
* that psa_aead_decrypt() will not fail due to an insufficient buffer size.
|
||||||
|
*
|
||||||
|
* \note This macro returns a compile-time constant if its arguments are
|
||||||
|
* compile-time constants.
|
||||||
|
*
|
||||||
|
* See also #PSA_AEAD_DECRYPT_OUTPUT_SIZE(\p key_type, \p alg,
|
||||||
|
* \p ciphertext_length).
|
||||||
|
*
|
||||||
|
* \param ciphertext_length Size of the ciphertext in bytes.
|
||||||
|
*
|
||||||
|
* \return A sufficient output buffer size for any of the
|
||||||
|
* supported key types and AEAD algorithms.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE(ciphertext_length) \
|
||||||
|
(ciphertext_length)
|
||||||
|
|
||||||
|
/** The default nonce size for an AEAD algorithm, in bytes.
|
||||||
|
*
|
||||||
|
* This macro can be used to allocate a buffer of sufficient size to
|
||||||
|
* store the nonce output from #psa_aead_generate_nonce().
|
||||||
|
*
|
||||||
|
* See also #PSA_AEAD_NONCE_MAX_SIZE.
|
||||||
|
*
|
||||||
|
* \note This is not the maximum size of nonce supported as input to
|
||||||
|
* #psa_aead_set_nonce(), #psa_aead_encrypt() or #psa_aead_decrypt(),
|
||||||
|
* just the default size that is generated by #psa_aead_generate_nonce().
|
||||||
|
*
|
||||||
|
* \warning This macro may evaluate its arguments multiple times or
|
||||||
|
* zero times, so you should not pass arguments that contain
|
||||||
|
* side effects.
|
||||||
|
*
|
||||||
|
* \param key_type A symmetric key type that is compatible with
|
||||||
|
* algorithm \p alg.
|
||||||
|
*
|
||||||
|
* \param alg An AEAD algorithm (\c PSA_ALG_XXX value such that
|
||||||
|
* #PSA_ALG_IS_AEAD(\p alg) is true).
|
||||||
|
*
|
||||||
|
* \return The default nonce size for the specified key type and algorithm.
|
||||||
|
* If the key type or AEAD algorithm is not recognized,
|
||||||
|
* or the parameters are incompatible, return 0.
|
||||||
|
*/
|
||||||
|
#define PSA_AEAD_NONCE_LENGTH(key_type, alg) \
|
||||||
|
(PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) == 16 ? \
|
||||||
|
MBEDTLS_PSA_ALG_AEAD_EQUAL(alg, PSA_ALG_CCM) ? 13 : \
|
||||||
|
MBEDTLS_PSA_ALG_AEAD_EQUAL(alg, PSA_ALG_GCM) ? 12 : \
|
||||||
|
0 : \
|
||||||
|
(key_type) == PSA_KEY_TYPE_CHACHA20 && \
|
||||||
|
MBEDTLS_PSA_ALG_AEAD_EQUAL(alg, PSA_ALG_CHACHA20_POLY1305) ? 12 : \
|
||||||
|
0)
|
||||||
|
|
||||||
|
/** The maximum default nonce size among all supported pairs of key types and
|
||||||
|
* AEAD algorithms, in bytes.
|
||||||
|
*
|
||||||
|
* This is equal to or greater than any value that #PSA_AEAD_NONCE_LENGTH()
|
||||||
|
* may return.
|
||||||
|
*
|
||||||
|
* \note This is not the maximum size of nonce supported as input to
|
||||||
|
* #psa_aead_set_nonce(), #psa_aead_encrypt() or #psa_aead_decrypt(),
|
||||||
|
* just the largest size that may be generated by
|
||||||
|
* #psa_aead_generate_nonce().
|
||||||
|
*/
|
||||||
|
#define PSA_AEAD_NONCE_MAX_SIZE 13
|
||||||
|
|
||||||
/** A sufficient output buffer size for psa_aead_update().
|
/** A sufficient output buffer size for psa_aead_update().
|
||||||
*
|
*
|
||||||
* If the size of the output buffer is at least this large, it is
|
* If the size of the output buffer is at least this large, it is
|
||||||
|
@ -233,6 +354,14 @@
|
||||||
* insufficient buffer size. The actual size of the output may be smaller
|
* insufficient buffer size. The actual size of the output may be smaller
|
||||||
* in any given call.
|
* in any given call.
|
||||||
*
|
*
|
||||||
|
* See also #PSA_AEAD_UPDATE_OUTPUT_MAX_SIZE(\p input_length).
|
||||||
|
*
|
||||||
|
* \warning This macro may evaluate its arguments multiple times or
|
||||||
|
* zero times, so you should not pass arguments that contain
|
||||||
|
* side effects.
|
||||||
|
*
|
||||||
|
* \param key_type A symmetric key type that is
|
||||||
|
* compatible with algorithm \p alg.
|
||||||
* \param alg An AEAD algorithm
|
* \param alg An AEAD algorithm
|
||||||
* (\c PSA_ALG_XXX value such that
|
* (\c PSA_ALG_XXX value such that
|
||||||
* #PSA_ALG_IS_AEAD(\p alg) is true).
|
* #PSA_ALG_IS_AEAD(\p alg) is true).
|
||||||
|
@ -240,19 +369,33 @@
|
||||||
*
|
*
|
||||||
* \return A sufficient output buffer size for the specified
|
* \return A sufficient output buffer size for the specified
|
||||||
* algorithm.
|
* algorithm.
|
||||||
* If the AEAD algorithm is not recognized, return 0.
|
* If the key type or AEAD algorithm is not
|
||||||
* An implementation may return either 0 or a
|
* recognized, or the parameters are incompatible,
|
||||||
* correct size for an AEAD algorithm that it
|
* return 0.
|
||||||
* recognizes, but does not support.
|
|
||||||
*/
|
*/
|
||||||
/* For all the AEAD modes defined in this specification, it is possible
|
/* For all the AEAD modes defined in this specification, it is possible
|
||||||
* to emit output without delay. However, hardware may not always be
|
* to emit output without delay. However, hardware may not always be
|
||||||
* capable of this. So for modes based on a block cipher, allow the
|
* capable of this. So for modes based on a block cipher, allow the
|
||||||
* implementation to delay the output until it has a full block. */
|
* implementation to delay the output until it has a full block. */
|
||||||
#define PSA_AEAD_UPDATE_OUTPUT_SIZE(alg, input_length) \
|
#define PSA_AEAD_UPDATE_OUTPUT_SIZE(key_type, alg, input_length) \
|
||||||
(PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
|
(PSA_AEAD_NONCE_LENGTH(key_type, alg) != 0 ? \
|
||||||
PSA_ROUND_UP_TO_MULTIPLE(PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE, (input_length)) : \
|
PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
|
||||||
(input_length))
|
PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type), (input_length)) : \
|
||||||
|
(input_length) : \
|
||||||
|
0)
|
||||||
|
|
||||||
|
/** A sufficient output buffer size for psa_aead_update(), for any of the
|
||||||
|
* supported key types and AEAD algorithms.
|
||||||
|
*
|
||||||
|
* If the size of the output buffer is at least this large, it is guaranteed
|
||||||
|
* that psa_aead_update() will not fail due to an insufficient buffer size.
|
||||||
|
*
|
||||||
|
* See also #PSA_AEAD_UPDATE_OUTPUT_SIZE(\p key_type, \p alg, \p input_length).
|
||||||
|
*
|
||||||
|
* \param input_length Size of the input in bytes.
|
||||||
|
*/
|
||||||
|
#define PSA_AEAD_UPDATE_OUTPUT_MAX_SIZE(input_length) \
|
||||||
|
(PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE, (input_length)))
|
||||||
|
|
||||||
/** A sufficient ciphertext buffer size for psa_aead_finish().
|
/** A sufficient ciphertext buffer size for psa_aead_finish().
|
||||||
*
|
*
|
||||||
|
@ -261,22 +404,33 @@
|
||||||
* insufficient ciphertext buffer size. The actual size of the output may
|
* insufficient ciphertext buffer size. The actual size of the output may
|
||||||
* be smaller in any given call.
|
* be smaller in any given call.
|
||||||
*
|
*
|
||||||
|
* See also #PSA_AEAD_FINISH_OUTPUT_MAX_SIZE.
|
||||||
|
*
|
||||||
|
* \param key_type A symmetric key type that is
|
||||||
|
compatible with algorithm \p alg.
|
||||||
* \param alg An AEAD algorithm
|
* \param alg An AEAD algorithm
|
||||||
* (\c PSA_ALG_XXX value such that
|
* (\c PSA_ALG_XXX value such that
|
||||||
* #PSA_ALG_IS_AEAD(\p alg) is true).
|
* #PSA_ALG_IS_AEAD(\p alg) is true).
|
||||||
*
|
*
|
||||||
* \return A sufficient ciphertext buffer size for the
|
* \return A sufficient ciphertext buffer size for the
|
||||||
* specified algorithm.
|
* specified algorithm.
|
||||||
* If the AEAD algorithm is not recognized, return 0.
|
* If the key type or AEAD algorithm is not
|
||||||
* An implementation may return either 0 or a
|
* recognized, or the parameters are incompatible,
|
||||||
* correct size for an AEAD algorithm that it
|
* return 0.
|
||||||
* recognizes, but does not support.
|
|
||||||
*/
|
*/
|
||||||
#define PSA_AEAD_FINISH_OUTPUT_SIZE(alg) \
|
#define PSA_AEAD_FINISH_OUTPUT_SIZE(key_type, alg) \
|
||||||
(PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
|
(PSA_AEAD_NONCE_LENGTH(key_type, alg) != 0 && \
|
||||||
PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE : \
|
PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
|
||||||
|
PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
|
||||||
0)
|
0)
|
||||||
|
|
||||||
|
/** A sufficient ciphertext buffer size for psa_aead_finish(), for any of the
|
||||||
|
* supported key types and AEAD algorithms.
|
||||||
|
*
|
||||||
|
* See also #PSA_AEAD_FINISH_OUTPUT_SIZE(\p key_type, \p alg).
|
||||||
|
*/
|
||||||
|
#define PSA_AEAD_FINISH_OUTPUT_MAX_SIZE (PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE)
|
||||||
|
|
||||||
/** A sufficient plaintext buffer size for psa_aead_verify().
|
/** A sufficient plaintext buffer size for psa_aead_verify().
|
||||||
*
|
*
|
||||||
* If the size of the plaintext buffer is at least this large, it is
|
* If the size of the plaintext buffer is at least this large, it is
|
||||||
|
@ -284,25 +438,36 @@
|
||||||
* insufficient plaintext buffer size. The actual size of the output may
|
* insufficient plaintext buffer size. The actual size of the output may
|
||||||
* be smaller in any given call.
|
* be smaller in any given call.
|
||||||
*
|
*
|
||||||
|
* See also #PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE.
|
||||||
|
*
|
||||||
|
* \param key_type A symmetric key type that is
|
||||||
|
* compatible with algorithm \p alg.
|
||||||
* \param alg An AEAD algorithm
|
* \param alg An AEAD algorithm
|
||||||
* (\c PSA_ALG_XXX value such that
|
* (\c PSA_ALG_XXX value such that
|
||||||
* #PSA_ALG_IS_AEAD(\p alg) is true).
|
* #PSA_ALG_IS_AEAD(\p alg) is true).
|
||||||
*
|
*
|
||||||
* \return A sufficient plaintext buffer size for the
|
* \return A sufficient plaintext buffer size for the
|
||||||
* specified algorithm.
|
* specified algorithm.
|
||||||
* If the AEAD algorithm is not recognized, return 0.
|
* If the key type or AEAD algorithm is not
|
||||||
* An implementation may return either 0 or a
|
* recognized, or the parameters are incompatible,
|
||||||
* correct size for an AEAD algorithm that it
|
* return 0.
|
||||||
* recognizes, but does not support.
|
|
||||||
*/
|
*/
|
||||||
#define PSA_AEAD_VERIFY_OUTPUT_SIZE(alg) \
|
#define PSA_AEAD_VERIFY_OUTPUT_SIZE(key_type, alg) \
|
||||||
(PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
|
(PSA_AEAD_NONCE_LENGTH(key_type, alg) != 0 && \
|
||||||
PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE : \
|
PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
|
||||||
|
PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
|
||||||
0)
|
0)
|
||||||
|
|
||||||
|
/** A sufficient plaintext buffer size for psa_aead_verify(), for any of the
|
||||||
|
* supported key types and AEAD algorithms.
|
||||||
|
*
|
||||||
|
* See also #PSA_AEAD_VERIFY_OUTPUT_SIZE(\p key_type, \p alg).
|
||||||
|
*/
|
||||||
|
#define PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE (PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE)
|
||||||
|
|
||||||
#define PSA_RSA_MINIMUM_PADDING_SIZE(alg) \
|
#define PSA_RSA_MINIMUM_PADDING_SIZE(alg) \
|
||||||
(PSA_ALG_IS_RSA_OAEP(alg) ? \
|
(PSA_ALG_IS_RSA_OAEP(alg) ? \
|
||||||
2 * PSA_HASH_SIZE(PSA_ALG_RSA_OAEP_GET_HASH(alg)) + 1 : \
|
2 * PSA_HASH_LENGTH(PSA_ALG_RSA_OAEP_GET_HASH(alg)) + 1 : \
|
||||||
11 /*PKCS#1v1.5*/)
|
11 /*PKCS#1v1.5*/)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -336,9 +501,8 @@
|
||||||
* a buffer size in bytes that guarantees that
|
* a buffer size in bytes that guarantees that
|
||||||
* psa_sign_hash() will not fail with
|
* psa_sign_hash() will not fail with
|
||||||
* #PSA_ERROR_BUFFER_TOO_SMALL.
|
* #PSA_ERROR_BUFFER_TOO_SMALL.
|
||||||
* If the parameters are a valid combination that is not supported
|
* If the parameters are a valid combination that is not supported,
|
||||||
* by the implementation, this macro shall return either a
|
* return either a sensible size or 0.
|
||||||
* sensible size or 0.
|
|
||||||
* If the parameters are not valid, the
|
* If the parameters are not valid, the
|
||||||
* return value is unspecified.
|
* return value is unspecified.
|
||||||
*/
|
*/
|
||||||
|
@ -354,9 +518,8 @@
|
||||||
*
|
*
|
||||||
* Maximum size of an asymmetric signature.
|
* Maximum size of an asymmetric signature.
|
||||||
*
|
*
|
||||||
* This macro must expand to a compile-time constant integer. This value
|
* This macro expands to a compile-time constant integer. This value
|
||||||
* should be the maximum size of a signature supported by the implementation,
|
* is the maximum size of a signature in bytes.
|
||||||
* in bytes, and must be no smaller than this maximum.
|
|
||||||
*/
|
*/
|
||||||
#define PSA_SIGNATURE_MAX_SIZE \
|
#define PSA_SIGNATURE_MAX_SIZE \
|
||||||
(PSA_BITS_TO_BYTES(PSA_VENDOR_RSA_MAX_KEY_BITS) > PSA_VENDOR_ECDSA_SIGNATURE_MAX_SIZE ? \
|
(PSA_BITS_TO_BYTES(PSA_VENDOR_RSA_MAX_KEY_BITS) > PSA_VENDOR_ECDSA_SIGNATURE_MAX_SIZE ? \
|
||||||
|
@ -383,9 +546,8 @@
|
||||||
* a buffer size in bytes that guarantees that
|
* a buffer size in bytes that guarantees that
|
||||||
* psa_asymmetric_encrypt() will not fail with
|
* psa_asymmetric_encrypt() will not fail with
|
||||||
* #PSA_ERROR_BUFFER_TOO_SMALL.
|
* #PSA_ERROR_BUFFER_TOO_SMALL.
|
||||||
* If the parameters are a valid combination that is not supported
|
* If the parameters are a valid combination that is not supported,
|
||||||
* by the implementation, this macro shall return either a
|
* return either a sensible size or 0.
|
||||||
* sensible size or 0.
|
|
||||||
* If the parameters are not valid, the
|
* If the parameters are not valid, the
|
||||||
* return value is unspecified.
|
* return value is unspecified.
|
||||||
*/
|
*/
|
||||||
|
@ -394,6 +556,15 @@
|
||||||
((void)alg, PSA_BITS_TO_BYTES(key_bits)) : \
|
((void)alg, PSA_BITS_TO_BYTES(key_bits)) : \
|
||||||
0)
|
0)
|
||||||
|
|
||||||
|
/** A sufficient output buffer size for psa_asymmetric_encrypt(), for any
|
||||||
|
* supported asymmetric encryption.
|
||||||
|
*
|
||||||
|
* See also #PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE(\p key_type, \p key_bits, \p alg).
|
||||||
|
*/
|
||||||
|
/* This macro assumes that RSA is the only supported asymmetric encryption. */
|
||||||
|
#define PSA_ASYMMETRIC_ENCRYPT_OUTPUT_MAX_SIZE \
|
||||||
|
(PSA_BITS_TO_BYTES(PSA_VENDOR_RSA_MAX_KEY_BITS))
|
||||||
|
|
||||||
/** Sufficient output buffer size for psa_asymmetric_decrypt().
|
/** Sufficient output buffer size for psa_asymmetric_decrypt().
|
||||||
*
|
*
|
||||||
* This macro returns a sufficient buffer size for a plaintext produced using
|
* This macro returns a sufficient buffer size for a plaintext produced using
|
||||||
|
@ -414,9 +585,8 @@
|
||||||
* a buffer size in bytes that guarantees that
|
* a buffer size in bytes that guarantees that
|
||||||
* psa_asymmetric_decrypt() will not fail with
|
* psa_asymmetric_decrypt() will not fail with
|
||||||
* #PSA_ERROR_BUFFER_TOO_SMALL.
|
* #PSA_ERROR_BUFFER_TOO_SMALL.
|
||||||
* If the parameters are a valid combination that is not supported
|
* If the parameters are a valid combination that is not supported,
|
||||||
* by the implementation, this macro shall return either a
|
* return either a sensible size or 0.
|
||||||
* sensible size or 0.
|
|
||||||
* If the parameters are not valid, the
|
* If the parameters are not valid, the
|
||||||
* return value is unspecified.
|
* return value is unspecified.
|
||||||
*/
|
*/
|
||||||
|
@ -425,6 +595,16 @@
|
||||||
PSA_BITS_TO_BYTES(key_bits) - PSA_RSA_MINIMUM_PADDING_SIZE(alg) : \
|
PSA_BITS_TO_BYTES(key_bits) - PSA_RSA_MINIMUM_PADDING_SIZE(alg) : \
|
||||||
0)
|
0)
|
||||||
|
|
||||||
|
/** A sufficient output buffer size for psa_asymmetric_decrypt(), for any
|
||||||
|
* supported asymmetric decryption.
|
||||||
|
*
|
||||||
|
* This macro assumes that RSA is the only supported asymmetric encryption.
|
||||||
|
*
|
||||||
|
* See also #PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE(\p key_type, \p key_bits, \p alg).
|
||||||
|
*/
|
||||||
|
#define PSA_ASYMMETRIC_DECRYPT_OUTPUT_MAX_SIZE \
|
||||||
|
(PSA_BITS_TO_BYTES(PSA_VENDOR_RSA_MAX_KEY_BITS))
|
||||||
|
|
||||||
/* Maximum size of the ASN.1 encoding of an INTEGER with the specified
|
/* Maximum size of the ASN.1 encoding of an INTEGER with the specified
|
||||||
* number of bits.
|
* number of bits.
|
||||||
*
|
*
|
||||||
|
@ -535,12 +715,13 @@
|
||||||
#define PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(key_bits) \
|
#define PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(key_bits) \
|
||||||
(PSA_BITS_TO_BYTES(key_bits))
|
(PSA_BITS_TO_BYTES(key_bits))
|
||||||
|
|
||||||
/** Sufficient output buffer size for psa_export_key() or psa_export_public_key().
|
/** Sufficient output buffer size for psa_export_key() or
|
||||||
|
* psa_export_public_key().
|
||||||
*
|
*
|
||||||
* This macro returns a compile-time constant if its arguments are
|
* This macro returns a compile-time constant if its arguments are
|
||||||
* compile-time constants.
|
* compile-time constants.
|
||||||
*
|
*
|
||||||
* \warning This function may call its arguments multiple times or
|
* \warning This macro may evaluate its arguments multiple times or
|
||||||
* zero times, so you should not pass arguments that contain
|
* zero times, so you should not pass arguments that contain
|
||||||
* side effects.
|
* side effects.
|
||||||
*
|
*
|
||||||
|
@ -553,7 +734,7 @@
|
||||||
* if (status != PSA_SUCCESS) handle_error(...);
|
* if (status != PSA_SUCCESS) handle_error(...);
|
||||||
* psa_key_type_t key_type = psa_get_key_type(&attributes);
|
* psa_key_type_t key_type = psa_get_key_type(&attributes);
|
||||||
* size_t key_bits = psa_get_key_bits(&attributes);
|
* size_t key_bits = psa_get_key_bits(&attributes);
|
||||||
* size_t buffer_size = PSA_KEY_EXPORT_MAX_SIZE(key_type, key_bits);
|
* size_t buffer_size = PSA_EXPORT_KEY_OUTPUT_SIZE(key_type, key_bits);
|
||||||
* psa_reset_key_attributes(&attributes);
|
* psa_reset_key_attributes(&attributes);
|
||||||
* uint8_t *buffer = malloc(buffer_size);
|
* uint8_t *buffer = malloc(buffer_size);
|
||||||
* if (buffer == NULL) handle_error(...);
|
* if (buffer == NULL) handle_error(...);
|
||||||
|
@ -562,18 +743,46 @@
|
||||||
* if (status != PSA_SUCCESS) handle_error(...);
|
* if (status != PSA_SUCCESS) handle_error(...);
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* For psa_export_public_key(), calculate the buffer size from the
|
* \param key_type A supported key type.
|
||||||
* public key type. You can use the macro #PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR
|
* \param key_bits The size of the key in bits.
|
||||||
* to convert a key pair type to the corresponding public key type.
|
*
|
||||||
|
* \return If the parameters are valid and supported, return
|
||||||
|
* a buffer size in bytes that guarantees that
|
||||||
|
* psa_export_key() or psa_export_public_key() will not fail with
|
||||||
|
* #PSA_ERROR_BUFFER_TOO_SMALL.
|
||||||
|
* If the parameters are a valid combination that is not supported,
|
||||||
|
* return either a sensible size or 0.
|
||||||
|
* If the parameters are not valid, the return value is unspecified.
|
||||||
|
*/
|
||||||
|
#define PSA_EXPORT_KEY_OUTPUT_SIZE(key_type, key_bits) \
|
||||||
|
(PSA_KEY_TYPE_IS_UNSTRUCTURED(key_type) ? PSA_BITS_TO_BYTES(key_bits) : \
|
||||||
|
(key_type) == PSA_KEY_TYPE_RSA_KEY_PAIR ? PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE(key_bits) : \
|
||||||
|
(key_type) == PSA_KEY_TYPE_RSA_PUBLIC_KEY ? PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE(key_bits) : \
|
||||||
|
(key_type) == PSA_KEY_TYPE_DSA_KEY_PAIR ? PSA_KEY_EXPORT_DSA_KEY_PAIR_MAX_SIZE(key_bits) : \
|
||||||
|
(key_type) == PSA_KEY_TYPE_DSA_PUBLIC_KEY ? PSA_KEY_EXPORT_DSA_PUBLIC_KEY_MAX_SIZE(key_bits) : \
|
||||||
|
PSA_KEY_TYPE_IS_ECC_KEY_PAIR(key_type) ? PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(key_bits) : \
|
||||||
|
PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY(key_type) ? PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(key_bits) : \
|
||||||
|
0)
|
||||||
|
|
||||||
|
/** Sufficient output buffer size for psa_export_public_key().
|
||||||
|
*
|
||||||
|
* This macro returns a compile-time constant if its arguments are
|
||||||
|
* compile-time constants.
|
||||||
|
*
|
||||||
|
* \warning This macro may evaluate its arguments multiple times or
|
||||||
|
* zero times, so you should not pass arguments that contain
|
||||||
|
* side effects.
|
||||||
|
*
|
||||||
|
* The following code illustrates how to allocate enough memory to export
|
||||||
|
* a public key by querying the key type and size at runtime.
|
||||||
* \code{c}
|
* \code{c}
|
||||||
* psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
* psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
||||||
* psa_status_t status;
|
* psa_status_t status;
|
||||||
* status = psa_get_key_attributes(key, &attributes);
|
* status = psa_get_key_attributes(key, &attributes);
|
||||||
* if (status != PSA_SUCCESS) handle_error(...);
|
* if (status != PSA_SUCCESS) handle_error(...);
|
||||||
* psa_key_type_t key_type = psa_get_key_type(&attributes);
|
* psa_key_type_t key_type = psa_get_key_type(&attributes);
|
||||||
* psa_key_type_t public_key_type = PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(key_type);
|
|
||||||
* size_t key_bits = psa_get_key_bits(&attributes);
|
* size_t key_bits = psa_get_key_bits(&attributes);
|
||||||
* size_t buffer_size = PSA_KEY_EXPORT_MAX_SIZE(public_key_type, key_bits);
|
* size_t buffer_size = PSA_EXPORT_PUBLIC_KEY_OUTPUT_SIZE(key_type, key_bits);
|
||||||
* psa_reset_key_attributes(&attributes);
|
* psa_reset_key_attributes(&attributes);
|
||||||
* uint8_t *buffer = malloc(buffer_size);
|
* uint8_t *buffer = malloc(buffer_size);
|
||||||
* if (buffer == NULL) handle_error(...);
|
* if (buffer == NULL) handle_error(...);
|
||||||
|
@ -582,73 +791,96 @@
|
||||||
* if (status != PSA_SUCCESS) handle_error(...);
|
* if (status != PSA_SUCCESS) handle_error(...);
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \param key_type A supported key type.
|
* \param key_type A public key or key pair key type.
|
||||||
* \param key_bits The size of the key in bits.
|
* \param key_bits The size of the key in bits.
|
||||||
*
|
*
|
||||||
* \return If the parameters are valid and supported, return
|
* \return If the parameters are valid and supported, return
|
||||||
* a buffer size in bytes that guarantees that
|
* a buffer size in bytes that guarantees that
|
||||||
* psa_sign_hash() will not fail with
|
* psa_export_public_key() will not fail with
|
||||||
* #PSA_ERROR_BUFFER_TOO_SMALL.
|
* #PSA_ERROR_BUFFER_TOO_SMALL.
|
||||||
* If the parameters are a valid combination that is not supported
|
* If the parameters are a valid combination that is not
|
||||||
* by the implementation, this macro shall return either a
|
* supported, return either a sensible size or 0.
|
||||||
* sensible size or 0.
|
* If the parameters are not valid,
|
||||||
* If the parameters are not valid, the
|
* the return value is unspecified.
|
||||||
* return value is unspecified.
|
*
|
||||||
|
* If the parameters are valid and supported,
|
||||||
|
* return the same result as
|
||||||
|
* #PSA_EXPORT_KEY_OUTPUT_SIZE(
|
||||||
|
* \p #PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(\p key_type),
|
||||||
|
* \p key_bits).
|
||||||
*/
|
*/
|
||||||
#define PSA_KEY_EXPORT_MAX_SIZE(key_type, key_bits) \
|
#define PSA_EXPORT_PUBLIC_KEY_OUTPUT_SIZE(key_type, key_bits) \
|
||||||
(PSA_KEY_TYPE_IS_UNSTRUCTURED(key_type) ? PSA_BITS_TO_BYTES(key_bits) : \
|
(PSA_KEY_TYPE_IS_RSA(key_type) ? PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE(key_bits) : \
|
||||||
(key_type) == PSA_KEY_TYPE_RSA_KEY_PAIR ? PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE(key_bits) : \
|
PSA_KEY_TYPE_IS_ECC(key_type) ? PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(key_bits) : \
|
||||||
(key_type) == PSA_KEY_TYPE_RSA_PUBLIC_KEY ? PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE(key_bits) : \
|
|
||||||
(key_type) == PSA_KEY_TYPE_DSA_KEY_PAIR ? PSA_KEY_EXPORT_DSA_KEY_PAIR_MAX_SIZE(key_bits) : \
|
|
||||||
(key_type) == PSA_KEY_TYPE_DSA_PUBLIC_KEY ? PSA_KEY_EXPORT_DSA_PUBLIC_KEY_MAX_SIZE(key_bits) : \
|
|
||||||
PSA_KEY_TYPE_IS_ECC_KEY_PAIR(key_type) ? PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(key_bits) : \
|
|
||||||
PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY(key_type) ? PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(key_bits) : \
|
|
||||||
0)
|
0)
|
||||||
|
|
||||||
/** The default nonce size for an AEAD algorithm, in bytes.
|
/** Sufficient buffer size for exporting any asymmetric key pair.
|
||||||
*
|
*
|
||||||
* This macro can be used to allocate a buffer of sufficient size to
|
* This macro expands to a compile-time constant integer. This value is
|
||||||
* store the nonce output from #psa_aead_generate_nonce().
|
* a sufficient buffer size when calling psa_export_key() to export any
|
||||||
|
* asymmetric key pair, regardless of the exact key type and key size.
|
||||||
*
|
*
|
||||||
* See also #PSA_AEAD_NONCE_MAX_SIZE.
|
* See also #PSA_EXPORT_KEY_OUTPUT_SIZE(\p key_type, \p key_bits).
|
||||||
|
*/
|
||||||
|
#define PSA_EXPORT_KEY_PAIR_MAX_SIZE \
|
||||||
|
(PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE(PSA_VENDOR_RSA_MAX_KEY_BITS) > \
|
||||||
|
PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS) ? \
|
||||||
|
PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE(PSA_VENDOR_RSA_MAX_KEY_BITS) : \
|
||||||
|
PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS))
|
||||||
|
|
||||||
|
/** Sufficient buffer size for exporting any asymmetric public key.
|
||||||
*
|
*
|
||||||
* \note This is not the maximum size of nonce supported as input to #psa_aead_set_nonce(),
|
* This macro expands to a compile-time constant integer. This value is
|
||||||
* #psa_aead_encrypt() or #psa_aead_decrypt(), just the default size that is generated by
|
* a sufficient buffer size when calling psa_export_key() or
|
||||||
* #psa_aead_generate_nonce().
|
* psa_export_public_key() to export any asymmetric public key,
|
||||||
|
* regardless of the exact key type and key size.
|
||||||
|
*
|
||||||
|
* See also #PSA_EXPORT_PUBLIC_KEY_OUTPUT_SIZE(\p key_type, \p key_bits).
|
||||||
|
*/
|
||||||
|
#define PSA_EXPORT_PUBLIC_KEY_MAX_SIZE \
|
||||||
|
(PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE(PSA_VENDOR_RSA_MAX_KEY_BITS) > \
|
||||||
|
PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS) ? \
|
||||||
|
PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE(PSA_VENDOR_RSA_MAX_KEY_BITS) : \
|
||||||
|
PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS))
|
||||||
|
|
||||||
|
/** Sufficient output buffer size for psa_raw_key_agreement().
|
||||||
|
*
|
||||||
|
* This macro returns a compile-time constant if its arguments are
|
||||||
|
* compile-time constants.
|
||||||
*
|
*
|
||||||
* \warning This macro may evaluate its arguments multiple times or
|
* \warning This macro may evaluate its arguments multiple times or
|
||||||
* zero times, so you should not pass arguments that contain
|
* zero times, so you should not pass arguments that contain
|
||||||
* side effects.
|
* side effects.
|
||||||
*
|
*
|
||||||
* \param key_type A symmetric key type that is compatible with algorithm \p alg.
|
* See also #PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE.
|
||||||
*
|
*
|
||||||
* \param alg An AEAD algorithm (\c PSA_ALG_XXX value such that
|
* \param key_type A supported key type.
|
||||||
* #PSA_ALG_IS_AEAD(\p alg) is true).
|
* \param key_bits The size of the key in bits.
|
||||||
*
|
*
|
||||||
* \return The default nonce size for the specified key type and algorithm.
|
* \return If the parameters are valid and supported, return
|
||||||
* If the key type or AEAD algorithm is not recognized,
|
* a buffer size in bytes that guarantees that
|
||||||
* or the parameters are incompatible, return 0.
|
* psa_raw_key_agreement() will not fail with
|
||||||
* An implementation can return either 0 or a correct size for a key type
|
* #PSA_ERROR_BUFFER_TOO_SMALL.
|
||||||
* and AEAD algorithm that it recognizes, but does not support.
|
* If the parameters are a valid combination that
|
||||||
|
* is not supported, return either a sensible size or 0.
|
||||||
|
* If the parameters are not valid,
|
||||||
|
* the return value is unspecified.
|
||||||
*/
|
*/
|
||||||
#define PSA_AEAD_NONCE_LENGTH(key_type, alg) \
|
/* FFDH is not yet supported in PSA. */
|
||||||
(PSA_BLOCK_CIPHER_BLOCK_SIZE(key_type) == 16 && \
|
#define PSA_RAW_KEY_AGREEMENT_OUTPUT_SIZE(key_type, key_bits) \
|
||||||
(PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH(alg) == PSA_ALG_CCM || \
|
(PSA_KEY_TYPE_IS_ECC_KEY_PAIR(key_type) ? \
|
||||||
PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH(alg) == PSA_ALG_GCM) ? 12 : \
|
PSA_BITS_TO_BYTES(key_bits) : \
|
||||||
(key_type) == PSA_KEY_TYPE_CHACHA20 && \
|
|
||||||
PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH(alg) == PSA_ALG_CHACHA20_POLY1305 ? 12 : \
|
|
||||||
0)
|
0)
|
||||||
|
|
||||||
/** The maximum default nonce size among all supported pairs of key types and
|
/** Maximum size of the output from psa_raw_key_agreement().
|
||||||
* AEAD algorithms, in bytes.
|
|
||||||
*
|
*
|
||||||
* This is equal to or greater than any value that #PSA_AEAD_NONCE_LENGTH() may return.
|
* This macro expands to a compile-time constant integer. This value is the
|
||||||
|
* maximum size of the output any raw key agreement algorithm, in bytes.
|
||||||
*
|
*
|
||||||
* \note This is not the maximum size of nonce supported as input to #psa_aead_set_nonce(),
|
* See also #PSA_RAW_KEY_AGREEMENT_OUTPUT_SIZE(\p key_type, \p key_bits).
|
||||||
* #psa_aead_encrypt() or #psa_aead_decrypt(), just the largest size that may be generated by
|
|
||||||
* #psa_aead_generate_nonce().
|
|
||||||
*/
|
*/
|
||||||
#define PSA_AEAD_NONCE_MAX_SIZE 12
|
#define PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE \
|
||||||
|
(PSA_BITS_TO_BYTES(PSA_VENDOR_ECC_MAX_CURVE_BITS))
|
||||||
|
|
||||||
/** The default IV size for a cipher algorithm, in bytes.
|
/** The default IV size for a cipher algorithm, in bytes.
|
||||||
*
|
*
|
||||||
|
@ -674,17 +906,15 @@
|
||||||
* If the algorithm does not use an IV, return 0.
|
* If the algorithm does not use an IV, return 0.
|
||||||
* If the key type or cipher algorithm is not recognized,
|
* If the key type or cipher algorithm is not recognized,
|
||||||
* or the parameters are incompatible, return 0.
|
* or the parameters are incompatible, return 0.
|
||||||
* An implementation can return either 0 or a correct size for a key type
|
|
||||||
* and cipher algorithm that it recognizes, but does not support.
|
|
||||||
*/
|
*/
|
||||||
#define PSA_CIPHER_IV_LENGTH(key_type, alg) \
|
#define PSA_CIPHER_IV_LENGTH(key_type, alg) \
|
||||||
(PSA_BLOCK_CIPHER_BLOCK_SIZE(key_type) > 1 && \
|
(PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) > 1 && \
|
||||||
((alg) == PSA_ALG_CTR || \
|
((alg) == PSA_ALG_CTR || \
|
||||||
(alg) == PSA_ALG_CFB || \
|
(alg) == PSA_ALG_CFB || \
|
||||||
(alg) == PSA_ALG_OFB || \
|
(alg) == PSA_ALG_OFB || \
|
||||||
(alg) == PSA_ALG_XTS || \
|
(alg) == PSA_ALG_XTS || \
|
||||||
(alg) == PSA_ALG_CBC_NO_PADDING || \
|
(alg) == PSA_ALG_CBC_NO_PADDING || \
|
||||||
(alg) == PSA_ALG_CBC_PKCS7) ? PSA_BLOCK_CIPHER_BLOCK_SIZE(key_type) : \
|
(alg) == PSA_ALG_CBC_PKCS7) ? PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
|
||||||
(key_type) == PSA_KEY_TYPE_CHACHA20 && \
|
(key_type) == PSA_KEY_TYPE_CHACHA20 && \
|
||||||
(alg) == PSA_ALG_STREAM_CIPHER ? 12 : \
|
(alg) == PSA_ALG_STREAM_CIPHER ? 12 : \
|
||||||
0)
|
0)
|
||||||
|
@ -695,4 +925,163 @@
|
||||||
*/
|
*/
|
||||||
#define PSA_CIPHER_IV_MAX_SIZE 16
|
#define PSA_CIPHER_IV_MAX_SIZE 16
|
||||||
|
|
||||||
|
/** The maximum size of the output of psa_cipher_encrypt(), in bytes.
|
||||||
|
*
|
||||||
|
* If the size of the output buffer is at least this large, it is guaranteed
|
||||||
|
* that psa_cipher_encrypt() will not fail due to an insufficient buffer size.
|
||||||
|
* Depending on the algorithm, the actual size of the output might be smaller.
|
||||||
|
*
|
||||||
|
* See also #PSA_CIPHER_ENCRYPT_OUTPUT_MAX_SIZE(\p input_length).
|
||||||
|
*
|
||||||
|
* \warning This macro may evaluate its arguments multiple times or
|
||||||
|
* zero times, so you should not pass arguments that contain
|
||||||
|
* side effects.
|
||||||
|
*
|
||||||
|
* \param key_type A symmetric key type that is compatible with algorithm
|
||||||
|
* alg.
|
||||||
|
* \param alg A cipher algorithm (\c PSA_ALG_XXX value such that
|
||||||
|
* #PSA_ALG_IS_CIPHER(\p alg) is true).
|
||||||
|
* \param input_length Size of the input in bytes.
|
||||||
|
*
|
||||||
|
* \return A sufficient output size for the specified key type and
|
||||||
|
* algorithm. If the key type or cipher algorithm is not
|
||||||
|
* recognized, or the parameters are incompatible,
|
||||||
|
* return 0.
|
||||||
|
*/
|
||||||
|
#define PSA_CIPHER_ENCRYPT_OUTPUT_SIZE(key_type, alg, input_length) \
|
||||||
|
(alg == PSA_ALG_CBC_PKCS7 ? \
|
||||||
|
PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type), \
|
||||||
|
(input_length) + 1) + \
|
||||||
|
PSA_CIPHER_IV_LENGTH((key_type), (alg)) : \
|
||||||
|
(PSA_ALG_IS_CIPHER(alg) ? \
|
||||||
|
(input_length) + PSA_CIPHER_IV_LENGTH((key_type), (alg)) : \
|
||||||
|
0))
|
||||||
|
|
||||||
|
/** A sufficient output buffer size for psa_cipher_encrypt(), for any of the
|
||||||
|
* supported key types and cipher algorithms.
|
||||||
|
*
|
||||||
|
* If the size of the output buffer is at least this large, it is guaranteed
|
||||||
|
* that psa_cipher_encrypt() will not fail due to an insufficient buffer size.
|
||||||
|
*
|
||||||
|
* See also #PSA_CIPHER_ENCRYPT_OUTPUT_SIZE(\p key_type, \p alg, \p input_length).
|
||||||
|
*
|
||||||
|
* \param input_length Size of the input in bytes.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define PSA_CIPHER_ENCRYPT_OUTPUT_MAX_SIZE(input_length) \
|
||||||
|
(PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE, \
|
||||||
|
(input_length) + 1) + \
|
||||||
|
PSA_CIPHER_IV_MAX_SIZE)
|
||||||
|
|
||||||
|
/** The maximum size of the output of psa_cipher_decrypt(), in bytes.
|
||||||
|
*
|
||||||
|
* If the size of the output buffer is at least this large, it is guaranteed
|
||||||
|
* that psa_cipher_decrypt() will not fail due to an insufficient buffer size.
|
||||||
|
* Depending on the algorithm, the actual size of the output might be smaller.
|
||||||
|
*
|
||||||
|
* See also #PSA_CIPHER_DECRYPT_OUTPUT_MAX_SIZE(\p input_length).
|
||||||
|
*
|
||||||
|
* \param key_type A symmetric key type that is compatible with algorithm
|
||||||
|
* alg.
|
||||||
|
* \param alg A cipher algorithm (\c PSA_ALG_XXX value such that
|
||||||
|
* #PSA_ALG_IS_CIPHER(\p alg) is true).
|
||||||
|
* \param input_length Size of the input in bytes.
|
||||||
|
*
|
||||||
|
* \return A sufficient output size for the specified key type and
|
||||||
|
* algorithm. If the key type or cipher algorithm is not
|
||||||
|
* recognized, or the parameters are incompatible,
|
||||||
|
* return 0.
|
||||||
|
*/
|
||||||
|
#define PSA_CIPHER_DECRYPT_OUTPUT_SIZE(key_type, alg, input_length) \
|
||||||
|
(PSA_ALG_IS_CIPHER(alg) && \
|
||||||
|
((key_type) & PSA_KEY_TYPE_CATEGORY_MASK) == PSA_KEY_TYPE_CATEGORY_SYMMETRIC ? \
|
||||||
|
(input_length) : \
|
||||||
|
0)
|
||||||
|
|
||||||
|
/** A sufficient output buffer size for psa_cipher_decrypt(), for any of the
|
||||||
|
* supported key types and cipher algorithms.
|
||||||
|
*
|
||||||
|
* If the size of the output buffer is at least this large, it is guaranteed
|
||||||
|
* that psa_cipher_decrypt() will not fail due to an insufficient buffer size.
|
||||||
|
*
|
||||||
|
* See also #PSA_CIPHER_DECRYPT_OUTPUT_SIZE(\p key_type, \p alg, \p input_length).
|
||||||
|
*
|
||||||
|
* \param input_length Size of the input in bytes.
|
||||||
|
*/
|
||||||
|
#define PSA_CIPHER_DECRYPT_OUTPUT_MAX_SIZE(input_length) \
|
||||||
|
(input_length)
|
||||||
|
|
||||||
|
/** A sufficient output buffer size for psa_cipher_update().
|
||||||
|
*
|
||||||
|
* If the size of the output buffer is at least this large, it is guaranteed
|
||||||
|
* that psa_cipher_update() will not fail due to an insufficient buffer size.
|
||||||
|
* The actual size of the output might be smaller in any given call.
|
||||||
|
*
|
||||||
|
* See also #PSA_CIPHER_UPDATE_OUTPUT_MAX_SIZE(\p input_length).
|
||||||
|
*
|
||||||
|
* \param key_type A symmetric key type that is compatible with algorithm
|
||||||
|
* alg.
|
||||||
|
* \param alg A cipher algorithm (PSA_ALG_XXX value such that
|
||||||
|
* #PSA_ALG_IS_CIPHER(\p alg) is true).
|
||||||
|
* \param input_length Size of the input in bytes.
|
||||||
|
*
|
||||||
|
* \return A sufficient output size for the specified key type and
|
||||||
|
* algorithm. If the key type or cipher algorithm is not
|
||||||
|
* recognized, or the parameters are incompatible, return 0.
|
||||||
|
*/
|
||||||
|
#define PSA_CIPHER_UPDATE_OUTPUT_SIZE(key_type, alg, input_length) \
|
||||||
|
(PSA_ALG_IS_CIPHER(alg) ? \
|
||||||
|
(((alg) == PSA_ALG_CBC_PKCS7 || \
|
||||||
|
(alg) == PSA_ALG_CBC_NO_PADDING || \
|
||||||
|
(alg) == PSA_ALG_ECB_NO_PADDING) ? \
|
||||||
|
PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type), \
|
||||||
|
input_length) : \
|
||||||
|
(input_length)) : \
|
||||||
|
0)
|
||||||
|
|
||||||
|
/** A sufficient output buffer size for psa_cipher_update(), for any of the
|
||||||
|
* supported key types and cipher algorithms.
|
||||||
|
*
|
||||||
|
* If the size of the output buffer is at least this large, it is guaranteed
|
||||||
|
* that psa_cipher_update() will not fail due to an insufficient buffer size.
|
||||||
|
*
|
||||||
|
* See also #PSA_CIPHER_UPDATE_OUTPUT_SIZE(\p key_type, \p alg, \p input_length).
|
||||||
|
*
|
||||||
|
* \param input_length Size of the input in bytes.
|
||||||
|
*/
|
||||||
|
#define PSA_CIPHER_UPDATE_OUTPUT_MAX_SIZE(input_length) \
|
||||||
|
(PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE, input_length))
|
||||||
|
|
||||||
|
/** A sufficient ciphertext buffer size for psa_cipher_finish().
|
||||||
|
*
|
||||||
|
* If the size of the ciphertext buffer is at least this large, it is
|
||||||
|
* guaranteed that psa_cipher_finish() will not fail due to an insufficient
|
||||||
|
* ciphertext buffer size. The actual size of the output might be smaller in
|
||||||
|
* any given call.
|
||||||
|
*
|
||||||
|
* See also #PSA_CIPHER_FINISH_OUTPUT_MAX_SIZE().
|
||||||
|
*
|
||||||
|
* \param key_type A symmetric key type that is compatible with algorithm
|
||||||
|
* alg.
|
||||||
|
* \param alg A cipher algorithm (PSA_ALG_XXX value such that
|
||||||
|
* #PSA_ALG_IS_CIPHER(\p alg) is true).
|
||||||
|
* \return A sufficient output size for the specified key type and
|
||||||
|
* algorithm. If the key type or cipher algorithm is not
|
||||||
|
* recognized, or the parameters are incompatible, return 0.
|
||||||
|
*/
|
||||||
|
#define PSA_CIPHER_FINISH_OUTPUT_SIZE(key_type, alg) \
|
||||||
|
(PSA_ALG_IS_CIPHER(alg) ? \
|
||||||
|
(alg == PSA_ALG_CBC_PKCS7 ? \
|
||||||
|
PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
|
||||||
|
0) : \
|
||||||
|
0)
|
||||||
|
|
||||||
|
/** A sufficient ciphertext buffer size for psa_cipher_finish(), for any of the
|
||||||
|
* supported key types and cipher algorithms.
|
||||||
|
*
|
||||||
|
* See also #PSA_CIPHER_FINISH_OUTPUT_SIZE(\p key_type, \p alg).
|
||||||
|
*/
|
||||||
|
#define PSA_CIPHER_FINISH_OUTPUT_MAX_SIZE \
|
||||||
|
(PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE)
|
||||||
|
|
||||||
#endif /* PSA_CRYPTO_SIZES_H */
|
#endif /* PSA_CRYPTO_SIZES_H */
|
||||||
|
|
|
@ -103,14 +103,14 @@ typedef uint32_t psa_algorithm_t;
|
||||||
* whether the key is _volatile_ or _persistent_.
|
* whether the key is _volatile_ or _persistent_.
|
||||||
* See ::psa_key_persistence_t for more information.
|
* See ::psa_key_persistence_t for more information.
|
||||||
* - Bits 8-31 (#PSA_KEY_LIFETIME_GET_LOCATION(\c lifetime)):
|
* - Bits 8-31 (#PSA_KEY_LIFETIME_GET_LOCATION(\c lifetime)):
|
||||||
* location indicator. This value indicates where the key is stored
|
* location indicator. This value indicates which part of the system
|
||||||
* and where operations on the key are performed.
|
* has access to the key material and can perform operations using the key.
|
||||||
* See ::psa_key_location_t for more information.
|
* See ::psa_key_location_t for more information.
|
||||||
*
|
*
|
||||||
* Volatile keys are automatically destroyed when the application instance
|
* Volatile keys are automatically destroyed when the application instance
|
||||||
* terminates or on a power reset of the device. Persistent keys are
|
* terminates or on a power reset of the device. Persistent keys are
|
||||||
* preserved until the application explicitly destroys them or until an
|
* preserved until the application explicitly destroys them or until an
|
||||||
* implementation-specific device management event occurs (for example,
|
* integration-specific device management event occurs (for example,
|
||||||
* a factory reset).
|
* a factory reset).
|
||||||
*
|
*
|
||||||
* Persistent keys have a key identifier of type #psa_key_id_t.
|
* Persistent keys have a key identifier of type #psa_key_id_t.
|
||||||
|
@ -119,12 +119,10 @@ typedef uint32_t psa_algorithm_t;
|
||||||
* The application can call psa_open_key() to open a persistent key that
|
* The application can call psa_open_key() to open a persistent key that
|
||||||
* it created previously.
|
* it created previously.
|
||||||
*
|
*
|
||||||
* This specification defines two basic lifetime values:
|
* The default lifetime of a key is #PSA_KEY_LIFETIME_VOLATILE. The lifetime
|
||||||
* - Keys with the lifetime #PSA_KEY_LIFETIME_VOLATILE are volatile.
|
* #PSA_KEY_LIFETIME_PERSISTENT is supported if persistent storage is
|
||||||
* All implementations should support this lifetime.
|
* available. Other lifetime values may be supported depending on the
|
||||||
* - Keys with the lifetime #PSA_KEY_LIFETIME_PERSISTENT are persistent.
|
* library configuration.
|
||||||
* All implementations that have access to persistent storage with
|
|
||||||
* appropriate security guarantees should support this lifetime.
|
|
||||||
*/
|
*/
|
||||||
typedef uint32_t psa_key_lifetime_t;
|
typedef uint32_t psa_key_lifetime_t;
|
||||||
|
|
||||||
|
@ -137,35 +135,21 @@ typedef uint32_t psa_key_lifetime_t;
|
||||||
* actually affect persistent keys at different levels is outside the
|
* actually affect persistent keys at different levels is outside the
|
||||||
* scope of the PSA Cryptography specification.
|
* scope of the PSA Cryptography specification.
|
||||||
*
|
*
|
||||||
* This specification defines the following values of persistence levels:
|
* The PSA Cryptography specification defines the following values of
|
||||||
|
* persistence levels:
|
||||||
* - \c 0 = #PSA_KEY_PERSISTENCE_VOLATILE: volatile key.
|
* - \c 0 = #PSA_KEY_PERSISTENCE_VOLATILE: volatile key.
|
||||||
* A volatile key is automatically destroyed by the implementation when
|
* A volatile key is automatically destroyed by the implementation when
|
||||||
* the application instance terminates. In particular, a volatile key
|
* the application instance terminates. In particular, a volatile key
|
||||||
* is automatically destroyed on a power reset of the device.
|
* is automatically destroyed on a power reset of the device.
|
||||||
* - \c 1 = #PSA_KEY_PERSISTENCE_DEFAULT:
|
* - \c 1 = #PSA_KEY_PERSISTENCE_DEFAULT:
|
||||||
* persistent key with a default lifetime.
|
* persistent key with a default lifetime.
|
||||||
* Implementations should support this value if they support persistent
|
* - \c 2-254: currently not supported by Mbed TLS.
|
||||||
* keys at all.
|
|
||||||
* Applications should use this value if they have no specific needs that
|
|
||||||
* are only met by implementation-specific features.
|
|
||||||
* - \c 2-127: persistent key with a PSA-specified lifetime.
|
|
||||||
* The PSA Cryptography specification does not define the meaning of these
|
|
||||||
* values, but other PSA specifications may do so.
|
|
||||||
* - \c 128-254: persistent key with a vendor-specified lifetime.
|
|
||||||
* No PSA specification will define the meaning of these values, so
|
|
||||||
* implementations may choose the meaning freely.
|
|
||||||
* As a guideline, higher persistence levels should cause a key to survive
|
|
||||||
* more management events than lower levels.
|
|
||||||
* - \c 255 = #PSA_KEY_PERSISTENCE_READ_ONLY:
|
* - \c 255 = #PSA_KEY_PERSISTENCE_READ_ONLY:
|
||||||
* read-only or write-once key.
|
* read-only or write-once key.
|
||||||
* A key with this persistence level cannot be destroyed.
|
* A key with this persistence level cannot be destroyed.
|
||||||
* Implementations that support such keys may either allow their creation
|
* Mbed TLS does not currently offer a way to create such keys, but
|
||||||
* through the PSA Cryptography API, preferably only to applications with
|
* integrations of Mbed TLS can use it for built-in keys that the
|
||||||
* the appropriate privilege, or only expose keys created through
|
* application cannot modify (for example, a hardware unique key (HUK)).
|
||||||
* implementation-specific means such as a factory ROM engraving process.
|
|
||||||
* Note that keys that are read-only due to policy restrictions
|
|
||||||
* rather than due to physical limitations should not have this
|
|
||||||
* persistence levels.
|
|
||||||
*
|
*
|
||||||
* \note Key persistence levels are 8-bit values. Key management
|
* \note Key persistence levels are 8-bit values. Key management
|
||||||
* interfaces operate on lifetimes (type ::psa_key_lifetime_t) which
|
* interfaces operate on lifetimes (type ::psa_key_lifetime_t) which
|
||||||
|
@ -175,28 +159,30 @@ typedef uint8_t psa_key_persistence_t;
|
||||||
|
|
||||||
/** Encoding of key location indicators.
|
/** Encoding of key location indicators.
|
||||||
*
|
*
|
||||||
* If an implementation of this API can make calls to external
|
* If an integration of Mbed TLS can make calls to external
|
||||||
* cryptoprocessors such as secure elements, the location of a key
|
* cryptoprocessors such as secure elements, the location of a key
|
||||||
* indicates which secure element performs the operations on the key.
|
* indicates which secure element performs the operations on the key.
|
||||||
* If an implementation offers multiple physical locations for persistent
|
* Depending on the design of the secure element, the key
|
||||||
* storage, the location indicator reflects at which physical location
|
* material may be stored either in the secure element, or
|
||||||
* the key is stored.
|
* in wrapped (encrypted) form alongside the key metadata in the
|
||||||
|
* primary local storage.
|
||||||
*
|
*
|
||||||
* This specification defines the following values of location indicators:
|
* The PSA Cryptography API specification defines the following values of
|
||||||
|
* location indicators:
|
||||||
* - \c 0: primary local storage.
|
* - \c 0: primary local storage.
|
||||||
* All implementations should support this value.
|
* This location is always available.
|
||||||
* The primary local storage is typically the same storage area that
|
* The primary local storage is typically the same storage area that
|
||||||
* contains the key metadata.
|
* contains the key metadata.
|
||||||
* - \c 1: primary secure element.
|
* - \c 1: primary secure element.
|
||||||
* Implementations should support this value if there is a secure element
|
* Integrations of Mbed TLS should support this value if there is a secure
|
||||||
* attached to the operating environment.
|
* element attached to the operating environment.
|
||||||
* As a guideline, secure elements may provide higher resistance against
|
* As a guideline, secure elements may provide higher resistance against
|
||||||
* side channel and physical attacks than the primary local storage, but may
|
* side channel and physical attacks than the primary local storage, but may
|
||||||
* have restrictions on supported key types, sizes, policies and operations
|
* have restrictions on supported key types, sizes, policies and operations
|
||||||
* and may have different performance characteristics.
|
* and may have different performance characteristics.
|
||||||
* - \c 2-0x7fffff: other locations defined by a PSA specification.
|
* - \c 2-0x7fffff: other locations defined by a PSA specification.
|
||||||
* The PSA Cryptography API does not currently assign any meaning to these
|
* The PSA Cryptography API does not currently assign any meaning to these
|
||||||
* locations, but future versions of this specification or other PSA
|
* locations, but future versions of that specification or other PSA
|
||||||
* specifications may do so.
|
* specifications may do so.
|
||||||
* - \c 0x800000-0xffffff: vendor-defined locations.
|
* - \c 0x800000-0xffffff: vendor-defined locations.
|
||||||
* No PSA specification will assign a meaning to locations in this range.
|
* No PSA specification will assign a meaning to locations in this range.
|
||||||
|
@ -211,7 +197,7 @@ typedef uint32_t psa_key_location_t;
|
||||||
*
|
*
|
||||||
* - Applications may freely choose key identifiers in the range
|
* - Applications may freely choose key identifiers in the range
|
||||||
* #PSA_KEY_ID_USER_MIN to #PSA_KEY_ID_USER_MAX.
|
* #PSA_KEY_ID_USER_MIN to #PSA_KEY_ID_USER_MAX.
|
||||||
* - Implementations may define additional key identifiers in the range
|
* - The implementation may define additional key identifiers in the range
|
||||||
* #PSA_KEY_ID_VENDOR_MIN to #PSA_KEY_ID_VENDOR_MAX.
|
* #PSA_KEY_ID_VENDOR_MIN to #PSA_KEY_ID_VENDOR_MAX.
|
||||||
* - 0 is reserved as an invalid key identifier.
|
* - 0 is reserved as an invalid key identifier.
|
||||||
* - Key identifiers outside these ranges are reserved for future use.
|
* - Key identifiers outside these ranges are reserved for future use.
|
||||||
|
@ -243,23 +229,18 @@ typedef uint32_t psa_key_usage_t;
|
||||||
* - The key's policy, comprising usage flags and a specification of
|
* - The key's policy, comprising usage flags and a specification of
|
||||||
* the permitted algorithm(s).
|
* the permitted algorithm(s).
|
||||||
* - Information about the key itself: the key type and its size.
|
* - Information about the key itself: the key type and its size.
|
||||||
* - Implementations may define additional attributes.
|
* - Additional implementation-defined attributes.
|
||||||
*
|
*
|
||||||
* The actual key material is not considered an attribute of a key.
|
* The actual key material is not considered an attribute of a key.
|
||||||
* Key attributes do not contain information that is generally considered
|
* Key attributes do not contain information that is generally considered
|
||||||
* highly confidential.
|
* highly confidential.
|
||||||
*
|
*
|
||||||
* An attribute structure can be a simple data structure where each function
|
* An attribute structure works like a simple data structure where each function
|
||||||
* `psa_set_key_xxx` sets a field and the corresponding function
|
* `psa_set_key_xxx` sets a field and the corresponding function
|
||||||
* `psa_get_key_xxx` retrieves the value of the corresponding field.
|
* `psa_get_key_xxx` retrieves the value of the corresponding field.
|
||||||
* However, implementations may report values that are equivalent to the
|
* However, a future version of the library may report values that are
|
||||||
* original one, but have a different encoding. For example, an
|
* equivalent to the original one, but have a different encoding. Invalid
|
||||||
* implementation may use a more compact representation for types where
|
* values may be mapped to different, also invalid values.
|
||||||
* many bit-patterns are invalid or not supported, and store all values
|
|
||||||
* that it does not support as a special marker value. In such an
|
|
||||||
* implementation, after setting an invalid value, the corresponding
|
|
||||||
* get function returns an invalid value which may not be the one that
|
|
||||||
* was originally stored.
|
|
||||||
*
|
*
|
||||||
* An attribute structure may contain references to auxiliary resources,
|
* An attribute structure may contain references to auxiliary resources,
|
||||||
* for example pointers to allocated memory or indirect references to
|
* for example pointers to allocated memory or indirect references to
|
||||||
|
|
|
@ -24,8 +24,6 @@
|
||||||
#ifndef PSA_CRYPTO_VALUES_H
|
#ifndef PSA_CRYPTO_VALUES_H
|
||||||
#define PSA_CRYPTO_VALUES_H
|
#define PSA_CRYPTO_VALUES_H
|
||||||
|
|
||||||
#include "mbedtls_svc_key_id.h"
|
|
||||||
|
|
||||||
/** \defgroup error Error codes
|
/** \defgroup error Error codes
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
@ -264,6 +262,46 @@
|
||||||
*/
|
*/
|
||||||
#define PSA_ERROR_INVALID_HANDLE ((psa_status_t)-136)
|
#define PSA_ERROR_INVALID_HANDLE ((psa_status_t)-136)
|
||||||
|
|
||||||
|
/** Stored data has been corrupted.
|
||||||
|
*
|
||||||
|
* This error indicates that some persistent storage has suffered corruption.
|
||||||
|
* It does not indicate the following situations, which have specific error
|
||||||
|
* codes:
|
||||||
|
*
|
||||||
|
* - A corruption of volatile memory - use #PSA_ERROR_CORRUPTION_DETECTED.
|
||||||
|
* - A communication error between the cryptoprocessor and its external
|
||||||
|
* storage - use #PSA_ERROR_COMMUNICATION_FAILURE.
|
||||||
|
* - When the storage is in a valid state but is full - use
|
||||||
|
* #PSA_ERROR_INSUFFICIENT_STORAGE.
|
||||||
|
* - When the storage fails for other reasons - use
|
||||||
|
* #PSA_ERROR_STORAGE_FAILURE.
|
||||||
|
* - When the stored data is not valid - use #PSA_ERROR_DATA_INVALID.
|
||||||
|
*
|
||||||
|
* \note A storage corruption does not indicate that any data that was
|
||||||
|
* previously read is invalid. However this previously read data might no
|
||||||
|
* longer be readable from storage.
|
||||||
|
*
|
||||||
|
* When a storage failure occurs, it is no longer possible to ensure the
|
||||||
|
* global integrity of the keystore.
|
||||||
|
*/
|
||||||
|
#define PSA_ERROR_DATA_CORRUPT ((psa_status_t)-152)
|
||||||
|
|
||||||
|
/** Data read from storage is not valid for the implementation.
|
||||||
|
*
|
||||||
|
* This error indicates that some data read from storage does not have a valid
|
||||||
|
* format. It does not indicate the following situations, which have specific
|
||||||
|
* error codes:
|
||||||
|
*
|
||||||
|
* - When the storage or stored data is corrupted - use #PSA_ERROR_DATA_CORRUPT
|
||||||
|
* - When the storage fails for other reasons - use #PSA_ERROR_STORAGE_FAILURE
|
||||||
|
* - An invalid argument to the API - use #PSA_ERROR_INVALID_ARGUMENT
|
||||||
|
*
|
||||||
|
* This error is typically a result of either storage corruption on a
|
||||||
|
* cleartext storage backend, or an attempt to read data that was
|
||||||
|
* written by an incompatible version of the library.
|
||||||
|
*/
|
||||||
|
#define PSA_ERROR_DATA_INVALID ((psa_status_t)-153)
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
/** \defgroup crypto_types Key and algorithm types
|
/** \defgroup crypto_types Key and algorithm types
|
||||||
|
@ -357,17 +395,61 @@
|
||||||
* used for.
|
* used for.
|
||||||
*
|
*
|
||||||
* HMAC keys should generally have the same size as the underlying hash.
|
* HMAC keys should generally have the same size as the underlying hash.
|
||||||
* This size can be calculated with #PSA_HASH_SIZE(\c alg) where
|
* This size can be calculated with #PSA_HASH_LENGTH(\c alg) where
|
||||||
* \c alg is the HMAC algorithm or the underlying hash algorithm. */
|
* \c alg is the HMAC algorithm or the underlying hash algorithm. */
|
||||||
#define PSA_KEY_TYPE_HMAC ((psa_key_type_t)0x1100)
|
#define PSA_KEY_TYPE_HMAC ((psa_key_type_t)0x1100)
|
||||||
|
|
||||||
/** A secret for key derivation.
|
/** A secret for key derivation.
|
||||||
|
*
|
||||||
|
* This key type is for high-entropy secrets only. For low-entropy secrets,
|
||||||
|
* #PSA_KEY_TYPE_PASSWORD should be used instead.
|
||||||
|
*
|
||||||
|
* These keys can be used as the #PSA_KEY_DERIVATION_INPUT_SECRET or
|
||||||
|
* #PSA_KEY_DERIVATION_INPUT_PASSWORD input of key derivation algorithms.
|
||||||
*
|
*
|
||||||
* The key policy determines which key derivation algorithm the key
|
* The key policy determines which key derivation algorithm the key
|
||||||
* can be used for.
|
* can be used for.
|
||||||
*/
|
*/
|
||||||
#define PSA_KEY_TYPE_DERIVE ((psa_key_type_t)0x1200)
|
#define PSA_KEY_TYPE_DERIVE ((psa_key_type_t)0x1200)
|
||||||
|
|
||||||
|
/** A low-entropy secret for password hashing or key derivation.
|
||||||
|
*
|
||||||
|
* This key type is suitable for passwords and passphrases which are typically
|
||||||
|
* intended to be memorizable by humans, and have a low entropy relative to
|
||||||
|
* their size. It can be used for randomly generated or derived keys with
|
||||||
|
* maximum or near-maximum entropy, but #PSA_KEY_TYPE_DERIVE is more suitable
|
||||||
|
* for such keys. It is not suitable for passwords with extremely low entropy,
|
||||||
|
* such as numerical PINs.
|
||||||
|
*
|
||||||
|
* These keys can be used as the #PSA_KEY_DERIVATION_INPUT_PASSWORD input of
|
||||||
|
* key derivation algorithms. Algorithms that accept such an input were
|
||||||
|
* designed to accept low-entropy secret and are known as password hashing or
|
||||||
|
* key stretching algorithms.
|
||||||
|
*
|
||||||
|
* These keys cannot be used as the #PSA_KEY_DERIVATION_INPUT_SECRET input of
|
||||||
|
* key derivation algorithms, as the algorithms that take such an input expect
|
||||||
|
* it to be high-entropy.
|
||||||
|
*
|
||||||
|
* The key policy determines which key derivation algorithm the key can be
|
||||||
|
* used for, among the permissible subset defined above.
|
||||||
|
*/
|
||||||
|
#define PSA_KEY_TYPE_PASSWORD ((psa_key_type_t)0x1203)
|
||||||
|
|
||||||
|
/** A secret value that can be used to verify a password hash.
|
||||||
|
*
|
||||||
|
* The key policy determines which key derivation algorithm the key
|
||||||
|
* can be used for, among the same permissible subset as for
|
||||||
|
* #PSA_KEY_TYPE_PASSWORD.
|
||||||
|
*/
|
||||||
|
#define PSA_KEY_TYPE_PASSWORD_HASH ((psa_key_type_t)0x1205)
|
||||||
|
|
||||||
|
/** A secret value that can be used in when computing a password hash.
|
||||||
|
*
|
||||||
|
* The key policy determines which key derivation algorithm the key
|
||||||
|
* can be used for, among the subset of algorithms that can use pepper.
|
||||||
|
*/
|
||||||
|
#define PSA_KEY_TYPE_PEPPER ((psa_key_type_t)0x1206)
|
||||||
|
|
||||||
/** Key for a cipher, AEAD or MAC algorithm based on the AES block cipher.
|
/** Key for a cipher, AEAD or MAC algorithm based on the AES block cipher.
|
||||||
*
|
*
|
||||||
* The size of the key can be 16 bytes (AES-128), 24 bytes (AES-192) or
|
* The size of the key can be 16 bytes (AES-128), 24 bytes (AES-192) or
|
||||||
|
@ -377,8 +459,8 @@
|
||||||
|
|
||||||
/** Key for a cipher or MAC algorithm based on DES or 3DES (Triple-DES).
|
/** Key for a cipher or MAC algorithm based on DES or 3DES (Triple-DES).
|
||||||
*
|
*
|
||||||
* The size of the key can be 8 bytes (single DES), 16 bytes (2-key 3DES) or
|
* The size of the key can be 64 bits (single DES), 128 bits (2-key 3DES) or
|
||||||
* 24 bytes (3-key 3DES).
|
* 192 bits (3-key 3DES).
|
||||||
*
|
*
|
||||||
* Note that single DES and 2-key 3DES are weak and strongly
|
* Note that single DES and 2-key 3DES are weak and strongly
|
||||||
* deprecated and should only be used to decrypt legacy data. 3-key 3DES
|
* deprecated and should only be used to decrypt legacy data. 3-key 3DES
|
||||||
|
@ -390,12 +472,6 @@
|
||||||
* Camellia block cipher. */
|
* Camellia block cipher. */
|
||||||
#define PSA_KEY_TYPE_CAMELLIA ((psa_key_type_t)0x2403)
|
#define PSA_KEY_TYPE_CAMELLIA ((psa_key_type_t)0x2403)
|
||||||
|
|
||||||
/** Key for the RC4 stream cipher.
|
|
||||||
*
|
|
||||||
* Note that RC4 is weak and deprecated and should only be used in
|
|
||||||
* legacy protocols. */
|
|
||||||
#define PSA_KEY_TYPE_ARC4 ((psa_key_type_t)0x2002)
|
|
||||||
|
|
||||||
/** Key for the ChaCha20 stream cipher or the Chacha20-Poly1305 AEAD algorithm.
|
/** Key for the ChaCha20 stream cipher or the Chacha20-Poly1305 AEAD algorithm.
|
||||||
*
|
*
|
||||||
* ChaCha20 and the ChaCha20_Poly1305 construction are defined in RFC 7539.
|
* ChaCha20 and the ChaCha20_Poly1305 construction are defined in RFC 7539.
|
||||||
|
@ -405,9 +481,15 @@
|
||||||
*/
|
*/
|
||||||
#define PSA_KEY_TYPE_CHACHA20 ((psa_key_type_t)0x2004)
|
#define PSA_KEY_TYPE_CHACHA20 ((psa_key_type_t)0x2004)
|
||||||
|
|
||||||
/** RSA public key. */
|
/** RSA public key.
|
||||||
|
*
|
||||||
|
* The size of an RSA key is the bit size of the modulus.
|
||||||
|
*/
|
||||||
#define PSA_KEY_TYPE_RSA_PUBLIC_KEY ((psa_key_type_t)0x4001)
|
#define PSA_KEY_TYPE_RSA_PUBLIC_KEY ((psa_key_type_t)0x4001)
|
||||||
/** RSA key pair (private and public key). */
|
/** RSA key pair (private and public key).
|
||||||
|
*
|
||||||
|
* The size of an RSA key is the bit size of the modulus.
|
||||||
|
*/
|
||||||
#define PSA_KEY_TYPE_RSA_KEY_PAIR ((psa_key_type_t)0x7001)
|
#define PSA_KEY_TYPE_RSA_KEY_PAIR ((psa_key_type_t)0x7001)
|
||||||
/** Whether a key type is an RSA key (pair or public-only). */
|
/** Whether a key type is an RSA key (pair or public-only). */
|
||||||
#define PSA_KEY_TYPE_IS_RSA(type) \
|
#define PSA_KEY_TYPE_IS_RSA(type) \
|
||||||
|
@ -417,6 +499,10 @@
|
||||||
#define PSA_KEY_TYPE_ECC_KEY_PAIR_BASE ((psa_key_type_t)0x7100)
|
#define PSA_KEY_TYPE_ECC_KEY_PAIR_BASE ((psa_key_type_t)0x7100)
|
||||||
#define PSA_KEY_TYPE_ECC_CURVE_MASK ((psa_key_type_t)0x00ff)
|
#define PSA_KEY_TYPE_ECC_CURVE_MASK ((psa_key_type_t)0x00ff)
|
||||||
/** Elliptic curve key pair.
|
/** Elliptic curve key pair.
|
||||||
|
*
|
||||||
|
* The size of an elliptic curve key is the bit size associated with the curve,
|
||||||
|
* i.e. the bit size of *q* for a curve over a field *F<sub>q</sub>*.
|
||||||
|
* See the documentation of `PSA_ECC_FAMILY_xxx` curve families for details.
|
||||||
*
|
*
|
||||||
* \param curve A value of type ::psa_ecc_family_t that
|
* \param curve A value of type ::psa_ecc_family_t that
|
||||||
* identifies the ECC curve to be used.
|
* identifies the ECC curve to be used.
|
||||||
|
@ -424,6 +510,10 @@
|
||||||
#define PSA_KEY_TYPE_ECC_KEY_PAIR(curve) \
|
#define PSA_KEY_TYPE_ECC_KEY_PAIR(curve) \
|
||||||
(PSA_KEY_TYPE_ECC_KEY_PAIR_BASE | (curve))
|
(PSA_KEY_TYPE_ECC_KEY_PAIR_BASE | (curve))
|
||||||
/** Elliptic curve public key.
|
/** Elliptic curve public key.
|
||||||
|
*
|
||||||
|
* The size of an elliptic curve public key is the same as the corresponding
|
||||||
|
* private key (see #PSA_KEY_TYPE_ECC_KEY_PAIR and the documentation of
|
||||||
|
* `PSA_ECC_FAMILY_xxx` curve families).
|
||||||
*
|
*
|
||||||
* \param curve A value of type ::psa_ecc_family_t that
|
* \param curve A value of type ::psa_ecc_family_t that
|
||||||
* identifies the ECC curve to be used.
|
* identifies the ECC curve to be used.
|
||||||
|
@ -523,6 +613,22 @@
|
||||||
*/
|
*/
|
||||||
#define PSA_ECC_FAMILY_MONTGOMERY ((psa_ecc_family_t) 0x41)
|
#define PSA_ECC_FAMILY_MONTGOMERY ((psa_ecc_family_t) 0x41)
|
||||||
|
|
||||||
|
/** The twisted Edwards curves Ed25519 and Ed448.
|
||||||
|
*
|
||||||
|
* These curves are suitable for EdDSA (#PSA_ALG_PURE_EDDSA for both curves,
|
||||||
|
* #PSA_ALG_ED25519PH for the 255-bit curve,
|
||||||
|
* #PSA_ALG_ED448PH for the 448-bit curve).
|
||||||
|
*
|
||||||
|
* This family comprises the following twisted Edwards curves:
|
||||||
|
* - 255-bit: Edwards25519, the twisted Edwards curve birationally equivalent
|
||||||
|
* to Curve25519.
|
||||||
|
* Bernstein et al., _Twisted Edwards curves_, Africacrypt 2008.
|
||||||
|
* - 448-bit: Edwards448, the twisted Edwards curve birationally equivalent
|
||||||
|
* to Curve448.
|
||||||
|
* Hamburg, _Ed448-Goldilocks, a new elliptic curve_, NIST ECC Workshop, 2015.
|
||||||
|
*/
|
||||||
|
#define PSA_ECC_FAMILY_TWISTED_EDWARDS ((psa_ecc_family_t) 0x42)
|
||||||
|
|
||||||
#define PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE ((psa_key_type_t)0x4200)
|
#define PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE ((psa_key_type_t)0x4200)
|
||||||
#define PSA_KEY_TYPE_DH_KEY_PAIR_BASE ((psa_key_type_t)0x7200)
|
#define PSA_KEY_TYPE_DH_KEY_PAIR_BASE ((psa_key_type_t)0x7200)
|
||||||
#define PSA_KEY_TYPE_DH_GROUP_MASK ((psa_key_type_t)0x00ff)
|
#define PSA_KEY_TYPE_DH_GROUP_MASK ((psa_key_type_t)0x00ff)
|
||||||
|
@ -588,9 +694,9 @@
|
||||||
*
|
*
|
||||||
* \warning This macro may evaluate its argument multiple times.
|
* \warning This macro may evaluate its argument multiple times.
|
||||||
*/
|
*/
|
||||||
#define PSA_BLOCK_CIPHER_BLOCK_SIZE(type) \
|
#define PSA_BLOCK_CIPHER_BLOCK_LENGTH(type) \
|
||||||
(((type) & PSA_KEY_TYPE_CATEGORY_MASK) == PSA_KEY_TYPE_CATEGORY_SYMMETRIC ? \
|
(((type) & PSA_KEY_TYPE_CATEGORY_MASK) == PSA_KEY_TYPE_CATEGORY_SYMMETRIC ? \
|
||||||
1u << PSA_GET_KEY_TYPE_BLOCK_SIZE_EXPONENT(type) : \
|
1u << PSA_GET_KEY_TYPE_BLOCK_SIZE_EXPONENT(type) : \
|
||||||
0u)
|
0u)
|
||||||
|
|
||||||
/** Vendor-defined algorithm flag.
|
/** Vendor-defined algorithm flag.
|
||||||
|
@ -710,11 +816,25 @@
|
||||||
#define PSA_ALG_IS_KEY_DERIVATION(alg) \
|
#define PSA_ALG_IS_KEY_DERIVATION(alg) \
|
||||||
(((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_KEY_DERIVATION)
|
(((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_KEY_DERIVATION)
|
||||||
|
|
||||||
|
/** Whether the specified algorithm is a key stretching / password hashing
|
||||||
|
* algorithm.
|
||||||
|
*
|
||||||
|
* A key stretching / password hashing algorithm is a key derivation algorithm
|
||||||
|
* that is suitable for use with a low-entropy secret such as a password.
|
||||||
|
* Equivalently, it's a key derivation algorithm that uses a
|
||||||
|
* #PSA_KEY_DERIVATION_INPUT_PASSWORD input step.
|
||||||
|
*
|
||||||
|
* \param alg An algorithm identifier (value of type #psa_algorithm_t).
|
||||||
|
*
|
||||||
|
* \return 1 if \p alg is a key stretching / password hashing algorithm, 0
|
||||||
|
* otherwise. This macro may return either 0 or 1 if \p alg is not a
|
||||||
|
* supported algorithm identifier.
|
||||||
|
*/
|
||||||
|
#define PSA_ALG_IS_KEY_DERIVATION_STRETCHING(alg) \
|
||||||
|
(PSA_ALG_IS_KEY_DERIVATION(alg) && \
|
||||||
|
(alg) & PSA_ALG_KEY_DERIVATION_STRETCHING_FLAG)
|
||||||
|
|
||||||
#define PSA_ALG_HASH_MASK ((psa_algorithm_t)0x000000ff)
|
#define PSA_ALG_HASH_MASK ((psa_algorithm_t)0x000000ff)
|
||||||
/** MD2 */
|
|
||||||
#define PSA_ALG_MD2 ((psa_algorithm_t)0x02000001)
|
|
||||||
/** MD4 */
|
|
||||||
#define PSA_ALG_MD4 ((psa_algorithm_t)0x02000002)
|
|
||||||
/** MD5 */
|
/** MD5 */
|
||||||
#define PSA_ALG_MD5 ((psa_algorithm_t)0x02000003)
|
#define PSA_ALG_MD5 ((psa_algorithm_t)0x02000003)
|
||||||
/** PSA_ALG_RIPEMD160 */
|
/** PSA_ALG_RIPEMD160 */
|
||||||
|
@ -741,6 +861,13 @@
|
||||||
#define PSA_ALG_SHA3_384 ((psa_algorithm_t)0x02000012)
|
#define PSA_ALG_SHA3_384 ((psa_algorithm_t)0x02000012)
|
||||||
/** SHA3-512 */
|
/** SHA3-512 */
|
||||||
#define PSA_ALG_SHA3_512 ((psa_algorithm_t)0x02000013)
|
#define PSA_ALG_SHA3_512 ((psa_algorithm_t)0x02000013)
|
||||||
|
/** The first 512 bits (64 bytes) of the SHAKE256 output.
|
||||||
|
*
|
||||||
|
* This is the prehashing for Ed448ph (see #PSA_ALG_ED448PH). For other
|
||||||
|
* scenarios where a hash function based on SHA3/SHAKE is desired, SHA3-512
|
||||||
|
* has the same output size and a (theoretically) higher security strength.
|
||||||
|
*/
|
||||||
|
#define PSA_ALG_SHAKE256_512 ((psa_algorithm_t)0x02000015)
|
||||||
|
|
||||||
/** In a hash-and-sign algorithm policy, allow any hash algorithm.
|
/** In a hash-and-sign algorithm policy, allow any hash algorithm.
|
||||||
*
|
*
|
||||||
|
@ -820,6 +947,14 @@
|
||||||
#define PSA_ALG_MAC_TRUNCATION_MASK ((psa_algorithm_t)0x003f0000)
|
#define PSA_ALG_MAC_TRUNCATION_MASK ((psa_algorithm_t)0x003f0000)
|
||||||
#define PSA_MAC_TRUNCATION_OFFSET 16
|
#define PSA_MAC_TRUNCATION_OFFSET 16
|
||||||
|
|
||||||
|
/* In the encoding of a MAC algorithm, the bit corresponding to
|
||||||
|
* #PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG encodes the fact that the algorithm
|
||||||
|
* is a wildcard algorithm. A key with such wildcard algorithm as permitted
|
||||||
|
* algorithm policy can be used with any algorithm corresponding to the
|
||||||
|
* same base class and having a (potentially truncated) MAC length greater or
|
||||||
|
* equal than the one encoded in #PSA_ALG_MAC_TRUNCATION_MASK. */
|
||||||
|
#define PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG ((psa_algorithm_t)0x00008000)
|
||||||
|
|
||||||
/** Macro to build a truncated MAC algorithm.
|
/** Macro to build a truncated MAC algorithm.
|
||||||
*
|
*
|
||||||
* A truncated MAC algorithm is identical to the corresponding MAC
|
* A truncated MAC algorithm is identical to the corresponding MAC
|
||||||
|
@ -838,7 +973,7 @@
|
||||||
* for policy comparison purposes.
|
* for policy comparison purposes.
|
||||||
*
|
*
|
||||||
* \param mac_alg A MAC algorithm identifier (value of type
|
* \param mac_alg A MAC algorithm identifier (value of type
|
||||||
* #psa_algorithm_t such that #PSA_ALG_IS_MAC(\p alg)
|
* #psa_algorithm_t such that #PSA_ALG_IS_MAC(\p mac_alg)
|
||||||
* is true). This may be a truncated or untruncated
|
* is true). This may be a truncated or untruncated
|
||||||
* MAC algorithm.
|
* MAC algorithm.
|
||||||
* \param mac_length Desired length of the truncated MAC in bytes.
|
* \param mac_length Desired length of the truncated MAC in bytes.
|
||||||
|
@ -849,43 +984,73 @@
|
||||||
*
|
*
|
||||||
* \return The corresponding MAC algorithm with the specified
|
* \return The corresponding MAC algorithm with the specified
|
||||||
* length.
|
* length.
|
||||||
* \return Unspecified if \p alg is not a supported
|
* \return Unspecified if \p mac_alg is not a supported
|
||||||
* MAC algorithm or if \p mac_length is too small or
|
* MAC algorithm or if \p mac_length is too small or
|
||||||
* too large for the specified MAC algorithm.
|
* too large for the specified MAC algorithm.
|
||||||
*/
|
*/
|
||||||
#define PSA_ALG_TRUNCATED_MAC(mac_alg, mac_length) \
|
#define PSA_ALG_TRUNCATED_MAC(mac_alg, mac_length) \
|
||||||
(((mac_alg) & ~PSA_ALG_MAC_TRUNCATION_MASK) | \
|
(((mac_alg) & ~(PSA_ALG_MAC_TRUNCATION_MASK | \
|
||||||
|
PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG)) | \
|
||||||
((mac_length) << PSA_MAC_TRUNCATION_OFFSET & PSA_ALG_MAC_TRUNCATION_MASK))
|
((mac_length) << PSA_MAC_TRUNCATION_OFFSET & PSA_ALG_MAC_TRUNCATION_MASK))
|
||||||
|
|
||||||
/** Macro to build the base MAC algorithm corresponding to a truncated
|
/** Macro to build the base MAC algorithm corresponding to a truncated
|
||||||
* MAC algorithm.
|
* MAC algorithm.
|
||||||
*
|
*
|
||||||
* \param mac_alg A MAC algorithm identifier (value of type
|
* \param mac_alg A MAC algorithm identifier (value of type
|
||||||
* #psa_algorithm_t such that #PSA_ALG_IS_MAC(\p alg)
|
* #psa_algorithm_t such that #PSA_ALG_IS_MAC(\p mac_alg)
|
||||||
* is true). This may be a truncated or untruncated
|
* is true). This may be a truncated or untruncated
|
||||||
* MAC algorithm.
|
* MAC algorithm.
|
||||||
*
|
*
|
||||||
* \return The corresponding base MAC algorithm.
|
* \return The corresponding base MAC algorithm.
|
||||||
* \return Unspecified if \p alg is not a supported
|
* \return Unspecified if \p mac_alg is not a supported
|
||||||
* MAC algorithm.
|
* MAC algorithm.
|
||||||
*/
|
*/
|
||||||
#define PSA_ALG_FULL_LENGTH_MAC(mac_alg) \
|
#define PSA_ALG_FULL_LENGTH_MAC(mac_alg) \
|
||||||
((mac_alg) & ~PSA_ALG_MAC_TRUNCATION_MASK)
|
((mac_alg) & ~(PSA_ALG_MAC_TRUNCATION_MASK | \
|
||||||
|
PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG))
|
||||||
|
|
||||||
/** Length to which a MAC algorithm is truncated.
|
/** Length to which a MAC algorithm is truncated.
|
||||||
*
|
*
|
||||||
* \param mac_alg A MAC algorithm identifier (value of type
|
* \param mac_alg A MAC algorithm identifier (value of type
|
||||||
* #psa_algorithm_t such that #PSA_ALG_IS_MAC(\p alg)
|
* #psa_algorithm_t such that #PSA_ALG_IS_MAC(\p mac_alg)
|
||||||
* is true).
|
* is true).
|
||||||
*
|
*
|
||||||
* \return Length of the truncated MAC in bytes.
|
* \return Length of the truncated MAC in bytes.
|
||||||
* \return 0 if \p alg is a non-truncated MAC algorithm.
|
* \return 0 if \p mac_alg is a non-truncated MAC algorithm.
|
||||||
* \return Unspecified if \p alg is not a supported
|
* \return Unspecified if \p mac_alg is not a supported
|
||||||
* MAC algorithm.
|
* MAC algorithm.
|
||||||
*/
|
*/
|
||||||
#define PSA_MAC_TRUNCATED_LENGTH(mac_alg) \
|
#define PSA_MAC_TRUNCATED_LENGTH(mac_alg) \
|
||||||
(((mac_alg) & PSA_ALG_MAC_TRUNCATION_MASK) >> PSA_MAC_TRUNCATION_OFFSET)
|
(((mac_alg) & PSA_ALG_MAC_TRUNCATION_MASK) >> PSA_MAC_TRUNCATION_OFFSET)
|
||||||
|
|
||||||
|
/** Macro to build a MAC minimum-MAC-length wildcard algorithm.
|
||||||
|
*
|
||||||
|
* A minimum-MAC-length MAC wildcard algorithm permits all MAC algorithms
|
||||||
|
* sharing the same base algorithm, and where the (potentially truncated) MAC
|
||||||
|
* length of the specific algorithm is equal to or larger then the wildcard
|
||||||
|
* algorithm's minimum MAC length.
|
||||||
|
*
|
||||||
|
* \note When setting the minimum required MAC length to less than the
|
||||||
|
* smallest MAC length allowed by the base algorithm, this effectively
|
||||||
|
* becomes an 'any-MAC-length-allowed' policy for that base algorithm.
|
||||||
|
*
|
||||||
|
* \param mac_alg A MAC algorithm identifier (value of type
|
||||||
|
* #psa_algorithm_t such that #PSA_ALG_IS_MAC(\p mac_alg)
|
||||||
|
* is true).
|
||||||
|
* \param min_mac_length Desired minimum length of the message authentication
|
||||||
|
* code in bytes. This must be at most the untruncated
|
||||||
|
* length of the MAC and must be at least 1.
|
||||||
|
*
|
||||||
|
* \return The corresponding MAC wildcard algorithm with the
|
||||||
|
* specified minimum length.
|
||||||
|
* \return Unspecified if \p mac_alg is not a supported MAC
|
||||||
|
* algorithm or if \p min_mac_length is less than 1 or
|
||||||
|
* too large for the specified MAC algorithm.
|
||||||
|
*/
|
||||||
|
#define PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(mac_alg, min_mac_length) \
|
||||||
|
( PSA_ALG_TRUNCATED_MAC(mac_alg, min_mac_length) | \
|
||||||
|
PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG )
|
||||||
|
|
||||||
#define PSA_ALG_CIPHER_MAC_BASE ((psa_algorithm_t)0x03c00000)
|
#define PSA_ALG_CIPHER_MAC_BASE ((psa_algorithm_t)0x03c00000)
|
||||||
/** The CBC-MAC construction over a block cipher
|
/** The CBC-MAC construction over a block cipher
|
||||||
*
|
*
|
||||||
|
@ -931,7 +1096,6 @@
|
||||||
*
|
*
|
||||||
* The underlying stream cipher is determined by the key type.
|
* The underlying stream cipher is determined by the key type.
|
||||||
* - To use ChaCha20, use a key type of #PSA_KEY_TYPE_CHACHA20.
|
* - To use ChaCha20, use a key type of #PSA_KEY_TYPE_CHACHA20.
|
||||||
* - To use ARC4, use a key type of #PSA_KEY_TYPE_ARC4.
|
|
||||||
*/
|
*/
|
||||||
#define PSA_ALG_STREAM_CIPHER ((psa_algorithm_t)0x04800100)
|
#define PSA_ALG_STREAM_CIPHER ((psa_algorithm_t)0x04800100)
|
||||||
|
|
||||||
|
@ -1046,6 +1210,14 @@
|
||||||
#define PSA_ALG_AEAD_TAG_LENGTH_MASK ((psa_algorithm_t)0x003f0000)
|
#define PSA_ALG_AEAD_TAG_LENGTH_MASK ((psa_algorithm_t)0x003f0000)
|
||||||
#define PSA_AEAD_TAG_LENGTH_OFFSET 16
|
#define PSA_AEAD_TAG_LENGTH_OFFSET 16
|
||||||
|
|
||||||
|
/* In the encoding of an AEAD algorithm, the bit corresponding to
|
||||||
|
* #PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG encodes the fact that the algorithm
|
||||||
|
* is a wildcard algorithm. A key with such wildcard algorithm as permitted
|
||||||
|
* algorithm policy can be used with any algorithm corresponding to the
|
||||||
|
* same base class and having a tag length greater than or equal to the one
|
||||||
|
* encoded in #PSA_ALG_AEAD_TAG_LENGTH_MASK. */
|
||||||
|
#define PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG ((psa_algorithm_t)0x00008000)
|
||||||
|
|
||||||
/** Macro to build a shortened AEAD algorithm.
|
/** Macro to build a shortened AEAD algorithm.
|
||||||
*
|
*
|
||||||
* A shortened AEAD algorithm is similar to the corresponding AEAD
|
* A shortened AEAD algorithm is similar to the corresponding AEAD
|
||||||
|
@ -1054,40 +1226,83 @@
|
||||||
* of the ciphertext.
|
* of the ciphertext.
|
||||||
*
|
*
|
||||||
* \param aead_alg An AEAD algorithm identifier (value of type
|
* \param aead_alg An AEAD algorithm identifier (value of type
|
||||||
* #psa_algorithm_t such that #PSA_ALG_IS_AEAD(\p alg)
|
* #psa_algorithm_t such that #PSA_ALG_IS_AEAD(\p aead_alg)
|
||||||
* is true).
|
* is true).
|
||||||
* \param tag_length Desired length of the authentication tag in bytes.
|
* \param tag_length Desired length of the authentication tag in bytes.
|
||||||
*
|
*
|
||||||
* \return The corresponding AEAD algorithm with the specified
|
* \return The corresponding AEAD algorithm with the specified
|
||||||
* length.
|
* length.
|
||||||
* \return Unspecified if \p alg is not a supported
|
* \return Unspecified if \p aead_alg is not a supported
|
||||||
* AEAD algorithm or if \p tag_length is not valid
|
* AEAD algorithm or if \p tag_length is not valid
|
||||||
* for the specified AEAD algorithm.
|
* for the specified AEAD algorithm.
|
||||||
*/
|
*/
|
||||||
#define PSA_ALG_AEAD_WITH_TAG_LENGTH(aead_alg, tag_length) \
|
#define PSA_ALG_AEAD_WITH_SHORTENED_TAG(aead_alg, tag_length) \
|
||||||
(((aead_alg) & ~PSA_ALG_AEAD_TAG_LENGTH_MASK) | \
|
(((aead_alg) & ~(PSA_ALG_AEAD_TAG_LENGTH_MASK | \
|
||||||
|
PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG)) | \
|
||||||
((tag_length) << PSA_AEAD_TAG_LENGTH_OFFSET & \
|
((tag_length) << PSA_AEAD_TAG_LENGTH_OFFSET & \
|
||||||
PSA_ALG_AEAD_TAG_LENGTH_MASK))
|
PSA_ALG_AEAD_TAG_LENGTH_MASK))
|
||||||
|
|
||||||
|
/** Retrieve the tag length of a specified AEAD algorithm
|
||||||
|
*
|
||||||
|
* \param aead_alg An AEAD algorithm identifier (value of type
|
||||||
|
* #psa_algorithm_t such that #PSA_ALG_IS_AEAD(\p aead_alg)
|
||||||
|
* is true).
|
||||||
|
*
|
||||||
|
* \return The tag length specified by the input algorithm.
|
||||||
|
* \return Unspecified if \p aead_alg is not a supported
|
||||||
|
* AEAD algorithm.
|
||||||
|
*/
|
||||||
|
#define PSA_ALG_AEAD_GET_TAG_LENGTH(aead_alg) \
|
||||||
|
(((aead_alg) & PSA_ALG_AEAD_TAG_LENGTH_MASK) >> \
|
||||||
|
PSA_AEAD_TAG_LENGTH_OFFSET )
|
||||||
|
|
||||||
/** Calculate the corresponding AEAD algorithm with the default tag length.
|
/** Calculate the corresponding AEAD algorithm with the default tag length.
|
||||||
*
|
*
|
||||||
* \param aead_alg An AEAD algorithm (\c PSA_ALG_XXX value such that
|
* \param aead_alg An AEAD algorithm (\c PSA_ALG_XXX value such that
|
||||||
* #PSA_ALG_IS_AEAD(\p alg) is true).
|
* #PSA_ALG_IS_AEAD(\p aead_alg) is true).
|
||||||
*
|
*
|
||||||
* \return The corresponding AEAD algorithm with the default
|
* \return The corresponding AEAD algorithm with the default
|
||||||
* tag length for that algorithm.
|
* tag length for that algorithm.
|
||||||
*/
|
*/
|
||||||
#define PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH(aead_alg) \
|
#define PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG(aead_alg) \
|
||||||
( \
|
( \
|
||||||
PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH_CASE(aead_alg, PSA_ALG_CCM) \
|
PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG_CASE(aead_alg, PSA_ALG_CCM) \
|
||||||
PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH_CASE(aead_alg, PSA_ALG_GCM) \
|
PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG_CASE(aead_alg, PSA_ALG_GCM) \
|
||||||
PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH_CASE(aead_alg, PSA_ALG_CHACHA20_POLY1305) \
|
PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG_CASE(aead_alg, PSA_ALG_CHACHA20_POLY1305) \
|
||||||
0)
|
0)
|
||||||
#define PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH_CASE(aead_alg, ref) \
|
#define PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG_CASE(aead_alg, ref) \
|
||||||
PSA_ALG_AEAD_WITH_TAG_LENGTH(aead_alg, 0) == \
|
PSA_ALG_AEAD_WITH_SHORTENED_TAG(aead_alg, 0) == \
|
||||||
PSA_ALG_AEAD_WITH_TAG_LENGTH(ref, 0) ? \
|
PSA_ALG_AEAD_WITH_SHORTENED_TAG(ref, 0) ? \
|
||||||
ref :
|
ref :
|
||||||
|
|
||||||
|
/** Macro to build an AEAD minimum-tag-length wildcard algorithm.
|
||||||
|
*
|
||||||
|
* A minimum-tag-length AEAD wildcard algorithm permits all AEAD algorithms
|
||||||
|
* sharing the same base algorithm, and where the tag length of the specific
|
||||||
|
* algorithm is equal to or larger then the minimum tag length specified by the
|
||||||
|
* wildcard algorithm.
|
||||||
|
*
|
||||||
|
* \note When setting the minimum required tag length to less than the
|
||||||
|
* smallest tag length allowed by the base algorithm, this effectively
|
||||||
|
* becomes an 'any-tag-length-allowed' policy for that base algorithm.
|
||||||
|
*
|
||||||
|
* \param aead_alg An AEAD algorithm identifier (value of type
|
||||||
|
* #psa_algorithm_t such that
|
||||||
|
* #PSA_ALG_IS_AEAD(\p aead_alg) is true).
|
||||||
|
* \param min_tag_length Desired minimum length of the authentication tag in
|
||||||
|
* bytes. This must be at least 1 and at most the largest
|
||||||
|
* allowed tag length of the algorithm.
|
||||||
|
*
|
||||||
|
* \return The corresponding AEAD wildcard algorithm with the
|
||||||
|
* specified minimum length.
|
||||||
|
* \return Unspecified if \p aead_alg is not a supported
|
||||||
|
* AEAD algorithm or if \p min_tag_length is less than 1
|
||||||
|
* or too large for the specified AEAD algorithm.
|
||||||
|
*/
|
||||||
|
#define PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(aead_alg, min_tag_length) \
|
||||||
|
( PSA_ALG_AEAD_WITH_SHORTENED_TAG(aead_alg, min_tag_length) | \
|
||||||
|
PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG )
|
||||||
|
|
||||||
#define PSA_ALG_RSA_PKCS1V15_SIGN_BASE ((psa_algorithm_t)0x06000200)
|
#define PSA_ALG_RSA_PKCS1V15_SIGN_BASE ((psa_algorithm_t)0x06000200)
|
||||||
/** RSA PKCS#1 v1.5 signature with hashing.
|
/** RSA PKCS#1 v1.5 signature with hashing.
|
||||||
*
|
*
|
||||||
|
@ -1209,6 +1424,94 @@
|
||||||
#define PSA_ALG_IS_RANDOMIZED_ECDSA(alg) \
|
#define PSA_ALG_IS_RANDOMIZED_ECDSA(alg) \
|
||||||
(PSA_ALG_IS_ECDSA(alg) && !PSA_ALG_ECDSA_IS_DETERMINISTIC(alg))
|
(PSA_ALG_IS_ECDSA(alg) && !PSA_ALG_ECDSA_IS_DETERMINISTIC(alg))
|
||||||
|
|
||||||
|
/** Edwards-curve digital signature algorithm without prehashing (PureEdDSA),
|
||||||
|
* using standard parameters.
|
||||||
|
*
|
||||||
|
* Contexts are not supported in the current version of this specification
|
||||||
|
* because there is no suitable signature interface that can take the
|
||||||
|
* context as a parameter. A future version of this specification may add
|
||||||
|
* suitable functions and extend this algorithm to support contexts.
|
||||||
|
*
|
||||||
|
* PureEdDSA requires an elliptic curve key on a twisted Edwards curve.
|
||||||
|
* In this specification, the following curves are supported:
|
||||||
|
* - #PSA_ECC_FAMILY_TWISTED_EDWARDS, 255-bit: Ed25519 as specified
|
||||||
|
* in RFC 8032.
|
||||||
|
* The curve is Edwards25519.
|
||||||
|
* The hash function used internally is SHA-512.
|
||||||
|
* - #PSA_ECC_FAMILY_TWISTED_EDWARDS, 448-bit: Ed448 as specified
|
||||||
|
* in RFC 8032.
|
||||||
|
* The curve is Edwards448.
|
||||||
|
* The hash function used internally is the first 114 bytes of the
|
||||||
|
* SHAKE256 output.
|
||||||
|
*
|
||||||
|
* This algorithm can be used with psa_sign_message() and
|
||||||
|
* psa_verify_message(). Since there is no prehashing, it cannot be used
|
||||||
|
* with psa_sign_hash() or psa_verify_hash().
|
||||||
|
*
|
||||||
|
* The signature format is the concatenation of R and S as defined by
|
||||||
|
* RFC 8032 §5.1.6 and §5.2.6 (a 64-byte string for Ed25519, a 114-byte
|
||||||
|
* string for Ed448).
|
||||||
|
*/
|
||||||
|
#define PSA_ALG_PURE_EDDSA ((psa_algorithm_t)0x06000800)
|
||||||
|
|
||||||
|
#define PSA_ALG_HASH_EDDSA_BASE ((psa_algorithm_t)0x06000900)
|
||||||
|
#define PSA_ALG_IS_HASH_EDDSA(alg) \
|
||||||
|
(((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_HASH_EDDSA_BASE)
|
||||||
|
|
||||||
|
/** Edwards-curve digital signature algorithm with prehashing (HashEdDSA),
|
||||||
|
* using SHA-512 and the Edwards25519 curve.
|
||||||
|
*
|
||||||
|
* See #PSA_ALG_PURE_EDDSA regarding context support and the signature format.
|
||||||
|
*
|
||||||
|
* This algorithm is Ed25519 as specified in RFC 8032.
|
||||||
|
* The curve is Edwards25519.
|
||||||
|
* The prehash is SHA-512.
|
||||||
|
* The hash function used internally is SHA-512.
|
||||||
|
*
|
||||||
|
* This is a hash-and-sign algorithm: to calculate a signature,
|
||||||
|
* you can either:
|
||||||
|
* - call psa_sign_message() on the message;
|
||||||
|
* - or calculate the SHA-512 hash of the message
|
||||||
|
* with psa_hash_compute()
|
||||||
|
* or with a multi-part hash operation started with psa_hash_setup(),
|
||||||
|
* using the hash algorithm #PSA_ALG_SHA_512,
|
||||||
|
* then sign the calculated hash with psa_sign_hash().
|
||||||
|
* Verifying a signature is similar, using psa_verify_message() or
|
||||||
|
* psa_verify_hash() instead of the signature function.
|
||||||
|
*/
|
||||||
|
#define PSA_ALG_ED25519PH \
|
||||||
|
(PSA_ALG_HASH_EDDSA_BASE | (PSA_ALG_SHA_512 & PSA_ALG_HASH_MASK))
|
||||||
|
|
||||||
|
/** Edwards-curve digital signature algorithm with prehashing (HashEdDSA),
|
||||||
|
* using SHAKE256 and the Edwards448 curve.
|
||||||
|
*
|
||||||
|
* See #PSA_ALG_PURE_EDDSA regarding context support and the signature format.
|
||||||
|
*
|
||||||
|
* This algorithm is Ed448 as specified in RFC 8032.
|
||||||
|
* The curve is Edwards448.
|
||||||
|
* The prehash is the first 64 bytes of the SHAKE256 output.
|
||||||
|
* The hash function used internally is the first 114 bytes of the
|
||||||
|
* SHAKE256 output.
|
||||||
|
*
|
||||||
|
* This is a hash-and-sign algorithm: to calculate a signature,
|
||||||
|
* you can either:
|
||||||
|
* - call psa_sign_message() on the message;
|
||||||
|
* - or calculate the first 64 bytes of the SHAKE256 output of the message
|
||||||
|
* with psa_hash_compute()
|
||||||
|
* or with a multi-part hash operation started with psa_hash_setup(),
|
||||||
|
* using the hash algorithm #PSA_ALG_SHAKE256_512,
|
||||||
|
* then sign the calculated hash with psa_sign_hash().
|
||||||
|
* Verifying a signature is similar, using psa_verify_message() or
|
||||||
|
* psa_verify_hash() instead of the signature function.
|
||||||
|
*/
|
||||||
|
#define PSA_ALG_ED448PH \
|
||||||
|
(PSA_ALG_HASH_EDDSA_BASE | (PSA_ALG_SHAKE256_512 & PSA_ALG_HASH_MASK))
|
||||||
|
|
||||||
|
/* Default definition, to be overridden if the library is extended with
|
||||||
|
* more hash-and-sign algorithms that we want to keep out of this header
|
||||||
|
* file. */
|
||||||
|
#define PSA_ALG_IS_VENDOR_HASH_AND_SIGN(alg) 0
|
||||||
|
|
||||||
/** Whether the specified algorithm is a hash-and-sign algorithm.
|
/** Whether the specified algorithm is a hash-and-sign algorithm.
|
||||||
*
|
*
|
||||||
* Hash-and-sign algorithms are asymmetric (public-key) signature algorithms
|
* Hash-and-sign algorithms are asymmetric (public-key) signature algorithms
|
||||||
|
@ -1224,7 +1527,22 @@
|
||||||
*/
|
*/
|
||||||
#define PSA_ALG_IS_HASH_AND_SIGN(alg) \
|
#define PSA_ALG_IS_HASH_AND_SIGN(alg) \
|
||||||
(PSA_ALG_IS_RSA_PSS(alg) || PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) || \
|
(PSA_ALG_IS_RSA_PSS(alg) || PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) || \
|
||||||
PSA_ALG_IS_ECDSA(alg))
|
PSA_ALG_IS_ECDSA(alg) || PSA_ALG_IS_HASH_EDDSA(alg) || \
|
||||||
|
PSA_ALG_IS_VENDOR_HASH_AND_SIGN(alg))
|
||||||
|
|
||||||
|
/** Whether the specified algorithm is a signature algorithm that can be used
|
||||||
|
* with psa_sign_message() and psa_verify_message().
|
||||||
|
*
|
||||||
|
* \param alg An algorithm identifier (value of type #psa_algorithm_t).
|
||||||
|
*
|
||||||
|
* \return 1 if alg is a signature algorithm that can be used to sign a
|
||||||
|
* message. 0 if \p alg is a signature algorithm that can only be used
|
||||||
|
* to sign an already-calculated hash. 0 if \p alg is not a signature
|
||||||
|
* algorithm. This macro can return either 0 or 1 if \p alg is not a
|
||||||
|
* supported algorithm identifier.
|
||||||
|
*/
|
||||||
|
#define PSA_ALG_IS_SIGN_MESSAGE(alg) \
|
||||||
|
(PSA_ALG_IS_HASH_AND_SIGN(alg) || (alg) == PSA_ALG_PURE_EDDSA )
|
||||||
|
|
||||||
/** Get the hash used by a hash-and-sign signature algorithm.
|
/** Get the hash used by a hash-and-sign signature algorithm.
|
||||||
*
|
*
|
||||||
|
@ -1406,6 +1724,67 @@
|
||||||
#define PSA_ALG_TLS12_PSK_TO_MS_GET_HASH(hkdf_alg) \
|
#define PSA_ALG_TLS12_PSK_TO_MS_GET_HASH(hkdf_alg) \
|
||||||
(PSA_ALG_CATEGORY_HASH | ((hkdf_alg) & PSA_ALG_HASH_MASK))
|
(PSA_ALG_CATEGORY_HASH | ((hkdf_alg) & PSA_ALG_HASH_MASK))
|
||||||
|
|
||||||
|
/* This flag indicates whether the key derivation algorithm is suitable for
|
||||||
|
* use on low-entropy secrets such as password - these algorithms are also
|
||||||
|
* known as key stretching or password hashing schemes. These are also the
|
||||||
|
* algorithms that accepts inputs of type #PSA_KEY_DERIVATION_INPUT_PASSWORD.
|
||||||
|
*
|
||||||
|
* Those algorithms cannot be combined with a key agreement algorithm.
|
||||||
|
*/
|
||||||
|
#define PSA_ALG_KEY_DERIVATION_STRETCHING_FLAG ((psa_algorithm_t)0x00800000)
|
||||||
|
|
||||||
|
#define PSA_ALG_PBKDF2_HMAC_BASE ((psa_algorithm_t)0x08800100)
|
||||||
|
/** Macro to build a PBKDF2-HMAC password hashing / key stretching algorithm.
|
||||||
|
*
|
||||||
|
* PBKDF2 is defined by PKCS#5, republished as RFC 8018 (section 5.2).
|
||||||
|
* This macro specifies the PBKDF2 algorithm constructed using a PRF based on
|
||||||
|
* HMAC with the specified hash.
|
||||||
|
* For example, `PSA_ALG_PBKDF2_HMAC(PSA_ALG_SHA256)` specifies PBKDF2
|
||||||
|
* using the PRF HMAC-SHA-256.
|
||||||
|
*
|
||||||
|
* This key derivation algorithm uses the following inputs, which must be
|
||||||
|
* provided in the following order:
|
||||||
|
* - #PSA_KEY_DERIVATION_INPUT_COST is the iteration count.
|
||||||
|
* This input step must be used exactly once.
|
||||||
|
* - #PSA_KEY_DERIVATION_INPUT_SALT is the salt.
|
||||||
|
* This input step must be used one or more times; if used several times, the
|
||||||
|
* inputs will be concatenated. This can be used to build the final salt
|
||||||
|
* from multiple sources, both public and secret (also known as pepper).
|
||||||
|
* - #PSA_KEY_DERIVATION_INPUT_PASSWORD is the password to be hashed.
|
||||||
|
* This input step must be used exactly once.
|
||||||
|
*
|
||||||
|
* \param hash_alg A hash algorithm (\c PSA_ALG_XXX value such that
|
||||||
|
* #PSA_ALG_IS_HASH(\p hash_alg) is true).
|
||||||
|
*
|
||||||
|
* \return The corresponding PBKDF2-HMAC-XXX algorithm.
|
||||||
|
* \return Unspecified if \p hash_alg is not a supported
|
||||||
|
* hash algorithm.
|
||||||
|
*/
|
||||||
|
#define PSA_ALG_PBKDF2_HMAC(hash_alg) \
|
||||||
|
(PSA_ALG_PBKDF2_HMAC_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
|
||||||
|
|
||||||
|
/** Whether the specified algorithm is a PBKDF2-HMAC algorithm.
|
||||||
|
*
|
||||||
|
* \param alg An algorithm identifier (value of type #psa_algorithm_t).
|
||||||
|
*
|
||||||
|
* \return 1 if \c alg is a PBKDF2-HMAC algorithm, 0 otherwise.
|
||||||
|
* This macro may return either 0 or 1 if \c alg is not a supported
|
||||||
|
* key derivation algorithm identifier.
|
||||||
|
*/
|
||||||
|
#define PSA_ALG_IS_PBKDF2_HMAC(alg) \
|
||||||
|
(((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_PBKDF2_HMAC_BASE)
|
||||||
|
|
||||||
|
/** The PBKDF2-AES-CMAC-PRF-128 password hashing / key stretching algorithm.
|
||||||
|
*
|
||||||
|
* PBKDF2 is defined by PKCS#5, republished as RFC 8018 (section 5.2).
|
||||||
|
* This macro specifies the PBKDF2 algorithm constructed using the
|
||||||
|
* AES-CMAC-PRF-128 PRF specified by RFC 4615.
|
||||||
|
*
|
||||||
|
* This key derivation algorithm uses the same inputs as
|
||||||
|
* #PSA_ALG_PBKDF2_HMAC() with the same constraints.
|
||||||
|
*/
|
||||||
|
#define PSA_ALG_PBKDF2_AES_CMAC_PRF_128 ((psa_algorithm_t)0x08800200)
|
||||||
|
|
||||||
#define PSA_ALG_KEY_DERIVATION_MASK ((psa_algorithm_t)0xfe00ffff)
|
#define PSA_ALG_KEY_DERIVATION_MASK ((psa_algorithm_t)0xfe00ffff)
|
||||||
#define PSA_ALG_KEY_AGREEMENT_MASK ((psa_algorithm_t)0xffff0000)
|
#define PSA_ALG_KEY_AGREEMENT_MASK ((psa_algorithm_t)0xffff0000)
|
||||||
|
|
||||||
|
@ -1534,11 +1913,27 @@
|
||||||
* \return This macro may return either 0 or 1 if \c alg is not a supported
|
* \return This macro may return either 0 or 1 if \c alg is not a supported
|
||||||
* algorithm identifier.
|
* algorithm identifier.
|
||||||
*/
|
*/
|
||||||
#define PSA_ALG_IS_WILDCARD(alg) \
|
#define PSA_ALG_IS_WILDCARD(alg) \
|
||||||
(PSA_ALG_IS_HASH_AND_SIGN(alg) ? \
|
(PSA_ALG_IS_HASH_AND_SIGN(alg) ? \
|
||||||
PSA_ALG_SIGN_GET_HASH(alg) == PSA_ALG_ANY_HASH : \
|
PSA_ALG_SIGN_GET_HASH(alg) == PSA_ALG_ANY_HASH : \
|
||||||
|
PSA_ALG_IS_MAC(alg) ? \
|
||||||
|
(alg & PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG) != 0 : \
|
||||||
|
PSA_ALG_IS_AEAD(alg) ? \
|
||||||
|
(alg & PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG) != 0 : \
|
||||||
(alg) == PSA_ALG_ANY_HASH)
|
(alg) == PSA_ALG_ANY_HASH)
|
||||||
|
|
||||||
|
/** Get the hash used by a composite algorithm.
|
||||||
|
*
|
||||||
|
* \param alg An algorithm identifier (value of type #psa_algorithm_t).
|
||||||
|
*
|
||||||
|
* \return The underlying hash algorithm if alg is a composite algorithm that
|
||||||
|
* uses a hash algorithm.
|
||||||
|
*
|
||||||
|
* \return \c 0 if alg is not a composite algorithm that uses a hash.
|
||||||
|
*/
|
||||||
|
#define PSA_ALG_GET_HASH(alg) \
|
||||||
|
(((alg) & 0x000000ff) == 0 ? ((psa_algorithm_t)0) : 0x02000000 | ((alg) & 0x000000ff))
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
/** \defgroup key_lifetimes Key lifetimes
|
/** \defgroup key_lifetimes Key lifetimes
|
||||||
|
@ -1562,13 +1957,12 @@
|
||||||
*
|
*
|
||||||
* A persistent key remains in storage until it is explicitly destroyed or
|
* A persistent key remains in storage until it is explicitly destroyed or
|
||||||
* until the corresponding storage area is wiped. This specification does
|
* until the corresponding storage area is wiped. This specification does
|
||||||
* not define any mechanism to wipe a storage area, but implementations may
|
* not define any mechanism to wipe a storage area, but integrations may
|
||||||
* provide their own mechanism (for example to perform a factory reset,
|
* provide their own mechanism (for example to perform a factory reset,
|
||||||
* to prepare for device refurbishment, or to uninstall an application).
|
* to prepare for device refurbishment, or to uninstall an application).
|
||||||
*
|
*
|
||||||
* This lifetime value is the default storage area for the calling
|
* This lifetime value is the default storage area for the calling
|
||||||
* application. Implementations may offer other storage areas designated
|
* application. Integrations of Mbed TLS may support other persistent lifetimes.
|
||||||
* by other lifetime values as implementation-specific extensions.
|
|
||||||
* See ::psa_key_lifetime_t for more information.
|
* See ::psa_key_lifetime_t for more information.
|
||||||
*/
|
*/
|
||||||
#define PSA_KEY_LIFETIME_PERSISTENT ((psa_key_lifetime_t)0x00000001)
|
#define PSA_KEY_LIFETIME_PERSISTENT ((psa_key_lifetime_t)0x00000001)
|
||||||
|
@ -1617,6 +2011,27 @@
|
||||||
(PSA_KEY_LIFETIME_GET_PERSISTENCE(lifetime) == \
|
(PSA_KEY_LIFETIME_GET_PERSISTENCE(lifetime) == \
|
||||||
PSA_KEY_PERSISTENCE_VOLATILE)
|
PSA_KEY_PERSISTENCE_VOLATILE)
|
||||||
|
|
||||||
|
/** Whether a key lifetime indicates that the key is read-only.
|
||||||
|
*
|
||||||
|
* Read-only keys cannot be created or destroyed through the PSA Crypto API.
|
||||||
|
* They must be created through platform-specific means that bypass the API.
|
||||||
|
*
|
||||||
|
* Some platforms may offer ways to destroy read-only keys. For example,
|
||||||
|
* consider a platform with multiple levels of privilege, where a
|
||||||
|
* low-privilege application can use a key but is not allowed to destroy
|
||||||
|
* it, and the platform exposes the key to the application with a read-only
|
||||||
|
* lifetime. High-privilege code can destroy the key even though the
|
||||||
|
* application sees the key as read-only.
|
||||||
|
*
|
||||||
|
* \param lifetime The lifetime value to query (value of type
|
||||||
|
* ::psa_key_lifetime_t).
|
||||||
|
*
|
||||||
|
* \return \c 1 if the key is read-only, otherwise \c 0.
|
||||||
|
*/
|
||||||
|
#define PSA_KEY_LIFETIME_IS_READ_ONLY(lifetime) \
|
||||||
|
(PSA_KEY_LIFETIME_GET_PERSISTENCE(lifetime) == \
|
||||||
|
PSA_KEY_PERSISTENCE_READ_ONLY)
|
||||||
|
|
||||||
/** Construct a lifetime from a persistence level and a location.
|
/** Construct a lifetime from a persistence level and a location.
|
||||||
*
|
*
|
||||||
* \param persistence The persistence level
|
* \param persistence The persistence level
|
||||||
|
@ -1710,6 +2125,26 @@
|
||||||
*/
|
*/
|
||||||
#define PSA_KEY_USAGE_DECRYPT ((psa_key_usage_t)0x00000200)
|
#define PSA_KEY_USAGE_DECRYPT ((psa_key_usage_t)0x00000200)
|
||||||
|
|
||||||
|
/** Whether the key may be used to sign a message.
|
||||||
|
*
|
||||||
|
* This flag allows the key to be used for a MAC calculation operation or for
|
||||||
|
* an asymmetric message signature operation, if otherwise permitted by the
|
||||||
|
* key’s type and policy.
|
||||||
|
*
|
||||||
|
* For a key pair, this concerns the private key.
|
||||||
|
*/
|
||||||
|
#define PSA_KEY_USAGE_SIGN_MESSAGE ((psa_key_usage_t)0x00000400)
|
||||||
|
|
||||||
|
/** Whether the key may be used to verify a message.
|
||||||
|
*
|
||||||
|
* This flag allows the key to be used for a MAC verification operation or for
|
||||||
|
* an asymmetric message signature verification operation, if otherwise
|
||||||
|
* permitted by the key’s type and policy.
|
||||||
|
*
|
||||||
|
* For a key pair, this concerns the public key.
|
||||||
|
*/
|
||||||
|
#define PSA_KEY_USAGE_VERIFY_MESSAGE ((psa_key_usage_t)0x00000800)
|
||||||
|
|
||||||
/** Whether the key may be used to sign a message.
|
/** Whether the key may be used to sign a message.
|
||||||
*
|
*
|
||||||
* This flag allows the key to be used for a MAC calculation operation
|
* This flag allows the key to be used for a MAC calculation operation
|
||||||
|
@ -1730,10 +2165,35 @@
|
||||||
*/
|
*/
|
||||||
#define PSA_KEY_USAGE_VERIFY_HASH ((psa_key_usage_t)0x00002000)
|
#define PSA_KEY_USAGE_VERIFY_HASH ((psa_key_usage_t)0x00002000)
|
||||||
|
|
||||||
/** Whether the key may be used to derive other keys.
|
/** Whether the key may be used to derive other keys or produce a password
|
||||||
|
* hash.
|
||||||
|
*
|
||||||
|
* This flag allows the key to be used for a key derivation operation or for
|
||||||
|
* a key agreement operation, if otherwise permitted by by the key's type and
|
||||||
|
* policy.
|
||||||
|
*
|
||||||
|
* If this flag is present on all keys used in calls to
|
||||||
|
* psa_key_derivation_input_key() for a key derivation operation, then it
|
||||||
|
* permits calling psa_key_derivation_output_bytes() or
|
||||||
|
* psa_key_derivation_output_key() at the end of the operation.
|
||||||
*/
|
*/
|
||||||
#define PSA_KEY_USAGE_DERIVE ((psa_key_usage_t)0x00004000)
|
#define PSA_KEY_USAGE_DERIVE ((psa_key_usage_t)0x00004000)
|
||||||
|
|
||||||
|
/** Whether the key may be used to verify the result of a key derivation,
|
||||||
|
* including password hashing.
|
||||||
|
*
|
||||||
|
* This flag allows the key to be used:
|
||||||
|
*
|
||||||
|
* This flag allows the key to be used in a key derivation operation, if
|
||||||
|
* otherwise permitted by by the key's type and policy.
|
||||||
|
*
|
||||||
|
* If this flag is present on all keys used in calls to
|
||||||
|
* psa_key_derivation_input_key() for a key derivation operation, then it
|
||||||
|
* permits calling psa_key_derivation_verify_bytes() or
|
||||||
|
* psa_key_derivation_verify_key() at the end of the operation.
|
||||||
|
*/
|
||||||
|
#define PSA_KEY_USAGE_VERIFY_DERIVATION ((psa_key_usage_t)0x00008000)
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
/** \defgroup derivation Key derivation
|
/** \defgroup derivation Key derivation
|
||||||
|
@ -1750,10 +2210,31 @@
|
||||||
* The secret can also be a direct input (passed to
|
* The secret can also be a direct input (passed to
|
||||||
* key_derivation_input_bytes()). In this case, the derivation operation
|
* key_derivation_input_bytes()). In this case, the derivation operation
|
||||||
* may not be used to derive keys: the operation will only allow
|
* may not be used to derive keys: the operation will only allow
|
||||||
* psa_key_derivation_output_bytes(), not psa_key_derivation_output_key().
|
* psa_key_derivation_output_bytes(),
|
||||||
|
* psa_key_derivation_verify_bytes(), or
|
||||||
|
* psa_key_derivation_verify_key(), but not
|
||||||
|
* psa_key_derivation_output_key().
|
||||||
*/
|
*/
|
||||||
#define PSA_KEY_DERIVATION_INPUT_SECRET ((psa_key_derivation_step_t)0x0101)
|
#define PSA_KEY_DERIVATION_INPUT_SECRET ((psa_key_derivation_step_t)0x0101)
|
||||||
|
|
||||||
|
/** A low-entropy secret input for password hashing / key stretching.
|
||||||
|
*
|
||||||
|
* This is usually a key of type #PSA_KEY_TYPE_PASSWORD (passed to
|
||||||
|
* psa_key_derivation_input_key()) or a direct input (passed to
|
||||||
|
* psa_key_derivation_input_bytes()) that is a password or passphrase. It can
|
||||||
|
* also be high-entropy secret such as a key of type #PSA_KEY_TYPE_DERIVE or
|
||||||
|
* the shared secret resulting from a key agreement.
|
||||||
|
*
|
||||||
|
* The secret can also be a direct input (passed to
|
||||||
|
* key_derivation_input_bytes()). In this case, the derivation operation
|
||||||
|
* may not be used to derive keys: the operation will only allow
|
||||||
|
* psa_key_derivation_output_bytes(),
|
||||||
|
* psa_key_derivation_verify_bytes(), or
|
||||||
|
* psa_key_derivation_verify_key(), but not
|
||||||
|
* psa_key_derivation_output_key().
|
||||||
|
*/
|
||||||
|
#define PSA_KEY_DERIVATION_INPUT_PASSWORD ((psa_key_derivation_step_t)0x0102)
|
||||||
|
|
||||||
/** A label for key derivation.
|
/** A label for key derivation.
|
||||||
*
|
*
|
||||||
* This should be a direct input.
|
* This should be a direct input.
|
||||||
|
@ -1764,7 +2245,8 @@
|
||||||
/** A salt for key derivation.
|
/** A salt for key derivation.
|
||||||
*
|
*
|
||||||
* This should be a direct input.
|
* This should be a direct input.
|
||||||
* It can also be a key of type #PSA_KEY_TYPE_RAW_DATA.
|
* It can also be a key of type #PSA_KEY_TYPE_RAW_DATA or
|
||||||
|
* #PSA_KEY_TYPE_PEPPER.
|
||||||
*/
|
*/
|
||||||
#define PSA_KEY_DERIVATION_INPUT_SALT ((psa_key_derivation_step_t)0x0202)
|
#define PSA_KEY_DERIVATION_INPUT_SALT ((psa_key_derivation_step_t)0x0202)
|
||||||
|
|
||||||
|
@ -1782,6 +2264,35 @@
|
||||||
*/
|
*/
|
||||||
#define PSA_KEY_DERIVATION_INPUT_SEED ((psa_key_derivation_step_t)0x0204)
|
#define PSA_KEY_DERIVATION_INPUT_SEED ((psa_key_derivation_step_t)0x0204)
|
||||||
|
|
||||||
|
/** A cost parameter for password hashing / key stretching.
|
||||||
|
*
|
||||||
|
* This must be a direct input, passed to psa_key_derivation_input_integer().
|
||||||
|
*/
|
||||||
|
#define PSA_KEY_DERIVATION_INPUT_COST ((psa_key_derivation_step_t)0x0205)
|
||||||
|
|
||||||
|
/**@}*/
|
||||||
|
|
||||||
|
/** \defgroup helper_macros Helper macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Helper macros */
|
||||||
|
|
||||||
|
/** Check if two AEAD algorithm identifiers refer to the same AEAD algorithm
|
||||||
|
* regardless of the tag length they encode.
|
||||||
|
*
|
||||||
|
* \param aead_alg_1 An AEAD algorithm identifier.
|
||||||
|
* \param aead_alg_2 An AEAD algorithm identifier.
|
||||||
|
*
|
||||||
|
* \return 1 if both identifiers refer to the same AEAD algorithm,
|
||||||
|
* 0 otherwise.
|
||||||
|
* Unspecified if neither \p aead_alg_1 nor \p aead_alg_2 are
|
||||||
|
* a supported AEAD algorithm.
|
||||||
|
*/
|
||||||
|
#define MBEDTLS_PSA_ALG_AEAD_EQUAL(aead_alg_1, aead_alg_2) \
|
||||||
|
(!(((aead_alg_1) ^ (aead_alg_2)) & \
|
||||||
|
~(PSA_ALG_AEAD_TAG_LENGTH_MASK | PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG)))
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
#endif /* PSA_CRYPTO_VALUES_H */
|
#endif /* PSA_CRYPTO_VALUES_H */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2020, Arm Limited. All rights reserved.
|
* Copyright (c) 2018-2021, Arm Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*
|
*
|
||||||
|
@ -201,26 +201,6 @@ psa_status_t
|
||||||
psa_initial_attest_get_token_size(size_t challenge_size,
|
psa_initial_attest_get_token_size(size_t challenge_size,
|
||||||
size_t *token_size);
|
size_t *token_size);
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Get the initial attestation public key.
|
|
||||||
*
|
|
||||||
* \param[out] public_key Pointer to the buffer where the public key
|
|
||||||
* will be stored.
|
|
||||||
* \param[in] key_buf_size Size of allocated buffer for key, in bytes.
|
|
||||||
* \param[out] public_key_len Size of public key in bytes.
|
|
||||||
* \param[out] public_key_curve Type of the elliptic curve which the key
|
|
||||||
* belongs to.
|
|
||||||
*
|
|
||||||
* \note Currently only the ECDSA P-256 over SHA-256 algorithm is supported.
|
|
||||||
*
|
|
||||||
* \return Returns error code as specified in \ref psa_status_t
|
|
||||||
*/
|
|
||||||
psa_status_t
|
|
||||||
tfm_initial_attest_get_public_key(uint8_t *public_key,
|
|
||||||
size_t public_key_buf_size,
|
|
||||||
size_t *public_key_len,
|
|
||||||
psa_ecc_family_t *elliptic_curve_type);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -207,6 +207,8 @@ psa_status_t psa_fwu_request_reboot(void);
|
||||||
/**
|
/**
|
||||||
* \brief Indicates to the implementation that the upgrade was successful.
|
* \brief Indicates to the implementation that the upgrade was successful.
|
||||||
*
|
*
|
||||||
|
* \param[in] image_id The image_id of the image to query
|
||||||
|
*
|
||||||
* \return A status indicating the success/failure of the operation
|
* \return A status indicating the success/failure of the operation
|
||||||
*
|
*
|
||||||
* \retval PSA_SUCCESS The image and its dependencies have
|
* \retval PSA_SUCCESS The image and its dependencies have
|
||||||
|
@ -217,7 +219,7 @@ psa_status_t psa_fwu_request_reboot(void);
|
||||||
* \retval PSA_ERROR_NOT_PERMITTED The caller is not permitted to make
|
* \retval PSA_ERROR_NOT_PERMITTED The caller is not permitted to make
|
||||||
* this call
|
* this call
|
||||||
*/
|
*/
|
||||||
psa_status_t psa_fwu_accept(void);
|
psa_status_t psa_fwu_accept(psa_image_id_t image_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Stores a manifest object and associates it with a particular image ID.
|
* \brief Stores a manifest object and associates it with a particular image ID.
|
||||||
|
|
|
@ -39,6 +39,7 @@ extern "C" {
|
||||||
/******** TFM_SP_CRYPTO ********/
|
/******** TFM_SP_CRYPTO ********/
|
||||||
#define TFM_CRYPTO_SID (0x00000080U)
|
#define TFM_CRYPTO_SID (0x00000080U)
|
||||||
#define TFM_CRYPTO_VERSION (1U)
|
#define TFM_CRYPTO_VERSION (1U)
|
||||||
|
#define TFM_CRYPTO_HANDLE (0x40000100U)
|
||||||
|
|
||||||
/******** TFM_SP_PLATFORM ********/
|
/******** TFM_SP_PLATFORM ********/
|
||||||
#define TFM_SP_PLATFORM_SYSTEM_RESET_SID (0x00000040U)
|
#define TFM_SP_PLATFORM_SYSTEM_RESET_SID (0x00000040U)
|
||||||
|
@ -53,8 +54,6 @@ extern "C" {
|
||||||
#define TFM_ATTEST_GET_TOKEN_VERSION (1U)
|
#define TFM_ATTEST_GET_TOKEN_VERSION (1U)
|
||||||
#define TFM_ATTEST_GET_TOKEN_SIZE_SID (0x00000021U)
|
#define TFM_ATTEST_GET_TOKEN_SIZE_SID (0x00000021U)
|
||||||
#define TFM_ATTEST_GET_TOKEN_SIZE_VERSION (1U)
|
#define TFM_ATTEST_GET_TOKEN_SIZE_VERSION (1U)
|
||||||
#define TFM_ATTEST_GET_PUBLIC_KEY_SID (0x00000022U)
|
|
||||||
#define TFM_ATTEST_GET_PUBLIC_KEY_VERSION (1U)
|
|
||||||
|
|
||||||
/******** TFM_SP_CORE_TEST ********/
|
/******** TFM_SP_CORE_TEST ********/
|
||||||
#define SPM_CORE_TEST_INIT_SUCCESS_SID (0x0000F020U)
|
#define SPM_CORE_TEST_INIT_SUCCESS_SID (0x0000F020U)
|
||||||
|
@ -87,10 +86,6 @@ extern "C" {
|
||||||
#define SPM_CORE_TEST_2_GET_EVERY_SECOND_BYTE_VERSION (1U)
|
#define SPM_CORE_TEST_2_GET_EVERY_SECOND_BYTE_VERSION (1U)
|
||||||
#define SPM_CORE_TEST_2_INVERT_SID (0x0000F043U)
|
#define SPM_CORE_TEST_2_INVERT_SID (0x0000F043U)
|
||||||
#define SPM_CORE_TEST_2_INVERT_VERSION (1U)
|
#define SPM_CORE_TEST_2_INVERT_VERSION (1U)
|
||||||
#define SPM_CORE_TEST_2_PREPARE_TEST_SCENARIO_SID (0x0000F044U)
|
|
||||||
#define SPM_CORE_TEST_2_PREPARE_TEST_SCENARIO_VERSION (1U)
|
|
||||||
#define SPM_CORE_TEST_2_EXECUTE_TEST_SCENARIO_SID (0x0000F045U)
|
|
||||||
#define SPM_CORE_TEST_2_EXECUTE_TEST_SCENARIO_VERSION (1U)
|
|
||||||
|
|
||||||
/******** TFM_SP_SECURE_TEST_PARTITION ********/
|
/******** TFM_SP_SECURE_TEST_PARTITION ********/
|
||||||
#define TFM_SECURE_CLIENT_SFN_RUN_TESTS_SID (0x0000F000U)
|
#define TFM_SECURE_CLIENT_SFN_RUN_TESTS_SID (0x0000F000U)
|
||||||
|
@ -122,12 +117,6 @@ extern "C" {
|
||||||
#define IPC_CLIENT_TEST_RETRIEVE_APP_MEM_SID (0x0000F065U)
|
#define IPC_CLIENT_TEST_RETRIEVE_APP_MEM_SID (0x0000F065U)
|
||||||
#define IPC_CLIENT_TEST_RETRIEVE_APP_MEM_VERSION (1U)
|
#define IPC_CLIENT_TEST_RETRIEVE_APP_MEM_VERSION (1U)
|
||||||
|
|
||||||
/******** TFM_IRQ_TEST_1 ********/
|
|
||||||
#define SPM_CORE_IRQ_TEST_1_PREPARE_TEST_SCENARIO_SID (0x0000F0A0U)
|
|
||||||
#define SPM_CORE_IRQ_TEST_1_PREPARE_TEST_SCENARIO_VERSION (1U)
|
|
||||||
#define SPM_CORE_IRQ_TEST_1_EXECUTE_TEST_SCENARIO_SID (0x0000F0A1U)
|
|
||||||
#define SPM_CORE_IRQ_TEST_1_EXECUTE_TEST_SCENARIO_VERSION (1U)
|
|
||||||
|
|
||||||
/******** TFM_SP_PS_TEST ********/
|
/******** TFM_SP_PS_TEST ********/
|
||||||
#define TFM_PS_TEST_PREPARE_SID (0x0000F0C0U)
|
#define TFM_PS_TEST_PREPARE_SID (0x0000F0C0U)
|
||||||
#define TFM_PS_TEST_PREPARE_VERSION (1U)
|
#define TFM_PS_TEST_PREPARE_VERSION (1U)
|
||||||
|
@ -136,40 +125,6 @@ extern "C" {
|
||||||
#define TFM_SECURE_CLIENT_2_SID (0x0000F0E0U)
|
#define TFM_SECURE_CLIENT_2_SID (0x0000F0E0U)
|
||||||
#define TFM_SECURE_CLIENT_2_VERSION (1U)
|
#define TFM_SECURE_CLIENT_2_VERSION (1U)
|
||||||
|
|
||||||
/******** TFM_SP_PSA_PROXY ********/
|
|
||||||
#define TFM_CRYPTO_SID (0x00000080U)
|
|
||||||
#define TFM_CRYPTO_VERSION (1U)
|
|
||||||
#define TFM_ATTEST_GET_TOKEN_SID (0x00000020U)
|
|
||||||
#define TFM_ATTEST_GET_TOKEN_VERSION (1U)
|
|
||||||
#define TFM_ATTEST_GET_TOKEN_SIZE_SID (0x00000021U)
|
|
||||||
#define TFM_ATTEST_GET_TOKEN_SIZE_VERSION (1U)
|
|
||||||
#define TFM_ATTEST_GET_PUBLIC_KEY_SID (0x00000022U)
|
|
||||||
#define TFM_ATTEST_GET_PUBLIC_KEY_VERSION (1U)
|
|
||||||
#define TFM_ITS_SET_SID (0x00000070U)
|
|
||||||
#define TFM_ITS_SET_VERSION (1U)
|
|
||||||
#define TFM_ITS_GET_SID (0x00000071U)
|
|
||||||
#define TFM_ITS_GET_VERSION (1U)
|
|
||||||
#define TFM_ITS_GET_INFO_SID (0x00000072U)
|
|
||||||
#define TFM_ITS_GET_INFO_VERSION (1U)
|
|
||||||
#define TFM_ITS_REMOVE_SID (0x00000073U)
|
|
||||||
#define TFM_ITS_REMOVE_VERSION (1U)
|
|
||||||
#define TFM_SP_PLATFORM_SYSTEM_RESET_SID (0x00000040U)
|
|
||||||
#define TFM_SP_PLATFORM_SYSTEM_RESET_VERSION (1U)
|
|
||||||
#define TFM_SP_PLATFORM_IOCTL_SID (0x00000041U)
|
|
||||||
#define TFM_SP_PLATFORM_IOCTL_VERSION (1U)
|
|
||||||
#define TFM_SP_PLATFORM_NV_COUNTER_SID (0x00000042U)
|
|
||||||
#define TFM_SP_PLATFORM_NV_COUNTER_VERSION (1U)
|
|
||||||
#define TFM_PS_SET_SID (0x00000060U)
|
|
||||||
#define TFM_PS_SET_VERSION (1U)
|
|
||||||
#define TFM_PS_GET_SID (0x00000061U)
|
|
||||||
#define TFM_PS_GET_VERSION (1U)
|
|
||||||
#define TFM_PS_GET_INFO_SID (0x00000062U)
|
|
||||||
#define TFM_PS_GET_INFO_VERSION (1U)
|
|
||||||
#define TFM_PS_REMOVE_SID (0x00000063U)
|
|
||||||
#define TFM_PS_REMOVE_VERSION (1U)
|
|
||||||
#define TFM_PS_GET_SUPPORT_SID (0x00000064U)
|
|
||||||
#define TFM_PS_GET_SUPPORT_VERSION (1U)
|
|
||||||
|
|
||||||
/******** TFM_SP_FWU ********/
|
/******** TFM_SP_FWU ********/
|
||||||
#define TFM_FWU_WRITE_SID (0x000000A0U)
|
#define TFM_FWU_WRITE_SID (0x000000A0U)
|
||||||
#define TFM_FWU_WRITE_VERSION (1U)
|
#define TFM_FWU_WRITE_VERSION (1U)
|
||||||
|
@ -187,13 +142,27 @@ extern "C" {
|
||||||
/******** TFM_SP_FFM11 ********/
|
/******** TFM_SP_FFM11 ********/
|
||||||
#define TFM_FFM11_SERVICE1_SID (0x0000F120U)
|
#define TFM_FFM11_SERVICE1_SID (0x0000F120U)
|
||||||
#define TFM_FFM11_SERVICE1_VERSION (1U)
|
#define TFM_FFM11_SERVICE1_VERSION (1U)
|
||||||
#define TFM_FFM11_SERVICE1_HANDLE (0x40000104U)
|
#define TFM_FFM11_SERVICE1_HANDLE (0x40000103U)
|
||||||
#define TFM_FFM11_SERVICE2_SID (0x0000F121U)
|
#define TFM_FFM11_SERVICE2_SID (0x0000F121U)
|
||||||
#define TFM_FFM11_SERVICE2_VERSION (1U)
|
#define TFM_FFM11_SERVICE2_VERSION (1U)
|
||||||
#define TFM_FFM11_SERVICE2_HANDLE (0x40000101U)
|
#define TFM_FFM11_SERVICE2_HANDLE (0x40000101U)
|
||||||
#define TFM_FFM11_SERVICE3_SID (0x0000F122U)
|
#define TFM_FFM11_SERVICE3_SID (0x0000F122U)
|
||||||
#define TFM_FFM11_SERVICE3_VERSION (1U)
|
#define TFM_FFM11_SERVICE3_VERSION (1U)
|
||||||
#define TFM_FFM11_SERVICE3_HANDLE (0x40000103U)
|
#define TFM_FFM11_SERVICE3_HANDLE (0x40000102U)
|
||||||
|
|
||||||
|
/******** TFM_SP_ATTEST_TEST ********/
|
||||||
|
#define TFM_ATTEST_TEST_GET_PUBLIC_KEY_SID (0x0000F140U)
|
||||||
|
#define TFM_ATTEST_TEST_GET_PUBLIC_KEY_VERSION (1U)
|
||||||
|
|
||||||
|
/******** TFM_SP_SLIH_TEST ********/
|
||||||
|
#define TFM_SLIH_TEST_CASE_SID (0x0000F0A0U)
|
||||||
|
#define TFM_SLIH_TEST_CASE_VERSION (1U)
|
||||||
|
#define TFM_SLIH_TEST_CASE_HANDLE (0x40000104U)
|
||||||
|
|
||||||
|
/******** TFM_SP_FLIH_TEST ********/
|
||||||
|
#define TFM_FLIH_TEST_CASE_SID (0x0000F0B0U)
|
||||||
|
#define TFM_FLIH_TEST_CASE_VERSION (1U)
|
||||||
|
#define TFM_FLIH_TEST_CASE_HANDLE (0x40000105U)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ enum tfm_status_e
|
||||||
TFM_ERROR_NOT_INITIALIZED,
|
TFM_ERROR_NOT_INITIALIZED,
|
||||||
TFM_ERROR_NO_ACTIVE_PARTITION,
|
TFM_ERROR_NO_ACTIVE_PARTITION,
|
||||||
TFM_ERROR_INVALID_EXC_MODE,
|
TFM_ERROR_INVALID_EXC_MODE,
|
||||||
|
TFM_ERROR_NOT_IN_RANGE,
|
||||||
TFM_SECURE_LOCK_FAILED,
|
TFM_SECURE_LOCK_FAILED,
|
||||||
TFM_SECURE_UNLOCK_FAILED,
|
TFM_SECURE_UNLOCK_FAILED,
|
||||||
TFM_ERROR_GENERIC = 0x1F,
|
TFM_ERROR_GENERIC = 0x1F,
|
||||||
|
@ -112,17 +113,17 @@ psa_handle_t tfm_psa_connect_veneer(uint32_t sid, uint32_t version);
|
||||||
* \brief Call a secure function referenced by a connection handle.
|
* \brief Call a secure function referenced by a connection handle.
|
||||||
*
|
*
|
||||||
* \param[in] handle Handle to connection.
|
* \param[in] handle Handle to connection.
|
||||||
* \param[in] ctrl_param Parameter structure, includes request type,
|
* \param[in] ctrl_param Parameters combined in uint32_t,
|
||||||
* in_num and out_num.
|
* includes request type, in_num and out_num.
|
||||||
* \param[in] in_vec Array of input \ref psa_invec structures.
|
* \param[in] in_vec Array of input \ref psa_invec structures.
|
||||||
* \param[in,out] out_vec Array of output \ref psa_outvec structures.
|
* \param[in,out] out_vec Array of output \ref psa_outvec structures.
|
||||||
*
|
*
|
||||||
* \return Returns \ref psa_status_t status code.
|
* \return Returns \ref psa_status_t status code.
|
||||||
*/
|
*/
|
||||||
psa_status_t tfm_psa_call_veneer(psa_handle_t handle,
|
psa_status_t tfm_psa_call_veneer(psa_handle_t handle,
|
||||||
const struct tfm_control_parameter_t *ctrl_param,
|
uint32_t ctrl_param,
|
||||||
const psa_invec *in_vec,
|
const psa_invec *in_vec,
|
||||||
psa_outvec *out_vec);
|
psa_outvec *out_vec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Close connection to secure function referenced by a connection handle.
|
* \brief Close connection to secure function referenced by a connection handle.
|
||||||
|
|
|
@ -103,6 +103,8 @@ enum {
|
||||||
TFM_CRYPTO_AEAD_FINISH_SID,
|
TFM_CRYPTO_AEAD_FINISH_SID,
|
||||||
TFM_CRYPTO_AEAD_VERIFY_SID,
|
TFM_CRYPTO_AEAD_VERIFY_SID,
|
||||||
TFM_CRYPTO_AEAD_ABORT_SID,
|
TFM_CRYPTO_AEAD_ABORT_SID,
|
||||||
|
TFM_CRYPTO_SIGN_MESSAGE_SID,
|
||||||
|
TFM_CRYPTO_VERIFY_MESSAGE_SID,
|
||||||
TFM_CRYPTO_SIGN_HASH_SID,
|
TFM_CRYPTO_SIGN_HASH_SID,
|
||||||
TFM_CRYPTO_VERIFY_HASH_SID,
|
TFM_CRYPTO_VERIFY_HASH_SID,
|
||||||
TFM_CRYPTO_ASYMMETRIC_ENCRYPT_SID,
|
TFM_CRYPTO_ASYMMETRIC_ENCRYPT_SID,
|
||||||
|
|
|
@ -24,11 +24,14 @@ typedef int32_t (*veneer_fn) (uint32_t arg0, uint32_t arg1,
|
||||||
* desired veneer function, to be called with the parameters
|
* desired veneer function, to be called with the parameters
|
||||||
* described from arg0 to arg3.
|
* described from arg0 to arg3.
|
||||||
*
|
*
|
||||||
|
* \note NSPE shall implement this dispatcher according to NS specific
|
||||||
|
* implementation and actual usage scenario.
|
||||||
|
*
|
||||||
* \param[in] fn Function pointer to the veneer function desired
|
* \param[in] fn Function pointer to the veneer function desired
|
||||||
* \param[in] arg0 Argument 0
|
* \param[in] arg0 Argument 0 of fn
|
||||||
* \param[in] arg1 Argument 1
|
* \param[in] arg1 Argument 1 of fn
|
||||||
* \param[in] arg2 Argument 2
|
* \param[in] arg2 Argument 2 of fn
|
||||||
* \param[in] arg3 Argument 3
|
* \param[in] arg3 Argument 3 of fn
|
||||||
*
|
*
|
||||||
* \return Returns the same return value of the requested veneer function
|
* \return Returns the same return value of the requested veneer function
|
||||||
*
|
*
|
||||||
|
@ -40,17 +43,6 @@ int32_t tfm_ns_interface_dispatch(veneer_fn fn,
|
||||||
uint32_t arg0, uint32_t arg1,
|
uint32_t arg0, uint32_t arg1,
|
||||||
uint32_t arg2, uint32_t arg3);
|
uint32_t arg2, uint32_t arg3);
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief NS interface, Initialise the NS interface
|
|
||||||
*
|
|
||||||
* \details This function needs to be called from the NS world to
|
|
||||||
* properly initialise the NS interface towards TF-M. This
|
|
||||||
* function will initialise all the objects required for
|
|
||||||
* runtime dispatching of TF-M requests to services
|
|
||||||
*
|
|
||||||
* \return A value according to \ref enum tfm_status_e
|
|
||||||
*/
|
|
||||||
enum tfm_status_e tfm_ns_interface_init(void);
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021, Arm Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __TFM_PSA_CALL_PARAM_H__
|
||||||
|
#define __TFM_PSA_CALL_PARAM_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TYPE_OFFSET 16U
|
||||||
|
#define TYPE_MASK (0xFFFFUL << TYPE_OFFSET)
|
||||||
|
#define IN_LEN_OFFSET 8U
|
||||||
|
#define IN_LEN_MASK (0xFFUL << IN_LEN_OFFSET)
|
||||||
|
#define OUT_LEN_OFFSET 0U
|
||||||
|
#define OUT_LEN_MASK (0xFFUL << OUT_LEN_OFFSET)
|
||||||
|
|
||||||
|
#define PARAM_PACK(type, in_len, out_len) \
|
||||||
|
(((((uint32_t)type) << TYPE_OFFSET) & TYPE_MASK) | \
|
||||||
|
((((uint32_t)in_len) << IN_LEN_OFFSET) & IN_LEN_MASK) | \
|
||||||
|
((((uint32_t)out_len) << OUT_LEN_OFFSET) & OUT_LEN_MASK))
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __TFM_PSA_CALL_PARAM_H__ */
|
|
@ -11,25 +11,14 @@
|
||||||
#include "psa_manifest/sid.h"
|
#include "psa_manifest/sid.h"
|
||||||
#include "psa/client.h"
|
#include "psa/client.h"
|
||||||
|
|
||||||
#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
|
|
||||||
|
|
||||||
#define PSA_CONNECT(service) \
|
|
||||||
psa_handle_t ipc_handle; \
|
|
||||||
ipc_handle = psa_connect(service##_SID, service##_VERSION); \
|
|
||||||
if (!PSA_HANDLE_IS_VALID(ipc_handle)) { \
|
|
||||||
return PSA_ERROR_GENERIC_ERROR; \
|
|
||||||
} \
|
|
||||||
|
|
||||||
#define PSA_CLOSE() psa_close(ipc_handle)
|
|
||||||
|
|
||||||
#define API_DISPATCH(sfn_name, sfn_id) \
|
#define API_DISPATCH(sfn_name, sfn_id) \
|
||||||
psa_call(ipc_handle, PSA_IPC_CALL, \
|
psa_call(TFM_CRYPTO_HANDLE, PSA_IPC_CALL, \
|
||||||
in_vec, ARRAY_SIZE(in_vec), \
|
in_vec, IOVEC_LEN(in_vec), \
|
||||||
out_vec, ARRAY_SIZE(out_vec))
|
out_vec, IOVEC_LEN(out_vec))
|
||||||
|
|
||||||
#define API_DISPATCH_NO_OUTVEC(sfn_name, sfn_id) \
|
#define API_DISPATCH_NO_OUTVEC(sfn_name, sfn_id) \
|
||||||
psa_call(ipc_handle, PSA_IPC_CALL, \
|
psa_call(TFM_CRYPTO_HANDLE, PSA_IPC_CALL, \
|
||||||
in_vec, ARRAY_SIZE(in_vec), \
|
in_vec, IOVEC_LEN(in_vec), \
|
||||||
(psa_outvec *)NULL, 0)
|
(psa_outvec *)NULL, 0)
|
||||||
|
|
||||||
psa_status_t psa_crypto_init(void)
|
psa_status_t psa_crypto_init(void)
|
||||||
|
@ -55,13 +44,9 @@ psa_status_t psa_open_key(psa_key_id_t id,
|
||||||
{.base = key, .len = sizeof(psa_key_id_t)},
|
{.base = key, .len = sizeof(psa_key_id_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_open_key,
|
status = API_DISPATCH(tfm_crypto_open_key,
|
||||||
TFM_CRYPTO_OPEN_KEY);
|
TFM_CRYPTO_OPEN_KEY);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,13 +61,9 @@ psa_status_t psa_close_key(psa_key_id_t key)
|
||||||
{.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
|
{.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_close_key,
|
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_close_key,
|
||||||
TFM_CRYPTO_CLOSE_KEY);;
|
TFM_CRYPTO_CLOSE_KEY);;
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,11 +85,8 @@ psa_status_t psa_import_key(const psa_key_attributes_t *attributes,
|
||||||
{.base = key, .len = sizeof(psa_key_id_t)}
|
{.base = key, .len = sizeof(psa_key_id_t)}
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_import_key,
|
status = API_DISPATCH(tfm_crypto_import_key,
|
||||||
TFM_CRYPTO_IMPORT_KEY);
|
TFM_CRYPTO_IMPORT_KEY);
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -124,11 +102,8 @@ psa_status_t psa_destroy_key(psa_key_id_t key)
|
||||||
{.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
|
{.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_destroy_key,
|
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_destroy_key,
|
||||||
TFM_CRYPTO_DESTROY_KEY);
|
TFM_CRYPTO_DESTROY_KEY);
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -148,11 +123,8 @@ psa_status_t psa_get_key_attributes(psa_key_id_t key,
|
||||||
{.base = attributes, .len = sizeof(psa_key_attributes_t)},
|
{.base = attributes, .len = sizeof(psa_key_attributes_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_get_key_attributes,
|
status = API_DISPATCH(tfm_crypto_get_key_attributes,
|
||||||
TFM_CRYPTO_GET_KEY_ATTRIBUTES);
|
TFM_CRYPTO_GET_KEY_ATTRIBUTES);
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -169,15 +141,8 @@ void psa_reset_key_attributes(psa_key_attributes_t *attributes)
|
||||||
{.base = attributes, .len = sizeof(psa_key_attributes_t)},
|
{.base = attributes, .len = sizeof(psa_key_attributes_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
psa_handle_t ipc_handle;
|
|
||||||
ipc_handle = psa_connect(TFM_CRYPTO_SID, TFM_CRYPTO_VERSION);
|
|
||||||
if (!PSA_HANDLE_IS_VALID(ipc_handle)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)API_DISPATCH(tfm_crypto_reset_key_attributes,
|
(void)API_DISPATCH(tfm_crypto_reset_key_attributes,
|
||||||
TFM_CRYPTO_RESET_KEY_ATTRIBUTES);
|
TFM_CRYPTO_RESET_KEY_ATTRIBUTES);
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -199,15 +164,11 @@ psa_status_t psa_export_key(psa_key_id_t key,
|
||||||
{.base = data, .len = data_size}
|
{.base = data, .len = data_size}
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_export_key,
|
status = API_DISPATCH(tfm_crypto_export_key,
|
||||||
TFM_CRYPTO_EXPORT_KEY);
|
TFM_CRYPTO_EXPORT_KEY);
|
||||||
|
|
||||||
*data_length = out_vec[0].len;
|
*data_length = out_vec[0].len;
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,15 +190,11 @@ psa_status_t psa_export_public_key(psa_key_id_t key,
|
||||||
{.base = data, .len = data_size}
|
{.base = data, .len = data_size}
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_export_public_key,
|
status = API_DISPATCH(tfm_crypto_export_public_key,
|
||||||
TFM_CRYPTO_EXPORT_PUBLIC_KEY);
|
TFM_CRYPTO_EXPORT_PUBLIC_KEY);
|
||||||
|
|
||||||
*data_length = out_vec[0].len;
|
*data_length = out_vec[0].len;
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,13 +209,9 @@ psa_status_t psa_purge_key(psa_key_id_t key)
|
||||||
{.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
|
{.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_purge_key,
|
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_purge_key,
|
||||||
TFM_CRYPTO_PURGE_KEY);
|
TFM_CRYPTO_PURGE_KEY);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,13 +235,9 @@ psa_status_t psa_copy_key(psa_key_id_t source_key,
|
||||||
{.base = target_key, .len = sizeof(psa_key_id_t)},
|
{.base = target_key, .len = sizeof(psa_key_id_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_copy_key,
|
status = API_DISPATCH(tfm_crypto_copy_key,
|
||||||
TFM_CRYPTO_COPY_KEY);
|
TFM_CRYPTO_COPY_KEY);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,15 +260,11 @@ psa_status_t psa_cipher_generate_iv(psa_cipher_operation_t *operation,
|
||||||
{.base = iv, .len = iv_size},
|
{.base = iv, .len = iv_size},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_cipher_generate_iv,
|
status = API_DISPATCH(tfm_crypto_cipher_generate_iv,
|
||||||
TFM_CRYPTO_CIPHER_GENERATE_IV);
|
TFM_CRYPTO_CIPHER_GENERATE_IV);
|
||||||
|
|
||||||
*iv_length = out_vec[1].len;
|
*iv_length = out_vec[1].len;
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,13 +286,9 @@ psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation,
|
||||||
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_cipher_set_iv,
|
status = API_DISPATCH(tfm_crypto_cipher_set_iv,
|
||||||
TFM_CRYPTO_CIPHER_SET_IV);
|
TFM_CRYPTO_CIPHER_SET_IV);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,13 +311,9 @@ psa_status_t psa_cipher_encrypt_setup(psa_cipher_operation_t *operation,
|
||||||
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_cipher_encrypt_setup,
|
status = API_DISPATCH(tfm_crypto_cipher_encrypt_setup,
|
||||||
TFM_CRYPTO_CIPHER_ENCRYPT_SETUP);
|
TFM_CRYPTO_CIPHER_ENCRYPT_SETUP);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,13 +336,9 @@ psa_status_t psa_cipher_decrypt_setup(psa_cipher_operation_t *operation,
|
||||||
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_cipher_decrypt_setup,
|
status = API_DISPATCH(tfm_crypto_cipher_decrypt_setup,
|
||||||
TFM_CRYPTO_CIPHER_DECRYPT_SETUP);
|
TFM_CRYPTO_CIPHER_DECRYPT_SETUP);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,15 +364,11 @@ psa_status_t psa_cipher_update(psa_cipher_operation_t *operation,
|
||||||
{.base = output, .len = output_size}
|
{.base = output, .len = output_size}
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_cipher_update,
|
status = API_DISPATCH(tfm_crypto_cipher_update,
|
||||||
TFM_CRYPTO_CIPHER_UPDATE);
|
TFM_CRYPTO_CIPHER_UPDATE);
|
||||||
|
|
||||||
*output_length = out_vec[1].len;
|
*output_length = out_vec[1].len;
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,13 +387,9 @@ psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation)
|
||||||
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_cipher_abort,
|
status = API_DISPATCH(tfm_crypto_cipher_abort,
|
||||||
TFM_CRYPTO_CIPHER_ABORT);
|
TFM_CRYPTO_CIPHER_ABORT);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,15 +412,11 @@ psa_status_t psa_cipher_finish(psa_cipher_operation_t *operation,
|
||||||
{.base = output, .len = output_size},
|
{.base = output, .len = output_size},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_cipher_finish,
|
status = API_DISPATCH(tfm_crypto_cipher_finish,
|
||||||
TFM_CRYPTO_CIPHER_FINISH);
|
TFM_CRYPTO_CIPHER_FINISH);
|
||||||
|
|
||||||
*output_length = out_vec[1].len;
|
*output_length = out_vec[1].len;
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,13 +437,9 @@ psa_status_t psa_hash_setup(psa_hash_operation_t *operation,
|
||||||
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_hash_setup,
|
status = API_DISPATCH(tfm_crypto_hash_setup,
|
||||||
TFM_CRYPTO_HASH_SETUP);
|
TFM_CRYPTO_HASH_SETUP);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -544,13 +461,9 @@ psa_status_t psa_hash_update(psa_hash_operation_t *operation,
|
||||||
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_hash_update,
|
status = API_DISPATCH(tfm_crypto_hash_update,
|
||||||
TFM_CRYPTO_HASH_UPDATE);
|
TFM_CRYPTO_HASH_UPDATE);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,15 +486,11 @@ psa_status_t psa_hash_finish(psa_hash_operation_t *operation,
|
||||||
{.base = hash, .len = hash_size},
|
{.base = hash, .len = hash_size},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_hash_finish,
|
status = API_DISPATCH(tfm_crypto_hash_finish,
|
||||||
TFM_CRYPTO_HASH_FINISH);
|
TFM_CRYPTO_HASH_FINISH);
|
||||||
|
|
||||||
*hash_length = out_vec[1].len;
|
*hash_length = out_vec[1].len;
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -603,13 +512,9 @@ psa_status_t psa_hash_verify(psa_hash_operation_t *operation,
|
||||||
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_hash_verify,
|
status = API_DISPATCH(tfm_crypto_hash_verify,
|
||||||
TFM_CRYPTO_HASH_VERIFY);
|
TFM_CRYPTO_HASH_VERIFY);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,13 +533,9 @@ psa_status_t psa_hash_abort(psa_hash_operation_t *operation)
|
||||||
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_hash_abort,
|
status = API_DISPATCH(tfm_crypto_hash_abort,
|
||||||
TFM_CRYPTO_HASH_ABORT);
|
TFM_CRYPTO_HASH_ABORT);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -658,13 +559,9 @@ psa_status_t psa_hash_clone(const psa_hash_operation_t *source_operation,
|
||||||
return PSA_ERROR_BAD_STATE;
|
return PSA_ERROR_BAD_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_hash_clone,
|
status = API_DISPATCH(tfm_crypto_hash_clone,
|
||||||
TFM_CRYPTO_HASH_CLONE);
|
TFM_CRYPTO_HASH_CLONE);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -690,15 +587,11 @@ psa_status_t psa_hash_compute(psa_algorithm_t alg,
|
||||||
{.base = hash, .len = hash_size}
|
{.base = hash, .len = hash_size}
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_hash_compute,
|
status = API_DISPATCH(tfm_crypto_hash_compute,
|
||||||
TFM_CRYPTO_HASH_COMPUTE);
|
TFM_CRYPTO_HASH_COMPUTE);
|
||||||
|
|
||||||
*hash_length = out_vec[0].len;
|
*hash_length = out_vec[0].len;
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -720,13 +613,9 @@ psa_status_t psa_hash_compare(psa_algorithm_t alg,
|
||||||
{.base = hash, .len = hash_length},
|
{.base = hash, .len = hash_length},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_hash_compare,
|
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_hash_compare,
|
||||||
TFM_CRYPTO_HASH_COMPARE);
|
TFM_CRYPTO_HASH_COMPARE);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -749,13 +638,9 @@ psa_status_t psa_mac_sign_setup(psa_mac_operation_t *operation,
|
||||||
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_mac_sign_setup,
|
status = API_DISPATCH(tfm_crypto_mac_sign_setup,
|
||||||
TFM_CRYPTO_MAC_SIGN_SETUP);
|
TFM_CRYPTO_MAC_SIGN_SETUP);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -778,13 +663,9 @@ psa_status_t psa_mac_verify_setup(psa_mac_operation_t *operation,
|
||||||
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_mac_verify_setup,
|
status = API_DISPATCH(tfm_crypto_mac_verify_setup,
|
||||||
TFM_CRYPTO_MAC_VERIFY_SETUP);
|
TFM_CRYPTO_MAC_VERIFY_SETUP);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -806,13 +687,9 @@ psa_status_t psa_mac_update(psa_mac_operation_t *operation,
|
||||||
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_mac_update,
|
status = API_DISPATCH(tfm_crypto_mac_update,
|
||||||
TFM_CRYPTO_MAC_UPDATE);
|
TFM_CRYPTO_MAC_UPDATE);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -835,15 +712,11 @@ psa_status_t psa_mac_sign_finish(psa_mac_operation_t *operation,
|
||||||
{.base = mac, .len = mac_size},
|
{.base = mac, .len = mac_size},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_mac_sign_finish,
|
status = API_DISPATCH(tfm_crypto_mac_sign_finish,
|
||||||
TFM_CRYPTO_MAC_SIGN_FINISH);
|
TFM_CRYPTO_MAC_SIGN_FINISH);
|
||||||
|
|
||||||
*mac_length = out_vec[1].len;
|
*mac_length = out_vec[1].len;
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,13 +738,9 @@ psa_status_t psa_mac_verify_finish(psa_mac_operation_t *operation,
|
||||||
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_mac_verify_finish,
|
status = API_DISPATCH(tfm_crypto_mac_verify_finish,
|
||||||
TFM_CRYPTO_MAC_VERIFY_FINISH);
|
TFM_CRYPTO_MAC_VERIFY_FINISH);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -890,13 +759,9 @@ psa_status_t psa_mac_abort(psa_mac_operation_t *operation)
|
||||||
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_mac_abort,
|
status = API_DISPATCH(tfm_crypto_mac_abort,
|
||||||
TFM_CRYPTO_MAC_ABORT);
|
TFM_CRYPTO_MAC_ABORT);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -945,19 +810,15 @@ psa_status_t psa_aead_encrypt(psa_key_id_t key,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
size_t in_len = IOVEC_LEN(in_vec);
|
||||||
|
|
||||||
size_t in_len = ARRAY_SIZE(in_vec);
|
|
||||||
if (additional_data == NULL) {
|
if (additional_data == NULL) {
|
||||||
in_len--;
|
in_len--;
|
||||||
}
|
}
|
||||||
status = psa_call(ipc_handle, PSA_IPC_CALL, in_vec, in_len,
|
status = psa_call(TFM_CRYPTO_HANDLE, PSA_IPC_CALL, in_vec, in_len,
|
||||||
out_vec, ARRAY_SIZE(out_vec));
|
out_vec, IOVEC_LEN(out_vec));
|
||||||
|
|
||||||
*ciphertext_length = out_vec[0].len;
|
*ciphertext_length = out_vec[0].len;
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1006,31 +867,75 @@ psa_status_t psa_aead_decrypt(psa_key_id_t key,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
size_t in_len = IOVEC_LEN(in_vec);
|
||||||
|
|
||||||
size_t in_len = ARRAY_SIZE(in_vec);
|
|
||||||
if (additional_data == NULL) {
|
if (additional_data == NULL) {
|
||||||
in_len--;
|
in_len--;
|
||||||
}
|
}
|
||||||
status = psa_call(ipc_handle, PSA_IPC_CALL, in_vec, in_len,
|
status = psa_call(TFM_CRYPTO_HANDLE, PSA_IPC_CALL, in_vec, in_len,
|
||||||
out_vec, ARRAY_SIZE(out_vec));
|
out_vec, IOVEC_LEN(out_vec));
|
||||||
|
|
||||||
*plaintext_length = out_vec[0].len;
|
*plaintext_length = out_vec[0].len;
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t psa_asymmetric_sign(psa_key_id_t key,
|
psa_status_t psa_sign_message(psa_key_id_t key,
|
||||||
psa_algorithm_t alg,
|
psa_algorithm_t alg,
|
||||||
const uint8_t *hash,
|
const uint8_t *input,
|
||||||
size_t hash_length,
|
size_t input_length,
|
||||||
uint8_t *signature,
|
uint8_t *signature,
|
||||||
size_t signature_size,
|
size_t signature_size,
|
||||||
size_t *signature_length)
|
size_t *signature_length)
|
||||||
{
|
{
|
||||||
return psa_sign_hash(key, alg, hash, hash_length, signature, signature_size, signature_length);
|
psa_status_t status;
|
||||||
|
struct tfm_crypto_pack_iovec iov = {
|
||||||
|
.sfn_id = TFM_CRYPTO_SIGN_MESSAGE_SID,
|
||||||
|
.key_id = key,
|
||||||
|
.alg = alg,
|
||||||
|
};
|
||||||
|
|
||||||
|
psa_invec in_vec[] = {
|
||||||
|
{.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
|
||||||
|
{.base = input, .len = input_length},
|
||||||
|
};
|
||||||
|
psa_outvec out_vec[] = {
|
||||||
|
{.base = signature, .len = signature_size},
|
||||||
|
};
|
||||||
|
|
||||||
|
status = API_DISPATCH(tfm_crypto_sign_message,
|
||||||
|
TFM_CRYPTO_SIGN_MESSAGE);
|
||||||
|
|
||||||
|
if (status == PSA_SUCCESS) {
|
||||||
|
*signature_length = out_vec[0].len;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
psa_status_t psa_verify_message(psa_key_id_t key,
|
||||||
|
psa_algorithm_t alg,
|
||||||
|
const uint8_t *input,
|
||||||
|
size_t input_length,
|
||||||
|
const uint8_t *signature,
|
||||||
|
size_t signature_length)
|
||||||
|
{
|
||||||
|
psa_status_t status;
|
||||||
|
struct tfm_crypto_pack_iovec iov = {
|
||||||
|
.sfn_id = TFM_CRYPTO_VERIFY_MESSAGE_SID,
|
||||||
|
.key_id = key,
|
||||||
|
.alg = alg
|
||||||
|
};
|
||||||
|
|
||||||
|
psa_invec in_vec[] = {
|
||||||
|
{.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
|
||||||
|
{.base = input, .len = input_length},
|
||||||
|
{.base = signature, .len = signature_length}
|
||||||
|
};
|
||||||
|
|
||||||
|
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_verify_message,
|
||||||
|
TFM_CRYPTO_VERIFY_MESSAGE);
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t psa_sign_hash(psa_key_id_t key,
|
psa_status_t psa_sign_hash(psa_key_id_t key,
|
||||||
|
@ -1056,28 +961,14 @@ psa_status_t psa_sign_hash(psa_key_id_t key,
|
||||||
{.base = signature, .len = signature_size},
|
{.base = signature, .len = signature_size},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_sign_hash,
|
status = API_DISPATCH(tfm_crypto_sign_hash,
|
||||||
TFM_CRYPTO_SIGN_HASH);
|
TFM_CRYPTO_SIGN_HASH);
|
||||||
|
|
||||||
*signature_length = out_vec[0].len;
|
*signature_length = out_vec[0].len;
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t psa_asymmetric_verify(psa_key_id_t key,
|
|
||||||
psa_algorithm_t alg,
|
|
||||||
const uint8_t *hash,
|
|
||||||
size_t hash_length,
|
|
||||||
const uint8_t *signature,
|
|
||||||
size_t signature_length)
|
|
||||||
{
|
|
||||||
return psa_verify_hash(key, alg, hash, hash_length, signature, signature_length);
|
|
||||||
}
|
|
||||||
|
|
||||||
psa_status_t psa_verify_hash(psa_key_id_t key,
|
psa_status_t psa_verify_hash(psa_key_id_t key,
|
||||||
psa_algorithm_t alg,
|
psa_algorithm_t alg,
|
||||||
const uint8_t *hash,
|
const uint8_t *hash,
|
||||||
|
@ -1098,13 +989,9 @@ psa_status_t psa_verify_hash(psa_key_id_t key,
|
||||||
{.base = signature, .len = signature_length}
|
{.base = signature, .len = signature_length}
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_verify_hash,
|
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_verify_hash,
|
||||||
TFM_CRYPTO_VERIFY_HASH);
|
TFM_CRYPTO_VERIFY_HASH);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1140,19 +1027,15 @@ psa_status_t psa_asymmetric_encrypt(psa_key_id_t key,
|
||||||
{.base = output, .len = output_size},
|
{.base = output, .len = output_size},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
size_t in_len = IOVEC_LEN(in_vec);
|
||||||
|
|
||||||
size_t in_len = ARRAY_SIZE(in_vec);
|
|
||||||
if (salt == NULL) {
|
if (salt == NULL) {
|
||||||
in_len--;
|
in_len--;
|
||||||
}
|
}
|
||||||
status = psa_call(ipc_handle, PSA_IPC_CALL, in_vec, in_len,
|
status = psa_call(TFM_CRYPTO_HANDLE, PSA_IPC_CALL, in_vec, in_len,
|
||||||
out_vec, ARRAY_SIZE(out_vec));
|
out_vec, IOVEC_LEN(out_vec));
|
||||||
|
|
||||||
*output_length = out_vec[0].len;
|
*output_length = out_vec[0].len;
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1188,19 +1071,15 @@ psa_status_t psa_asymmetric_decrypt(psa_key_id_t key,
|
||||||
{.base = output, .len = output_size},
|
{.base = output, .len = output_size},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
size_t in_len = IOVEC_LEN(in_vec);
|
||||||
|
|
||||||
size_t in_len = ARRAY_SIZE(in_vec);
|
|
||||||
if (salt == NULL) {
|
if (salt == NULL) {
|
||||||
in_len--;
|
in_len--;
|
||||||
}
|
}
|
||||||
status = psa_call(ipc_handle, PSA_IPC_CALL, in_vec, in_len,
|
status = psa_call(TFM_CRYPTO_HANDLE, PSA_IPC_CALL, in_vec, in_len,
|
||||||
out_vec, ARRAY_SIZE(out_vec));
|
out_vec, IOVEC_LEN(out_vec));
|
||||||
|
|
||||||
*output_length = out_vec[0].len;
|
*output_length = out_vec[0].len;
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1222,13 +1101,9 @@ psa_status_t psa_key_derivation_get_capacity(
|
||||||
{.base = capacity, .len = sizeof(size_t)},
|
{.base = capacity, .len = sizeof(size_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_key_derivation_get_capacity,
|
status = API_DISPATCH(tfm_crypto_key_derivation_get_capacity,
|
||||||
TFM_CRYPTO_KEY_DERIVATION_GET_CAPACITY);
|
TFM_CRYPTO_KEY_DERIVATION_GET_CAPACITY);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1251,13 +1126,9 @@ psa_status_t psa_key_derivation_output_bytes(
|
||||||
{.base = output, .len = output_length},
|
{.base = output, .len = output_length},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_key_derivation_output_bytes,
|
status = API_DISPATCH(tfm_crypto_key_derivation_output_bytes,
|
||||||
TFM_CRYPTO_KEY_DERIVATION_OUTPUT_BYTES);
|
TFM_CRYPTO_KEY_DERIVATION_OUTPUT_BYTES);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1278,13 +1149,9 @@ psa_status_t psa_key_derivation_input_key(
|
||||||
{.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
|
{.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_key_derivation_input_key,
|
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_key_derivation_input_key,
|
||||||
TFM_CRYPTO_KEY_DERIVATION_INPUT_KEY);
|
TFM_CRYPTO_KEY_DERIVATION_INPUT_KEY);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1305,13 +1172,9 @@ psa_status_t psa_key_derivation_abort(
|
||||||
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_key_derivation_abort,
|
status = API_DISPATCH(tfm_crypto_key_derivation_abort,
|
||||||
TFM_CRYPTO_KEY_DERIVATION_ABORT);
|
TFM_CRYPTO_KEY_DERIVATION_ABORT);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1335,13 +1198,9 @@ psa_status_t psa_key_derivation_key_agreement(
|
||||||
{.base = peer_key, .len = peer_key_length},
|
{.base = peer_key, .len = peer_key_length},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_key_derivation_key_agreement,
|
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_key_derivation_key_agreement,
|
||||||
TFM_CRYPTO_KEY_DERIVATION_KEY_AGREEMENT);
|
TFM_CRYPTO_KEY_DERIVATION_KEY_AGREEMENT);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1365,13 +1224,9 @@ psa_status_t psa_generate_random(uint8_t *output,
|
||||||
return PSA_SUCCESS;
|
return PSA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_generate_random,
|
status = API_DISPATCH(tfm_crypto_generate_random,
|
||||||
TFM_CRYPTO_GENERATE_RANDOM);
|
TFM_CRYPTO_GENERATE_RANDOM);
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1392,36 +1247,8 @@ psa_status_t psa_generate_key(const psa_key_attributes_t *attributes,
|
||||||
{.base = key, .len = sizeof(psa_key_id_t)},
|
{.base = key, .len = sizeof(psa_key_id_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_generate_key,
|
status = API_DISPATCH(tfm_crypto_generate_key,
|
||||||
TFM_CRYPTO_GENERATE_KEY);
|
TFM_CRYPTO_GENERATE_KEY);
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
psa_status_t psa_set_key_domain_parameters(psa_key_attributes_t *attributes,
|
|
||||||
psa_key_type_t type,
|
|
||||||
const uint8_t *data,
|
|
||||||
size_t data_length)
|
|
||||||
{
|
|
||||||
psa_status_t status;
|
|
||||||
|
|
||||||
status = PSA_ERROR_NOT_SUPPORTED;
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
psa_status_t psa_get_key_domain_parameters(
|
|
||||||
const psa_key_attributes_t *attributes,
|
|
||||||
uint8_t *data,
|
|
||||||
size_t data_size,
|
|
||||||
size_t *data_length)
|
|
||||||
{
|
|
||||||
psa_status_t status;
|
|
||||||
|
|
||||||
status = PSA_ERROR_NOT_SUPPORTED;
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -1484,8 +1311,26 @@ psa_status_t psa_mac_compute(psa_key_id_t key,
|
||||||
size_t *mac_length)
|
size_t *mac_length)
|
||||||
{
|
{
|
||||||
psa_status_t status;
|
psa_status_t status;
|
||||||
|
struct tfm_crypto_pack_iovec iov = {
|
||||||
|
.sfn_id = TFM_CRYPTO_MAC_COMPUTE_SID,
|
||||||
|
.key_id = key,
|
||||||
|
.alg = alg,
|
||||||
|
};
|
||||||
|
|
||||||
status = PSA_ERROR_NOT_SUPPORTED;
|
psa_invec in_vec[] = {
|
||||||
|
{.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
|
||||||
|
{.base = input, .len = input_length},
|
||||||
|
};
|
||||||
|
psa_outvec out_vec[] = {
|
||||||
|
{.base = mac, .len = mac_size},
|
||||||
|
};
|
||||||
|
|
||||||
|
status = API_DISPATCH(tfm_crypto_mac_compute,
|
||||||
|
TFM_CRYPTO_MAC_COMPUTE);
|
||||||
|
|
||||||
|
if (status == PSA_SUCCESS) {
|
||||||
|
*mac_length = out_vec[0].len;
|
||||||
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -1498,8 +1343,20 @@ psa_status_t psa_mac_verify(psa_key_id_t key,
|
||||||
const size_t mac_length)
|
const size_t mac_length)
|
||||||
{
|
{
|
||||||
psa_status_t status;
|
psa_status_t status;
|
||||||
|
struct tfm_crypto_pack_iovec iov = {
|
||||||
|
.sfn_id = TFM_CRYPTO_MAC_VERIFY_SID,
|
||||||
|
.key_id = key,
|
||||||
|
.alg = alg,
|
||||||
|
};
|
||||||
|
|
||||||
status = PSA_ERROR_NOT_SUPPORTED;
|
psa_invec in_vec[] = {
|
||||||
|
{.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
|
||||||
|
{.base = input, .len = input_length},
|
||||||
|
{.base = mac, .len = mac_length},
|
||||||
|
};
|
||||||
|
|
||||||
|
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_mac_verify,
|
||||||
|
TFM_CRYPTO_MAC_VERIFY);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -1513,8 +1370,26 @@ psa_status_t psa_cipher_encrypt(psa_key_id_t key,
|
||||||
size_t *output_length)
|
size_t *output_length)
|
||||||
{
|
{
|
||||||
psa_status_t status;
|
psa_status_t status;
|
||||||
|
struct tfm_crypto_pack_iovec iov = {
|
||||||
|
.sfn_id = TFM_CRYPTO_CIPHER_ENCRYPT_SID,
|
||||||
|
.key_id = key,
|
||||||
|
.alg = alg,
|
||||||
|
};
|
||||||
|
|
||||||
status = PSA_ERROR_NOT_SUPPORTED;
|
psa_invec in_vec[] = {
|
||||||
|
{.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
|
||||||
|
{.base = input, .len = input_length},
|
||||||
|
};
|
||||||
|
psa_outvec out_vec[] = {
|
||||||
|
{.base = output, .len = output_size}
|
||||||
|
};
|
||||||
|
|
||||||
|
status = API_DISPATCH(tfm_crypto_cipher_encrypt,
|
||||||
|
TFM_CRYPTO_CIPHER_ENCRYPT);
|
||||||
|
|
||||||
|
if (status == PSA_SUCCESS) {
|
||||||
|
*output_length = out_vec[0].len;
|
||||||
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -1528,8 +1403,26 @@ psa_status_t psa_cipher_decrypt(psa_key_id_t key,
|
||||||
size_t *output_length)
|
size_t *output_length)
|
||||||
{
|
{
|
||||||
psa_status_t status;
|
psa_status_t status;
|
||||||
|
struct tfm_crypto_pack_iovec iov = {
|
||||||
|
.sfn_id = TFM_CRYPTO_CIPHER_DECRYPT_SID,
|
||||||
|
.key_id = key,
|
||||||
|
.alg = alg,
|
||||||
|
};
|
||||||
|
|
||||||
status = PSA_ERROR_NOT_SUPPORTED;
|
psa_invec in_vec[] = {
|
||||||
|
{.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
|
||||||
|
{.base = input, .len = input_length},
|
||||||
|
};
|
||||||
|
psa_outvec out_vec[] = {
|
||||||
|
{.base = output, .len = output_size}
|
||||||
|
};
|
||||||
|
|
||||||
|
status = API_DISPATCH(tfm_crypto_cipher_decrypt,
|
||||||
|
TFM_CRYPTO_CIPHER_DECRYPT);
|
||||||
|
|
||||||
|
if (status == PSA_SUCCESS) {
|
||||||
|
*output_length = out_vec[0].len;
|
||||||
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -1558,15 +1451,11 @@ psa_status_t psa_raw_key_agreement(psa_algorithm_t alg,
|
||||||
{.base = output, .len = output_size},
|
{.base = output, .len = output_size},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_raw_key_agreement,
|
status = API_DISPATCH(tfm_crypto_raw_key_agreement,
|
||||||
TFM_CRYPTO_RAW_KEY_AGREEMENT);
|
TFM_CRYPTO_RAW_KEY_AGREEMENT);
|
||||||
|
|
||||||
*output_length = out_vec[0].len;
|
*output_length = out_vec[0].len;
|
||||||
|
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1587,11 +1476,8 @@ psa_status_t psa_key_derivation_setup(psa_key_derivation_operation_t *operation,
|
||||||
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
{.base = &(operation->handle), .len = sizeof(uint32_t)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_key_derivation_setup,
|
status = API_DISPATCH(tfm_crypto_key_derivation_setup,
|
||||||
TFM_CRYPTO_KEY_DERIVATION_SETUP);
|
TFM_CRYPTO_KEY_DERIVATION_SETUP);
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -1611,11 +1497,8 @@ psa_status_t psa_key_derivation_set_capacity(
|
||||||
{.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
|
{.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_key_derivation_set_capacity,
|
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_key_derivation_set_capacity,
|
||||||
TFM_CRYPTO_KEY_DERIVATION_SET_CAPACITY);
|
TFM_CRYPTO_KEY_DERIVATION_SET_CAPACITY);
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -1638,11 +1521,8 @@ psa_status_t psa_key_derivation_input_bytes(
|
||||||
{.base = data, .len = data_length},
|
{.base = data, .len = data_length},
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_key_derivation_input_bytes,
|
status = API_DISPATCH_NO_OUTVEC(tfm_crypto_key_derivation_input_bytes,
|
||||||
TFM_CRYPTO_KEY_DERIVATION_INPUT_BYTES);
|
TFM_CRYPTO_KEY_DERIVATION_INPUT_BYTES);
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -1667,11 +1547,8 @@ psa_status_t psa_key_derivation_output_key(
|
||||||
{.base = key, .len = sizeof(psa_key_id_t)}
|
{.base = key, .len = sizeof(psa_key_id_t)}
|
||||||
};
|
};
|
||||||
|
|
||||||
PSA_CONNECT(TFM_CRYPTO);
|
|
||||||
|
|
||||||
status = API_DISPATCH(tfm_crypto_key_derivation_output_key,
|
status = API_DISPATCH(tfm_crypto_key_derivation_output_key,
|
||||||
TFM_CRYPTO_KEY_DERIVATION_OUTPUT_KEY);
|
TFM_CRYPTO_KEY_DERIVATION_OUTPUT_KEY);
|
||||||
PSA_CLOSE();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,10 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "psa/update.h"
|
|
||||||
#include "tfm_api.h"
|
|
||||||
|
|
||||||
#include "psa/client.h"
|
#include "psa/client.h"
|
||||||
|
#include "psa/update.h"
|
||||||
#include "psa_manifest/sid.h"
|
#include "psa_manifest/sid.h"
|
||||||
|
#include "tfm_api.h"
|
||||||
#define IOVEC_LEN(x) (uint32_t)(sizeof(x)/sizeof(x[0]))
|
|
||||||
|
|
||||||
psa_status_t psa_fwu_write(const psa_image_id_t image_id,
|
psa_status_t psa_fwu_write(const psa_image_id_t image_id,
|
||||||
size_t block_offset,
|
size_t block_offset,
|
||||||
|
@ -158,10 +155,13 @@ psa_status_t psa_fwu_request_reboot(void)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t psa_fwu_accept(void)
|
psa_status_t psa_fwu_accept(psa_image_id_t image_id)
|
||||||
{
|
{
|
||||||
psa_handle_t handle;
|
psa_handle_t handle;
|
||||||
psa_status_t status;
|
psa_status_t status;
|
||||||
|
psa_invec in_vec[] = {
|
||||||
|
{ .base = &image_id, .len = sizeof(image_id) }
|
||||||
|
};
|
||||||
|
|
||||||
handle = psa_connect(TFM_FWU_ACCEPT_SID,
|
handle = psa_connect(TFM_FWU_ACCEPT_SID,
|
||||||
TFM_FWU_ACCEPT_VERSION);
|
TFM_FWU_ACCEPT_VERSION);
|
||||||
|
@ -169,7 +169,7 @@ psa_status_t psa_fwu_accept(void)
|
||||||
return PSA_ERROR_GENERIC_ERROR;
|
return PSA_ERROR_GENERIC_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = psa_call(handle, PSA_IPC_CALL, NULL, 0, NULL, 0);
|
status = psa_call(handle, PSA_IPC_CALL, in_vec, IOVEC_LEN(in_vec), NULL, 0);
|
||||||
|
|
||||||
psa_close(handle);
|
psa_close(handle);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2020, Arm Limited. All rights reserved.
|
* Copyright (c) 2018-2021, Arm Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*
|
*
|
||||||
|
@ -11,8 +11,6 @@
|
||||||
#include "psa/crypto_types.h"
|
#include "psa/crypto_types.h"
|
||||||
#include "psa_manifest/sid.h"
|
#include "psa_manifest/sid.h"
|
||||||
|
|
||||||
#define IOVEC_LEN(x) (sizeof(x)/sizeof(x[0]))
|
|
||||||
|
|
||||||
psa_status_t
|
psa_status_t
|
||||||
psa_initial_attest_get_token(const uint8_t *auth_challenge,
|
psa_initial_attest_get_token(const uint8_t *auth_challenge,
|
||||||
size_t challenge_size,
|
size_t challenge_size,
|
||||||
|
@ -74,32 +72,3 @@ psa_initial_attest_get_token_size(size_t challenge_size,
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t
|
|
||||||
tfm_initial_attest_get_public_key(uint8_t *public_key,
|
|
||||||
size_t public_key_buf_size,
|
|
||||||
size_t *public_key_len,
|
|
||||||
psa_ecc_family_t *elliptic_curve_type)
|
|
||||||
{
|
|
||||||
psa_handle_t handle = PSA_NULL_HANDLE;
|
|
||||||
psa_status_t status;
|
|
||||||
|
|
||||||
psa_outvec out_vec[] = {
|
|
||||||
{.base = public_key, .len = public_key_buf_size},
|
|
||||||
{.base = elliptic_curve_type, .len = sizeof(*elliptic_curve_type)},
|
|
||||||
{.base = public_key_len, .len = sizeof(*public_key_len)}
|
|
||||||
};
|
|
||||||
|
|
||||||
handle = psa_connect(TFM_ATTEST_GET_PUBLIC_KEY_SID,
|
|
||||||
TFM_ATTEST_GET_PUBLIC_KEY_VERSION);
|
|
||||||
if (!PSA_HANDLE_IS_VALID(handle)) {
|
|
||||||
return PSA_HANDLE_TO_ERROR(handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
status = psa_call(handle, PSA_IPC_CALL,
|
|
||||||
NULL, 0,
|
|
||||||
out_vec, IOVEC_LEN(out_vec));
|
|
||||||
psa_close(handle);
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,17 +1,14 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, Arm Limited. All rights reserved.
|
* Copyright (c) 2019-2021, Arm Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "psa/internal_trusted_storage.h"
|
|
||||||
#include "tfm_api.h"
|
|
||||||
|
|
||||||
#include "psa/client.h"
|
#include "psa/client.h"
|
||||||
|
#include "psa/internal_trusted_storage.h"
|
||||||
#include "psa_manifest/sid.h"
|
#include "psa_manifest/sid.h"
|
||||||
|
#include "tfm_api.h"
|
||||||
#define IOVEC_LEN(x) (sizeof(x)/sizeof(x[0]))
|
|
||||||
|
|
||||||
psa_status_t psa_its_set(psa_storage_uid_t uid,
|
psa_status_t psa_its_set(psa_storage_uid_t uid,
|
||||||
size_t data_length,
|
size_t data_length,
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2017-2020, Arm Limited. All rights reserved.
|
* Copyright (c) 2017-2021, Arm Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "psa/client.h"
|
||||||
#include "psa/protected_storage.h"
|
#include "psa/protected_storage.h"
|
||||||
|
|
||||||
#include "tfm_ns_interface.h"
|
|
||||||
#include "psa_manifest/sid.h"
|
#include "psa_manifest/sid.h"
|
||||||
|
#include "tfm_ns_interface.h"
|
||||||
#define IOVEC_LEN(x) (uint32_t)(sizeof(x)/sizeof(x[0]))
|
|
||||||
|
|
||||||
psa_status_t psa_ps_set(psa_storage_uid_t uid,
|
psa_status_t psa_ps_set(psa_storage_uid_t uid,
|
||||||
size_t data_length,
|
size_t data_length,
|
||||||
|
|
Loading…
Reference in New Issue