Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit c0301b1

Browse files
committed
[EFR32] Adding hardware acceleration for mbed TLS
Initial check-in of hardware acceleration support on EFR32 for mbed TLS (AES, SHA and ECC).
1 parent 035c08d commit c0301b1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+18873
-0
lines changed

features/mbedtls/platform/inc/platform_mbed.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,21 @@
2020
#if defined(DEVICE_TRNG)
2121
#define MBEDTLS_ENTROPY_HARDWARE_ALT
2222
#endif
23+
24+
#if defined(DEVICE_AES)
25+
#define MBEDTLS_AES_ALT
26+
#endif
27+
28+
#if defined(DEVICE_SHA)
29+
#define MBEDTLS_SHA1_ALT
30+
#define MBEDTLS_SHA256_ALT
31+
#endif
32+
33+
#if defined(DEVICE_ECC)
34+
#define MBEDTLS_ECP_DEVICE_ALT
35+
#define MBEDTLS_ECP_DOUBLE_JAC_ALT
36+
#define MBEDTLS_ECP_DEVICE_ADD_MIXED_ALT
37+
#define MBEDTLS_ECP_NORMALIZE_JAC_ALT
38+
#define MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT
39+
#define MBEDTLS_MPI_MODULAR_DIVISION_ALT
40+
#endif
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
================ Revision history ============================================
2+
5.0.0:
3+
- Added basic support for Series 1 Configuration 2 devices (EFR32MG12, etc.)
4+
- Bugfix: The asynchronous callback of mbedtls_ccm_auth_decrypt and
5+
mbedtls_cmac_verify_tag reported incorrect error codes when authentication
6+
verification fails.
7+
- Bugfix: In asynchronous mode, the output buffer of mbedtls_ccm_auth_decrypt
8+
was not properly cleared when authentication verification fails.
9+
10+
4.4.0:
11+
- Added CMAC support with a Silicon Labs specific API (slcl_cmac.c).
12+
CMAC is not covered by the standard mbedtls interface.
13+
The CMAC plugin use the CRYPTO hardware module for acceleration.
14+
- Added CCM plugin (slcl_ccm.c) with CRYPTO hardware acceleration and
15+
optimized CCM functions for BLE (mbedtls_ccm_encrypt_and_tag_ble and
16+
mbedtls_ccm_auth_decrypt_ble).
17+
- Added CRYPTO preemption support in the following plugins:
18+
slcl_aes.c, slcl_ccm.c, slcl_cmac.c, slcl_ecp.c, slcl_sha1.c and
19+
slcl_sha256.c.
20+
- Added support for alternative CRYPTO critical region implementations
21+
(for the CRYPTO preemption support).
22+
- Added support for asynchronous (non-blocking) API calls in the following
23+
plugins: slcl_aes.c, slcl_ccm.c and slcl_cmac.c.
24+
- Added support for moving data with BUFC and DMA (to/from CRYPTO registers)
25+
in the following plugins: slcl_aes.c and slcl_ccm.c.
26+
- In order to support error codes in new SIlicon Labs specific APIs
27+
extended error code interface of the standard mbedtls by using the full
28+
32-bit integer range, see details in mbedtls_ecode.h.
29+
- Added support for AES module on EFM32GG (Giant Gecko) in slcl_aes.c.
30+
Compile with MBEDTLS_SLCL_PLUGINS in order to enable EFM32GG support.
31+
32+
4.3.1:
33+
- No changes.
34+
35+
4.3.0:
36+
- Updated to mbedtls-2.2.0 including EC JPAKE support.
37+
- sl_aes.c:
38+
In mbedtls_aes_setkey_enc and mbedtls_aes_setkey_dec change return value to
39+
MBEDTLS_ERR_AES_INVALID_KEY_LENGTH when key length is not 128 or 256 bits.
40+
In mbedtls_aes_crypt_cfb128 added support for data lengths not dividable
41+
with 16 (AES block size), by using software (no crypto) implementation.
42+
In mbedtls_aes_crypt_cfb8 return errors from mbedtls_aes_crypt_ecb.
43+
- library/bignum.c:
44+
In mbedtls_mpi_sub_abs and mbedtls_mpi_mul_mpi copy to and use local
45+
variables only if necessary.
46+
- library/ecp.c:
47+
In ecp_modp call halResetWatchdog #ifdef MBEDTLS_HAVE_HAL_WATCHDOG_TIMER
48+
for Thread stack integration.
49+
- library/aes.c:
50+
In mbedtls_aes_self_test allow failure when setting 192 bit keys which is
51+
not supported by CRYPTO.
52+
- library/gcm.c:
53+
In mbedtls_gcm_self_test allow failure when setting 192 bit keys which is
54+
not supported by CRYPTO.
55+
- library/x509.c and x509_crt.c:
56+
Excluded code when MBEDTLS_FS_IO is defined which is not supported on
57+
Silicon Labs devices.
58+
- Added sl_timing.c and timing_alt.h in order to compiler modules depending on
59+
MBEDTLS_TIMING_C. The user should #define MBEDTLS_TIMING_ALT in order to
60+
compile.
61+
62+
4.2.1:
63+
- No changes.
64+
65+
4.2.0:
66+
- First version including support for mbedtls 2.0.0 and CRYPTO acceleration of
67+
AES (sl_aes.c), ECC (sl_ecp.c), SHA1 (sl_sha1.c) and SHA256 (sl_sha256.c).
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
README for mbed TLS CRYPTO hardware acceleraton plugins from Silicon Labs
2+
=========================================================================
3+
4+
Introduction
5+
------------
6+
This folder include alternative implementations (plugins) from Silicon Labs for some of the mbed TLS library functions, including AES, CCM, CMAC, ECC (ECP, ECDH, ECDSA, ECJPAKE), SHA1 and SHA256. The plugins use the AES and CRYPTO hardware modules to accelerate the standard mbed TLS library functions that are implemented in C. The CRYPTO hardware module is incorporated in the new generations of MCUs from SIlicon Labs and the AES hardware module is incorporated in the classic EFM32 MCUs from Silicon Labs.
7+
8+
Please refer to the mbedTLS section of the Gecko SDK documentation for more information on using mbed TLS on Silicon Labs devices.
9+
10+
Configuration
11+
-------------
12+
The configuration macros of the CRYPTO hardware acceleraton plugins from Silicon Labs are documented in configs/config-sl-crypto-all-acceleration.h. The configs/config-sl-crypto-all-acceleration.h enables acceleration of all plugins from Silicon Labs and provides a full mbedtls configuration which can be used to get started with application development. Please refer to the Gecko SDK documentation for more information on using mbed TLS on Silicon Labs devices. Please refer to the main README file (in the mbedtls base folder) and `include/mbedtls/config.h` for general mbed TLS configuration. Below is a summary of the configuration macros of the CRYPTO hardware acceleraton plugins:
13+
14+
#define MBEDTLS_AES_ALT /* Includes CRYPTO accelerated implementation of the aes.h interface. */
15+
#define MBEDTLS_SHA1_ALT /* Includes CRYPTO accelerated implementation of the sha1.h interface. */
16+
#define MBEDTLS_SHA256_ALT /* Includes CRYPTO accelerated implementation of the sha256.h interface. */
17+
#define MBEDTLS_ECP_DEVICE_ALT /* Includes CRYPTO accelerated implementation of some functions in ecp.c. */
18+
#define MBEDTLS_ECP_DOUBLE_JAC_ALT /* Includes CRYPTO accelerated implementation of the ecp_double_jac function. */
19+
#define MBEDTLS_ECP_DEVICE_ADD_MIXED_ALT /* Includes CRYPTO accelerated implementation of the ecp_add_mixed function. */
20+
#define MBEDTLS_ECP_NORMALIZE_JAC_ALT /* Includes CRYPTO accelerated implementation of the ecp_normalize_jac function. */
21+
#define MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT /* Includes CRYPTO accelerated implementation of the ecp_normalize_jac_many function. */
22+
#define MBEDTLS_MPI_MODULAR_DIVISION_ALT /* Includes the CRYPTO accelerated function mbedtls_mpi_div_mod which can serve as a replacement of the regular mbedtls_mpi_inv_mod function of mbedtls. */
23+
#define MBEDTLS_SLCL_PLUGINS /* Enables group 2 plugins (slcl_xxx.c) including support for CRYPTO preemption, asynchronous API support, DMA and BUFC I/O modes, and support for classic EFM32 devices with AES module, EFM32GG, etc. */
24+
#define MBEDTLS_CRYPTO_DEVICE_PREEMPTION /* Include CRYPTO preemption */
25+
#define MBEDTLS_CRYPTO_CRITICAL_REGION_ALT /* Include alternative implementation of CRYPTO critical regions (of CRYPTO preemption support). */
26+
#define MBEDTLS_INCLUDE_ASYNCH_API /* Include asynchronous API support */
27+
#define MBEDTLS_INCLUDE_IO_MODE_DMA /* Include support for moving data to/from CRYPTO with DMA */
28+
29+
Compiling
30+
---------
31+
Please refer to the example programs in the EFM32 SDK for project files examples for various IDE/toolchains.
32+
I.e:
33+
kits/SLSTK3401A_EFM32PG/examples/mbedtls_aescrypt
34+
kits/SLSTK3401A_EFM32PG/examples/mbedtls_ecdsa
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*~

0 commit comments

Comments
 (0)