use memset_s

lib roken includes support for memset_s() but it was not applied
to the Heimdal source tree.

Change-Id: I8362ec97a9be50205bb2d398e65b629b88ce1acd
This commit is contained in:
Jeffrey Altman
2017-04-28 11:11:07 -04:00
parent 85acd57c8a
commit 93518bfab4
21 changed files with 80 additions and 76 deletions

View File

@@ -159,7 +159,7 @@ md_result(MD_CTX * ctx, unsigned char *dst)
memcpy(&tmp, ctx, sizeof(*ctx));
SHA256_Final(dst, &tmp);
memset(&tmp, 0, sizeof(tmp));
memset_s(&tmp, sizeof(tmp), 0, sizeof(tmp));
}
/*
@@ -234,7 +234,7 @@ enough_time_passed(FState * st)
if (ok)
memcpy(last, &tv, sizeof(tv));
memset(&tv, 0, sizeof(tv));
memset_s(&tv, sizeof(tv), 0, sizeof(tv));
return ok;
}
@@ -284,8 +284,8 @@ reseed(FState * st)
/* use new key */
ciph_init(&st->ciph, st->key, BLOCK);
memset(&key_md, 0, sizeof(key_md));
memset(buf, 0, BLOCK);
memset_s(&key_md, sizeof(key_md), 0, sizeof(key_md));
memset_s(buf, sizeof(buf), 0, sizeof(buf));
}
/*
@@ -335,8 +335,8 @@ add_entropy(FState * st, const unsigned char *data, unsigned len)
if (pos == 0)
st->pool0_bytes += len;
memset(hash, 0, BLOCK);
memset(&md, 0, sizeof(md));
memset_s(hash, sizeof(hash), 0, sizeof(hash));
memset_s(&md, sizeof(hash), 0, sizeof(md));
}
/*
@@ -372,7 +372,7 @@ startup_tricks(FState * st)
encrypt_counter(st, buf + CIPH_BLOCK);
md_update(&st->pool[i], buf, BLOCK);
}
memset(buf, 0, BLOCK);
memset_s(buf, sizeof(buf), 0, sizeof(buf));
/* Hide the key. */
rekey(st);
@@ -468,7 +468,7 @@ fortuna_reseed(void)
if ((*hc_rand_unix_method.bytes)(buf, sizeof(buf)) == 1) {
add_entropy(&main_state, buf, sizeof(buf));
entropy_p = 1;
memset(buf, 0, sizeof(buf));
memset_s(buf, sizeof(buf), 0, sizeof(buf));
}
}
#endif
@@ -509,7 +509,7 @@ fortuna_reseed(void)
close(fd);
}
memset(&u, 0, sizeof(u));
memset_s(&u, sizeof(u), 0, sizeof(u));
entropy_p = 1; /* sure about this ? */
}
@@ -593,7 +593,7 @@ fortuna_cleanup(void)
init_done = 0;
have_entropy = 0;
memset(&main_state, 0, sizeof(main_state));
memset_s(&main_state, sizeof(main_state), 0, sizeof(main_state));
HEIMDAL_MUTEX_unlock(&fortuna_mutex);
}