Skip to content

Commit

Permalink
Restyle Adds PSA crypto support file for SiWx917 (#178)
Browse files Browse the repository at this point in the history
Restyled by clang-format

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
restyled-io[bot] and restyled-commits authored Mar 21, 2024
1 parent 054c618 commit 95aece3
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 116 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// This is an autogenerated config file, any changes to this file will be overwritten
// This is an autogenerated config file, any changes to this file will be
// overwritten

#ifndef SLI_MBEDTLS_CONFIG_AUTOGEN_H
#define SLI_MBEDTLS_CONFIG_AUTOGEN_H
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// This is an autogenerated config file, any changes to this file will be overwritten
// This is an autogenerated config file, any changes to this file will be
// overwritten

#ifndef SLI_MBEDTLS_CONFIG_TRANSFORM_AUTOGEN_H
#define SLI_MBEDTLS_CONFIG_TRANSFORM_AUTOGEN_H
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// This is an autogenerated config file, any changes to this file will be overwritten
// This is an autogenerated config file, any changes to this file will be
// overwritten

#ifndef SLI_PSA_BUILTIN_CONFIG_AUTOGEN_H
#define SLI_PSA_BUILTIN_CONFIG_AUTOGEN_H

#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_AES 1
#define MBEDTLS_PSA_BUILTIN_ALG_CMAC 1
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_PUBLIC_KEY 1
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR_BASIC 1
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR_IMPORT 1
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR_EXPORT 1
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_AES 1
#define MBEDTLS_PSA_BUILTIN_ALG_CMAC 1
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_PUBLIC_KEY 1
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR_BASIC 1
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR_IMPORT 1
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR_EXPORT 1
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR_GENERATE 1
#define MBEDTLS_PSA_BUILTIN_ECC_SECP_R1_256 1
#define MBEDTLS_PSA_BUILTIN_ALG_SHA_224 1
#define MBEDTLS_PSA_BUILTIN_ALG_SHA_256 1
#define MBEDTLS_PSA_BUILTIN_ECC_SECP_R1_256 1
#define MBEDTLS_PSA_BUILTIN_ALG_SHA_224 1
#define MBEDTLS_PSA_BUILTIN_ALG_SHA_256 1

#endif // SLI_PSA_BUILTIN_CONFIG_AUTOGEN_H
37 changes: 19 additions & 18 deletions matter/si91x/siwx917/BRD4338A/autogen/sli_psa_config_autogen.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
// This is an autogenerated config file, any changes to this file will be overwritten
// This is an autogenerated config file, any changes to this file will be
// overwritten

#ifndef SLI_PSA_CONFIG_AUTOGEN_H
#define SLI_PSA_CONFIG_AUTOGEN_H

#define MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
#define PSA_WANT_KEY_TYPE_AES 1
#define PSA_WANT_ALG_CCM 1
#define PSA_WANT_ALG_CMAC 1
#define PSA_WANT_ALG_SHA_224 1
#define PSA_WANT_ALG_SHA_256 1
#define PSA_WANT_ALG_ECB_NO_PADDING 1
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR 1
#define PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY 1
#define PSA_WANT_ECC_SECP_R1_256 1
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC 1
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT 1
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT 1
#define PSA_WANT_KEY_TYPE_AES 1
#define PSA_WANT_ALG_CCM 1
#define PSA_WANT_ALG_CMAC 1
#define PSA_WANT_ALG_SHA_224 1
#define PSA_WANT_ALG_SHA_256 1
#define PSA_WANT_ALG_ECB_NO_PADDING 1
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR 1
#define PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY 1
#define PSA_WANT_ECC_SECP_R1_256 1
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC 1
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT 1
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT 1
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE 1
#define PSA_WANT_ALG_ECDH 1
#define PSA_WANT_ALG_ECDSA 1
#define PSA_WANT_ALG_HKDF 1
#define PSA_WANT_ALG_HMAC 1
#define PSA_WANT_KEY_TYPE_HMAC 1
#define PSA_WANT_ALG_ECDH 1
#define PSA_WANT_ALG_ECDSA 1
#define PSA_WANT_ALG_HKDF 1
#define PSA_WANT_ALG_HMAC 1
#define PSA_WANT_KEY_TYPE_HMAC 1

#define MBEDTLS_PSA_KEY_SLOT_COUNT (1 + SL_PSA_KEY_USER_SLOT_COUNT)
#ifndef SL_PSA_ITS_MAX_FILES
Expand Down
46 changes: 21 additions & 25 deletions matter/si91x/siwx917/BRD4338A/config/psa_crypto_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,28 @@
// <i> setup, until it finishes or aborts.
// <i> When an application tries to open more keys than this value accounts for,
// <i> the PSA API may return PSA_ERROR_INSUFFICIENT_MEMORY. Keep in mind that
// <i> other software included in the application (e.g. wireless protocol stacks)
// <i> also can have a need to have open keys in PSA Crypto. This could lead to
// <i> a race condition when the application key slot count is set too low for
// <i> the actual usage of the application, as a software stack may not fail
// <i> gracefully in case an application opens more than its declared amount of
// <i> keys, thereby precluding the stack from functioning.
// <i> Default: 4
// <i> other software included in the application (e.g. wireless protocol
// stacks) <i> also can have a need to have open keys in PSA Crypto. This could
// lead to <i> a race condition when the application key slot count is set too
// low for <i> the actual usage of the application, as a software stack may not
// fail <i> gracefully in case an application opens more than its declared
// amount of <i> keys, thereby precluding the stack from functioning. <i>
// Default: 4
#define SL_PSA_KEY_USER_SLOT_COUNT (4)

// <o SL_PSA_ITS_USER_MAX_FILES> PSA Maximum User Persistent Keys Count <0-1024>
// <i> Maximum amount of keys (or other files) that can be stored persistently
// <i> by the application through the PSA interface, when persistent storage
// <i> support for PSA Crypto is included in the project.
// <i> Due to caching logic, this setting does have an impact on static RAM usage.
// <i> Note that this number is added to the potential requirements from other
// <i> software components in the project, such that the total amount of keys
// <i> which can be stored through the ITS backend can be higher than what is
// <i> configured here.
// <i>
// <i> WARNING: When changing this setting on an application that is already
// <i> deployed, and thus will get the change through an application upgrade,
// <i> care should be taken to ensure that the setting is only ever increased,
// <i> and never decreased. Decreasing this setting might cause previously
// <i> stored keys/files to become inaccessible.
// <i> Due to caching logic, this setting does have an impact on static RAM
// usage. <i> Note that this number is added to the potential requirements from
// other <i> software components in the project, such that the total amount of
// keys <i> which can be stored through the ITS backend can be higher than what
// is <i> configured here. <i> <i> WARNING: When changing this setting on an
// application that is already <i> deployed, and thus will get the change
// through an application upgrade, <i> care should be taken to ensure that the
// setting is only ever increased, <i> and never decreased. Decreasing this
// setting might cause previously <i> stored keys/files to become inaccessible.
// <i>
// <i> It is not possible to change this setting when using V3 ITS Driver.
// <i> The file-storage indexing is dependent on the maximum number of files,
Expand Down Expand Up @@ -77,13 +75,11 @@
// <i> that those devices have full nvm3 and not enough space for the
// <i> upgrade, (that requires an extra space to store largest key in memory
// <i> twice), this config option can disable v3 driver and use v2 one.
// <i> To upgrade the device, make space for the upgrade, and enable v3 driver again.
// <i>
// <i> WARNING: When using V3 driver, it is not possible to increase or decrease
// <i> the value of SL_PSA_ITS_USER_MAX_FILES. If the change of
// <i> SL_PSA_ITS_USER_MAX_FILES is required, ITS should be cleared and
// <i> all files need to be stored again.
// <i> Default: 1
// <i> To upgrade the device, make space for the upgrade, and enable v3 driver
// again. <i> <i> WARNING: When using V3 driver, it is not possible to increase
// or decrease <i> the value of SL_PSA_ITS_USER_MAX_FILES. If the change of <i>
// SL_PSA_ITS_USER_MAX_FILES is required, ITS should be cleared and <i> all
// files need to be stored again. <i> Default: 1
#define SL_PSA_ITS_SUPPORT_V3_DRIVER 1

// <o SL_SE_BUILTIN_KEY_AES128_ALG_CONFIG> Built-in AES Key Mode of Operation
Expand Down
85 changes: 40 additions & 45 deletions matter/si91x/siwx917/BRD4338A/config/sl_mbedtls_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,83 +8,78 @@

// <h> TLS/DTLS configuration

// <o MBEDTLS_SSL_CIPHERSUITES> Complete list of ciphersuites to use, in order of preference.
// <i> Default: MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8
// <i> Complete list of ciphersuites to use, in order of preference.
// <i> The value of this configuration should be updated for the application needs.
// <o MBEDTLS_SSL_CIPHERSUITES> Complete list of ciphersuites to use, in order
// of preference. <i> Default: MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 <i>
// Complete list of ciphersuites to use, in order of preference. <i> The value
// of this configuration should be updated for the application needs.
#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8

// <o SL_MBEDTLS_SSL_IN_CONTENT_LEN> Maximum TLS/DTLS fragment length in bytes (input).
// <i> Default: 768
// <i> The size configured here determines the size of the internal I/O
// <i> buffer used in mbedTLS when receiving data.
// <o SL_MBEDTLS_SSL_IN_CONTENT_LEN> Maximum TLS/DTLS fragment length in bytes
// (input). <i> Default: 768 <i> The size configured here determines the size of
// the internal I/O <i> buffer used in mbedTLS when receiving data.
#define SL_MBEDTLS_SSL_IN_CONTENT_LEN 768

// <o SL_MBEDTLS_SSL_OUT_CONTENT_LEN> Maximum TLS/DTLS fragment length in bytes (output).
// <i> Default: 768
// <i> The size configured here determines the size of the internal I/O
// <i> buffer used in mbedTLS when sending data.
// <o SL_MBEDTLS_SSL_OUT_CONTENT_LEN> Maximum TLS/DTLS fragment length in bytes
// (output). <i> Default: 768 <i> The size configured here determines the size
// of the internal I/O <i> buffer used in mbedTLS when sending data.
#define SL_MBEDTLS_SSL_OUT_CONTENT_LEN 768

// <q SL_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH> Enable support for RFC 6066 max_fragment_length extension in SSL.
// <i> Default: 1
// <i> Enable support for RFC 6066 max_fragment_length extension in SSL.
// <q SL_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH> Enable support for RFC 6066
// max_fragment_length extension in SSL. <i> Default: 1 <i> Enable support for
// RFC 6066 max_fragment_length extension in SSL.
#define SL_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 1

// <q SL_MBEDTLS_SSL_EXPORT_KEYS> Enable support for exporting key block and master secret.
// <i> Default: 1
// <i> Enable support for exporting key block and master secret.
// <i> This is required for certain users of TLS, e.g. EAP-TLS.
// <q SL_MBEDTLS_SSL_EXPORT_KEYS> Enable support for exporting key block and
// master secret. <i> Default: 1 <i> Enable support for exporting key block and
// master secret. <i> This is required for certain users of TLS, e.g. EAP-TLS.
#define SL_MBEDTLS_SSL_EXPORT_KEYS 1

// <q SL_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED> Enable the PSK based ciphersuite modes in SSL / TLS.
// <i> Default: 0
// <i> Enable the PSK based ciphersuite modes in SSL / TLS.
// <q SL_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED> Enable the PSK based ciphersuite
// modes in SSL / TLS. <i> Default: 0 <i> Enable the PSK based ciphersuite modes
// in SSL / TLS.
#define SL_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED 0

// <q SL_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED> Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS.
// <i> Default: 0
// <i> Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS.
// <q SL_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED> Enable the ECDHE-PSK based
// ciphersuite modes in SSL / TLS. <i> Default: 0 <i> Enable the ECDHE-PSK based
// ciphersuite modes in SSL / TLS.
#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED 0

// <q SL_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED> Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS.
// <i> Default: 0
// <i> Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS.
// <q SL_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED> Enable the ECDHE-ECDSA based
// ciphersuite modes in SSL / TLS. <i> Default: 0 <i> Enable the ECDHE-ECDSA
// based ciphersuite modes in SSL / TLS.
#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 0

// <q SL_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED> Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS.
// <i> Default: 0
// <i> Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS.
// <q SL_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED> Enable the ECDHE-RSA based
// ciphersuite modes in SSL / TLS. <i> Default: 0 <i> Enable the ECDHE-RSA based
// ciphersuite modes in SSL / TLS.
#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED 0

// <q SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED> Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS.
// <i> Default: 0
// <i> Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS.
// <q SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED> Enable the ECDH-ECDSA based
// ciphersuite modes in SSL / TLS. <i> Default: 0 <i> Enable the ECDH-ECDSA
// based ciphersuite modes in SSL / TLS.
#define SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED 0

// <q SL_MBEDTLS_ECP_ENABLE_COMPRESSED_CURVE_PARSING> Enable parsing of the compressed curves.
// <i> Default: 0
// <i> Enable parsing of the compressed curves.
// <q SL_MBEDTLS_ECP_ENABLE_COMPRESSED_CURVE_PARSING> Enable parsing of the
// compressed curves. <i> Default: 0 <i> Enable parsing of the compressed
// curves.
#define SL_MBEDTLS_ECP_ENABLE_COMPRESSED_CURVE_PARSING 0

// </h>

// <h> RSA configuration

// <q SL_MBEDTLS_RSA_NO_CRT> Disable use of the Chinese Remainder Theorem for RSA.
// <i> Default: 0
// <i> Disable use of the Chinese Remainder Theorem for RSA private key
// <i> computations.
// <q SL_MBEDTLS_RSA_NO_CRT> Disable use of the Chinese Remainder Theorem for
// RSA. <i> Default: 0 <i> Disable use of the Chinese Remainder Theorem for RSA
// private key <i> computations.
#define SL_MBEDTLS_RSA_NO_CRT 0

// </h>

// <h> Miscellaneous configuration

// <q SL_MBEDTLS_DRIVERS_ENABLED> Enable Silicon Labs' Mbed TLS- and PSA Crypto drivers.
// <i> Default: 1
// <i> Enable drivers for hardware acceleration (Mbed TLS and PSA Crypto) and
// <i> secure key handling (PSA Crypto).
// <q SL_MBEDTLS_DRIVERS_ENABLED> Enable Silicon Labs' Mbed TLS- and PSA Crypto
// drivers. <i> Default: 1 <i> Enable drivers for hardware acceleration (Mbed
// TLS and PSA Crypto) and <i> secure key handling (PSA Crypto).
#define SL_MBEDTLS_DRIVERS_ENABLED 1

// </h>
Expand Down
30 changes: 14 additions & 16 deletions matter/si91x/siwx917/BRD4338A/config/sl_mbedtls_device_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

// <h> Secure Engine (SE) version configuration

// <o SL_SE_SUPPORT_FW_PRIOR_TO_1_2_2> Support SE firmware versions older than 1.2.2 <0-1>
// <i> Enable software fallback for ECDH and ECC public key validation on xG21
// <i> devices running SE firmware versions lower than 1.2.2.
// <o SL_SE_SUPPORT_FW_PRIOR_TO_1_2_2> Support SE firmware versions older
// than 1.2.2 <0-1> <i> Enable software fallback for ECDH and ECC public key
// validation on xG21 <i> devices running SE firmware versions lower than 1.2.2.
// <i>
// <i> Due to other stability concerns, it is strongly recommended to upgrade
// <i> these devices to the latest firmware revision instead of turning on
Expand All @@ -22,21 +22,19 @@
// <i> Default: 0
#define SL_SE_SUPPORT_FW_PRIOR_TO_1_2_2 0

// <o SL_SE_ASSUME_FW_AT_LEAST_1_2_2> Assume an SE firmware version newer than 1.2.2 <0-1>
// <i> For enhanced performance: if it is guaranteed that all devices on which
// <i> this library will run are updated to at least SE FW 1.2.2, then turning
// <i> on this option will remove certain fallback checks, thereby reducing the
// <i> amount of processing required for ECDH and public key verification
// <i> operations.
// <i> Default: 0
// <o SL_SE_ASSUME_FW_AT_LEAST_1_2_2> Assume an SE firmware version newer
// than 1.2.2 <0-1> <i> For enhanced performance: if it is guaranteed that all
// devices on which <i> this library will run are updated to at least SE
// FW 1.2.2, then turning <i> on this option will remove certain fallback
// checks, thereby reducing the <i> amount of processing required for ECDH and
// public key verification <i> operations. <i> Default: 0
#define SL_SE_ASSUME_FW_AT_LEAST_1_2_2 0

// <o SL_SE_ASSUME_FW_UNAFFECTED_BY_ED25519_ERRATA> Assume an SE firmware version that is unaffected by Ed25519 errata <0-1>
// <i> For minimal code size and performance savings: if it is guaranteed that
// <i> none of the devices running this library has SE FWs in the range
// <i> [1.2.2, 1.2.8], then enabling this option will disable runtime version
// <i> checks.
// <i> Default: 0
// <o SL_SE_ASSUME_FW_UNAFFECTED_BY_ED25519_ERRATA> Assume an SE firmware
// version that is unaffected by Ed25519 errata <0-1> <i> For minimal code size
// and performance savings: if it is guaranteed that <i> none of the devices
// running this library has SE FWs in the range <i> [1.2.2, 1.2.8], then
// enabling this option will disable runtime version <i> checks. <i> Default: 0
#define SL_SE_ASSUME_FW_UNAFFECTED_BY_ED25519_ERRATA 0

// </h>
Expand Down

0 comments on commit 95aece3

Please sign in to comment.