[libfko] apply zero_buf() to stack allocated Rijndael context for encrypt/decrypt
authorMichael Rash <mbr@cipherdyne.org>
Sat, 13 Jul 2013 03:21:38 +0000 (23:21 -0400)
committerMichael Rash <mbr@cipherdyne.org>
Sat, 13 Jul 2013 03:21:38 +0000 (23:21 -0400)
lib/cipher_funcs.c

index 911e1c6..ca538ae 100644 (file)
@@ -262,6 +262,10 @@ rij_encrypt(unsigned char *in, size_t in_len,
 
     ondx += in_len+pad_val;
 
+    zero_buf((char *)ctx.key, RIJNDAEL_MAX_KEYSIZE);
+    zero_buf((char *)ctx.iv, RIJNDAEL_BLOCKSIZE);
+    zero_buf((char *)ctx.salt, SALT_LEN);
+
     return(ondx - out);
 }
 
@@ -312,6 +316,10 @@ rij_decrypt(unsigned char *in, size_t in_len,
 
     *ondx = '\0';
 
+    zero_buf((char *)ctx.key, RIJNDAEL_MAX_KEYSIZE);
+    zero_buf((char *)ctx.iv, RIJNDAEL_BLOCKSIZE);
+    zero_buf((char *)ctx.salt, SALT_LEN);
+
     return(ondx - out);
 }