Skip to content

Commit c6706d2

Browse files
committed
Add ForceZero for wolfSSL < 5.8.4
1 parent 5a83739 commit c6706d2

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/internal.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@
102102
#error "wolfTPM and MAXQ10XX are incompatible with each other."
103103
#endif
104104

105+
/* wc_ForceZero was added in wolfSSL 5.8.4. Provide a fallback for older
106+
* versions to securely zero sensitive memory. */
107+
#if defined(LIBWOLFSSL_VERSION_HEX) && LIBWOLFSSL_VERSION_HEX >= 0x05008004
108+
#include <wolfssl/wolfcrypt/memory.h>
109+
#else
110+
static void wc_ForceZero(void* mem, size_t len) {
111+
volatile byte* p = (volatile byte*)mem;
112+
while (len--) *p++ = 0;
113+
}
114+
#endif
115+
105116
/* Helper to get size of struct field */
106117
#define FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
107118

0 commit comments

Comments
 (0)