-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ESP32 HW ED25519 test #5997
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed please implement fix using the memset we discussed. Bug here is use of uninitialized stack memory.
@@ -115,19 +115,26 @@ int esp_CryptHwMutexUnLock(wolfSSL_Mutex* mutex); | |||
ESP32_SHA_INIT = 0, | |||
ESP32_SHA_HW = 1, | |||
ESP32_SHA_SW = 2, | |||
ESP32_SHA_FAIL_NEED_UNROLL = -1 | |||
ESP32_SHA_FAIL_NEED_UNROLL = 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If -1
worked consider reverting this change.
…essif_ED25519_fix
…essif_ED25519_fix
Can one of the admins verify this patch? |
Closing in favor of #6068. |
@dgarske I do not believe the zeroize of buffer will fully resolve this issue. The situation that caused the odd ED25519 failure here was the use of a copy of an already-initialized SHA |
For reference, see #5948 (comment) for notes on resolution of this issue. |
Description
This PR reorders the items in the WC_ESP32SHA typedef struct in the esp32-crypt.h used by Espressif HW Acceleration as noted in #5948 (comment), addressing the byte-alignment problem that cause the ESP32 ED25519 test to fail with Stack Smashing disabled. (The test did not fail with Stack Smashing set to
Normal
)Fixes zd# n/a
Testing
Confirm Error Condition
With a struct like this, having the
lockDepth
listed first, Stack Smashing set toNone
and Espressif Hardware Acceleration enabled:Results in this error -229 (SIG_VERIFY_E = wolfcrypt signature verify error):
Confirm Success
Load the VisualGDB project and confirm
Stack Smashing
is set toNone
:Run the wolfSSL test as changed in this PR (be sure the latest wolfSSL component is installed) and confirm all tests pass:
Thank you @dgarske for suggesting item order. I may have otherwise simply changed the struct item
mode
type fromESP32_MODE mode
tobyte mode
as a working but still very fragile solution.Note the
ESP32_SHA_FAIL_NEED_UNROLL
value, although changed in this PR, did not actually affect the success or failure of the ED25519 test as related to this byte alignment problem. It is changed only as related to a Best Practice advice.This code is still somewhat fragile. It might be nice to have something detect such byte alignment problems in Espressif, and possibly other environments as noted in #5989.
Checklist