comparison dbhelpers.c @ 1283:3017bc7d6238

move m_burn and function attributes to dbhelpers use m_burn for libtomcrypt zeromem() too
author Matt Johnston <matt@ucc.asn.au>
date Thu, 17 Mar 2016 23:21:33 +0800
parents
children 4b1a807a3188
comparison
equal deleted inserted replaced
1282:a3bb15115816 1283:3017bc7d6238
1 #include "dbhelpers.h"
2 #include "includes.h"
3
4 /* Erase data */
5 void m_burn(void *data, unsigned int len) {
6
7 #if defined(HAVE_MEMSET_S)
8 memset_s(data, len, 0x0, len);
9 #elif defined(HAVE_EXPLICIT_BZERO)
10 explicit_bzero(data, len);
11 #else
12 /* Based on the method in David Wheeler's
13 * "Secure Programming for Linux and Unix HOWTO". May not be safe
14 * against link-time optimisation. */
15 volatile char *p = data;
16
17 if (data == NULL)
18 return;
19 while (len--) {
20 *p++ = 0x0;
21 }
22 #endif
23 }
24
25