Erase memory that might contain sensitive info

This commit is contained in:
Chris Oei 2012-09-03 16:44:24 -07:00
parent 4e034e399b
commit 4ae843f18e

3
main.c
View file

@ -166,6 +166,7 @@ main(int argc, char *argv[])
char buf1[65]; char buf1[65];
bintohex(buf1, 32, passhash); bintohex(buf1, 32, passhash);
printf("Master hex: %s\n", buf1); printf("Master hex: %s\n", buf1);
memset(buf1, 0, 65);
uint8_t dk[64]; uint8_t dk[64];
rc = genpass(dk, (uint8_t *)passwd, passwdlen, (void*) *argv, rc = genpass(dk, (uint8_t *)passwd, passwdlen, (void*) *argv,
@ -179,6 +180,7 @@ main(int argc, char *argv[])
char buf[129]; char buf[129];
bintohex(buf, 64, dk); bintohex(buf, 64, dk);
printf("Pass hex: %s\n", buf); printf("Pass hex: %s\n", buf);
memset(buf, 0, 129);
if ((outputlength < 3)||(outputlength > 64)) { if ((outputlength < 3)||(outputlength > 64)) {
warn("Unable to generate password for output length %lu", outputlength); warn("Unable to generate password for output length %lu", outputlength);
@ -188,6 +190,7 @@ main(int argc, char *argv[])
char output[outputlength + 1]; char output[outputlength + 1];
hashtopass(output, outputlength, dk); hashtopass(output, outputlength, dk);
printf("Generated password: %s\n", output); printf("Generated password: %s\n", output);
memset(output, 0, outputlength + 1);
/* If we failed, print the right error message and exit. */ /* If we failed, print the right error message and exit. */
if (rc != 0) { if (rc != 0) {