mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-27 01:14:14 +01:00
psa: Move key identifier related macros and functions
Move key identifier related macros and functions from crypto_types.h to crypto_values.h as the latter is the intended file to put them in. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
cb54610e97
commit
7424f0d998
@ -233,36 +233,6 @@ typedef uint32_t psa_key_id_t;
|
|||||||
#if !defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
|
#if !defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
|
||||||
typedef psa_key_id_t mbedtls_svc_key_id_t;
|
typedef psa_key_id_t mbedtls_svc_key_id_t;
|
||||||
|
|
||||||
#define MBEDTLS_SVC_KEY_ID_INIT ( (psa_key_id_t)0 )
|
|
||||||
#define MBEDTLS_SVC_KEY_ID_GET_KEY_ID( id ) ( id )
|
|
||||||
#define MBEDTLS_SVC_KEY_ID_GET_OWNER_ID( id ) ( 0 )
|
|
||||||
|
|
||||||
/** Utility to initialize a key identifier at runtime.
|
|
||||||
*
|
|
||||||
* \param unused Unused parameter.
|
|
||||||
* \param key_id Identifier of the key.
|
|
||||||
*/
|
|
||||||
static inline mbedtls_svc_key_id_t mbedtls_svc_key_id_make(
|
|
||||||
unsigned int unused, psa_key_id_t key_id )
|
|
||||||
{
|
|
||||||
(void)unused;
|
|
||||||
|
|
||||||
return( key_id );
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Compare two key identifiers.
|
|
||||||
*
|
|
||||||
* \param id1 First key identifier.
|
|
||||||
* \param id2 Second key identifier.
|
|
||||||
*
|
|
||||||
* \return Non-zero if the two key identifier are equal, zero otherwise.
|
|
||||||
*/
|
|
||||||
static inline int mbedtls_svc_key_id_equal( mbedtls_svc_key_id_t id1,
|
|
||||||
mbedtls_svc_key_id_t id2 )
|
|
||||||
{
|
|
||||||
return( id1 == id2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
|
#else /* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
|
||||||
/* Implementation-specific: The Mbed Cryptography library can be built as
|
/* Implementation-specific: The Mbed Cryptography library can be built as
|
||||||
* part of a multi-client service that exposes the PSA Cryptograpy API in each
|
* part of a multi-client service that exposes the PSA Cryptograpy API in each
|
||||||
@ -275,36 +245,6 @@ typedef struct
|
|||||||
mbedtls_key_owner_id_t owner;
|
mbedtls_key_owner_id_t owner;
|
||||||
} mbedtls_svc_key_id_t;
|
} mbedtls_svc_key_id_t;
|
||||||
|
|
||||||
#define MBEDTLS_SVC_KEY_ID_INIT ( (mbedtls_svc_key_id_t){ 0, 0 } )
|
|
||||||
#define MBEDTLS_SVC_KEY_ID_GET_KEY_ID( id ) ( ( id ).key_id )
|
|
||||||
#define MBEDTLS_SVC_KEY_ID_GET_OWNER_ID( id ) ( ( id ).owner )
|
|
||||||
|
|
||||||
/** Utility to initialize a key identifier at runtime.
|
|
||||||
*
|
|
||||||
* \param owner_id Identifier of the key owner.
|
|
||||||
* \param key_id Identifier of the key.
|
|
||||||
*/
|
|
||||||
static inline mbedtls_svc_key_id_t mbedtls_svc_key_id_make(
|
|
||||||
mbedtls_key_owner_id_t owner_id, psa_key_id_t key_id )
|
|
||||||
{
|
|
||||||
return( (mbedtls_svc_key_id_t){ .key_id = key_id,
|
|
||||||
.owner = owner_id } );
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Compare two key identifiers.
|
|
||||||
*
|
|
||||||
* \param id1 First key identifier.
|
|
||||||
* \param id2 Second key identifier.
|
|
||||||
*
|
|
||||||
* \return Non-zero if the two key identifier are equal, zero otherwise.
|
|
||||||
*/
|
|
||||||
static inline int mbedtls_svc_key_id_equal( mbedtls_svc_key_id_t id1,
|
|
||||||
mbedtls_svc_key_id_t id2 )
|
|
||||||
{
|
|
||||||
return( ( id1.key_id == id2.key_id ) &&
|
|
||||||
mbedtls_key_owner_id_equal( id1.owner, id2.owner ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* !MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
|
#endif /* !MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
@ -1647,6 +1647,73 @@
|
|||||||
*/
|
*/
|
||||||
#define PSA_KEY_ID_VENDOR_MAX ((psa_key_id_t)0x7fffffff)
|
#define PSA_KEY_ID_VENDOR_MAX ((psa_key_id_t)0x7fffffff)
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
|
||||||
|
|
||||||
|
#define MBEDTLS_SVC_KEY_ID_INIT ( (psa_key_id_t)0 )
|
||||||
|
#define MBEDTLS_SVC_KEY_ID_GET_KEY_ID( id ) ( id )
|
||||||
|
#define MBEDTLS_SVC_KEY_ID_GET_OWNER_ID( id ) ( 0 )
|
||||||
|
|
||||||
|
/** Utility to initialize a key identifier at runtime.
|
||||||
|
*
|
||||||
|
* \param unused Unused parameter.
|
||||||
|
* \param key_id Identifier of the key.
|
||||||
|
*/
|
||||||
|
static inline mbedtls_svc_key_id_t mbedtls_svc_key_id_make(
|
||||||
|
unsigned int unused, psa_key_id_t key_id )
|
||||||
|
{
|
||||||
|
(void)unused;
|
||||||
|
|
||||||
|
return( key_id );
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Compare two key identifiers.
|
||||||
|
*
|
||||||
|
* \param id1 First key identifier.
|
||||||
|
* \param id2 Second key identifier.
|
||||||
|
*
|
||||||
|
* \return Non-zero if the two key identifier are equal, zero otherwise.
|
||||||
|
*/
|
||||||
|
static inline int mbedtls_svc_key_id_equal( mbedtls_svc_key_id_t id1,
|
||||||
|
mbedtls_svc_key_id_t id2 )
|
||||||
|
{
|
||||||
|
return( id1 == id2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
|
||||||
|
|
||||||
|
#define MBEDTLS_SVC_KEY_ID_INIT ( (mbedtls_svc_key_id_t){ 0, 0 } )
|
||||||
|
#define MBEDTLS_SVC_KEY_ID_GET_KEY_ID( id ) ( ( id ).key_id )
|
||||||
|
#define MBEDTLS_SVC_KEY_ID_GET_OWNER_ID( id ) ( ( id ).owner )
|
||||||
|
|
||||||
|
/** Utility to initialize a key identifier at runtime.
|
||||||
|
*
|
||||||
|
* \param owner_id Identifier of the key owner.
|
||||||
|
* \param key_id Identifier of the key.
|
||||||
|
*/
|
||||||
|
static inline mbedtls_svc_key_id_t mbedtls_svc_key_id_make(
|
||||||
|
mbedtls_key_owner_id_t owner_id, psa_key_id_t key_id )
|
||||||
|
{
|
||||||
|
return( (mbedtls_svc_key_id_t){ .key_id = key_id,
|
||||||
|
.owner = owner_id } );
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Compare two key identifiers.
|
||||||
|
*
|
||||||
|
* \param id1 First key identifier.
|
||||||
|
* \param id2 Second key identifier.
|
||||||
|
*
|
||||||
|
* \return Non-zero if the two key identifier are equal, zero otherwise.
|
||||||
|
*/
|
||||||
|
static inline int mbedtls_svc_key_id_equal( mbedtls_svc_key_id_t id1,
|
||||||
|
mbedtls_svc_key_id_t id2 )
|
||||||
|
{
|
||||||
|
return( ( id1.key_id == id2.key_id ) &&
|
||||||
|
mbedtls_key_owner_id_equal( id1.owner, id2.owner ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* !MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
/** \defgroup policy Key policies
|
/** \defgroup policy Key policies
|
||||||
|
Loading…
Reference in New Issue
Block a user