|
77 | 77 | #include <wolfssl/wolfcrypt/pwdbased.h> |
78 | 78 |
|
79 | 79 | #include <wolfengine/we_openssl_bc.h> |
80 | | - |
81 | 80 | #include <wolfengine/we_logging.h> |
82 | 81 | #include <wolfengine/we_fips.h> |
83 | 82 |
|
| 83 | +/* Defining WE_NO_OPENSSL_MALLOC will cause wolfEngine to not use the OpenSSL |
| 84 | + * memory management functions (e.g. OPENSSL_malloc, OPENSSL_free, etc.). |
| 85 | + * Instead, the corresponding wolfSSL functions will be used (e.g. XMALLOC, |
| 86 | + * XFREE, etc.). */ |
| 87 | +#ifdef WE_NO_OPENSSL_MALLOC |
| 88 | +#undef OPENSSL_malloc |
| 89 | +#define OPENSSL_malloc(num) XMALLOC((num), NULL, DYNAMIC_TYPE_TMP_BUFFER) |
| 90 | +#undef OPENSSL_free |
| 91 | +#define OPENSSL_free(ptr) XFREE((ptr), NULL, DYNAMIC_TYPE_TMP_BUFFER) |
| 92 | +#undef OPENSSL_realloc |
| 93 | +#define OPENSSL_realloc(ptr, num) XREALLOC((ptr), (num), NULL, DYNAMIC_TYPE_TMP_BUFFER) |
| 94 | + |
| 95 | +#if OPENSSL_VERSION_NUMBER >= 0x10100000L |
| 96 | +void *we_zalloc(size_t num); |
| 97 | +void we_clear_free(void *str, size_t num); |
| 98 | +void *we_memdup(const void *data, size_t siz); |
| 99 | + |
| 100 | +#undef OPENSSL_zalloc |
| 101 | +#define OPENSSL_zalloc we_zalloc |
| 102 | +#undef OPENSSL_clear_free |
| 103 | +#define OPENSSL_clear_free we_clear_free |
| 104 | +#undef OPENSSL_memdup |
| 105 | +#define OPENSSL_memdup we_memdup |
| 106 | +#endif /* OPENSSL_VERSION_NUMBER >= 0x10100000L */ |
| 107 | +#endif /* WE_NO_OPENSSL_MALLOC */ |
| 108 | + |
84 | 109 | #if defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__) |
85 | 110 | /* Function is a printf style function. Pretend parameter is string literal. |
86 | 111 | * |
|
0 commit comments