aboutsummaryrefslogtreecommitdiffstats
path: root/cipher/md5.c
diff options
context:
space:
mode:
Diffstat (limited to 'cipher/md5.c')
-rw-r--r--cipher/md5.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/cipher/md5.c b/cipher/md5.c
index 9bba57641..cf8861d10 100644
--- a/cipher/md5.c
+++ b/cipher/md5.c
@@ -72,6 +72,18 @@ md5_init( MD5_CONTEXT *ctx )
#define FH(b, c, d) (b ^ c ^ d)
#define FI(b, c, d) (c ^ (b | ~d))
+static void
+burn_stack (int bytes)
+{
+ char buf[128];
+
+ memset (buf, 0, sizeof buf);
+ bytes -= sizeof buf;
+ if (bytes > 0)
+ burn_stack (bytes);
+}
+
+
/****************
* transform n*64 bytes
@@ -217,6 +229,7 @@ md5_write( MD5_CONTEXT *hd, byte *inbuf, size_t inlen)
{
if( hd->count == 64 ) { /* flush the buffer */
transform( hd, hd->buf );
+ burn_stack (80+6*sizeof(void*));
hd->count = 0;
hd->nblocks++;
}
@@ -237,9 +250,9 @@ md5_write( MD5_CONTEXT *hd, byte *inbuf, size_t inlen)
inlen -= 64;
inbuf += 64;
}
+ burn_stack (80+6*sizeof(void*));
for( ; inlen && hd->count < 64; inlen-- )
hd->buf[hd->count++] = *inbuf++;
-
}
@@ -294,6 +307,7 @@ md5_final( MD5_CONTEXT *hd )
hd->buf[62] = msb >> 16;
hd->buf[63] = msb >> 24;
transform( hd, hd->buf );
+ burn_stack (80+6*sizeof(void*));
p = hd->buf;
#ifdef BIG_ENDIAN_HOST