Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits committed May 8, 2024
1 parent cbcc0d1 commit 57e2710
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@

/*******************************************************************************
* \addtogroup sl_crypto_aes Accelerated AES Block Cipher
* \brief Accelerated AES block cipher for the mbed TLS API using the AES, CRYPTO,
* CRYPTOACC or SE peripheral
* \brief Accelerated AES block cipher for the mbed TLS API using the AES,
*CRYPTO, CRYPTOACC or SE peripheral
*
* \{
******************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@

/*******************************************************************************
* \addtogroup sl_crypto_ccm Accelerated AES-CCM AEAD Cipher
* \brief Accelerated AES-CCM AEAD cipher for the mbed TLS API using the CRYPTOACC
* or SE peripheral
* \brief Accelerated AES-CCM AEAD cipher for the mbed TLS API using the
*CRYPTOACC or SE peripheral
*
* \{
******************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@

/*******************************************************************************
* \addtogroup sl_crypto_cmac Accelerated AES-CMAC Cipher
* \brief Accelerated AES-CMAC cipher for the mbed TLS API using the CRYPTOACC or
* SE peripheral. This implementation builds on the PSA Crypto drivers
* \brief Accelerated AES-CMAC cipher for the mbed TLS API using the CRYPTOACC
*or SE peripheral. This implementation builds on the PSA Crypto drivers
* (\ref sl_psa_drivers).
*
* \{
Expand Down
13 changes: 7 additions & 6 deletions platform/security/sl_component/sl_mbedtls_support/inc/gcm_alt.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*******************************************************************************
* @file
* @brief Accelerated mbed TLS Galois/Counter Mode (GCM) for AES-128-bit block ciphers
* @brief Accelerated mbed TLS Galois/Counter Mode (GCM) for AES-128-bit block
*ciphers
*******************************************************************************
* # License
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
Expand Down Expand Up @@ -37,8 +38,8 @@

/*******************************************************************************
* \addtogroup sl_crypto_gcm Accelerated GCM AES-128 Cipher
* \brief Accelerated AES-GCM-128 cipher for the mbed TLS API using the CRYPTOACC
* or SE peripheral
* \brief Accelerated AES-GCM-128 cipher for the mbed TLS API using the
*CRYPTOACC or SE peripheral
*
* \{
* This module implements the GCM AES-128 cipher, as defined in
Expand All @@ -59,8 +60,8 @@
#elif defined(SEMAILBOX_PRESENT)
#include "em_se.h"
#elif defined(CRYPTOACC_PRESENT)
#include "sx_aes.h"
#include "sl_enum.h"
#include "sx_aes.h"
#endif

#ifdef __cplusplus
Expand All @@ -69,8 +70,8 @@ extern "C" {

#if defined(CRYPTOACC_PRESENT)
SL_ENUM(sli_gcm_mode_t){
SLI_GCM_ENC = 1,
SLI_GCM_DEC = 2,
SLI_GCM_ENC = 1,
SLI_GCM_DEC = 2,
};
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ extern "C" {
*
* \return 0 if successful, negative on error
*/
__STATIC_INLINE int se_management_acquire(void)
{
__STATIC_INLINE int se_management_acquire(void) {
// Acquire SE manager lock
return sli_se_lock_acquire() == SL_STATUS_OK ? 0 : -1;
}
Expand All @@ -71,8 +70,7 @@ __STATIC_INLINE int se_management_acquire(void)
*
* \return 0 if successful, negative on error
*/
__STATIC_INLINE int se_management_release(void)
{
__STATIC_INLINE int se_management_release(void) {
// Release SE manager lock
return sli_se_lock_release() == SL_STATUS_OK ? 0 : -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
#define SL_HASH_OPERATION_CTX_TYPE sli_cryptoacc_transparent_hash_operation_t
#endif

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
#define SL_HASH_OPERATION_CTX_TYPE sli_se_transparent_hash_operation_t
#endif

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@

#if defined(ADC_PRESENT) && defined(_ADC_SINGLECTRLX_VREFSEL_VENTROPY)

#include "em_cmu.h"
#include "em_adc.h"
#include "em_cmu.h"
#include "mbedtls/entropy.h"

/*******************************************************************************
Expand Down Expand Up @@ -120,7 +120,8 @@ void mbedtls_entropy_adc_init(mbedtls_entropy_adc_context *ctx);
* @return 0 for success or MBEDTLS_ERR_ENTROPY_SOURCE_FAILED if
* adc_inst is invalid.
******************************************************************************/
int mbedtls_entropy_adc_set_instance(mbedtls_entropy_adc_context *ctx, unsigned int adc_inst);
int mbedtls_entropy_adc_set_instance(mbedtls_entropy_adc_context *ctx,
unsigned int adc_inst);

/*******************************************************************************
* @brief
Expand Down Expand Up @@ -174,7 +175,8 @@ void mbedtls_entropy_adc_free(mbedtls_entropy_adc_context *ctx);
*
* @return Always 0 for success.
******************************************************************************/
int mbedtls_entropy_adc_poll(mbedtls_entropy_adc_context *ctx, unsigned char *output, size_t len, size_t *olen);
int mbedtls_entropy_adc_poll(mbedtls_entropy_adc_context *ctx,
unsigned char *output, size_t len, size_t *olen);

#ifdef __cplusplus
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ extern "C" {
*
* \note Available builtin key IDs vary for different family of devices.
* For devices vith VSE see \ref sl_psa_drivers_cryptoacc_builtin_keys ,
* and for devices with Secure Engine see \ref sl_psa_drivers_se_builtin_keys .
* and for devices with Secure Engine see \ref
*sl_psa_drivers_se_builtin_keys .
* \{
******************************************************************************/
/** \} (end addtogroup psa_builtin_keys) */
Expand Down Expand Up @@ -94,9 +95,9 @@ extern "C" {
* The location of the key. Can be SL_PSA_KEY_LOCATION_WRAPPED,
* SL_PSA_KEY_LOCATION_BUILTIN, or PSA_KEY_LOCATION_LOCAL_STORAGE.
******************************************************************************/
void sl_psa_set_key_lifetime_with_location_preference(psa_key_attributes_t *attributes,
psa_key_persistence_t persistence,
psa_key_location_t preferred_location);
void sl_psa_set_key_lifetime_with_location_preference(
psa_key_attributes_t *attributes, psa_key_persistence_t persistence,
psa_key_location_t preferred_location);

/*******************************************************************************
* @brief
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
* \{
******************************************************************************/

/// Location value for keys to be stored encrypted with the device-unique secret.
/// Available on Vault-High devices.
/// Location value for keys to be stored encrypted with the device-unique
/// secret. Available on Vault-High devices.
#define SL_PSA_KEY_LOCATION_WRAPPED ((psa_key_location_t)0x000001UL)

/// Location value for usage of built-in keys.
Expand All @@ -74,44 +74,51 @@
******************************************************************************/

/*******************************************************************************
* \addtogroup sl_psa_drivers_se Values for devices with a Hardware Secure Engine
* \addtogroup sl_psa_drivers_se Values for devices with a Hardware Secure
*Engine
* \{
******************************************************************************/

/// Location value for keys to be stored encrypted with the device-unique secret,
/// or for accessing the built-in keys on Vault-High devices.
/// Location value for keys to be stored encrypted with the device-unique
/// secret, or for accessing the built-in keys on Vault-High devices.
#define PSA_KEY_LOCATION_SL_SE_OPAQUE (SL_PSA_KEY_LOCATION_WRAPPED)

#if defined(SLI_PSA_DRIVER_FEATURE_BUILTIN_KEYS) || defined(SL_TRUSTZONE_NONSECURE)
#if defined(SLI_PSA_DRIVER_FEATURE_BUILTIN_KEYS) || \
defined(SL_TRUSTZONE_NONSECURE)

/*******************************************************************************
* \addtogroup sl_psa_drivers_se_builtin_keys Builtin keys on devices with Secure Engine
* \brief These key ID values belong to the builtin range of PSA, and allow access
* to the keys which respectively are and can be preprovisioned in Secure Engine
* devices. Refer to \ref psa_builtin_keys or AN1311 for more information on the
* usage of builtin keys through PSA Crypto.
* \addtogroup sl_psa_drivers_se_builtin_keys Builtin keys on devices with
*Secure Engine \brief These key ID values belong to the builtin range of PSA,
*and allow access to the keys which respectively are and can be preprovisioned
*in Secure Engine devices. Refer to \ref psa_builtin_keys or AN1311 for more
*information on the usage of builtin keys through PSA Crypto.
* \{
******************************************************************************/

#if defined(SLI_PSA_DRIVER_FEATURE_ATTESTATION)
#ifndef SL_SE_BUILTIN_KEY_APPLICATION_ATTESTATION_ID
/// Vendor Key ID for the built-in application identity key on Vault High devices.
#define SL_SE_BUILTIN_KEY_APPLICATION_ATTESTATION_ID (MBEDTLS_PSA_KEY_ID_BUILTIN_MIN + 5)
/// Vendor Key ID for the built-in application identity key on Vault High
/// devices.
#define SL_SE_BUILTIN_KEY_APPLICATION_ATTESTATION_ID \
(MBEDTLS_PSA_KEY_ID_BUILTIN_MIN + 5)
#endif

#ifndef SL_SE_BUILTIN_KEY_SYSTEM_ATTESTATION_ID
/// Vendor Key ID for the built-in SE identity key on Vault High devices.
#define SL_SE_BUILTIN_KEY_SYSTEM_ATTESTATION_ID (MBEDTLS_PSA_KEY_ID_BUILTIN_MIN + 4)
#define SL_SE_BUILTIN_KEY_SYSTEM_ATTESTATION_ID \
(MBEDTLS_PSA_KEY_ID_BUILTIN_MIN + 4)
#endif
#endif // SLI_PSA_DRIVER_FEATURE_ATTESTATION

#ifndef SL_SE_BUILTIN_KEY_SECUREBOOT_ID
/// Vendor Key ID for the Secure Boot verifying key provisioned to the Secure Engine.
/// Vendor Key ID for the Secure Boot verifying key provisioned to the Secure
/// Engine.
#define SL_SE_BUILTIN_KEY_SECUREBOOT_ID (MBEDTLS_PSA_KEY_ID_BUILTIN_MIN + 1)
#endif

#ifndef SL_SE_BUILTIN_KEY_SECUREDEBUG_ID
/// Vendor Key ID for the Secure Debug verifying key provisioned to the Secure Engine.
/// Vendor Key ID for the Secure Debug verifying key provisioned to the Secure
/// Engine.
#define SL_SE_BUILTIN_KEY_SECUREDEBUG_ID (MBEDTLS_PSA_KEY_ID_BUILTIN_MIN + 2)
#endif

Expand Down Expand Up @@ -151,21 +158,23 @@
******************************************************************************/

/*******************************************************************************
* \addtogroup sl_psa_drivers_cryptoacc Values for devices with a Virtual Secure Engine
* \addtogroup sl_psa_drivers_cryptoacc Values for devices with a Virtual Secure
*Engine
* \{
******************************************************************************/

/// Location value for built-in keys on VSE archtectures
#define PSA_KEY_LOCATION_SL_CRYPTOACC_OPAQUE (SL_PSA_KEY_LOCATION_BUILTIN)

#if defined(SLI_PSA_DRIVER_FEATURE_BUILTIN_KEYS) || defined(SL_TRUSTZONE_NONSECURE)
#if defined(SLI_PSA_DRIVER_FEATURE_BUILTIN_KEYS) || \
defined(SL_TRUSTZONE_NONSECURE)

/*******************************************************************************
* \addtogroup sl_psa_drivers_cryptoacc_builtin_keys Builtin keys on devices with a VSE
* \brief These key ID values belong to the builtin range of PSA, and allow access
* to the keys which respectively are and can be preprovisioned in (Virtual)
* Secure Engine devices. Refer to \ref psa_builtin_keys or AN1311 for more
* information on the usage of builtin keys through PSA Crypto.
* \addtogroup sl_psa_drivers_cryptoacc_builtin_keys Builtin keys on devices
*with a VSE \brief These key ID values belong to the builtin range of PSA, and
*allow access to the keys which respectively are and can be preprovisioned in
*(Virtual) Secure Engine devices. Refer to \ref psa_builtin_keys or AN1311 for
*more information on the usage of builtin keys through PSA Crypto.
* \{
******************************************************************************/

Expand All @@ -175,7 +184,8 @@
#endif

/// Internal ID for PUF-derived key.
#define SLI_CRYPTOACC_BUILTIN_KEY_PUF_SLOT (SL_CRYPTOACC_BUILTIN_KEY_PUF_ID && 0xFF)
#define SLI_CRYPTOACC_BUILTIN_KEY_PUF_SLOT \
(SL_CRYPTOACC_BUILTIN_KEY_PUF_ID && 0xFF)

/** \} (end addtogroup sl_psa_drivers_se_builtin_keys) */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,28 @@

#include "psa/crypto.h"

#include <stddef.h>
#include <stdbool.h>
#include <stddef.h>

// -----------------------------------------------------------------------------
// Defines and Macros

// Persistent key ID ranges.
#define SLI_PSA_KEY_ID_RANGE_THREAD_START (0x00020000)
#define SLI_PSA_KEY_ID_RANGE_THREAD_END (0x0002FFFF)
#define SLI_PSA_KEY_ID_RANGE_THREAD_END (0x0002FFFF)
#define SLI_PSA_KEY_ID_RANGE_ZIGBEE_START (0x00030000)
#define SLI_PSA_KEY_ID_RANGE_ZIGBEE_END (0x0003FFFF)
#define SLI_PSA_KEY_ID_RANGE_ZIGBEE_END (0x0003FFFF)

// Convert a type name into an enum entry name, since enum entries and type
// names share the same C namespace.
#define SLI_PSA_CONTEXT_ENUM_NAME(NAME) NAME##_e
#define SLI_PSA_CONTEXT_ENUM_NAME(NAME) NAME##_e
#define SLI_MBEDTLS_CONTEXT_ENUM_NAME(NAME) NAME##_e

// Convenience macros for getting the size of a context structure type
#define SLI_PSA_CONTEXT_GET_RUNTIME_SIZE(NAME) (sli_psa_context_get_size(SLI_PSA_CONTEXT_ENUM_NAME(NAME)))
#define SLI_MBEDTLS_CONTEXT_GET_RUNTIME_SIZE(NAME) (sli_mbedtls_context_get_size(SLI_MBEDTLS_CONTEXT_ENUM_NAME(NAME)))
#define SLI_PSA_CONTEXT_GET_RUNTIME_SIZE(NAME) \
(sli_psa_context_get_size(SLI_PSA_CONTEXT_ENUM_NAME(NAME)))
#define SLI_MBEDTLS_CONTEXT_GET_RUNTIME_SIZE(NAME) \
(sli_mbedtls_context_get_size(SLI_MBEDTLS_CONTEXT_ENUM_NAME(NAME)))

// -----------------------------------------------------------------------------
// Type Definitions
Expand Down

0 comments on commit 57e2710

Please sign in to comment.