lib: use secure zero memory platform functions

This commit is contained in:
Dave Pate
2019-01-07 14:37:30 -08:00
committed by Klas Lindfors
parent 2e72c8f85c
commit 28189201a4
2 changed files with 13 additions and 1 deletions
+12
View File
@@ -236,6 +236,18 @@ typedef enum _yc_log_level_t {
void yc_log_event(uint32_t id, yc_log_level_t level, const char *sz_format, ...); void yc_log_event(uint32_t id, yc_log_level_t level, const char *sz_format, ...);
#ifdef _WIN32
#include <windows.h>
#define yc_memzero SecureZeroMemory
#elif __OPENBSD__
#include <strings.h>
#define yc_memzero explicit_bzero;
#else
#define __STDC_WANT_LIB_EXT1__ 1
#include <string.h>
#define yc_memzero(_p, _n) (void)memset_s(_p, (rsize_t)_n, 0, (rsize_t)_n)
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
+1 -1
View File
@@ -1146,7 +1146,7 @@ ykpiv_rc ykpiv_util_get_protected_mgm(ykpiv_state *state, ykpiv_mgm *mgm) {
Cleanup: Cleanup:
memset(data, 0, sizeof(data)); yc_memzero(data, sizeof(data));
_ykpiv_end_transaction(state); _ykpiv_end_transaction(state);
return res; return res;