Introduce Espressif wolfcrypt warmup#9227
Conversation
|
🛟 Devin Lifeguard found 2 likely issues in this PR
@gojimmypi |
5471bfe to
98f3647
Compare
98f3647 to
afba91e
Compare
|
Jenkins retest this please. For Cannot contact wolf-linux-cloud-node-[n]: java.lang.InterruptedException java.io.StreamCorruptedException: invalid stream header: 636F7272 |
dgarske
left a comment
There was a problem hiding this comment.
Were you able to identify the heap memory that was allocated and left allocated by AES/RNG? Is it a large allocation? I don't think this PR to do warm-up is the right solution. Again sounds more like a workaround. The right solution is finding out what heap memory is allocated and not free'd. Then solving use of it. I am certain if its in wolfCrypt we have build options to resolve it. If its in the ESP crypto layers than its a different problem and consider calling ESP API's to init/warm up, not code in wolfCrypt.
Not yet.
No, just enough to spoil a later large allocation.
Agreed.
Probably. |
|
Can one of the admins verify this patch? |
This is the Espressif-specific version of #9203
I tend to agree that this may not belong in the
wolfCrypt_Init(), but the code does need to be available and consistent.I plan to use this in all the Espressif examples.
Description
Adds a
esp_sdk_wolfssl_warmup()warmup, call as desired, enabled by default, disable withNO_WOLFCRYPT_WARMUP.To use, call this early in the application startup:
Reason
The random number generator and AES functions were observed allocating long term (perhaps permanent?) heap memory. This PR "warms up" wolfCrypt by calling some sample code early, ensuring (hoping?) any heap allocations are at the edge of the heap and not in the middle.
A long term heap allocation in the middle of the heap, say after reading a large object such as a certificate, may interfere with the long term maximum memory availability.
This PR also makes the wolfcrypt test result more pretty.
Background
I've been optimizing wolfssl for small embedded targets. Some time ago, I introduced a heap discrepancy alert in the wolfcrypt tests. It was intended to find memory leaks after repeatedly running the tests, for example #8506
See the wolfcrypt/test/test.c around line 154 for the
PRINT_HEAP_CHECKPOINTimplementation forWOLFSSL_ESPIDFtargets.There's been a nagging reminder in the tests:
As it only occurs on the first pass of these tests, I did not consider it a memory leak. Still, it's not pretty. But until recently "not pretty" did not warrant attention. Until recently when considering the location of the heap object and no memory available even with a seemingly large quality of total heap space.
Fixes zd# n/a
Testing
How did you test?
Tested locally on ESP32 targets
Checklist