Fix parenthesis spacing in crypto_struct.h
crypto_struct.h is implementation-specific so it was intended to have Mbed TLS whitespace style. Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
parent
55dd5dc355
commit
33434a9f60
1 changed files with 34 additions and 30 deletions
|
@ -92,7 +92,7 @@ struct psa_hash_operation_s
|
||||||
psa_driver_hash_context_t ctx;
|
psa_driver_hash_context_t ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PSA_HASH_OPERATION_INIT {0, {0}}
|
#define PSA_HASH_OPERATION_INIT { 0, { 0 } }
|
||||||
static inline struct psa_hash_operation_s psa_hash_operation_init( void )
|
static inline struct psa_hash_operation_s psa_hash_operation_init( void )
|
||||||
{
|
{
|
||||||
const struct psa_hash_operation_s v = PSA_HASH_OPERATION_INIT;
|
const struct psa_hash_operation_s v = PSA_HASH_OPERATION_INIT;
|
||||||
|
@ -117,7 +117,7 @@ struct psa_cipher_operation_s
|
||||||
psa_driver_cipher_context_t ctx;
|
psa_driver_cipher_context_t ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PSA_CIPHER_OPERATION_INIT {0, 0, 0, 0, {0}}
|
#define PSA_CIPHER_OPERATION_INIT { 0, 0, 0, 0, { 0 } }
|
||||||
static inline struct psa_cipher_operation_s psa_cipher_operation_init( void )
|
static inline struct psa_cipher_operation_s psa_cipher_operation_init( void )
|
||||||
{
|
{
|
||||||
const struct psa_cipher_operation_s v = PSA_CIPHER_OPERATION_INIT;
|
const struct psa_cipher_operation_s v = PSA_CIPHER_OPERATION_INIT;
|
||||||
|
@ -142,7 +142,7 @@ struct psa_mac_operation_s
|
||||||
psa_driver_mac_context_t ctx;
|
psa_driver_mac_context_t ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PSA_MAC_OPERATION_INIT {0, 0, 0, {0}}
|
#define PSA_MAC_OPERATION_INIT { 0, 0, 0, { 0 } }
|
||||||
static inline struct psa_mac_operation_s psa_mac_operation_init( void )
|
static inline struct psa_mac_operation_s psa_mac_operation_init( void )
|
||||||
{
|
{
|
||||||
const struct psa_mac_operation_s v = PSA_MAC_OPERATION_INIT;
|
const struct psa_mac_operation_s v = PSA_MAC_OPERATION_INIT;
|
||||||
|
@ -163,7 +163,7 @@ struct psa_aead_operation_s
|
||||||
} ctx;
|
} ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, {0}}
|
#define PSA_AEAD_OPERATION_INIT { 0, 0, 0, 0, 0, { 0 } }
|
||||||
static inline struct psa_aead_operation_s psa_aead_operation_init( void )
|
static inline struct psa_aead_operation_s psa_aead_operation_init( void )
|
||||||
{
|
{
|
||||||
const struct psa_aead_operation_s v = PSA_AEAD_OPERATION_INIT;
|
const struct psa_aead_operation_s v = PSA_AEAD_OPERATION_INIT;
|
||||||
|
@ -223,7 +223,7 @@ typedef struct psa_tls12_prf_key_derivation_s
|
||||||
|
|
||||||
uint8_t Ai[PSA_HASH_MAX_SIZE];
|
uint8_t Ai[PSA_HASH_MAX_SIZE];
|
||||||
|
|
||||||
/* `HMAC_hash( prk, A(i) + seed )` in the notation of RFC 5246, Sect. 5. */
|
/* `HMAC_hash( prk, A( i ) + seed )` in the notation of RFC 5246, Sect. 5. */
|
||||||
uint8_t output_block[PSA_HASH_MAX_SIZE];
|
uint8_t output_block[PSA_HASH_MAX_SIZE];
|
||||||
} psa_tls12_prf_key_derivation_t;
|
} psa_tls12_prf_key_derivation_t;
|
||||||
#endif /* MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF) ||
|
#endif /* MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF) ||
|
||||||
|
@ -249,8 +249,9 @@ struct psa_key_derivation_s
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This only zeroes out the first byte in the union, the rest is unspecified. */
|
/* This only zeroes out the first byte in the union, the rest is unspecified. */
|
||||||
#define PSA_KEY_DERIVATION_OPERATION_INIT {0, 0, 0, {0}}
|
#define PSA_KEY_DERIVATION_OPERATION_INIT { 0, 0, 0, { 0 } }
|
||||||
static inline struct psa_key_derivation_s psa_key_derivation_operation_init( void )
|
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;
|
const struct psa_key_derivation_s v = PSA_KEY_DERIVATION_OPERATION_INIT;
|
||||||
return( v );
|
return( v );
|
||||||
|
@ -264,7 +265,7 @@ struct psa_key_policy_s
|
||||||
};
|
};
|
||||||
typedef struct psa_key_policy_s psa_key_policy_t;
|
typedef struct psa_key_policy_s psa_key_policy_t;
|
||||||
|
|
||||||
#define PSA_KEY_POLICY_INIT {0, 0, 0}
|
#define PSA_KEY_POLICY_INIT { 0, 0, 0 }
|
||||||
static inline struct psa_key_policy_s psa_key_policy_init( void )
|
static inline struct psa_key_policy_s psa_key_policy_init( void )
|
||||||
{
|
{
|
||||||
const struct psa_key_policy_s v = PSA_KEY_POLICY_INIT;
|
const struct psa_key_policy_s v = PSA_KEY_POLICY_INIT;
|
||||||
|
@ -276,7 +277,7 @@ static inline struct psa_key_policy_s psa_key_policy_init( void )
|
||||||
typedef uint16_t psa_key_bits_t;
|
typedef uint16_t psa_key_bits_t;
|
||||||
/* The maximum value of the type used to represent bit-sizes.
|
/* The maximum value of the type used to represent bit-sizes.
|
||||||
* This is used to mark an invalid key size. */
|
* 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.
|
/* The maximum size of a key in bits.
|
||||||
* Currently defined as the maximum that can be represented, rounded down
|
* Currently defined as the maximum that can be represented, rounded down
|
||||||
* to a whole number of bytes.
|
* to a whole number of bytes.
|
||||||
|
@ -317,7 +318,10 @@ typedef struct
|
||||||
psa_key_attributes_flag_t flags;
|
psa_key_attributes_flag_t flags;
|
||||||
} psa_core_key_attributes_t;
|
} 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
|
||||||
{
|
{
|
||||||
|
@ -330,9 +334,9 @@ struct psa_key_attributes_s
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
|
#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
|
#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
|
#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 )
|
||||||
|
@ -358,7 +362,7 @@ static inline void psa_set_key_id( psa_key_attributes_t *attributes,
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline mbedtls_svc_key_id_t psa_get_key_id(
|
static inline mbedtls_svc_key_id_t psa_get_key_id(
|
||||||
const psa_key_attributes_t *attributes)
|
const psa_key_attributes_t *attributes )
|
||||||
{
|
{
|
||||||
return( attributes->core.id );
|
return( attributes->core.id );
|
||||||
}
|
}
|
||||||
|
@ -371,8 +375,8 @@ static inline void mbedtls_set_key_owner_id( psa_key_attributes_t *attributes,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void psa_set_key_lifetime(psa_key_attributes_t *attributes,
|
static inline void psa_set_key_lifetime( psa_key_attributes_t *attributes,
|
||||||
psa_key_lifetime_t lifetime)
|
psa_key_lifetime_t lifetime )
|
||||||
{
|
{
|
||||||
attributes->core.lifetime = lifetime;
|
attributes->core.lifetime = lifetime;
|
||||||
if( PSA_KEY_LIFETIME_IS_VOLATILE( lifetime ) )
|
if( PSA_KEY_LIFETIME_IS_VOLATILE( lifetime ) )
|
||||||
|
@ -386,44 +390,44 @@ static inline void psa_set_key_lifetime(psa_key_attributes_t *attributes,
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline psa_key_lifetime_t psa_get_key_lifetime(
|
static inline psa_key_lifetime_t psa_get_key_lifetime(
|
||||||
const psa_key_attributes_t *attributes)
|
const psa_key_attributes_t *attributes )
|
||||||
{
|
{
|
||||||
return( attributes->core.lifetime );
|
return( attributes->core.lifetime );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void psa_set_key_usage_flags(psa_key_attributes_t *attributes,
|
static inline void psa_set_key_usage_flags( psa_key_attributes_t *attributes,
|
||||||
psa_key_usage_t usage_flags)
|
psa_key_usage_t usage_flags )
|
||||||
{
|
{
|
||||||
attributes->core.policy.usage = usage_flags;
|
attributes->core.policy.usage = usage_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline psa_key_usage_t psa_get_key_usage_flags(
|
static inline psa_key_usage_t psa_get_key_usage_flags(
|
||||||
const psa_key_attributes_t *attributes)
|
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,
|
static inline void psa_set_key_algorithm( psa_key_attributes_t *attributes,
|
||||||
psa_algorithm_t alg)
|
psa_algorithm_t alg )
|
||||||
{
|
{
|
||||||
attributes->core.policy.alg = alg;
|
attributes->core.policy.alg = alg;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline psa_algorithm_t psa_get_key_algorithm(
|
static inline psa_algorithm_t psa_get_key_algorithm(
|
||||||
const psa_key_attributes_t *attributes)
|
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
|
/* This function is declared in crypto_extra.h, which comes after this
|
||||||
* header file, but we need the function here, so repeat the declaration. */
|
* header file, but we need the function here, so repeat the declaration. */
|
||||||
psa_status_t psa_set_key_domain_parameters(psa_key_attributes_t *attributes,
|
psa_status_t psa_set_key_domain_parameters( psa_key_attributes_t *attributes,
|
||||||
psa_key_type_t type,
|
psa_key_type_t type,
|
||||||
const uint8_t *data,
|
const uint8_t *data,
|
||||||
size_t data_length);
|
size_t data_length );
|
||||||
|
|
||||||
static inline void psa_set_key_type(psa_key_attributes_t *attributes,
|
static inline void psa_set_key_type( psa_key_attributes_t *attributes,
|
||||||
psa_key_type_t type)
|
psa_key_type_t type )
|
||||||
{
|
{
|
||||||
if( attributes->domain_parameters == NULL )
|
if( attributes->domain_parameters == NULL )
|
||||||
{
|
{
|
||||||
|
@ -441,13 +445,13 @@ static inline void psa_set_key_type(psa_key_attributes_t *attributes,
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline psa_key_type_t psa_get_key_type(
|
static inline psa_key_type_t psa_get_key_type(
|
||||||
const psa_key_attributes_t *attributes)
|
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,
|
static inline void psa_set_key_bits( psa_key_attributes_t *attributes,
|
||||||
size_t bits)
|
size_t bits )
|
||||||
{
|
{
|
||||||
if( bits > PSA_MAX_KEY_BITS )
|
if( bits > PSA_MAX_KEY_BITS )
|
||||||
attributes->core.bits = PSA_KEY_BITS_TOO_LARGE;
|
attributes->core.bits = PSA_KEY_BITS_TOO_LARGE;
|
||||||
|
@ -456,7 +460,7 @@ static inline void psa_set_key_bits(psa_key_attributes_t *attributes,
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline size_t psa_get_key_bits(
|
static inline size_t psa_get_key_bits(
|
||||||
const psa_key_attributes_t *attributes)
|
const psa_key_attributes_t *attributes )
|
||||||
{
|
{
|
||||||
return( attributes->core.bits );
|
return( attributes->core.bits );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue