File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#include " Identity.h"
22#include < string.h>
3- #include < assert.h >
3+ #include < atomic >
44#define ED25519_NO_SEED 1
55#include < ed_25519.h>
66
@@ -16,12 +16,11 @@ Identity::Identity(const char* pub_hex) {
1616
1717bool Identity::verify (const uint8_t * sig, const uint8_t * message, int msg_len) const {
1818 // ed25519_verify uses static buffers internally (ge.c) and is NOT reentrant.
19- // This guard catches concurrent calls (e.g. from multiple FreeRTOS tasks).
20- static volatile bool in_verify = false ;
21- assert (!in_verify && " ed25519_verify is not reentrant - concurrent call detected" );
22- in_verify = true ;
19+ // Spinlock to serialize concurrent calls (e.g. from multiple FreeRTOS tasks).
20+ static std::atomic<bool > in_verify{false };
21+ while (in_verify.exchange (true , std::memory_order_acquire)) { /* spin */ }
2322 bool result = ed25519_verify (sig, message, msg_len, pub_key);
24- in_verify = false ;
23+ in_verify. store ( false , std::memory_order_release) ;
2524 return result;
2625}
2726
You can’t perform that action at this time.
0 commit comments