Skip to content

Commit 2ee9402

Browse files
authored
Merge pull request #6937 from dgarske/stm32wl
Support for the STM32WL55 and PKA improvements for ECC parameters
2 parents 9e34ed9 + 0dde07e commit 2ee9402

9 files changed

Lines changed: 435 additions & 375 deletions

File tree

IDE/STM32Cube/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ You need both the STM32 IDE and the STM32 initialization code generator (STM32Cu
3131
2. Under “Software Packs” choose “Select Components”.
3232
3. Find and check all components for the wolfSSL.wolfSSL packs (wolfSSL / Core, wolfCrypt / Core and wolfCrypt / Test). Close
3333
4. Under the “Software Packs” section click on “wolfSSL.wolfSSL” and configure the parameters.
34-
5. For Cortex-M recommend “Math Configuration” -> “Single Precision Cortex-M Math” for the fastest option.
34+
5. For Cortex-M recommend “Math Configuration” -> “Single Precision Cortex-M Math” for the fastest option. If seeing `error: r7 cannot be used in 'asm` add `-fomit-frame-pointer` to the CFLAGS. This only happens in debug builds, because r7 is used for debug.
3535
6. Hit the "Generate Code" button
3636
7. Open the project in STM32CubeIDE
3737
8. The Benchmark example uses float. To enable go to "Project Properties" -> "C/C++ Build" -> "Settings" -> "Tool Settings" -> "MCU Settings" -> Check "Use float with printf".
@@ -87,6 +87,7 @@ The section for "Hardware platform" may need to be adjusted depending on your pr
8787
* To enable STM32L5 support define `WOLFSSL_STM32L5`.
8888
* To enable STM32H7 support define `WOLFSSL_STM32H7`.
8989
* To enable STM32WB support define `WOLFSSL_STM32WB`.
90+
* To enable STM32WL support define `WOLFSSL_STM32WL`.
9091
* To enable STM32U5 support define `WOLFSSL_STM32U5`.
9192
* To enable STM32H5 support define `WOLFSSL_STM32H5`.
9293

IDE/STM32Cube/STM32_Benchmarks.md

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* [STM32H753ZI](#stm32h753zi)
44
* [STM32WB55](#stm32wb55)
5+
* [STM32WL55](#stm32wl55)
56
* [STM32F437](#stm32f437)
67
* [STM32L4A6Z](#stm32l4a6z)
78
* [STM32L562E](#stm32l562e)
@@ -10,6 +11,7 @@
1011
* [STM32H563ZI](#stm32h563zi)
1112
* [STM32G071RB](#stm32g071rb)
1213

14+
1315
## STM32H753ZI
1416

1517
Supports RNG, AES CBC/GCM and SHA-2 acceleration.
@@ -94,6 +96,7 @@ Benchmark complete
9496
Benchmark Test: Return code 0
9597
```
9698

99+
97100
## STM32WB55
98101

99102
Supports RNG, ECC P-256, AES-CBC and SHA-256 acceleration.
@@ -211,6 +214,86 @@ Benchmark complete
211214
Benchmark Test: Return code 0
212215
```
213216

217+
218+
## STM32WL55
219+
220+
Supports RNG, ECC P-256 and AES-CBC acceleration.
221+
Note: SP math beats PKA HW. HW RNG on for all tests
222+
223+
Board: NUCLEO-WL55JC1 (MB1389-HIGHBAND-E02)
224+
CPU: Cortex-M4 at 64 MHz
225+
IDE: STM32CubeIDE
226+
RTOS: Bare-Metal
227+
228+
### STM32WL55 (STM AES-CBC Acceleration, -Os, SP-ASM Cortex-M WOLF_CONF_MATH=4)
229+
230+
```
231+
------------------------------------------------------------------------------
232+
wolfSSL version 5.6.4
233+
------------------------------------------------------------------------------
234+
wolfCrypt Benchmark (block bytes 1024, min 1.0 sec each)
235+
RNG 200 KiB took 1.012 seconds, 197.628 KiB/s
236+
AES-128-CBC-enc 2 MiB took 1.000 seconds, 2.246 MiB/s
237+
AES-128-CBC-dec 2 MiB took 1.004 seconds, 2.213 MiB/s
238+
AES-256-CBC-enc 2 MiB took 1.008 seconds, 2.228 MiB/s
239+
AES-256-CBC-dec 2 MiB took 1.000 seconds, 2.197 MiB/s
240+
SHA-256 600 KiB took 1.000 seconds, 600.000 KiB/s
241+
HMAC-SHA256 600 KiB took 1.012 seconds, 592.885 KiB/s
242+
ECC [ SECP256R1] 256 key gen 56 ops took 1.023 sec, avg 18.268 ms, 54.741 ops/sec
243+
ECDHE [ SECP256R1] 256 agree 26 ops took 1.024 sec, avg 39.385 ms, 25.391 ops/sec
244+
ECDSA [ SECP256R1] 256 sign 30 ops took 1.019 sec, avg 33.967 ms, 29.441 ops/sec
245+
ECDSA [ SECP256R1] 256 verify 18 ops took 1.098 sec, avg 61.000 ms, 16.393 ops/sec
246+
Benchmark complete
247+
Benchmark Test: Return code 0
248+
```
249+
250+
### STM32WL55 (STM AES-CBC Acceleration and PKA ECC, -Os)
251+
252+
```
253+
------------------------------------------------------------------------------
254+
wolfSSL version 5.6.4
255+
------------------------------------------------------------------------------
256+
wolfCrypt Benchmark (block bytes 1024, min 1.0 sec each)
257+
RNG 200 KiB took 1.000 seconds, 200.000 KiB/s
258+
AES-128-CBC-enc 2 MiB took 1.000 seconds, 2.295 MiB/s
259+
AES-128-CBC-dec 2 MiB took 1.007 seconds, 2.279 MiB/s
260+
AES-256-CBC-enc 2 MiB took 1.000 seconds, 2.295 MiB/s
261+
AES-256-CBC-dec 2 MiB took 1.008 seconds, 2.252 MiB/s
262+
SHA-256 575 KiB took 1.043 seconds, 551.294 KiB/s
263+
HMAC-SHA256 550 KiB took 1.000 seconds, 550.000 KiB/s
264+
ECC [ SECP256R1] 256 key gen 4 ops took 1.172 sec, avg 293.000 ms, 3.413 ops/sec
265+
ECDHE [ SECP256R1] 256 agree 4 ops took 1.165 sec, avg 291.250 ms, 3.433 ops/sec
266+
ECDSA [ SECP256R1] 256 sign 10 ops took 1.070 sec, avg 107.000 ms, 9.346 ops/sec
267+
ECDSA [ SECP256R1] 256 verify 6 ops took 1.275 sec, avg 212.500 ms, 4.706 ops/sec
268+
Benchmark complete
269+
Benchmark Test: Return code 0
270+
```
271+
272+
### STM32WL55 (No HW Crypto, -Os, SP Math All (WOLF_CONF_MATH=6))
273+
274+
```
275+
------------------------------------------------------------------------------
276+
wolfSSL version 5.6.4
277+
------------------------------------------------------------------------------
278+
wolfCrypt Benchmark (block bytes 1024, min 1.0 sec each)
279+
RNG 200 KiB took 1.015 seconds, 197.044 KiB/s
280+
AES-128-CBC-enc 400 KiB took 1.004 seconds, 398.406 KiB/s
281+
AES-128-CBC-dec 400 KiB took 1.000 seconds, 400.000 KiB/s
282+
AES-192-CBC-enc 350 KiB took 1.031 seconds, 339.476 KiB/s
283+
AES-192-CBC-dec 350 KiB took 1.028 seconds, 340.467 KiB/s
284+
AES-256-CBC-enc 300 KiB took 1.007 seconds, 297.915 KiB/s
285+
AES-256-CBC-dec 300 KiB took 1.004 seconds, 298.805 KiB/s
286+
SHA-256 550 KiB took 1.016 seconds, 541.339 KiB/s
287+
HMAC-SHA256 550 KiB took 1.024 seconds, 537.109 KiB/s
288+
ECC [ SECP256R1] 256 key gen 4 ops took 1.180 sec, avg 295.000 ms, 3.390 ops/sec
289+
ECDHE [ SECP256R1] 256 agree 4 ops took 1.181 sec, avg 295.250 ms, 3.387 ops/sec
290+
ECDSA [ SECP256R1] 256 sign 4 ops took 1.306 sec, avg 326.500 ms, 3.063 ops/sec
291+
ECDSA [ SECP256R1] 256 verify 2 ops took 1.188 sec, avg 594.000 ms, 1.684 ops/sec
292+
Benchmark complete
293+
Benchmark Test: Return code 0
294+
```
295+
296+
214297
## STM32F437
215298

216299
Supports RNG, AES-CBC/GCM and SHA-256 acceleration.
@@ -295,6 +378,7 @@ Benchmark complete
295378
Benchmark Test: Return code 0
296379
```
297380

381+
298382
## STM32L4A6Z
299383

300384
Supports RNG, AES-CBC/GCM and SHA-256 acceleration.
@@ -307,7 +391,6 @@ RTOS: FreeRTOS
307391

308392
### STM32L4A6Z (STM Crypto/Hash Acceleration, -Os, SP-ASM Cortex-M)
309393

310-
311394
```
312395
------------------------------------------------------------------------------
313396
wolfSSL version 4.4.1
@@ -376,6 +459,7 @@ Benchmark complete
376459
Benchmark Test: Return code 0
377460
```
378461

462+
379463
## STM32L562E
380464

381465
Supports RNG, AES-CBC/GCM and SHA-256 acceleration.
@@ -489,6 +573,7 @@ Benchmark complete
489573
Benchmark Test: Return code 0
490574
```
491575

576+
492577
## STM32F777
493578

494579
Supports RNG, AES-CBC/GCM and SHA-256 acceleration.
@@ -573,6 +658,7 @@ Benchmark complete
573658
Benchmark Test: Return code 0
574659
```
575660

661+
576662
## STM32U585
577663

578664
Supports RNG, AES CBC/GCM and SHA-1,SHA-2 acceleration.
@@ -711,6 +797,7 @@ Benchmark complete
711797
Benchmark Test: Return code 0
712798
```
713799

800+
714801
## STM32H563ZI
715802

716803
Cortex-M33 at 150MHz

IDE/STM32Cube/default_conf.ftl

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
[#list SWIPdatas as SWIP]
3434
[#-- Global variables --]
3535
[#if SWIP.variables??]
36-
[#list SWIP.variables as variable]
36+
[#list SWIP.variables as variable]
3737
extern ${variable.value} ${variable.name};
38-
[/#list]
38+
[/#list]
3939
[/#if]
4040

4141
[#-- Global variables --]
@@ -45,16 +45,16 @@ extern ${variable.value} ${variable.name};
4545
[#assign version = SWIP.version]
4646

4747
/**
48-
MiddleWare name : ${instName}
49-
MiddleWare fileName : ${fileName}
50-
MiddleWare version : ${version}
48+
MiddleWare name : ${instName}
49+
MiddleWare fileName : ${fileName}
50+
MiddleWare version : ${version}
5151
*/
5252
[#if SWIP.defines??]
53-
[#list SWIP.defines as definition]
53+
[#list SWIP.defines as definition]
5454
/*---------- [#if definition.comments??]${definition.comments}[/#if] -----------*/
5555
#define ${definition.name} #t#t ${definition.value}
5656
[#if definition.description??]${definition.description} [/#if]
57-
[/#list]
57+
[/#list]
5858
[/#if]
5959

6060

@@ -76,6 +76,11 @@ extern ${variable.value} ${variable.name};
7676
#define WOLFSSL_STM32_PKA
7777
#undef NO_STM32_CRYPTO
7878
#define HAL_CONSOLE_UART huart1
79+
#elif defined(STM32WL55xx)
80+
#define WOLFSSL_STM32WL
81+
#define WOLFSSL_STM32_PKA
82+
#undef NO_STM32_CRYPTO
83+
#define HAL_CONSOLE_UART huart2
7984
#elif defined(STM32F407xx)
8085
#define WOLFSSL_STM32F4
8186
#define HAL_CONSOLE_UART huart2
@@ -177,7 +182,8 @@ extern ${variable.value} ${variable.name};
177182
//#define NO_STM32_RNG
178183
//#undef NO_STM32_HASH
179184
//#undef NO_STM32_CRYPTO
180-
//#define WOLFSSL_GENSEED_FORTEST /* if no HW RNG is available use test seed */
185+
/* if no HW RNG is available use test seed */
186+
//#define WOLFSSL_GENSEED_FORTEST
181187
//#define STM32_HAL_V2
182188
#endif
183189

@@ -242,13 +248,14 @@ extern ${variable.value} ${variable.name};
242248
#define WOLFSSL_HAVE_SP_ECC
243249
#endif
244250
#if WOLF_CONF_MATH == 6 || WOLF_CONF_MATH == 7
251+
#define WOLFSSL_SP_MATH_ALL /* use sp_int.c multi precision math */
252+
#else
245253
#define WOLFSSL_SP_MATH /* disable non-standard curves / key sizes */
246254
#endif
247255
#define SP_WORD_SIZE 32
248256

249257
/* Enable to put all math on stack (no heap) */
250258
//#define WOLFSSL_SP_NO_MALLOC
251-
/* Enable for SP cache resistance (not usually enabled for embedded micros) */
252259

253260
#if WOLF_CONF_MATH == 4 || WOLF_CONF_MATH == 5
254261
#define WOLFSSL_SP_ASM /* required if using the ASM versions */
@@ -504,12 +511,12 @@ extern ${variable.value} ${variable.name};
504511
/* Sha3 */
505512
#undef WOLFSSL_SHA3
506513
#if defined(WOLF_CONF_SHA3) && WOLF_CONF_SHA3 == 1
507-
#define WOLFSSL_SHA3
514+
#define WOLFSSL_SHA3
508515
#endif
509516

510517
/* MD5 */
511518
#if defined(WOLF_CONF_MD5) && WOLF_CONF_MD5 == 1
512-
/* enabled */
519+
/* enabled */
513520
#else
514521
#define NO_MD5
515522
#endif
@@ -534,8 +541,8 @@ extern ${variable.value} ${variable.name};
534541
#if 0
535542
#define USE_WOLFSSL_MEMORY
536543
#define WOLFSSL_TRACK_MEMORY
537-
#define WOLFSSL_DEBUG_MEMORY
538-
#define WOLFSSL_DEBUG_MEMORY_PRINT
544+
#define WOLFSSL_DEBUG_MEMORY
545+
#define WOLFSSL_DEBUG_MEMORY_PRINT
539546
#endif
540547
#else
541548
//#define NO_WOLFSSL_MEMORY

0 commit comments

Comments
 (0)