Skip to content

Commit b5fcb9b

Browse files
committed
Move wc_ForceZero for wolfSSL < 5.8.4
1 parent 8471fa2 commit b5fcb9b

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

src/internal.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,6 @@
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-
116105
/* Helper to get size of struct field */
117106
#define FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
118107

wolfpkcs11/internal.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@
3939
#include <wolfpkcs11/pkcs11.h>
4040
#include <wolfpkcs11/version.h>
4141

42+
/* wc_ForceZero was added in wolfSSL 5.8.4. Provide a fallback for older
43+
* versions to securely zero sensitive memory. */
44+
#include <wolfssl/version.h>
45+
#if !defined(LIBWOLFSSL_VERSION_HEX) || LIBWOLFSSL_VERSION_HEX < 0x05008004
46+
static WC_INLINE void wc_ForceZero(void* mem, size_t len) {
47+
volatile byte* p = (volatile byte*)mem;
48+
while (len--) *p++ = 0;
49+
}
50+
#endif
51+
4252
#ifdef __cplusplus
4353
extern "C" {
4454
#endif

0 commit comments

Comments
 (0)