summaryrefslogtreecommitdiff
path: root/cipher/rmd160.c
diff options
context:
space:
mode:
Diffstat (limited to 'cipher/rmd160.c')
-rw-r--r--cipher/rmd160.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/cipher/rmd160.c b/cipher/rmd160.c
index cce9d3c5..d3f00f2e 100644
--- a/cipher/rmd160.c
+++ b/cipher/rmd160.c
@@ -141,6 +141,18 @@
* 1 million times "a" 52783243c1697bdbe16d37f97f68f08325dc1528
*/
+static void
+burn_stack (int bytes)
+{
+ char buf[150];
+
+ memset (buf, 0, sizeof buf);
+ bytes -= sizeof buf;
+ if (bytes > 0)
+ burn_stack (bytes);
+}
+
+
void
_gcry_rmd160_init( RMD160_CONTEXT *hd )
@@ -405,6 +417,7 @@ rmd160_write( RMD160_CONTEXT *hd, byte *inbuf, size_t inlen)
{
if( hd->count == 64 ) { /* flush the buffer */
transform( hd, hd->buf );
+ burn_stack (108+5*sizeof(void*));
hd->count = 0;
hd->nblocks++;
}
@@ -425,6 +438,7 @@ rmd160_write( RMD160_CONTEXT *hd, byte *inbuf, size_t inlen)
inlen -= 64;
inbuf += 64;
}
+ burn_stack (108+5*sizeof(void*));
for( ; inlen && hd->count < 64; inlen-- )
hd->buf[hd->count++] = *inbuf++;
}
@@ -497,6 +511,7 @@ rmd160_final( RMD160_CONTEXT *hd )
hd->buf[62] = msb >> 16;
hd->buf[63] = msb >> 24;
transform( hd, hd->buf );
+ burn_stack (108+5*sizeof(void*));
p = hd->buf;
#ifdef BIG_ENDIAN_HOST