mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-08 17:42:09 +03:00
Switch to the new code style
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@@ -116,7 +116,7 @@ psa_status_t psa_crypto_init(void);
|
||||
/* This is an example definition for documentation purposes.
|
||||
* Implementations should define a suitable value in `crypto_struct.h`.
|
||||
*/
|
||||
#define PSA_KEY_ATTRIBUTES_INIT {0}
|
||||
#define PSA_KEY_ATTRIBUTES_INIT { 0 }
|
||||
#endif
|
||||
|
||||
/** Return an initial value for a key attributes structure.
|
||||
@@ -143,8 +143,8 @@ static psa_key_attributes_t psa_key_attributes_init(void);
|
||||
* \param[out] attributes The attribute structure to write to.
|
||||
* \param key The persistent identifier for the key.
|
||||
*/
|
||||
static void psa_set_key_id( psa_key_attributes_t *attributes,
|
||||
mbedtls_svc_key_id_t key );
|
||||
static void psa_set_key_id(psa_key_attributes_t *attributes,
|
||||
mbedtls_svc_key_id_t key);
|
||||
|
||||
#ifdef MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
|
||||
/** Set the owner identifier of a key.
|
||||
@@ -161,8 +161,8 @@ static void psa_set_key_id( psa_key_attributes_t *attributes,
|
||||
* \param[out] attributes The attribute structure to write to.
|
||||
* \param owner The key owner identifier.
|
||||
*/
|
||||
static void mbedtls_set_key_owner_id( psa_key_attributes_t *attributes,
|
||||
mbedtls_key_owner_id_t owner );
|
||||
static void mbedtls_set_key_owner_id(psa_key_attributes_t *attributes,
|
||||
mbedtls_key_owner_id_t owner);
|
||||
#endif
|
||||
|
||||
/** Set the location of a persistent key.
|
||||
@@ -944,7 +944,7 @@ typedef struct psa_hash_operation_s psa_hash_operation_t;
|
||||
/* This is an example definition for documentation purposes.
|
||||
* Implementations should define a suitable value in `crypto_struct.h`.
|
||||
*/
|
||||
#define PSA_HASH_OPERATION_INIT {0}
|
||||
#define PSA_HASH_OPERATION_INIT { 0 }
|
||||
#endif
|
||||
|
||||
/** Return an initial value for a hash operation object.
|
||||
@@ -1308,7 +1308,7 @@ 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}
|
||||
#define PSA_MAC_OPERATION_INIT { 0 }
|
||||
#endif
|
||||
|
||||
/** Return an initial value for a MAC operation object.
|
||||
@@ -1727,7 +1727,7 @@ typedef struct psa_cipher_operation_s psa_cipher_operation_t;
|
||||
/* This is an example definition for documentation purposes.
|
||||
* Implementations should define a suitable value in `crypto_struct.h`.
|
||||
*/
|
||||
#define PSA_CIPHER_OPERATION_INIT {0}
|
||||
#define PSA_CIPHER_OPERATION_INIT { 0 }
|
||||
#endif
|
||||
|
||||
/** Return an initial value for a cipher operation object.
|
||||
@@ -2251,7 +2251,7 @@ typedef struct psa_aead_operation_s psa_aead_operation_t;
|
||||
/* This is an example definition for documentation purposes.
|
||||
* Implementations should define a suitable value in `crypto_struct.h`.
|
||||
*/
|
||||
#define PSA_AEAD_OPERATION_INIT {0}
|
||||
#define PSA_AEAD_OPERATION_INIT { 0 }
|
||||
#endif
|
||||
|
||||
/** Return an initial value for an AEAD operation object.
|
||||
@@ -2913,13 +2913,13 @@ psa_status_t psa_aead_abort(psa_aead_operation_t *operation);
|
||||
* It is implementation-dependent whether a failure to initialize
|
||||
* results in this error code.
|
||||
*/
|
||||
psa_status_t psa_sign_message( mbedtls_svc_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 );
|
||||
psa_status_t psa_sign_message(mbedtls_svc_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.
|
||||
@@ -2965,12 +2965,12 @@ psa_status_t psa_sign_message( mbedtls_svc_key_id_t key,
|
||||
* It is implementation-dependent whether a failure to initialize
|
||||
* results in this error code.
|
||||
*/
|
||||
psa_status_t psa_verify_message( mbedtls_svc_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 psa_verify_message(mbedtls_svc_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.
|
||||
@@ -3244,7 +3244,7 @@ typedef struct psa_key_derivation_s psa_key_derivation_operation_t;
|
||||
/* 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}
|
||||
#define PSA_KEY_DERIVATION_OPERATION_INIT { 0 }
|
||||
#endif
|
||||
|
||||
/** Return an initial value for a key derivation operation object.
|
||||
@@ -3371,7 +3371,7 @@ psa_status_t psa_key_derivation_set_capacity(
|
||||
* The value of the maximum possible capacity depends on the key derivation
|
||||
* algorithm.
|
||||
*/
|
||||
#define PSA_KEY_DERIVATION_UNLIMITED_CAPACITY ((size_t)(-1))
|
||||
#define PSA_KEY_DERIVATION_UNLIMITED_CAPACITY ((size_t) (-1))
|
||||
|
||||
/** Provide an input for key derivation or key agreement.
|
||||
*
|
||||
|
@@ -50,8 +50,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_HMAC) || defined(PSA_CRYPTO_DRIVER_TEST)
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
/** The HMAC algorithm in use */
|
||||
psa_algorithm_t alg;
|
||||
/** The hash context. */
|
||||
@@ -60,16 +59,14 @@ typedef struct
|
||||
uint8_t opad[PSA_HMAC_MAX_HASH_BLOCK_SIZE];
|
||||
} mbedtls_psa_hmac_operation_t;
|
||||
|
||||
#define MBEDTLS_PSA_HMAC_OPERATION_INIT {0, PSA_HASH_OPERATION_INIT, {0}}
|
||||
#define MBEDTLS_PSA_HMAC_OPERATION_INIT { 0, PSA_HASH_OPERATION_INIT, { 0 } }
|
||||
#endif /* MBEDTLS_PSA_BUILTIN_ALG_HMAC */
|
||||
|
||||
#include "mbedtls/cmac.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
psa_algorithm_t alg;
|
||||
union
|
||||
{
|
||||
union {
|
||||
unsigned dummy; /* Make the union non-empty even with no supported algorithms. */
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_HMAC) || defined(PSA_CRYPTO_DRIVER_TEST)
|
||||
mbedtls_psa_hmac_operation_t hmac;
|
||||
@@ -80,6 +77,6 @@ typedef struct
|
||||
} ctx;
|
||||
} mbedtls_psa_mac_operation_t;
|
||||
|
||||
#define MBEDTLS_PSA_MAC_OPERATION_INIT {0, {0}}
|
||||
#define MBEDTLS_PSA_MAC_OPERATION_INIT { 0, { 0 } }
|
||||
|
||||
#endif /* PSA_CRYPTO_BUILTIN_COMPOSITES_H */
|
||||
|
@@ -59,11 +59,9 @@
|
||||
#define MBEDTLS_PSA_BUILTIN_HASH
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
psa_algorithm_t alg;
|
||||
union
|
||||
{
|
||||
union {
|
||||
unsigned dummy; /* Make the union non-empty even with no supported algorithms. */
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_MD2)
|
||||
mbedtls_md2_context md2;
|
||||
@@ -81,17 +79,17 @@ typedef struct
|
||||
mbedtls_sha1_context sha1;
|
||||
#endif
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_256) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_224)
|
||||
defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_224)
|
||||
mbedtls_sha256_context sha256;
|
||||
#endif
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_512) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_384)
|
||||
defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_384)
|
||||
mbedtls_sha512_context sha512;
|
||||
#endif
|
||||
} ctx;
|
||||
} mbedtls_psa_hash_operation_t;
|
||||
|
||||
#define MBEDTLS_PSA_HASH_OPERATION_INIT {0, {0}}
|
||||
#define MBEDTLS_PSA_HASH_OPERATION_INIT { 0, { 0 } }
|
||||
|
||||
/*
|
||||
* Cipher multi-part operation definitions.
|
||||
@@ -120,6 +118,6 @@ typedef struct {
|
||||
} ctx;
|
||||
} mbedtls_psa_cipher_operation_t;
|
||||
|
||||
#define MBEDTLS_PSA_CIPHER_OPERATION_INIT {0, 0, 0, {0}}
|
||||
#define MBEDTLS_PSA_CIPHER_OPERATION_INIT { 0, 0, 0, { 0 } }
|
||||
|
||||
#endif /* PSA_CRYPTO_BUILTIN_PRIMITIVES_H */
|
||||
|
@@ -50,9 +50,9 @@ typedef mbedtls_svc_key_id_t psa_key_handle_t;
|
||||
*
|
||||
* \return Non-zero if the handle is null, zero otherwise.
|
||||
*/
|
||||
static inline int psa_key_handle_is_null( psa_key_handle_t handle )
|
||||
static inline int psa_key_handle_is_null(psa_key_handle_t handle)
|
||||
{
|
||||
return( mbedtls_svc_key_id_is_null( handle ) );
|
||||
return mbedtls_svc_key_id_is_null(handle);
|
||||
}
|
||||
|
||||
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
|
||||
@@ -78,196 +78,197 @@ typedef MBEDTLS_PSA_DEPRECATED psa_algorithm_t mbedtls_deprecated_psa_algorithm_
|
||||
#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 ) )
|
||||
#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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 ) )
|
||||
#define PSA_KEY_EXPORT_MAX_SIZE( key_type, key_bits ) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_EXPORT_KEY_OUTPUT_SIZE( key_type, key_bits ) )
|
||||
#define PSA_BLOCK_CIPHER_BLOCK_SIZE( type ) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_BLOCK_CIPHER_BLOCK_LENGTH( type ) )
|
||||
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))
|
||||
#define PSA_KEY_EXPORT_MAX_SIZE(key_type, key_bits) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT(size_t, PSA_EXPORT_KEY_OUTPUT_SIZE(key_type, key_bits))
|
||||
#define PSA_BLOCK_CIPHER_BLOCK_SIZE(type) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT(size_t, PSA_BLOCK_CIPHER_BLOCK_LENGTH(type))
|
||||
#define PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE \
|
||||
MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE )
|
||||
#define PSA_HASH_SIZE( alg ) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_HASH_LENGTH( alg ) )
|
||||
#define PSA_MAC_FINAL_SIZE( key_type, key_bits, alg ) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_MAC_LENGTH( key_type, key_bits, alg ) )
|
||||
MBEDTLS_DEPRECATED_CONSTANT(size_t, PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE)
|
||||
#define PSA_HASH_SIZE(alg) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT(size_t, PSA_HASH_LENGTH(alg))
|
||||
#define PSA_MAC_FINAL_SIZE(key_type, key_bits, alg) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT(size_t, PSA_MAC_LENGTH(key_type, key_bits, alg))
|
||||
#define PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN \
|
||||
MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_TLS12_PSK_TO_MS_PSK_MAX_SIZE )
|
||||
MBEDTLS_DEPRECATED_CONSTANT(size_t, PSA_TLS12_PSK_TO_MS_PSK_MAX_SIZE)
|
||||
|
||||
/*
|
||||
* Deprecated PSA Crypto function names (PSA Crypto API <= 1.0 beta3)
|
||||
*/
|
||||
MBEDTLS_PSA_DEPRECATED static inline 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 static inline 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)
|
||||
{
|
||||
return psa_sign_hash( key, alg, hash, hash_length, signature, signature_size, signature_length );
|
||||
return psa_sign_hash(key, alg, hash, hash_length, signature, signature_size, signature_length);
|
||||
}
|
||||
|
||||
MBEDTLS_PSA_DEPRECATED static inline 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 )
|
||||
MBEDTLS_PSA_DEPRECATED static inline 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)
|
||||
{
|
||||
return psa_verify_hash( key, alg, hash, hash_length, signature, signature_length );
|
||||
return psa_verify_hash(key, alg, hash, hash_length, signature, signature_length);
|
||||
}
|
||||
|
||||
/*
|
||||
* Size-specific elliptic curve families.
|
||||
*/
|
||||
#define PSA_ECC_CURVE_SECP160K1 \
|
||||
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
MBEDTLS_DEPRECATED_CONSTANT(psa_algorithm_t, PSA_ALG_STREAM_CIPHER)
|
||||
#define PSA_ALG_CHACHA20 \
|
||||
MBEDTLS_DEPRECATED_CONSTANT( psa_algorithm_t, PSA_ALG_STREAM_CIPHER )
|
||||
MBEDTLS_DEPRECATED_CONSTANT(psa_algorithm_t, PSA_ALG_STREAM_CIPHER)
|
||||
|
||||
/*
|
||||
* Renamed AEAD tag length macros (PSA Crypto API <= 1.0 beta3)
|
||||
*/
|
||||
#define PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH( aead_alg ) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT( psa_algorithm_t, PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG( aead_alg ) )
|
||||
#define PSA_ALG_AEAD_WITH_TAG_LENGTH( aead_alg, tag_length ) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT( psa_algorithm_t, PSA_ALG_AEAD_WITH_SHORTENED_TAG( aead_alg, tag_length ) )
|
||||
#define PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH(aead_alg) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT(psa_algorithm_t, PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG(aead_alg))
|
||||
#define PSA_ALG_AEAD_WITH_TAG_LENGTH(aead_alg, tag_length) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT(psa_algorithm_t, \
|
||||
PSA_ALG_AEAD_WITH_SHORTENED_TAG(aead_alg, tag_length))
|
||||
|
||||
/*
|
||||
* Deprecated PSA AEAD output size macros (PSA Crypto API <= 1.0 beta3)
|
||||
@@ -285,11 +286,11 @@ MBEDTLS_PSA_DEPRECATED static inline psa_status_t psa_asymmetric_verify( psa_key
|
||||
* the ciphertext, return 0.
|
||||
* If the AEAD algorithm is not recognized, return 0.
|
||||
*/
|
||||
#define PSA_AEAD_TAG_LENGTH_1_ARG( alg ) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT( size_t, \
|
||||
PSA_ALG_IS_AEAD( alg ) ? \
|
||||
PSA_ALG_AEAD_GET_TAG_LENGTH( alg ) : \
|
||||
0 )
|
||||
#define PSA_AEAD_TAG_LENGTH_1_ARG(alg) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT(size_t, \
|
||||
PSA_ALG_IS_AEAD(alg) ? \
|
||||
PSA_ALG_AEAD_GET_TAG_LENGTH(alg) : \
|
||||
0)
|
||||
|
||||
/** The maximum size of the output of psa_aead_encrypt(), in bytes.
|
||||
*
|
||||
@@ -311,11 +312,11 @@ MBEDTLS_PSA_DEPRECATED static inline psa_status_t psa_asymmetric_verify( psa_key
|
||||
* algorithm.
|
||||
* If the AEAD algorithm is not recognized, return 0.
|
||||
*/
|
||||
#define PSA_AEAD_ENCRYPT_OUTPUT_SIZE_2_ARG( alg, plaintext_length ) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT( size_t, \
|
||||
PSA_ALG_IS_AEAD( alg ) ? \
|
||||
(plaintext_length) + PSA_ALG_AEAD_GET_TAG_LENGTH( alg ) : \
|
||||
0 )
|
||||
#define PSA_AEAD_ENCRYPT_OUTPUT_SIZE_2_ARG(alg, plaintext_length) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT(size_t, \
|
||||
PSA_ALG_IS_AEAD(alg) ? \
|
||||
(plaintext_length) + PSA_ALG_AEAD_GET_TAG_LENGTH(alg) : \
|
||||
0)
|
||||
|
||||
/** The maximum size of the output of psa_aead_decrypt(), in bytes.
|
||||
*
|
||||
@@ -337,12 +338,12 @@ MBEDTLS_PSA_DEPRECATED static inline psa_status_t psa_asymmetric_verify( psa_key
|
||||
* algorithm.
|
||||
* If the AEAD algorithm is not recognized, return 0.
|
||||
*/
|
||||
#define PSA_AEAD_DECRYPT_OUTPUT_SIZE_2_ARG( alg, ciphertext_length ) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT( size_t, \
|
||||
PSA_ALG_IS_AEAD( alg ) && \
|
||||
(ciphertext_length) > PSA_ALG_AEAD_GET_TAG_LENGTH( alg ) ? \
|
||||
(ciphertext_length) - PSA_ALG_AEAD_GET_TAG_LENGTH( alg ) : \
|
||||
0 )
|
||||
#define PSA_AEAD_DECRYPT_OUTPUT_SIZE_2_ARG(alg, ciphertext_length) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT(size_t, \
|
||||
PSA_ALG_IS_AEAD(alg) && \
|
||||
(ciphertext_length) > PSA_ALG_AEAD_GET_TAG_LENGTH(alg) ? \
|
||||
(ciphertext_length) - PSA_ALG_AEAD_GET_TAG_LENGTH(alg) : \
|
||||
0)
|
||||
|
||||
/** A sufficient output buffer size for psa_aead_update().
|
||||
*
|
||||
@@ -368,11 +369,12 @@ MBEDTLS_PSA_DEPRECATED static inline psa_status_t psa_asymmetric_verify( psa_key
|
||||
* to emit output without delay. However, hardware may not always be
|
||||
* capable of this. So for modes based on a block cipher, allow the
|
||||
* implementation to delay the output until it has a full block. */
|
||||
#define PSA_AEAD_UPDATE_OUTPUT_SIZE_2_ARG( alg, input_length ) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT( size_t, \
|
||||
PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER( alg ) ? \
|
||||
PSA_ROUND_UP_TO_MULTIPLE( PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE, (input_length) ) : \
|
||||
(input_length) )
|
||||
#define PSA_AEAD_UPDATE_OUTPUT_SIZE_2_ARG(alg, input_length) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT(size_t, \
|
||||
PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
|
||||
PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE, \
|
||||
(input_length)) : \
|
||||
(input_length))
|
||||
|
||||
/** A sufficient ciphertext buffer size for psa_aead_finish().
|
||||
*
|
||||
@@ -389,11 +391,11 @@ MBEDTLS_PSA_DEPRECATED static inline psa_status_t psa_asymmetric_verify( psa_key
|
||||
* specified algorithm.
|
||||
* If the AEAD algorithm is not recognized, return 0.
|
||||
*/
|
||||
#define PSA_AEAD_FINISH_OUTPUT_SIZE_1_ARG( alg ) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT( size_t, \
|
||||
PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER( alg ) ? \
|
||||
PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE : \
|
||||
0 )
|
||||
#define PSA_AEAD_FINISH_OUTPUT_SIZE_1_ARG(alg) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT(size_t, \
|
||||
PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
|
||||
PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE : \
|
||||
0)
|
||||
|
||||
/** A sufficient plaintext buffer size for psa_aead_verify().
|
||||
*
|
||||
@@ -410,11 +412,11 @@ MBEDTLS_PSA_DEPRECATED static inline psa_status_t psa_asymmetric_verify( psa_key
|
||||
* specified algorithm.
|
||||
* If the AEAD algorithm is not recognized, return 0.
|
||||
*/
|
||||
#define PSA_AEAD_VERIFY_OUTPUT_SIZE_1_ARG( alg ) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT( size_t, \
|
||||
PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER( alg ) ? \
|
||||
PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE : \
|
||||
0 )
|
||||
#define PSA_AEAD_VERIFY_OUTPUT_SIZE_1_ARG(alg) \
|
||||
MBEDTLS_DEPRECATED_CONSTANT(size_t, \
|
||||
PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
|
||||
PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE : \
|
||||
0)
|
||||
|
||||
#endif /* MBEDTLS_DEPRECATED_REMOVED */
|
||||
|
||||
@@ -478,8 +480,8 @@ MBEDTLS_PSA_DEPRECATED static inline psa_status_t psa_asymmetric_verify( psa_key
|
||||
* It is implementation-dependent whether a failure to initialize
|
||||
* results in this error code.
|
||||
*/
|
||||
psa_status_t psa_open_key( mbedtls_svc_key_id_t key,
|
||||
psa_key_handle_t *handle );
|
||||
psa_status_t psa_open_key(mbedtls_svc_key_id_t key,
|
||||
psa_key_handle_t *handle);
|
||||
|
||||
/** Close a key handle.
|
||||
*
|
||||
|
@@ -50,25 +50,25 @@
|
||||
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
|
||||
defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_MAC)
|
||||
typedef libtestdriver1_mbedtls_psa_mac_operation_t
|
||||
mbedtls_transparent_test_driver_mac_operation_t;
|
||||
mbedtls_transparent_test_driver_mac_operation_t;
|
||||
typedef libtestdriver1_mbedtls_psa_mac_operation_t
|
||||
mbedtls_opaque_test_driver_mac_operation_t;
|
||||
mbedtls_opaque_test_driver_mac_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_MAC_OPERATION_INIT \
|
||||
LIBTESTDRIVER1_MBEDTLS_PSA_MAC_OPERATION_INIT
|
||||
LIBTESTDRIVER1_MBEDTLS_PSA_MAC_OPERATION_INIT
|
||||
#define MBEDTLS_OPAQUE_TEST_DRIVER_MAC_OPERATION_INIT \
|
||||
LIBTESTDRIVER1_MBEDTLS_PSA_MAC_OPERATION_INIT
|
||||
LIBTESTDRIVER1_MBEDTLS_PSA_MAC_OPERATION_INIT
|
||||
|
||||
#else
|
||||
typedef mbedtls_psa_mac_operation_t
|
||||
mbedtls_transparent_test_driver_mac_operation_t;
|
||||
mbedtls_transparent_test_driver_mac_operation_t;
|
||||
typedef mbedtls_psa_mac_operation_t
|
||||
mbedtls_opaque_test_driver_mac_operation_t;
|
||||
mbedtls_opaque_test_driver_mac_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_MAC_OPERATION_INIT \
|
||||
MBEDTLS_PSA_MAC_OPERATION_INIT
|
||||
MBEDTLS_PSA_MAC_OPERATION_INIT
|
||||
#define MBEDTLS_OPAQUE_TEST_DRIVER_MAC_OPERATION_INIT \
|
||||
MBEDTLS_PSA_MAC_OPERATION_INIT
|
||||
MBEDTLS_PSA_MAC_OPERATION_INIT
|
||||
|
||||
#endif /* MBEDTLS_TEST_LIBTESTDRIVER1 */
|
||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||
|
@@ -50,32 +50,32 @@
|
||||
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
|
||||
defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
|
||||
typedef libtestdriver1_mbedtls_psa_cipher_operation_t
|
||||
mbedtls_transparent_test_driver_cipher_operation_t;
|
||||
mbedtls_transparent_test_driver_cipher_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT \
|
||||
LIBTESTDRIVER1_MBEDTLS_PSA_CIPHER_OPERATION_INIT
|
||||
LIBTESTDRIVER1_MBEDTLS_PSA_CIPHER_OPERATION_INIT
|
||||
#else
|
||||
typedef mbedtls_psa_cipher_operation_t
|
||||
mbedtls_transparent_test_driver_cipher_operation_t;
|
||||
mbedtls_transparent_test_driver_cipher_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT \
|
||||
MBEDTLS_PSA_CIPHER_OPERATION_INIT
|
||||
MBEDTLS_PSA_CIPHER_OPERATION_INIT
|
||||
#endif /* MBEDTLS_TEST_LIBTESTDRIVER1 &&
|
||||
LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER */
|
||||
|
||||
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
|
||||
defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_HASH)
|
||||
typedef libtestdriver1_mbedtls_psa_hash_operation_t
|
||||
mbedtls_transparent_test_driver_hash_operation_t;
|
||||
mbedtls_transparent_test_driver_hash_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_HASH_OPERATION_INIT \
|
||||
LIBTESTDRIVER1_MBEDTLS_PSA_HASH_OPERATION_INIT
|
||||
LIBTESTDRIVER1_MBEDTLS_PSA_HASH_OPERATION_INIT
|
||||
#else
|
||||
typedef mbedtls_psa_hash_operation_t
|
||||
mbedtls_transparent_test_driver_hash_operation_t;
|
||||
mbedtls_transparent_test_driver_hash_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_HASH_OPERATION_INIT \
|
||||
MBEDTLS_PSA_HASH_OPERATION_INIT
|
||||
MBEDTLS_PSA_HASH_OPERATION_INIT
|
||||
#endif /* MBEDTLS_TEST_LIBTESTDRIVER1 &&
|
||||
LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_HASH */
|
||||
|
||||
@@ -85,7 +85,7 @@ typedef struct {
|
||||
} mbedtls_opaque_test_driver_cipher_operation_t;
|
||||
|
||||
#define MBEDTLS_OPAQUE_TEST_DRIVER_CIPHER_OPERATION_INIT \
|
||||
{ 0, MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT }
|
||||
{ 0, MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT }
|
||||
|
||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||
|
||||
|
@@ -84,7 +84,7 @@ static inline void psa_set_key_enrollment_algorithm(
|
||||
static inline psa_algorithm_t psa_get_key_enrollment_algorithm(
|
||||
const psa_key_attributes_t *attributes)
|
||||
{
|
||||
return( attributes->core.policy.alg2 );
|
||||
return attributes->core.policy.alg2;
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
|
||||
@@ -113,7 +113,7 @@ static inline psa_algorithm_t psa_get_key_enrollment_algorithm(
|
||||
*/
|
||||
psa_status_t psa_get_key_slot_number(
|
||||
const psa_key_attributes_t *attributes,
|
||||
psa_key_slot_number_t *slot_number );
|
||||
psa_key_slot_number_t *slot_number);
|
||||
|
||||
/** Choose the slot number where a key is stored.
|
||||
*
|
||||
@@ -140,7 +140,7 @@ psa_status_t psa_get_key_slot_number(
|
||||
*/
|
||||
static inline void psa_set_key_slot_number(
|
||||
psa_key_attributes_t *attributes,
|
||||
psa_key_slot_number_t slot_number )
|
||||
psa_key_slot_number_t slot_number)
|
||||
{
|
||||
attributes->core.flags |= MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER;
|
||||
attributes->slot_number = slot_number;
|
||||
@@ -153,7 +153,7 @@ static inline void psa_set_key_slot_number(
|
||||
* \param[out] attributes The attribute structure to write to.
|
||||
*/
|
||||
static inline void psa_clear_key_slot_number(
|
||||
psa_key_attributes_t *attributes )
|
||||
psa_key_attributes_t *attributes)
|
||||
{
|
||||
attributes->core.flags &= ~MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER;
|
||||
}
|
||||
@@ -213,7 +213,7 @@ psa_status_t mbedtls_psa_register_se_key(
|
||||
*
|
||||
* This is an Mbed TLS extension.
|
||||
*/
|
||||
void mbedtls_psa_crypto_free( void );
|
||||
void mbedtls_psa_crypto_free(void);
|
||||
|
||||
/** \brief Statistics about
|
||||
* resource consumption related to the PSA keystore.
|
||||
@@ -221,8 +221,7 @@ void mbedtls_psa_crypto_free( void );
|
||||
* \note The content of this structure is not part of the stable API and ABI
|
||||
* of Mbed Crypto and may change arbitrarily from version to version.
|
||||
*/
|
||||
typedef struct mbedtls_psa_stats_s
|
||||
{
|
||||
typedef struct mbedtls_psa_stats_s {
|
||||
/** Number of slots containing key material for a volatile key. */
|
||||
size_t volatile_slots;
|
||||
/** Number of slots containing key material for a key which is in
|
||||
@@ -253,7 +252,7 @@ typedef struct mbedtls_psa_stats_s
|
||||
* between the application and the keystore, the service may or
|
||||
* may not expose this function.
|
||||
*/
|
||||
void mbedtls_psa_get_stats( mbedtls_psa_stats_t *stats );
|
||||
void mbedtls_psa_get_stats(mbedtls_psa_stats_t *stats);
|
||||
|
||||
/**
|
||||
* \brief Inject an initial entropy seed for the random generator into
|
||||
@@ -336,7 +335,7 @@ psa_status_t mbedtls_psa_inject_entropy(const uint8_t *seed,
|
||||
* string. The length of the byte string is the length of the base prime `p`
|
||||
* in bytes.
|
||||
*/
|
||||
#define PSA_KEY_TYPE_DSA_PUBLIC_KEY ((psa_key_type_t)0x4002)
|
||||
#define PSA_KEY_TYPE_DSA_PUBLIC_KEY ((psa_key_type_t) 0x4002)
|
||||
|
||||
/** DSA key pair (private and public key).
|
||||
*
|
||||
@@ -354,13 +353,13 @@ psa_status_t mbedtls_psa_inject_entropy(const uint8_t *seed,
|
||||
* Add 1 to the resulting integer and use this as the private key *x*.
|
||||
*
|
||||
*/
|
||||
#define PSA_KEY_TYPE_DSA_KEY_PAIR ((psa_key_type_t)0x7002)
|
||||
#define PSA_KEY_TYPE_DSA_KEY_PAIR ((psa_key_type_t) 0x7002)
|
||||
|
||||
/** Whether a key type is a DSA key (pair or public-only). */
|
||||
#define PSA_KEY_TYPE_IS_DSA(type) \
|
||||
(PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) == PSA_KEY_TYPE_DSA_PUBLIC_KEY)
|
||||
|
||||
#define PSA_ALG_DSA_BASE ((psa_algorithm_t)0x06000400)
|
||||
#define PSA_ALG_DSA_BASE ((psa_algorithm_t) 0x06000400)
|
||||
/** DSA signature with hashing.
|
||||
*
|
||||
* This is the signature scheme defined by FIPS 186-4,
|
||||
@@ -377,7 +376,7 @@ psa_status_t mbedtls_psa_inject_entropy(const uint8_t *seed,
|
||||
*/
|
||||
#define PSA_ALG_DSA(hash_alg) \
|
||||
(PSA_ALG_DSA_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
|
||||
#define PSA_ALG_DETERMINISTIC_DSA_BASE ((psa_algorithm_t)0x06000500)
|
||||
#define PSA_ALG_DETERMINISTIC_DSA_BASE ((psa_algorithm_t) 0x06000500)
|
||||
#define PSA_ALG_DSA_DETERMINISTIC_FLAG PSA_ALG_ECDSA_DETERMINISTIC_FLAG
|
||||
/** Deterministic DSA signature with hashing.
|
||||
*
|
||||
@@ -584,53 +583,52 @@ psa_status_t psa_get_key_domain_parameters(
|
||||
* (`PSA_ECC_FAMILY_xxx`).
|
||||
* \return \c 0 on failure (\p grpid is not recognized).
|
||||
*/
|
||||
static inline psa_ecc_family_t mbedtls_ecc_group_to_psa( mbedtls_ecp_group_id grpid,
|
||||
size_t *bits )
|
||||
static inline psa_ecc_family_t mbedtls_ecc_group_to_psa(mbedtls_ecp_group_id grpid,
|
||||
size_t *bits)
|
||||
{
|
||||
switch( grpid )
|
||||
{
|
||||
switch (grpid) {
|
||||
case MBEDTLS_ECP_DP_SECP192R1:
|
||||
*bits = 192;
|
||||
return( PSA_ECC_FAMILY_SECP_R1 );
|
||||
return PSA_ECC_FAMILY_SECP_R1;
|
||||
case MBEDTLS_ECP_DP_SECP224R1:
|
||||
*bits = 224;
|
||||
return( PSA_ECC_FAMILY_SECP_R1 );
|
||||
return PSA_ECC_FAMILY_SECP_R1;
|
||||
case MBEDTLS_ECP_DP_SECP256R1:
|
||||
*bits = 256;
|
||||
return( PSA_ECC_FAMILY_SECP_R1 );
|
||||
return PSA_ECC_FAMILY_SECP_R1;
|
||||
case MBEDTLS_ECP_DP_SECP384R1:
|
||||
*bits = 384;
|
||||
return( PSA_ECC_FAMILY_SECP_R1 );
|
||||
return PSA_ECC_FAMILY_SECP_R1;
|
||||
case MBEDTLS_ECP_DP_SECP521R1:
|
||||
*bits = 521;
|
||||
return( PSA_ECC_FAMILY_SECP_R1 );
|
||||
return PSA_ECC_FAMILY_SECP_R1;
|
||||
case MBEDTLS_ECP_DP_BP256R1:
|
||||
*bits = 256;
|
||||
return( PSA_ECC_FAMILY_BRAINPOOL_P_R1 );
|
||||
return PSA_ECC_FAMILY_BRAINPOOL_P_R1;
|
||||
case MBEDTLS_ECP_DP_BP384R1:
|
||||
*bits = 384;
|
||||
return( PSA_ECC_FAMILY_BRAINPOOL_P_R1 );
|
||||
return PSA_ECC_FAMILY_BRAINPOOL_P_R1;
|
||||
case MBEDTLS_ECP_DP_BP512R1:
|
||||
*bits = 512;
|
||||
return( PSA_ECC_FAMILY_BRAINPOOL_P_R1 );
|
||||
return PSA_ECC_FAMILY_BRAINPOOL_P_R1;
|
||||
case MBEDTLS_ECP_DP_CURVE25519:
|
||||
*bits = 255;
|
||||
return( PSA_ECC_FAMILY_MONTGOMERY );
|
||||
return PSA_ECC_FAMILY_MONTGOMERY;
|
||||
case MBEDTLS_ECP_DP_SECP192K1:
|
||||
*bits = 192;
|
||||
return( PSA_ECC_FAMILY_SECP_K1 );
|
||||
return PSA_ECC_FAMILY_SECP_K1;
|
||||
case MBEDTLS_ECP_DP_SECP224K1:
|
||||
*bits = 224;
|
||||
return( PSA_ECC_FAMILY_SECP_K1 );
|
||||
return PSA_ECC_FAMILY_SECP_K1;
|
||||
case MBEDTLS_ECP_DP_SECP256K1:
|
||||
*bits = 256;
|
||||
return( PSA_ECC_FAMILY_SECP_K1 );
|
||||
return PSA_ECC_FAMILY_SECP_K1;
|
||||
case MBEDTLS_ECP_DP_CURVE448:
|
||||
*bits = 448;
|
||||
return( PSA_ECC_FAMILY_MONTGOMERY );
|
||||
return PSA_ECC_FAMILY_MONTGOMERY;
|
||||
default:
|
||||
*bits = 0;
|
||||
return( 0 );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -653,9 +651,9 @@ static inline psa_ecc_family_t mbedtls_ecc_group_to_psa( mbedtls_ecp_group_id gr
|
||||
* \return #MBEDTLS_ECP_DP_NONE if \p bits is not
|
||||
* correct for \p curve.
|
||||
*/
|
||||
mbedtls_ecp_group_id mbedtls_ecc_group_of_psa( psa_ecc_family_t curve,
|
||||
size_t bits,
|
||||
int bits_is_sloppy );
|
||||
mbedtls_ecp_group_id mbedtls_ecc_group_of_psa(psa_ecc_family_t curve,
|
||||
size_t bits,
|
||||
int bits_is_sloppy);
|
||||
#endif /* MBEDTLS_ECP_C */
|
||||
|
||||
/**@}*/
|
||||
@@ -706,7 +704,7 @@ mbedtls_ecp_group_id mbedtls_ecc_group_of_psa( psa_ecc_family_t curve,
|
||||
*/
|
||||
psa_status_t mbedtls_psa_external_get_random(
|
||||
mbedtls_psa_external_random_context_t *context,
|
||||
uint8_t *output, size_t output_size, size_t *output_length );
|
||||
uint8_t *output, size_t output_size, size_t *output_length);
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */
|
||||
|
||||
/**@}*/
|
||||
@@ -726,14 +724,14 @@ psa_status_t mbedtls_psa_external_get_random(
|
||||
* This value is part of the library's ABI since changing it would invalidate
|
||||
* the values of built-in key identifiers in applications.
|
||||
*/
|
||||
#define MBEDTLS_PSA_KEY_ID_BUILTIN_MIN ((psa_key_id_t)0x7fff0000)
|
||||
#define MBEDTLS_PSA_KEY_ID_BUILTIN_MIN ((psa_key_id_t) 0x7fff0000)
|
||||
|
||||
/** The maximum value for a key identifier that is built into the
|
||||
* implementation.
|
||||
*
|
||||
* See #MBEDTLS_PSA_KEY_ID_BUILTIN_MIN for more information.
|
||||
*/
|
||||
#define MBEDTLS_PSA_KEY_ID_BUILTIN_MAX ((psa_key_id_t)0x7fffefff)
|
||||
#define MBEDTLS_PSA_KEY_ID_BUILTIN_MAX ((psa_key_id_t) 0x7fffefff)
|
||||
|
||||
/** A slot number identifying a key in a driver.
|
||||
*
|
||||
@@ -751,10 +749,10 @@ typedef uint64_t psa_drv_slot_number_t;
|
||||
* \retval 0
|
||||
* The key identifier is not a builtin key identifier.
|
||||
*/
|
||||
static inline int psa_key_id_is_builtin( psa_key_id_t key_id )
|
||||
static inline int psa_key_id_is_builtin(psa_key_id_t key_id)
|
||||
{
|
||||
return( ( key_id >= MBEDTLS_PSA_KEY_ID_BUILTIN_MIN ) &&
|
||||
( key_id <= MBEDTLS_PSA_KEY_ID_BUILTIN_MAX ) );
|
||||
return (key_id >= MBEDTLS_PSA_KEY_ID_BUILTIN_MIN) &&
|
||||
(key_id <= MBEDTLS_PSA_KEY_ID_BUILTIN_MAX);
|
||||
}
|
||||
|
||||
/** Platform function to obtain the location and slot number of a built-in key.
|
||||
@@ -804,7 +802,7 @@ static inline int psa_key_id_is_builtin( psa_key_id_t key_id )
|
||||
psa_status_t mbedtls_psa_platform_get_builtin_key(
|
||||
mbedtls_svc_key_id_t key_id,
|
||||
psa_key_lifetime_t *lifetime,
|
||||
psa_drv_slot_number_t *slot_number );
|
||||
psa_drv_slot_number_t *slot_number);
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS */
|
||||
|
||||
/** @} */
|
||||
|
@@ -48,7 +48,7 @@
|
||||
/* PSA requires several types which C99 provides in stdint.h. */
|
||||
#include <stdint.h>
|
||||
|
||||
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
|
||||
#if (defined(__ARMCC_VERSION) || defined(_MSC_VER)) && \
|
||||
!defined(inline) && !defined(__cplusplus)
|
||||
#define inline __inline
|
||||
#endif
|
||||
@@ -73,10 +73,10 @@ typedef int32_t mbedtls_key_owner_id_t;
|
||||
*
|
||||
* \return Non-zero if the two key owner identifiers are equal, zero otherwise.
|
||||
*/
|
||||
static inline int mbedtls_key_owner_id_equal( mbedtls_key_owner_id_t id1,
|
||||
mbedtls_key_owner_id_t id2 )
|
||||
static inline int mbedtls_key_owner_id_equal(mbedtls_key_owner_id_t id1,
|
||||
mbedtls_key_owner_id_t id2)
|
||||
{
|
||||
return( id1 == id2 );
|
||||
return id1 == id2;
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
|
||||
|
@@ -322,7 +322,7 @@ typedef psa_status_t (*psa_drv_se_mac_verify_t)(psa_drv_se_context_t *drv_contex
|
||||
typedef struct {
|
||||
/**The size in bytes of the hardware-specific secure element MAC context
|
||||
* structure
|
||||
*/
|
||||
*/
|
||||
size_t context_size;
|
||||
/** Function that performs a MAC setup operation
|
||||
*/
|
||||
@@ -814,8 +814,7 @@ typedef struct {
|
||||
|
||||
/** An enumeration indicating how a key is created.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
PSA_KEY_CREATION_IMPORT, /**< During psa_import_key() */
|
||||
PSA_KEY_CREATION_GENERATE, /**< During psa_generate_key() */
|
||||
PSA_KEY_CREATION_DERIVE, /**< During psa_key_derivation_output_key() */
|
||||
@@ -1234,7 +1233,7 @@ typedef psa_status_t (*psa_drv_se_key_derivation_collateral_t)(void *op_context,
|
||||
* \retval #PSA_SUCCESS
|
||||
*/
|
||||
typedef psa_status_t (*psa_drv_se_key_derivation_derive_t)(void *op_context,
|
||||
psa_key_slot_number_t dest_key);
|
||||
psa_key_slot_number_t dest_key);
|
||||
|
||||
/** \brief A function that performs the final step of a secure element key
|
||||
* agreement and place the generated key material in a buffer
|
||||
|
@@ -275,7 +275,7 @@
|
||||
((alg) & PSA_ALG_MAC_TRUNCATION_MASK ? PSA_MAC_TRUNCATED_LENGTH(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_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.
|
||||
*
|
||||
@@ -358,8 +358,8 @@
|
||||
*/
|
||||
#define PSA_AEAD_DECRYPT_OUTPUT_SIZE(key_type, alg, ciphertext_length) \
|
||||
(PSA_AEAD_NONCE_LENGTH(key_type, alg) != 0 && \
|
||||
(ciphertext_length) > PSA_ALG_AEAD_GET_TAG_LENGTH(alg) ? \
|
||||
(ciphertext_length) - PSA_ALG_AEAD_GET_TAG_LENGTH(alg) : \
|
||||
(ciphertext_length) > PSA_ALG_AEAD_GET_TAG_LENGTH(alg) ? \
|
||||
(ciphertext_length) - PSA_ALG_AEAD_GET_TAG_LENGTH(alg) : \
|
||||
0)
|
||||
|
||||
/** A sufficient output buffer size for psa_aead_decrypt(), for any of the
|
||||
@@ -381,7 +381,7 @@
|
||||
*
|
||||
*/
|
||||
#define PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE(ciphertext_length) \
|
||||
(ciphertext_length)
|
||||
(ciphertext_length)
|
||||
|
||||
/** The default nonce size for an AEAD algorithm, in bytes.
|
||||
*
|
||||
@@ -410,11 +410,11 @@
|
||||
*/
|
||||
#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 : \
|
||||
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 : \
|
||||
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
|
||||
@@ -462,9 +462,9 @@
|
||||
* implementation to delay the output until it has a full block. */
|
||||
#define PSA_AEAD_UPDATE_OUTPUT_SIZE(key_type, alg, input_length) \
|
||||
(PSA_AEAD_NONCE_LENGTH(key_type, alg) != 0 ? \
|
||||
PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
|
||||
PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type), (input_length)) : \
|
||||
(input_length) : \
|
||||
PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
|
||||
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
|
||||
@@ -503,8 +503,8 @@
|
||||
*/
|
||||
#define PSA_AEAD_FINISH_OUTPUT_SIZE(key_type, alg) \
|
||||
(PSA_AEAD_NONCE_LENGTH(key_type, alg) != 0 && \
|
||||
PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
|
||||
PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
|
||||
PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
|
||||
PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
|
||||
0)
|
||||
|
||||
/** A sufficient ciphertext buffer size for psa_aead_finish(), for any of the
|
||||
@@ -537,8 +537,8 @@
|
||||
*/
|
||||
#define PSA_AEAD_VERIFY_OUTPUT_SIZE(key_type, alg) \
|
||||
(PSA_AEAD_NONCE_LENGTH(key_type, alg) != 0 && \
|
||||
PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
|
||||
PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
|
||||
PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
|
||||
PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
|
||||
0)
|
||||
|
||||
/** A sufficient plaintext buffer size for psa_aead_verify(), for any of the
|
||||
@@ -590,9 +590,9 @@
|
||||
* return value is unspecified.
|
||||
*/
|
||||
#define PSA_SIGN_OUTPUT_SIZE(key_type, key_bits, alg) \
|
||||
(PSA_KEY_TYPE_IS_RSA(key_type) ? ((void)alg, PSA_BITS_TO_BYTES(key_bits)) : \
|
||||
(PSA_KEY_TYPE_IS_RSA(key_type) ? ((void) alg, PSA_BITS_TO_BYTES(key_bits)) : \
|
||||
PSA_KEY_TYPE_IS_ECC(key_type) ? PSA_ECDSA_SIGNATURE_SIZE(key_bits) : \
|
||||
((void)alg, 0))
|
||||
((void) alg, 0))
|
||||
|
||||
#define PSA_VENDOR_ECDSA_SIGNATURE_MAX_SIZE \
|
||||
PSA_ECDSA_SIGNATURE_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS)
|
||||
@@ -636,7 +636,7 @@
|
||||
*/
|
||||
#define PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE(key_type, key_bits, alg) \
|
||||
(PSA_KEY_TYPE_IS_RSA(key_type) ? \
|
||||
((void)alg, PSA_BITS_TO_BYTES(key_bits)) : \
|
||||
((void) alg, PSA_BITS_TO_BYTES(key_bits)) : \
|
||||
0)
|
||||
|
||||
/** A sufficient output buffer size for psa_asymmetric_encrypt(), for any
|
||||
@@ -991,14 +991,14 @@
|
||||
*/
|
||||
#define PSA_CIPHER_IV_LENGTH(key_type, alg) \
|
||||
(PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) > 1 && \
|
||||
((alg) == PSA_ALG_CTR || \
|
||||
(alg) == PSA_ALG_CFB || \
|
||||
(alg) == PSA_ALG_OFB || \
|
||||
(alg) == PSA_ALG_XTS || \
|
||||
(alg) == PSA_ALG_CBC_NO_PADDING || \
|
||||
(alg) == PSA_ALG_CBC_PKCS7) ? PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
|
||||
((alg) == PSA_ALG_CTR || \
|
||||
(alg) == PSA_ALG_CFB || \
|
||||
(alg) == PSA_ALG_OFB || \
|
||||
(alg) == PSA_ALG_XTS || \
|
||||
(alg) == PSA_ALG_CBC_NO_PADDING || \
|
||||
(alg) == PSA_ALG_CBC_PKCS7) ? PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
|
||||
(key_type) == PSA_KEY_TYPE_CHACHA20 && \
|
||||
(alg) == PSA_ALG_STREAM_CIPHER ? 12 : \
|
||||
(alg) == PSA_ALG_STREAM_CIPHER ? 12 : \
|
||||
0)
|
||||
|
||||
/** The maximum IV size for all supported cipher algorithms, in bytes.
|
||||
@@ -1033,12 +1033,12 @@
|
||||
#define PSA_CIPHER_ENCRYPT_OUTPUT_SIZE(key_type, alg, input_length) \
|
||||
(alg == PSA_ALG_CBC_PKCS7 ? \
|
||||
(PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) != 0 ? \
|
||||
PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type), \
|
||||
(input_length) + 1) + \
|
||||
PSA_CIPHER_IV_LENGTH((key_type), (alg)) : 0) : \
|
||||
PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type), \
|
||||
(input_length) + 1) + \
|
||||
PSA_CIPHER_IV_LENGTH((key_type), (alg)) : 0) : \
|
||||
(PSA_ALG_IS_CIPHER(alg) ? \
|
||||
(input_length) + PSA_CIPHER_IV_LENGTH((key_type), (alg)) : \
|
||||
0))
|
||||
0))
|
||||
|
||||
/** A sufficient output buffer size for psa_cipher_encrypt(), for any of the
|
||||
* supported key types and cipher algorithms.
|
||||
@@ -1114,13 +1114,13 @@
|
||||
*/
|
||||
#define PSA_CIPHER_UPDATE_OUTPUT_SIZE(key_type, alg, input_length) \
|
||||
(PSA_ALG_IS_CIPHER(alg) ? \
|
||||
(PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) != 0 ? \
|
||||
(((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), \
|
||||
(PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) != 0 ? \
|
||||
(((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) : \
|
||||
(input_length)) : 0) : \
|
||||
0)
|
||||
|
||||
/** A sufficient output buffer size for psa_cipher_update(), for any of the
|
||||
|
@@ -80,8 +80,7 @@ extern "C" {
|
||||
* algorithms. */
|
||||
#include "psa/crypto_driver_contexts_primitives.h"
|
||||
|
||||
struct psa_hash_operation_s
|
||||
{
|
||||
struct psa_hash_operation_s {
|
||||
/** Unique ID indicating which driver got assigned to do the
|
||||
* operation. Since driver contexts are driver-specific, swapping
|
||||
* drivers halfway through the operation is not supported.
|
||||
@@ -92,15 +91,14 @@ struct psa_hash_operation_s
|
||||
psa_driver_hash_context_t ctx;
|
||||
};
|
||||
|
||||
#define PSA_HASH_OPERATION_INIT {0, {0}}
|
||||
static inline struct psa_hash_operation_s psa_hash_operation_init( void )
|
||||
#define PSA_HASH_OPERATION_INIT { 0, { 0 } }
|
||||
static inline struct psa_hash_operation_s psa_hash_operation_init(void)
|
||||
{
|
||||
const struct psa_hash_operation_s v = PSA_HASH_OPERATION_INIT;
|
||||
return( v );
|
||||
return v;
|
||||
}
|
||||
|
||||
struct psa_cipher_operation_s
|
||||
{
|
||||
struct psa_cipher_operation_s {
|
||||
/** Unique ID indicating which driver got assigned to do the
|
||||
* operation. Since driver contexts are driver-specific, swapping
|
||||
* drivers halfway through the operation is not supported.
|
||||
@@ -117,19 +115,18 @@ struct psa_cipher_operation_s
|
||||
psa_driver_cipher_context_t ctx;
|
||||
};
|
||||
|
||||
#define PSA_CIPHER_OPERATION_INIT {0, 0, 0, 0, {0}}
|
||||
static inline struct psa_cipher_operation_s psa_cipher_operation_init( void )
|
||||
#define PSA_CIPHER_OPERATION_INIT { 0, 0, 0, 0, { 0 } }
|
||||
static inline struct psa_cipher_operation_s psa_cipher_operation_init(void)
|
||||
{
|
||||
const struct psa_cipher_operation_s v = PSA_CIPHER_OPERATION_INIT;
|
||||
return( v );
|
||||
return v;
|
||||
}
|
||||
|
||||
/* Include the context definition for the compiled-in drivers for the composite
|
||||
* algorithms. */
|
||||
#include "psa/crypto_driver_contexts_composites.h"
|
||||
|
||||
struct psa_mac_operation_s
|
||||
{
|
||||
struct psa_mac_operation_s {
|
||||
/** Unique ID indicating which driver got assigned to do the
|
||||
* operation. Since driver contexts are driver-specific, swapping
|
||||
* drivers halfway through the operation is not supported.
|
||||
@@ -142,37 +139,34 @@ struct psa_mac_operation_s
|
||||
psa_driver_mac_context_t ctx;
|
||||
};
|
||||
|
||||
#define PSA_MAC_OPERATION_INIT {0, 0, 0, {0}}
|
||||
static inline struct psa_mac_operation_s psa_mac_operation_init( void )
|
||||
#define PSA_MAC_OPERATION_INIT { 0, 0, 0, { 0 } }
|
||||
static inline struct psa_mac_operation_s psa_mac_operation_init(void)
|
||||
{
|
||||
const struct psa_mac_operation_s v = PSA_MAC_OPERATION_INIT;
|
||||
return( v );
|
||||
return v;
|
||||
}
|
||||
|
||||
struct psa_aead_operation_s
|
||||
{
|
||||
struct psa_aead_operation_s {
|
||||
psa_algorithm_t alg;
|
||||
unsigned int key_set : 1;
|
||||
unsigned int iv_set : 1;
|
||||
uint8_t iv_size;
|
||||
uint8_t block_size;
|
||||
union
|
||||
{
|
||||
union {
|
||||
unsigned dummy; /* Enable easier initializing of the union. */
|
||||
mbedtls_cipher_context_t cipher;
|
||||
} ctx;
|
||||
};
|
||||
|
||||
#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, {0}}
|
||||
static inline struct psa_aead_operation_s psa_aead_operation_init( void )
|
||||
#define PSA_AEAD_OPERATION_INIT { 0, 0, 0, 0, 0, { 0 } }
|
||||
static inline struct psa_aead_operation_s psa_aead_operation_init(void)
|
||||
{
|
||||
const struct psa_aead_operation_s v = PSA_AEAD_OPERATION_INIT;
|
||||
return( v );
|
||||
return v;
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF)
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
uint8_t *info;
|
||||
size_t info_length;
|
||||
#if PSA_HASH_MAX_SIZE > 0xff
|
||||
@@ -190,8 +184,7 @@ typedef struct
|
||||
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS)
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
PSA_TLS12_PRF_STATE_INIT, /* no input provided */
|
||||
PSA_TLS12_PRF_STATE_SEED_SET, /* seed has been set */
|
||||
PSA_TLS12_PRF_STATE_KEY_SET, /* key has been set */
|
||||
@@ -199,8 +192,7 @@ typedef enum
|
||||
PSA_TLS12_PRF_STATE_OUTPUT /* output has been started */
|
||||
} psa_tls12_prf_key_derivation_state_t;
|
||||
|
||||
typedef struct psa_tls12_prf_key_derivation_s
|
||||
{
|
||||
typedef struct psa_tls12_prf_key_derivation_s {
|
||||
#if PSA_HASH_MAX_SIZE > 0xff
|
||||
#error "PSA_HASH_MAX_SIZE does not fit in uint8_t"
|
||||
#endif
|
||||
@@ -229,46 +221,43 @@ typedef struct psa_tls12_prf_key_derivation_s
|
||||
#endif /* MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF) ||
|
||||
* MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS */
|
||||
|
||||
struct psa_key_derivation_s
|
||||
{
|
||||
struct psa_key_derivation_s {
|
||||
psa_algorithm_t alg;
|
||||
unsigned int can_output_key : 1;
|
||||
size_t capacity;
|
||||
union
|
||||
{
|
||||
union {
|
||||
/* Make the union non-empty even with no supported algorithms. */
|
||||
uint8_t dummy;
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF)
|
||||
psa_hkdf_key_derivation_t hkdf;
|
||||
#endif
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS)
|
||||
defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS)
|
||||
psa_tls12_prf_key_derivation_t tls12_prf;
|
||||
#endif
|
||||
} ctx;
|
||||
};
|
||||
|
||||
/* This only zeroes out the first byte in the union, the rest is unspecified. */
|
||||
#define PSA_KEY_DERIVATION_OPERATION_INIT {0, 0, 0, {0}}
|
||||
static inline struct psa_key_derivation_s psa_key_derivation_operation_init( void )
|
||||
#define PSA_KEY_DERIVATION_OPERATION_INIT { 0, 0, 0, { 0 } }
|
||||
static inline struct psa_key_derivation_s psa_key_derivation_operation_init(void)
|
||||
{
|
||||
const struct psa_key_derivation_s v = PSA_KEY_DERIVATION_OPERATION_INIT;
|
||||
return( v );
|
||||
return v;
|
||||
}
|
||||
|
||||
struct psa_key_policy_s
|
||||
{
|
||||
struct psa_key_policy_s {
|
||||
psa_key_usage_t usage;
|
||||
psa_algorithm_t alg;
|
||||
psa_algorithm_t alg2;
|
||||
};
|
||||
typedef struct psa_key_policy_s psa_key_policy_t;
|
||||
|
||||
#define PSA_KEY_POLICY_INIT {0, 0, 0}
|
||||
static inline struct psa_key_policy_s psa_key_policy_init( void )
|
||||
#define PSA_KEY_POLICY_INIT { 0, 0, 0 }
|
||||
static inline struct psa_key_policy_s psa_key_policy_init(void)
|
||||
{
|
||||
const struct psa_key_policy_s v = PSA_KEY_POLICY_INIT;
|
||||
return( v );
|
||||
return v;
|
||||
}
|
||||
|
||||
/* The type used internally for key sizes.
|
||||
@@ -276,7 +265,7 @@ static inline struct psa_key_policy_s psa_key_policy_init( void )
|
||||
typedef uint16_t psa_key_bits_t;
|
||||
/* The maximum value of the type used to represent bit-sizes.
|
||||
* This is used to mark an invalid key size. */
|
||||
#define PSA_KEY_BITS_TOO_LARGE ( (psa_key_bits_t) ( -1 ) )
|
||||
#define PSA_KEY_BITS_TOO_LARGE ((psa_key_bits_t) (-1))
|
||||
/* The maximum size of a key in bits.
|
||||
* Currently defined as the maximum that can be represented, rounded down
|
||||
* to a whole number of bytes.
|
||||
@@ -294,21 +283,20 @@ typedef uint16_t psa_key_bits_t;
|
||||
typedef uint16_t psa_key_attributes_flag_t;
|
||||
|
||||
#define MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER \
|
||||
( (psa_key_attributes_flag_t) 0x0001 )
|
||||
((psa_key_attributes_flag_t) 0x0001)
|
||||
|
||||
/* A mask of key attribute flags used externally only.
|
||||
* Only meant for internal checks inside the library. */
|
||||
#define MBEDTLS_PSA_KA_MASK_EXTERNAL_ONLY ( \
|
||||
MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER | \
|
||||
0 )
|
||||
0)
|
||||
|
||||
/* A mask of key attribute flags used both internally and externally.
|
||||
* Currently there aren't any. */
|
||||
#define MBEDTLS_PSA_KA_MASK_DUAL_USE ( \
|
||||
0 )
|
||||
0)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
psa_key_type_t type;
|
||||
psa_key_bits_t bits;
|
||||
psa_key_lifetime_t lifetime;
|
||||
@@ -317,10 +305,10 @@ typedef struct
|
||||
psa_key_attributes_flag_t flags;
|
||||
} psa_core_key_attributes_t;
|
||||
|
||||
#define PSA_CORE_KEY_ATTRIBUTES_INIT {PSA_KEY_TYPE_NONE, 0, PSA_KEY_LIFETIME_VOLATILE, MBEDTLS_SVC_KEY_ID_INIT, PSA_KEY_POLICY_INIT, 0}
|
||||
#define PSA_CORE_KEY_ATTRIBUTES_INIT { PSA_KEY_TYPE_NONE, 0, PSA_KEY_LIFETIME_VOLATILE, \
|
||||
MBEDTLS_SVC_KEY_ID_INIT, PSA_KEY_POLICY_INIT, 0 }
|
||||
|
||||
struct psa_key_attributes_s
|
||||
{
|
||||
struct psa_key_attributes_s {
|
||||
psa_core_key_attributes_t core;
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
|
||||
psa_key_slot_number_t slot_number;
|
||||
@@ -330,42 +318,41 @@ struct psa_key_attributes_s
|
||||
};
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
|
||||
#define PSA_KEY_ATTRIBUTES_INIT {PSA_CORE_KEY_ATTRIBUTES_INIT, 0, NULL, 0}
|
||||
#define PSA_KEY_ATTRIBUTES_INIT { PSA_CORE_KEY_ATTRIBUTES_INIT, 0, NULL, 0 }
|
||||
#else
|
||||
#define PSA_KEY_ATTRIBUTES_INIT {PSA_CORE_KEY_ATTRIBUTES_INIT, NULL, 0}
|
||||
#define PSA_KEY_ATTRIBUTES_INIT { PSA_CORE_KEY_ATTRIBUTES_INIT, NULL, 0 }
|
||||
#endif
|
||||
|
||||
static inline struct psa_key_attributes_s psa_key_attributes_init( void )
|
||||
static inline struct psa_key_attributes_s psa_key_attributes_init(void)
|
||||
{
|
||||
const struct psa_key_attributes_s v = PSA_KEY_ATTRIBUTES_INIT;
|
||||
return( v );
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline void psa_set_key_id( psa_key_attributes_t *attributes,
|
||||
mbedtls_svc_key_id_t key )
|
||||
static inline void psa_set_key_id(psa_key_attributes_t *attributes,
|
||||
mbedtls_svc_key_id_t key)
|
||||
{
|
||||
psa_key_lifetime_t lifetime = attributes->core.lifetime;
|
||||
|
||||
attributes->core.id = key;
|
||||
|
||||
if( PSA_KEY_LIFETIME_IS_VOLATILE( lifetime ) )
|
||||
{
|
||||
if (PSA_KEY_LIFETIME_IS_VOLATILE(lifetime)) {
|
||||
attributes->core.lifetime =
|
||||
PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(
|
||||
PSA_KEY_LIFETIME_PERSISTENT,
|
||||
PSA_KEY_LIFETIME_GET_LOCATION( lifetime ) );
|
||||
PSA_KEY_LIFETIME_GET_LOCATION(lifetime));
|
||||
}
|
||||
}
|
||||
|
||||
static inline mbedtls_svc_key_id_t psa_get_key_id(
|
||||
const psa_key_attributes_t *attributes)
|
||||
{
|
||||
return( attributes->core.id );
|
||||
return attributes->core.id;
|
||||
}
|
||||
|
||||
#ifdef MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
|
||||
static inline void mbedtls_set_key_owner_id( psa_key_attributes_t *attributes,
|
||||
mbedtls_key_owner_id_t owner )
|
||||
static inline void mbedtls_set_key_owner_id(psa_key_attributes_t *attributes,
|
||||
mbedtls_key_owner_id_t owner)
|
||||
{
|
||||
attributes->core.id.owner = owner;
|
||||
}
|
||||
@@ -375,8 +362,7 @@ static inline void psa_set_key_lifetime(psa_key_attributes_t *attributes,
|
||||
psa_key_lifetime_t lifetime)
|
||||
{
|
||||
attributes->core.lifetime = lifetime;
|
||||
if( PSA_KEY_LIFETIME_IS_VOLATILE( lifetime ) )
|
||||
{
|
||||
if (PSA_KEY_LIFETIME_IS_VOLATILE(lifetime)) {
|
||||
#ifdef MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
|
||||
attributes->core.id.key_id = 0;
|
||||
#else
|
||||
@@ -388,29 +374,31 @@ static inline void psa_set_key_lifetime(psa_key_attributes_t *attributes,
|
||||
static inline psa_key_lifetime_t psa_get_key_lifetime(
|
||||
const psa_key_attributes_t *attributes)
|
||||
{
|
||||
return( attributes->core.lifetime );
|
||||
return attributes->core.lifetime;
|
||||
}
|
||||
|
||||
static inline void psa_extend_key_usage_flags( psa_key_usage_t *usage_flags )
|
||||
static inline void psa_extend_key_usage_flags(psa_key_usage_t *usage_flags)
|
||||
{
|
||||
if( *usage_flags & PSA_KEY_USAGE_SIGN_HASH )
|
||||
if (*usage_flags & PSA_KEY_USAGE_SIGN_HASH) {
|
||||
*usage_flags |= PSA_KEY_USAGE_SIGN_MESSAGE;
|
||||
}
|
||||
|
||||
if( *usage_flags & PSA_KEY_USAGE_VERIFY_HASH )
|
||||
if (*usage_flags & PSA_KEY_USAGE_VERIFY_HASH) {
|
||||
*usage_flags |= PSA_KEY_USAGE_VERIFY_MESSAGE;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void psa_set_key_usage_flags(psa_key_attributes_t *attributes,
|
||||
psa_key_usage_t usage_flags)
|
||||
{
|
||||
psa_extend_key_usage_flags( &usage_flags );
|
||||
psa_extend_key_usage_flags(&usage_flags);
|
||||
attributes->core.policy.usage = usage_flags;
|
||||
}
|
||||
|
||||
static inline psa_key_usage_t psa_get_key_usage_flags(
|
||||
const psa_key_attributes_t *attributes)
|
||||
{
|
||||
return( attributes->core.policy.usage );
|
||||
return attributes->core.policy.usage;
|
||||
}
|
||||
|
||||
static inline void psa_set_key_algorithm(psa_key_attributes_t *attributes,
|
||||
@@ -422,7 +410,7 @@ static inline void psa_set_key_algorithm(psa_key_attributes_t *attributes,
|
||||
static inline psa_algorithm_t psa_get_key_algorithm(
|
||||
const psa_key_attributes_t *attributes)
|
||||
{
|
||||
return( attributes->core.policy.alg );
|
||||
return attributes->core.policy.alg;
|
||||
}
|
||||
|
||||
/* This function is declared in crypto_extra.h, which comes after this
|
||||
@@ -435,40 +423,38 @@ psa_status_t psa_set_key_domain_parameters(psa_key_attributes_t *attributes,
|
||||
static inline void psa_set_key_type(psa_key_attributes_t *attributes,
|
||||
psa_key_type_t type)
|
||||
{
|
||||
if( attributes->domain_parameters == NULL )
|
||||
{
|
||||
if (attributes->domain_parameters == NULL) {
|
||||
/* Common case: quick path */
|
||||
attributes->core.type = type;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* Call the bigger function to free the old domain parameters.
|
||||
* Ignore any errors which may arise due to type requiring
|
||||
* non-default domain parameters, since this function can't
|
||||
* report errors. */
|
||||
(void) psa_set_key_domain_parameters( attributes, type, NULL, 0 );
|
||||
(void) psa_set_key_domain_parameters(attributes, type, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static inline psa_key_type_t psa_get_key_type(
|
||||
const psa_key_attributes_t *attributes)
|
||||
{
|
||||
return( attributes->core.type );
|
||||
return attributes->core.type;
|
||||
}
|
||||
|
||||
static inline void psa_set_key_bits(psa_key_attributes_t *attributes,
|
||||
size_t bits)
|
||||
{
|
||||
if( bits > PSA_MAX_KEY_BITS )
|
||||
if (bits > PSA_MAX_KEY_BITS) {
|
||||
attributes->core.bits = PSA_KEY_BITS_TOO_LARGE;
|
||||
else
|
||||
} else {
|
||||
attributes->core.bits = (psa_key_bits_t) bits;
|
||||
}
|
||||
}
|
||||
|
||||
static inline size_t psa_get_key_bits(
|
||||
const psa_key_attributes_t *attributes)
|
||||
{
|
||||
return( attributes->core.bits );
|
||||
return attributes->core.bits;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -290,7 +290,7 @@ typedef uint32_t psa_key_id_t;
|
||||
* Any changes to existing values will require bumping the storage
|
||||
* format version and providing a translation when reading the old
|
||||
* format.
|
||||
*/
|
||||
*/
|
||||
#if !defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
|
||||
typedef psa_key_id_t mbedtls_svc_key_id_t;
|
||||
|
||||
@@ -300,8 +300,7 @@ typedef psa_key_id_t mbedtls_svc_key_id_t;
|
||||
* client and encodes the client identity in the key identifier argument of
|
||||
* functions such as psa_open_key().
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
psa_key_id_t key_id;
|
||||
mbedtls_key_owner_id_t owner;
|
||||
} mbedtls_svc_key_id_t;
|
||||
|
@@ -352,7 +352,7 @@
|
||||
*
|
||||
* Zero is not the encoding of any key type.
|
||||
*/
|
||||
#define PSA_KEY_TYPE_NONE ((psa_key_type_t)0x0000)
|
||||
#define PSA_KEY_TYPE_NONE ((psa_key_type_t) 0x0000)
|
||||
|
||||
/** Vendor-defined key type flag.
|
||||
*
|
||||
@@ -361,15 +361,15 @@
|
||||
* must use an encoding with the #PSA_KEY_TYPE_VENDOR_FLAG bit set and should
|
||||
* respect the bitwise structure used by standard encodings whenever practical.
|
||||
*/
|
||||
#define PSA_KEY_TYPE_VENDOR_FLAG ((psa_key_type_t)0x8000)
|
||||
#define PSA_KEY_TYPE_VENDOR_FLAG ((psa_key_type_t) 0x8000)
|
||||
|
||||
#define PSA_KEY_TYPE_CATEGORY_MASK ((psa_key_type_t)0x7000)
|
||||
#define PSA_KEY_TYPE_CATEGORY_RAW ((psa_key_type_t)0x1000)
|
||||
#define PSA_KEY_TYPE_CATEGORY_SYMMETRIC ((psa_key_type_t)0x2000)
|
||||
#define PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY ((psa_key_type_t)0x4000)
|
||||
#define PSA_KEY_TYPE_CATEGORY_KEY_PAIR ((psa_key_type_t)0x7000)
|
||||
#define PSA_KEY_TYPE_CATEGORY_MASK ((psa_key_type_t) 0x7000)
|
||||
#define PSA_KEY_TYPE_CATEGORY_RAW ((psa_key_type_t) 0x1000)
|
||||
#define PSA_KEY_TYPE_CATEGORY_SYMMETRIC ((psa_key_type_t) 0x2000)
|
||||
#define PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY ((psa_key_type_t) 0x4000)
|
||||
#define PSA_KEY_TYPE_CATEGORY_KEY_PAIR ((psa_key_type_t) 0x7000)
|
||||
|
||||
#define PSA_KEY_TYPE_CATEGORY_FLAG_PAIR ((psa_key_type_t)0x3000)
|
||||
#define PSA_KEY_TYPE_CATEGORY_FLAG_PAIR ((psa_key_type_t) 0x3000)
|
||||
|
||||
/** Whether a key type is vendor-defined.
|
||||
*
|
||||
@@ -427,7 +427,7 @@
|
||||
*
|
||||
* A "key" of this type cannot be used for any cryptographic operation.
|
||||
* Applications may use this type to store arbitrary data in the keystore. */
|
||||
#define PSA_KEY_TYPE_RAW_DATA ((psa_key_type_t)0x1001)
|
||||
#define PSA_KEY_TYPE_RAW_DATA ((psa_key_type_t) 0x1001)
|
||||
|
||||
/** HMAC key.
|
||||
*
|
||||
@@ -437,25 +437,25 @@
|
||||
* HMAC keys should generally have the same size as the underlying hash.
|
||||
* This size can be calculated with #PSA_HASH_LENGTH(\c alg) where
|
||||
* \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.
|
||||
*
|
||||
* The key policy determines which key derivation algorithm the key
|
||||
* can be used for.
|
||||
*/
|
||||
#define PSA_KEY_TYPE_DERIVE ((psa_key_type_t)0x1200)
|
||||
#define PSA_KEY_TYPE_DERIVE ((psa_key_type_t) 0x1200)
|
||||
|
||||
/** 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
|
||||
* 32 bytes (AES-256).
|
||||
*/
|
||||
#define PSA_KEY_TYPE_AES ((psa_key_type_t)0x2400)
|
||||
#define PSA_KEY_TYPE_AES ((psa_key_type_t) 0x2400)
|
||||
|
||||
/** Key for a cipher, AEAD or MAC algorithm based on the
|
||||
* ARIA block cipher. */
|
||||
#define PSA_KEY_TYPE_ARIA ((psa_key_type_t)0x2406)
|
||||
#define PSA_KEY_TYPE_ARIA ((psa_key_type_t) 0x2406)
|
||||
|
||||
/** Key for a cipher or MAC algorithm based on DES or 3DES (Triple-DES).
|
||||
*
|
||||
@@ -466,17 +466,17 @@
|
||||
* deprecated and should only be used to decrypt legacy data. 3-key 3DES
|
||||
* is weak and deprecated and should only be used in legacy protocols.
|
||||
*/
|
||||
#define PSA_KEY_TYPE_DES ((psa_key_type_t)0x2301)
|
||||
#define PSA_KEY_TYPE_DES ((psa_key_type_t) 0x2301)
|
||||
|
||||
/** Key for a cipher, AEAD or MAC algorithm based on the
|
||||
* 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 ARC4 stream cipher (also known as RC4 or ARCFOUR).
|
||||
*
|
||||
* Note that ARC4 is weak and deprecated and should only be used in
|
||||
* legacy protocols. */
|
||||
#define PSA_KEY_TYPE_ARC4 ((psa_key_type_t)0x2002)
|
||||
#define PSA_KEY_TYPE_ARC4 ((psa_key_type_t) 0x2002)
|
||||
|
||||
/** Key for the ChaCha20 stream cipher or the Chacha20-Poly1305 AEAD algorithm.
|
||||
*
|
||||
@@ -485,25 +485,25 @@
|
||||
* Implementations must support 12-byte nonces, may support 8-byte nonces,
|
||||
* and should reject other sizes.
|
||||
*/
|
||||
#define PSA_KEY_TYPE_CHACHA20 ((psa_key_type_t)0x2004)
|
||||
#define PSA_KEY_TYPE_CHACHA20 ((psa_key_type_t) 0x2004)
|
||||
|
||||
/** 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).
|
||||
*
|
||||
* 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). */
|
||||
#define PSA_KEY_TYPE_IS_RSA(type) \
|
||||
(PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) == PSA_KEY_TYPE_RSA_PUBLIC_KEY)
|
||||
|
||||
#define PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE ((psa_key_type_t)0x4100)
|
||||
#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_PUBLIC_KEY_BASE ((psa_key_type_t) 0x4100)
|
||||
#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)
|
||||
/** Elliptic curve key pair.
|
||||
*
|
||||
* The size of an elliptic curve key is the bit size associated with the curve,
|
||||
@@ -543,8 +543,8 @@
|
||||
/** Extract the curve from an elliptic curve key type. */
|
||||
#define PSA_KEY_TYPE_ECC_GET_FAMILY(type) \
|
||||
((psa_ecc_family_t) (PSA_KEY_TYPE_IS_ECC(type) ? \
|
||||
((type) & PSA_KEY_TYPE_ECC_CURVE_MASK) : \
|
||||
0))
|
||||
((type) & PSA_KEY_TYPE_ECC_CURVE_MASK) : \
|
||||
0))
|
||||
|
||||
/** SEC Koblitz curves over prime fields.
|
||||
*
|
||||
@@ -635,9 +635,9 @@
|
||||
*/
|
||||
#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_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_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_GROUP_MASK ((psa_key_type_t) 0x00ff)
|
||||
/** Diffie-Hellman key pair.
|
||||
*
|
||||
* \param group A value of type ::psa_dh_family_t that identifies the
|
||||
@@ -669,8 +669,8 @@
|
||||
/** Extract the group from a Diffie-Hellman key type. */
|
||||
#define PSA_KEY_TYPE_DH_GET_FAMILY(type) \
|
||||
((psa_dh_family_t) (PSA_KEY_TYPE_IS_DH(type) ? \
|
||||
((type) & PSA_KEY_TYPE_DH_GROUP_MASK) : \
|
||||
0))
|
||||
((type) & PSA_KEY_TYPE_DH_GROUP_MASK) : \
|
||||
0))
|
||||
|
||||
/** Diffie-Hellman groups defined in RFC 7919 Appendix A.
|
||||
*
|
||||
@@ -703,7 +703,7 @@
|
||||
#define PSA_BLOCK_CIPHER_BLOCK_LENGTH(type) \
|
||||
(((type) & PSA_KEY_TYPE_CATEGORY_MASK) == PSA_KEY_TYPE_CATEGORY_SYMMETRIC ? \
|
||||
1u << PSA_GET_KEY_TYPE_BLOCK_SIZE_EXPONENT(type) : \
|
||||
0u)
|
||||
0u)
|
||||
|
||||
/* Note that algorithm values are embedded in the persistent key store,
|
||||
* as part of key metadata. As a consequence, they must not be changed
|
||||
@@ -717,17 +717,17 @@
|
||||
* the #PSA_ALG_VENDOR_FLAG bit set and should respect the bitwise structure
|
||||
* used by standard encodings whenever practical.
|
||||
*/
|
||||
#define PSA_ALG_VENDOR_FLAG ((psa_algorithm_t)0x80000000)
|
||||
#define PSA_ALG_VENDOR_FLAG ((psa_algorithm_t) 0x80000000)
|
||||
|
||||
#define PSA_ALG_CATEGORY_MASK ((psa_algorithm_t)0x7f000000)
|
||||
#define PSA_ALG_CATEGORY_HASH ((psa_algorithm_t)0x02000000)
|
||||
#define PSA_ALG_CATEGORY_MAC ((psa_algorithm_t)0x03000000)
|
||||
#define PSA_ALG_CATEGORY_CIPHER ((psa_algorithm_t)0x04000000)
|
||||
#define PSA_ALG_CATEGORY_AEAD ((psa_algorithm_t)0x05000000)
|
||||
#define PSA_ALG_CATEGORY_SIGN ((psa_algorithm_t)0x06000000)
|
||||
#define PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION ((psa_algorithm_t)0x07000000)
|
||||
#define PSA_ALG_CATEGORY_KEY_DERIVATION ((psa_algorithm_t)0x08000000)
|
||||
#define PSA_ALG_CATEGORY_KEY_AGREEMENT ((psa_algorithm_t)0x09000000)
|
||||
#define PSA_ALG_CATEGORY_MASK ((psa_algorithm_t) 0x7f000000)
|
||||
#define PSA_ALG_CATEGORY_HASH ((psa_algorithm_t) 0x02000000)
|
||||
#define PSA_ALG_CATEGORY_MAC ((psa_algorithm_t) 0x03000000)
|
||||
#define PSA_ALG_CATEGORY_CIPHER ((psa_algorithm_t) 0x04000000)
|
||||
#define PSA_ALG_CATEGORY_AEAD ((psa_algorithm_t) 0x05000000)
|
||||
#define PSA_ALG_CATEGORY_SIGN ((psa_algorithm_t) 0x06000000)
|
||||
#define PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION ((psa_algorithm_t) 0x07000000)
|
||||
#define PSA_ALG_CATEGORY_KEY_DERIVATION ((psa_algorithm_t) 0x08000000)
|
||||
#define PSA_ALG_CATEGORY_KEY_AGREEMENT ((psa_algorithm_t) 0x09000000)
|
||||
|
||||
/** Whether an algorithm is vendor-defined.
|
||||
*
|
||||
@@ -832,44 +832,44 @@
|
||||
#define PSA_ALG_NONE ((psa_algorithm_t)0)
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#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)
|
||||
#define PSA_ALG_MD2 ((psa_algorithm_t) 0x02000001)
|
||||
/** MD4 */
|
||||
#define PSA_ALG_MD4 ((psa_algorithm_t)0x02000002)
|
||||
#define PSA_ALG_MD4 ((psa_algorithm_t) 0x02000002)
|
||||
/** MD5 */
|
||||
#define PSA_ALG_MD5 ((psa_algorithm_t)0x02000003)
|
||||
#define PSA_ALG_MD5 ((psa_algorithm_t) 0x02000003)
|
||||
/** PSA_ALG_RIPEMD160 */
|
||||
#define PSA_ALG_RIPEMD160 ((psa_algorithm_t)0x02000004)
|
||||
#define PSA_ALG_RIPEMD160 ((psa_algorithm_t) 0x02000004)
|
||||
/** SHA1 */
|
||||
#define PSA_ALG_SHA_1 ((psa_algorithm_t)0x02000005)
|
||||
#define PSA_ALG_SHA_1 ((psa_algorithm_t) 0x02000005)
|
||||
/** SHA2-224 */
|
||||
#define PSA_ALG_SHA_224 ((psa_algorithm_t)0x02000008)
|
||||
#define PSA_ALG_SHA_224 ((psa_algorithm_t) 0x02000008)
|
||||
/** SHA2-256 */
|
||||
#define PSA_ALG_SHA_256 ((psa_algorithm_t)0x02000009)
|
||||
#define PSA_ALG_SHA_256 ((psa_algorithm_t) 0x02000009)
|
||||
/** SHA2-384 */
|
||||
#define PSA_ALG_SHA_384 ((psa_algorithm_t)0x0200000a)
|
||||
#define PSA_ALG_SHA_384 ((psa_algorithm_t) 0x0200000a)
|
||||
/** SHA2-512 */
|
||||
#define PSA_ALG_SHA_512 ((psa_algorithm_t)0x0200000b)
|
||||
#define PSA_ALG_SHA_512 ((psa_algorithm_t) 0x0200000b)
|
||||
/** SHA2-512/224 */
|
||||
#define PSA_ALG_SHA_512_224 ((psa_algorithm_t)0x0200000c)
|
||||
#define PSA_ALG_SHA_512_224 ((psa_algorithm_t) 0x0200000c)
|
||||
/** SHA2-512/256 */
|
||||
#define PSA_ALG_SHA_512_256 ((psa_algorithm_t)0x0200000d)
|
||||
#define PSA_ALG_SHA_512_256 ((psa_algorithm_t) 0x0200000d)
|
||||
/** SHA3-224 */
|
||||
#define PSA_ALG_SHA3_224 ((psa_algorithm_t)0x02000010)
|
||||
#define PSA_ALG_SHA3_224 ((psa_algorithm_t) 0x02000010)
|
||||
/** SHA3-256 */
|
||||
#define PSA_ALG_SHA3_256 ((psa_algorithm_t)0x02000011)
|
||||
#define PSA_ALG_SHA3_256 ((psa_algorithm_t) 0x02000011)
|
||||
/** SHA3-384 */
|
||||
#define PSA_ALG_SHA3_384 ((psa_algorithm_t)0x02000012)
|
||||
#define PSA_ALG_SHA3_384 ((psa_algorithm_t) 0x02000012)
|
||||
/** 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)
|
||||
#define PSA_ALG_SHAKE256_512 ((psa_algorithm_t) 0x02000015)
|
||||
|
||||
/** In a hash-and-sign algorithm policy, allow any hash algorithm.
|
||||
*
|
||||
@@ -904,10 +904,10 @@
|
||||
* This value may not be used to build an algorithm specification to
|
||||
* perform an operation. It is only valid to build policies.
|
||||
*/
|
||||
#define PSA_ALG_ANY_HASH ((psa_algorithm_t)0x020000ff)
|
||||
#define PSA_ALG_ANY_HASH ((psa_algorithm_t) 0x020000ff)
|
||||
|
||||
#define PSA_ALG_MAC_SUBCATEGORY_MASK ((psa_algorithm_t)0x00c00000)
|
||||
#define PSA_ALG_HMAC_BASE ((psa_algorithm_t)0x03800000)
|
||||
#define PSA_ALG_MAC_SUBCATEGORY_MASK ((psa_algorithm_t) 0x00c00000)
|
||||
#define PSA_ALG_HMAC_BASE ((psa_algorithm_t) 0x03800000)
|
||||
/** Macro to build an HMAC algorithm.
|
||||
*
|
||||
* For example, #PSA_ALG_HMAC(#PSA_ALG_SHA_256) is HMAC-SHA-256.
|
||||
@@ -946,7 +946,7 @@
|
||||
* reach up to 63; the largest MAC is 64 bytes so its trivial truncation
|
||||
* to full length is correctly encoded as 0 and any non-trivial truncation
|
||||
* is correctly encoded as a value between 1 and 63. */
|
||||
#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
|
||||
|
||||
/* In the encoding of a MAC algorithm, the bit corresponding to
|
||||
@@ -955,7 +955,7 @@
|
||||
* 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)
|
||||
#define PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG ((psa_algorithm_t) 0x00008000)
|
||||
|
||||
/** Macro to build a truncated MAC algorithm.
|
||||
*
|
||||
@@ -1050,18 +1050,18 @@
|
||||
* 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 )
|
||||
(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
|
||||
*
|
||||
* \warning CBC-MAC is insecure in many cases.
|
||||
* A more secure mode, such as #PSA_ALG_CMAC, is recommended.
|
||||
*/
|
||||
#define PSA_ALG_CBC_MAC ((psa_algorithm_t)0x03c00100)
|
||||
#define PSA_ALG_CBC_MAC ((psa_algorithm_t) 0x03c00100)
|
||||
/** The CMAC construction over a block cipher */
|
||||
#define PSA_ALG_CMAC ((psa_algorithm_t)0x03c00200)
|
||||
#define PSA_ALG_CMAC ((psa_algorithm_t) 0x03c00200)
|
||||
|
||||
/** Whether the specified algorithm is a MAC algorithm based on a block cipher.
|
||||
*
|
||||
@@ -1075,8 +1075,8 @@
|
||||
(((alg) & (PSA_ALG_CATEGORY_MASK | PSA_ALG_MAC_SUBCATEGORY_MASK)) == \
|
||||
PSA_ALG_CIPHER_MAC_BASE)
|
||||
|
||||
#define PSA_ALG_CIPHER_STREAM_FLAG ((psa_algorithm_t)0x00800000)
|
||||
#define PSA_ALG_CIPHER_FROM_BLOCK_FLAG ((psa_algorithm_t)0x00400000)
|
||||
#define PSA_ALG_CIPHER_STREAM_FLAG ((psa_algorithm_t) 0x00800000)
|
||||
#define PSA_ALG_CIPHER_FROM_BLOCK_FLAG ((psa_algorithm_t) 0x00400000)
|
||||
|
||||
/** Whether the specified algorithm is a stream cipher.
|
||||
*
|
||||
@@ -1092,7 +1092,7 @@
|
||||
*/
|
||||
#define PSA_ALG_IS_STREAM_CIPHER(alg) \
|
||||
(((alg) & (PSA_ALG_CATEGORY_MASK | PSA_ALG_CIPHER_STREAM_FLAG)) == \
|
||||
(PSA_ALG_CATEGORY_CIPHER | PSA_ALG_CIPHER_STREAM_FLAG))
|
||||
(PSA_ALG_CATEGORY_CIPHER | PSA_ALG_CIPHER_STREAM_FLAG))
|
||||
|
||||
/** The stream cipher mode of a stream cipher algorithm.
|
||||
*
|
||||
@@ -1100,7 +1100,7 @@
|
||||
* - 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)
|
||||
|
||||
/** The CTR stream cipher mode.
|
||||
*
|
||||
@@ -1109,19 +1109,19 @@
|
||||
* For example, to use AES-128-CTR, use this algorithm with
|
||||
* a key of type #PSA_KEY_TYPE_AES and a length of 128 bits (16 bytes).
|
||||
*/
|
||||
#define PSA_ALG_CTR ((psa_algorithm_t)0x04c01000)
|
||||
#define PSA_ALG_CTR ((psa_algorithm_t) 0x04c01000)
|
||||
|
||||
/** The CFB stream cipher mode.
|
||||
*
|
||||
* The underlying block cipher is determined by the key type.
|
||||
*/
|
||||
#define PSA_ALG_CFB ((psa_algorithm_t)0x04c01100)
|
||||
#define PSA_ALG_CFB ((psa_algorithm_t) 0x04c01100)
|
||||
|
||||
/** The OFB stream cipher mode.
|
||||
*
|
||||
* The underlying block cipher is determined by the key type.
|
||||
*/
|
||||
#define PSA_ALG_OFB ((psa_algorithm_t)0x04c01200)
|
||||
#define PSA_ALG_OFB ((psa_algorithm_t) 0x04c01200)
|
||||
|
||||
/** The XTS cipher mode.
|
||||
*
|
||||
@@ -1129,7 +1129,7 @@
|
||||
* least one full block of input, but beyond this minimum the input
|
||||
* does not need to be a whole number of blocks.
|
||||
*/
|
||||
#define PSA_ALG_XTS ((psa_algorithm_t)0x0440ff00)
|
||||
#define PSA_ALG_XTS ((psa_algorithm_t) 0x0440ff00)
|
||||
|
||||
/** The Electronic Code Book (ECB) mode of a block cipher, with no padding.
|
||||
*
|
||||
@@ -1149,7 +1149,7 @@
|
||||
* multi-part cipher operation with this algorithm, psa_cipher_generate_iv()
|
||||
* and psa_cipher_set_iv() must not be called.
|
||||
*/
|
||||
#define PSA_ALG_ECB_NO_PADDING ((psa_algorithm_t)0x04404400)
|
||||
#define PSA_ALG_ECB_NO_PADDING ((psa_algorithm_t) 0x04404400)
|
||||
|
||||
/** The CBC block cipher chaining mode, with no padding.
|
||||
*
|
||||
@@ -1158,7 +1158,7 @@
|
||||
* This symmetric cipher mode can only be used with messages whose lengths
|
||||
* are whole number of blocks for the chosen block cipher.
|
||||
*/
|
||||
#define PSA_ALG_CBC_NO_PADDING ((psa_algorithm_t)0x04404000)
|
||||
#define PSA_ALG_CBC_NO_PADDING ((psa_algorithm_t) 0x04404000)
|
||||
|
||||
/** The CBC block cipher chaining mode with PKCS#7 padding.
|
||||
*
|
||||
@@ -1166,9 +1166,9 @@
|
||||
*
|
||||
* This is the padding method defined by PKCS#7 (RFC 2315) §10.3.
|
||||
*/
|
||||
#define PSA_ALG_CBC_PKCS7 ((psa_algorithm_t)0x04404100)
|
||||
#define PSA_ALG_CBC_PKCS7 ((psa_algorithm_t) 0x04404100)
|
||||
|
||||
#define PSA_ALG_AEAD_FROM_BLOCK_FLAG ((psa_algorithm_t)0x00400000)
|
||||
#define PSA_ALG_AEAD_FROM_BLOCK_FLAG ((psa_algorithm_t) 0x00400000)
|
||||
|
||||
/** Whether the specified algorithm is an AEAD mode on a block cipher.
|
||||
*
|
||||
@@ -1187,13 +1187,13 @@
|
||||
*
|
||||
* The underlying block cipher is determined by the key type.
|
||||
*/
|
||||
#define PSA_ALG_CCM ((psa_algorithm_t)0x05500100)
|
||||
#define PSA_ALG_CCM ((psa_algorithm_t) 0x05500100)
|
||||
|
||||
/** The GCM authenticated encryption algorithm.
|
||||
*
|
||||
* The underlying block cipher is determined by the key type.
|
||||
*/
|
||||
#define PSA_ALG_GCM ((psa_algorithm_t)0x05500200)
|
||||
#define PSA_ALG_GCM ((psa_algorithm_t) 0x05500200)
|
||||
|
||||
/** The Chacha20-Poly1305 AEAD algorithm.
|
||||
*
|
||||
@@ -1204,13 +1204,13 @@
|
||||
*
|
||||
* Implementations must support 16-byte tags and should reject other sizes.
|
||||
*/
|
||||
#define PSA_ALG_CHACHA20_POLY1305 ((psa_algorithm_t)0x05100500)
|
||||
#define PSA_ALG_CHACHA20_POLY1305 ((psa_algorithm_t) 0x05100500)
|
||||
|
||||
/* In the encoding of an AEAD algorithm, the bits corresponding to
|
||||
* PSA_ALG_AEAD_TAG_LENGTH_MASK encode the length of the AEAD tag.
|
||||
* The constants for default lengths follow this encoding.
|
||||
*/
|
||||
#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
|
||||
|
||||
/* In the encoding of an AEAD algorithm, the bit corresponding to
|
||||
@@ -1219,7 +1219,7 @@
|
||||
* 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)
|
||||
#define PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG ((psa_algorithm_t) 0x00008000)
|
||||
|
||||
/** Macro to build a shortened AEAD algorithm.
|
||||
*
|
||||
@@ -1243,7 +1243,7 @@
|
||||
(((aead_alg) & ~(PSA_ALG_AEAD_TAG_LENGTH_MASK | \
|
||||
PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG)) | \
|
||||
((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
|
||||
*
|
||||
@@ -1257,7 +1257,7 @@
|
||||
*/
|
||||
#define PSA_ALG_AEAD_GET_TAG_LENGTH(aead_alg) \
|
||||
(((aead_alg) & PSA_ALG_AEAD_TAG_LENGTH_MASK) >> \
|
||||
PSA_AEAD_TAG_LENGTH_OFFSET )
|
||||
PSA_AEAD_TAG_LENGTH_OFFSET)
|
||||
|
||||
/** Calculate the corresponding AEAD algorithm with the default tag length.
|
||||
*
|
||||
@@ -1303,10 +1303,10 @@
|
||||
* 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 )
|
||||
(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.
|
||||
*
|
||||
* This is the signature scheme defined by RFC 8017
|
||||
@@ -1334,8 +1334,8 @@
|
||||
#define PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) \
|
||||
(((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PKCS1V15_SIGN_BASE)
|
||||
|
||||
#define PSA_ALG_RSA_PSS_BASE ((psa_algorithm_t)0x06000300)
|
||||
#define PSA_ALG_RSA_PSS_ANY_SALT_BASE ((psa_algorithm_t)0x06001300)
|
||||
#define PSA_ALG_RSA_PSS_BASE ((psa_algorithm_t) 0x06000300)
|
||||
#define PSA_ALG_RSA_PSS_ANY_SALT_BASE ((psa_algorithm_t) 0x06001300)
|
||||
/** RSA PSS signature with hashing.
|
||||
*
|
||||
* This is the signature scheme defined by RFC 8017
|
||||
@@ -1424,7 +1424,7 @@
|
||||
(PSA_ALG_IS_RSA_PSS_STANDARD_SALT(alg) || \
|
||||
PSA_ALG_IS_RSA_PSS_ANY_SALT(alg))
|
||||
|
||||
#define PSA_ALG_ECDSA_BASE ((psa_algorithm_t)0x06000600)
|
||||
#define PSA_ALG_ECDSA_BASE ((psa_algorithm_t) 0x06000600)
|
||||
/** ECDSA signature with hashing.
|
||||
*
|
||||
* This is the ECDSA signature scheme defined by ANSI X9.62,
|
||||
@@ -1457,7 +1457,7 @@
|
||||
* the curve size.
|
||||
*/
|
||||
#define PSA_ALG_ECDSA_ANY PSA_ALG_ECDSA_BASE
|
||||
#define PSA_ALG_DETERMINISTIC_ECDSA_BASE ((psa_algorithm_t)0x06000700)
|
||||
#define PSA_ALG_DETERMINISTIC_ECDSA_BASE ((psa_algorithm_t) 0x06000700)
|
||||
/** Deterministic ECDSA signature with hashing.
|
||||
*
|
||||
* This is the deterministic ECDSA signature scheme defined by RFC 6979.
|
||||
@@ -1482,7 +1482,7 @@
|
||||
*/
|
||||
#define PSA_ALG_DETERMINISTIC_ECDSA(hash_alg) \
|
||||
(PSA_ALG_DETERMINISTIC_ECDSA_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
|
||||
#define PSA_ALG_ECDSA_DETERMINISTIC_FLAG ((psa_algorithm_t)0x00000100)
|
||||
#define PSA_ALG_ECDSA_DETERMINISTIC_FLAG ((psa_algorithm_t) 0x00000100)
|
||||
#define PSA_ALG_IS_ECDSA(alg) \
|
||||
(((alg) & ~PSA_ALG_HASH_MASK & ~PSA_ALG_ECDSA_DETERMINISTIC_FLAG) == \
|
||||
PSA_ALG_ECDSA_BASE)
|
||||
@@ -1521,9 +1521,9 @@
|
||||
* 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_PURE_EDDSA ((psa_algorithm_t) 0x06000800)
|
||||
|
||||
#define PSA_ALG_HASH_EDDSA_BASE ((psa_algorithm_t)0x06000900)
|
||||
#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)
|
||||
|
||||
@@ -1615,7 +1615,7 @@
|
||||
* supported algorithm identifier.
|
||||
*/
|
||||
#define PSA_ALG_IS_SIGN_MESSAGE(alg) \
|
||||
(PSA_ALG_IS_SIGN_HASH(alg) || (alg) == PSA_ALG_PURE_EDDSA )
|
||||
(PSA_ALG_IS_SIGN_HASH(alg) || (alg) == PSA_ALG_PURE_EDDSA)
|
||||
|
||||
/** Whether the specified algorithm is a hash-and-sign algorithm.
|
||||
*
|
||||
@@ -1672,9 +1672,9 @@
|
||||
|
||||
/** RSA PKCS#1 v1.5 encryption.
|
||||
*/
|
||||
#define PSA_ALG_RSA_PKCS1V15_CRYPT ((psa_algorithm_t)0x07000200)
|
||||
#define PSA_ALG_RSA_PKCS1V15_CRYPT ((psa_algorithm_t) 0x07000200)
|
||||
|
||||
#define PSA_ALG_RSA_OAEP_BASE ((psa_algorithm_t)0x07000300)
|
||||
#define PSA_ALG_RSA_OAEP_BASE ((psa_algorithm_t) 0x07000300)
|
||||
/** RSA OAEP encryption.
|
||||
*
|
||||
* This is the encryption scheme defined by RFC 8017
|
||||
@@ -1698,7 +1698,7 @@
|
||||
((alg) & PSA_ALG_HASH_MASK) | PSA_ALG_CATEGORY_HASH : \
|
||||
0)
|
||||
|
||||
#define PSA_ALG_HKDF_BASE ((psa_algorithm_t)0x08000100)
|
||||
#define PSA_ALG_HKDF_BASE ((psa_algorithm_t) 0x08000100)
|
||||
/** Macro to build an HKDF algorithm.
|
||||
*
|
||||
* For example, `PSA_ALG_HKDF(PSA_ALG_SHA_256)` is HKDF using HMAC-SHA-256.
|
||||
@@ -1737,7 +1737,7 @@
|
||||
#define PSA_ALG_HKDF_GET_HASH(hkdf_alg) \
|
||||
(PSA_ALG_CATEGORY_HASH | ((hkdf_alg) & PSA_ALG_HASH_MASK))
|
||||
|
||||
#define PSA_ALG_TLS12_PRF_BASE ((psa_algorithm_t)0x08000200)
|
||||
#define PSA_ALG_TLS12_PRF_BASE ((psa_algorithm_t) 0x08000200)
|
||||
/** Macro to build a TLS-1.2 PRF algorithm.
|
||||
*
|
||||
* TLS 1.2 uses a custom pseudorandom function (PRF) for key schedule,
|
||||
@@ -1780,7 +1780,7 @@
|
||||
#define PSA_ALG_TLS12_PRF_GET_HASH(hkdf_alg) \
|
||||
(PSA_ALG_CATEGORY_HASH | ((hkdf_alg) & PSA_ALG_HASH_MASK))
|
||||
|
||||
#define PSA_ALG_TLS12_PSK_TO_MS_BASE ((psa_algorithm_t)0x08000300)
|
||||
#define PSA_ALG_TLS12_PSK_TO_MS_BASE ((psa_algorithm_t) 0x08000300)
|
||||
/** Macro to build a TLS-1.2 PSK-to-MasterSecret algorithm.
|
||||
*
|
||||
* In a pure-PSK handshake in TLS 1.2, the master secret is derived
|
||||
@@ -1826,8 +1826,8 @@
|
||||
#define PSA_ALG_TLS12_PSK_TO_MS_GET_HASH(hkdf_alg) \
|
||||
(PSA_ALG_CATEGORY_HASH | ((hkdf_alg) & PSA_ALG_HASH_MASK))
|
||||
|
||||
#define PSA_ALG_KEY_DERIVATION_MASK ((psa_algorithm_t)0xfe00ffff)
|
||||
#define PSA_ALG_KEY_AGREEMENT_MASK ((psa_algorithm_t)0xffff0000)
|
||||
#define PSA_ALG_KEY_DERIVATION_MASK ((psa_algorithm_t) 0xfe00ffff)
|
||||
#define PSA_ALG_KEY_AGREEMENT_MASK ((psa_algorithm_t) 0xffff0000)
|
||||
|
||||
/** Macro to build a combined algorithm that chains a key agreement with
|
||||
* a key derivation.
|
||||
@@ -1880,7 +1880,7 @@
|
||||
* It is `ceiling(m / 8)` bytes long where `m` is the size of the prime `p`
|
||||
* in bits.
|
||||
*/
|
||||
#define PSA_ALG_FFDH ((psa_algorithm_t)0x09010000)
|
||||
#define PSA_ALG_FFDH ((psa_algorithm_t) 0x09010000)
|
||||
|
||||
/** Whether the specified algorithm is a finite field Diffie-Hellman algorithm.
|
||||
*
|
||||
@@ -1922,7 +1922,7 @@
|
||||
* in big-endian byte order.
|
||||
* The bit size is `m` for the field `F_{2^m}`.
|
||||
*/
|
||||
#define PSA_ALG_ECDH ((psa_algorithm_t)0x09020000)
|
||||
#define PSA_ALG_ECDH ((psa_algorithm_t) 0x09020000)
|
||||
|
||||
/** Whether the specified algorithm is an elliptic curve Diffie-Hellman
|
||||
* algorithm.
|
||||
@@ -1985,7 +1985,7 @@
|
||||
* it must release all the resources associated with the key and erase the
|
||||
* key material if the calling application terminates.
|
||||
*/
|
||||
#define PSA_KEY_LIFETIME_VOLATILE ((psa_key_lifetime_t)0x00000000)
|
||||
#define PSA_KEY_LIFETIME_VOLATILE ((psa_key_lifetime_t) 0x00000000)
|
||||
|
||||
/** The default lifetime for persistent keys.
|
||||
*
|
||||
@@ -1999,31 +1999,31 @@
|
||||
* application. Integrations of Mbed TLS may support other persistent lifetimes.
|
||||
* 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)
|
||||
|
||||
/** The persistence level of volatile keys.
|
||||
*
|
||||
* See ::psa_key_persistence_t for more information.
|
||||
*/
|
||||
#define PSA_KEY_PERSISTENCE_VOLATILE ((psa_key_persistence_t)0x00)
|
||||
#define PSA_KEY_PERSISTENCE_VOLATILE ((psa_key_persistence_t) 0x00)
|
||||
|
||||
/** The default persistence level for persistent keys.
|
||||
*
|
||||
* See ::psa_key_persistence_t for more information.
|
||||
*/
|
||||
#define PSA_KEY_PERSISTENCE_DEFAULT ((psa_key_persistence_t)0x01)
|
||||
#define PSA_KEY_PERSISTENCE_DEFAULT ((psa_key_persistence_t) 0x01)
|
||||
|
||||
/** A persistence level indicating that a key is never destroyed.
|
||||
*
|
||||
* See ::psa_key_persistence_t for more information.
|
||||
*/
|
||||
#define PSA_KEY_PERSISTENCE_READ_ONLY ((psa_key_persistence_t)0xff)
|
||||
#define PSA_KEY_PERSISTENCE_READ_ONLY ((psa_key_persistence_t) 0xff)
|
||||
|
||||
#define PSA_KEY_LIFETIME_GET_PERSISTENCE(lifetime) \
|
||||
((psa_key_persistence_t)((lifetime) & 0x000000ff))
|
||||
((psa_key_persistence_t) ((lifetime) & 0x000000ff))
|
||||
|
||||
#define PSA_KEY_LIFETIME_GET_LOCATION(lifetime) \
|
||||
((psa_key_location_t)((lifetime) >> 8))
|
||||
((psa_key_location_t) ((lifetime) >> 8))
|
||||
|
||||
/** Whether a key lifetime indicates that the key is volatile.
|
||||
*
|
||||
@@ -2085,9 +2085,9 @@
|
||||
*
|
||||
* See ::psa_key_location_t for more information.
|
||||
*/
|
||||
#define PSA_KEY_LOCATION_LOCAL_STORAGE ((psa_key_location_t)0x000000)
|
||||
#define PSA_KEY_LOCATION_LOCAL_STORAGE ((psa_key_location_t) 0x000000)
|
||||
|
||||
#define PSA_KEY_LOCATION_VENDOR_FLAG ((psa_key_location_t)0x800000)
|
||||
#define PSA_KEY_LOCATION_VENDOR_FLAG ((psa_key_location_t) 0x800000)
|
||||
|
||||
/* Note that key identifier values are embedded in the
|
||||
* persistent key store, as part of key metadata. As a consequence, they
|
||||
@@ -2101,23 +2101,23 @@
|
||||
/* *INDENT-ON* */
|
||||
/** The minimum value for a key identifier chosen by the application.
|
||||
*/
|
||||
#define PSA_KEY_ID_USER_MIN ((psa_key_id_t)0x00000001)
|
||||
#define PSA_KEY_ID_USER_MIN ((psa_key_id_t) 0x00000001)
|
||||
/** The maximum value for a key identifier chosen by the application.
|
||||
*/
|
||||
#define PSA_KEY_ID_USER_MAX ((psa_key_id_t)0x3fffffff)
|
||||
#define PSA_KEY_ID_USER_MAX ((psa_key_id_t) 0x3fffffff)
|
||||
/** The minimum value for a key identifier chosen by the implementation.
|
||||
*/
|
||||
#define PSA_KEY_ID_VENDOR_MIN ((psa_key_id_t)0x40000000)
|
||||
#define PSA_KEY_ID_VENDOR_MIN ((psa_key_id_t) 0x40000000)
|
||||
/** The maximum value for a key identifier chosen by the implementation.
|
||||
*/
|
||||
#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 )
|
||||
#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.
|
||||
*
|
||||
@@ -2125,11 +2125,11 @@
|
||||
* \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 )
|
||||
unsigned int unused, psa_key_id_t key_id)
|
||||
{
|
||||
(void)unused;
|
||||
(void) unused;
|
||||
|
||||
return( key_id );
|
||||
return key_id;
|
||||
}
|
||||
|
||||
/** Compare two key identifiers.
|
||||
@@ -2139,10 +2139,10 @@ static inline mbedtls_svc_key_id_t mbedtls_svc_key_id_make(
|
||||
*
|
||||
* \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 )
|
||||
static inline int mbedtls_svc_key_id_equal(mbedtls_svc_key_id_t id1,
|
||||
mbedtls_svc_key_id_t id2)
|
||||
{
|
||||
return( id1 == id2 );
|
||||
return id1 == id2;
|
||||
}
|
||||
|
||||
/** Check whether a key identifier is null.
|
||||
@@ -2151,16 +2151,16 @@ static inline int mbedtls_svc_key_id_equal( mbedtls_svc_key_id_t id1,
|
||||
*
|
||||
* \return Non-zero if the key identifier is null, zero otherwise.
|
||||
*/
|
||||
static inline int mbedtls_svc_key_id_is_null( mbedtls_svc_key_id_t key )
|
||||
static inline int mbedtls_svc_key_id_is_null(mbedtls_svc_key_id_t key)
|
||||
{
|
||||
return( key == 0 );
|
||||
return key == 0;
|
||||
}
|
||||
|
||||
#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 )
|
||||
#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.
|
||||
*
|
||||
@@ -2168,10 +2168,10 @@ static inline int mbedtls_svc_key_id_is_null( mbedtls_svc_key_id_t key )
|
||||
* \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 )
|
||||
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 } );
|
||||
return (mbedtls_svc_key_id_t){ .key_id = key_id,
|
||||
.owner = owner_id };
|
||||
}
|
||||
|
||||
/** Compare two key identifiers.
|
||||
@@ -2181,11 +2181,11 @@ static inline mbedtls_svc_key_id_t mbedtls_svc_key_id_make(
|
||||
*
|
||||
* \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 )
|
||||
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 ) );
|
||||
return (id1.key_id == id2.key_id) &&
|
||||
mbedtls_key_owner_id_equal(id1.owner, id2.owner);
|
||||
}
|
||||
|
||||
/** Check whether a key identifier is null.
|
||||
@@ -2194,9 +2194,9 @@ static inline int mbedtls_svc_key_id_equal( mbedtls_svc_key_id_t id1,
|
||||
*
|
||||
* \return Non-zero if the key identifier is null, zero otherwise.
|
||||
*/
|
||||
static inline int mbedtls_svc_key_id_is_null( mbedtls_svc_key_id_t key )
|
||||
static inline int mbedtls_svc_key_id_is_null(mbedtls_svc_key_id_t key)
|
||||
{
|
||||
return( key.key_id == 0 );
|
||||
return key.key_id == 0;
|
||||
}
|
||||
|
||||
#endif /* !MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
|
||||
@@ -2223,7 +2223,7 @@ static inline int mbedtls_svc_key_id_is_null( mbedtls_svc_key_id_t key )
|
||||
* The key may however be exportable in a wrapped form, i.e. in a form
|
||||
* where it is encrypted by another key.
|
||||
*/
|
||||
#define PSA_KEY_USAGE_EXPORT ((psa_key_usage_t)0x00000001)
|
||||
#define PSA_KEY_USAGE_EXPORT ((psa_key_usage_t) 0x00000001)
|
||||
|
||||
/** Whether the key may be copied.
|
||||
*
|
||||
@@ -2239,7 +2239,7 @@ static inline int mbedtls_svc_key_id_is_null( mbedtls_svc_key_id_t key )
|
||||
* #PSA_KEY_LIFETIME_PERSISTENT, the usage flag #PSA_KEY_USAGE_COPY
|
||||
* is sufficient to permit the copy.
|
||||
*/
|
||||
#define PSA_KEY_USAGE_COPY ((psa_key_usage_t)0x00000002)
|
||||
#define PSA_KEY_USAGE_COPY ((psa_key_usage_t) 0x00000002)
|
||||
|
||||
/** Whether the key may be used to encrypt a message.
|
||||
*
|
||||
@@ -2250,7 +2250,7 @@ static inline int mbedtls_svc_key_id_is_null( mbedtls_svc_key_id_t key )
|
||||
*
|
||||
* For a key pair, this concerns the public key.
|
||||
*/
|
||||
#define PSA_KEY_USAGE_ENCRYPT ((psa_key_usage_t)0x00000100)
|
||||
#define PSA_KEY_USAGE_ENCRYPT ((psa_key_usage_t) 0x00000100)
|
||||
|
||||
/** Whether the key may be used to decrypt a message.
|
||||
*
|
||||
@@ -2261,7 +2261,7 @@ static inline int mbedtls_svc_key_id_is_null( mbedtls_svc_key_id_t key )
|
||||
*
|
||||
* For a key pair, this concerns the private key.
|
||||
*/
|
||||
#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.
|
||||
*
|
||||
@@ -2271,7 +2271,7 @@ static inline int mbedtls_svc_key_id_is_null( mbedtls_svc_key_id_t key )
|
||||
*
|
||||
* For a key pair, this concerns the private key.
|
||||
*/
|
||||
#define PSA_KEY_USAGE_SIGN_MESSAGE ((psa_key_usage_t)0x00000400)
|
||||
#define PSA_KEY_USAGE_SIGN_MESSAGE ((psa_key_usage_t) 0x00000400)
|
||||
|
||||
/** Whether the key may be used to verify a message.
|
||||
*
|
||||
@@ -2281,7 +2281,7 @@ static inline int mbedtls_svc_key_id_is_null( mbedtls_svc_key_id_t key )
|
||||
*
|
||||
* For a key pair, this concerns the public key.
|
||||
*/
|
||||
#define PSA_KEY_USAGE_VERIFY_MESSAGE ((psa_key_usage_t)0x00000800)
|
||||
#define PSA_KEY_USAGE_VERIFY_MESSAGE ((psa_key_usage_t) 0x00000800)
|
||||
|
||||
/** Whether the key may be used to sign a message.
|
||||
*
|
||||
@@ -2291,7 +2291,7 @@ static inline int mbedtls_svc_key_id_is_null( mbedtls_svc_key_id_t key )
|
||||
*
|
||||
* For a key pair, this concerns the private key.
|
||||
*/
|
||||
#define PSA_KEY_USAGE_SIGN_HASH ((psa_key_usage_t)0x00001000)
|
||||
#define PSA_KEY_USAGE_SIGN_HASH ((psa_key_usage_t) 0x00001000)
|
||||
|
||||
/** Whether the key may be used to verify a message signature.
|
||||
*
|
||||
@@ -2301,11 +2301,11 @@ static inline int mbedtls_svc_key_id_is_null( mbedtls_svc_key_id_t key )
|
||||
*
|
||||
* For a key pair, this concerns the public key.
|
||||
*/
|
||||
#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.
|
||||
*/
|
||||
#define PSA_KEY_USAGE_DERIVE ((psa_key_usage_t)0x00004000)
|
||||
#define PSA_KEY_USAGE_DERIVE ((psa_key_usage_t) 0x00004000)
|
||||
|
||||
/**@}*/
|
||||
|
||||
@@ -2328,35 +2328,35 @@ static inline int mbedtls_svc_key_id_is_null( mbedtls_svc_key_id_t key )
|
||||
* may not be used to derive keys: the operation will only allow
|
||||
* psa_key_derivation_output_bytes(), 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 label for key derivation.
|
||||
*
|
||||
* This should be a direct input.
|
||||
* It can also be a key of type #PSA_KEY_TYPE_RAW_DATA.
|
||||
*/
|
||||
#define PSA_KEY_DERIVATION_INPUT_LABEL ((psa_key_derivation_step_t)0x0201)
|
||||
#define PSA_KEY_DERIVATION_INPUT_LABEL ((psa_key_derivation_step_t) 0x0201)
|
||||
|
||||
/** A salt for key derivation.
|
||||
*
|
||||
* This should be a direct input.
|
||||
* It can also be a key of type #PSA_KEY_TYPE_RAW_DATA.
|
||||
*/
|
||||
#define PSA_KEY_DERIVATION_INPUT_SALT ((psa_key_derivation_step_t)0x0202)
|
||||
#define PSA_KEY_DERIVATION_INPUT_SALT ((psa_key_derivation_step_t) 0x0202)
|
||||
|
||||
/** An information string for key derivation.
|
||||
*
|
||||
* This should be a direct input.
|
||||
* It can also be a key of type #PSA_KEY_TYPE_RAW_DATA.
|
||||
*/
|
||||
#define PSA_KEY_DERIVATION_INPUT_INFO ((psa_key_derivation_step_t)0x0203)
|
||||
#define PSA_KEY_DERIVATION_INPUT_INFO ((psa_key_derivation_step_t) 0x0203)
|
||||
|
||||
/** A seed for key derivation.
|
||||
*
|
||||
* This should be a direct input.
|
||||
* It can also be a key of type #PSA_KEY_TYPE_RAW_DATA.
|
||||
*/
|
||||
#define PSA_KEY_DERIVATION_INPUT_SEED ((psa_key_derivation_step_t)0x0204)
|
||||
#define PSA_KEY_DERIVATION_INPUT_SEED ((psa_key_derivation_step_t) 0x0204)
|
||||
|
||||
/**@}*/
|
||||
|
||||
|
Reference in New Issue
Block a user