Implement memset_s() and use it instead of zero_bytes().

A new constant, SUDO_CONV_REPL_MAX, is defined by the plugin
API as the max conversation reply length.  This constant can be
used as a max value for memset_s() when clearing passwords
filled in by the conversation function.
This commit is contained in:
Todd C. Miller
2013-08-03 08:30:06 -06:00
parent 8c867be419
commit 1f3ea50afd
34 changed files with 371 additions and 233 deletions

View File

@@ -58,6 +58,7 @@
# include "compat/endian.h"
#endif
#include "missing.h"
#include "sha2.h"
/*
@@ -117,8 +118,6 @@
#define g(i) T[(6-i)&7]
#define h(i) T[(7-i)&7]
extern void zero_bytes(volatile void *, size_t);
void
SHA224Init(SHA2_CTX *ctx)
{
@@ -249,8 +248,8 @@ SHA256Transform(uint32_t state[8], const uint8_t data[SHA256_BLOCK_LENGTH])
state[6] += g(0);
state[7] += h(0);
/* Cleanup */
zero_bytes(T, sizeof(T));
zero_bytes(W, sizeof(W));
memset_s(T, sizeof(T), 0, sizeof(T));
memset_s(W, sizeof(W), 0, sizeof(W));
}
#undef S0
@@ -466,8 +465,8 @@ SHA512Transform(uint64_t state[8], const uint8_t data[SHA512_BLOCK_LENGTH])
state[6] += g(0);
state[7] += h(0);
/* Cleanup. */
zero_bytes(T, sizeof(T));
zero_bytes(W, sizeof(W));
memset_s(T, sizeof(T), 0, sizeof(T));
memset_s(W, sizeof(W), 0, sizeof(W));
}
void