diff options
author | Werner Koch <wk@gnupg.org> | 2001-08-03 10:57:34 +0000 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2001-08-03 10:57:34 +0000 |
commit | 0c667cbdebcd34dfa556b6b8d786b0677f09f5a5 (patch) | |
tree | d31d08dfe51104bc4e26c6c69b87c8dd4b545047 /cipher/sha1.c | |
parent | 442e7215fb0b7455d31587bd6ad9ccb5d5a64dd7 (diff) | |
download | libgcrypt-0c667cbdebcd34dfa556b6b8d786b0677f09f5a5.tar.gz |
Applied changes from GnuPG stable.
Add a first tes program
Diffstat (limited to 'cipher/sha1.c')
-rw-r--r-- | cipher/sha1.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cipher/sha1.c b/cipher/sha1.c index 39583208..8f0cfc19 100644 --- a/cipher/sha1.c +++ b/cipher/sha1.c @@ -50,6 +50,16 @@ typedef struct { } SHA1_CONTEXT; +static void +burn_stack (int bytes) +{ + char buf[128]; + + memset (buf, 0, sizeof buf); + bytes -= sizeof buf; + if (bytes > 0) + burn_stack (bytes); +} static void @@ -214,6 +224,7 @@ sha1_write( SHA1_CONTEXT *hd, byte *inbuf, size_t inlen) { if( hd->count == 64 ) { /* flush the buffer */ transform( hd, hd->buf ); + burn_stack (88+4*sizeof(void*)); hd->count = 0; hd->nblocks++; } @@ -234,6 +245,7 @@ sha1_write( SHA1_CONTEXT *hd, byte *inbuf, size_t inlen) inlen -= 64; inbuf += 64; } + burn_stack (88+4*sizeof(void*)); for( ; inlen && hd->count < 64; inlen-- ) hd->buf[hd->count++] = *inbuf++; } @@ -290,6 +302,7 @@ sha1_final(SHA1_CONTEXT *hd) hd->buf[62] = lsb >> 8; hd->buf[63] = lsb ; transform( hd, hd->buf ); + burn_stack (88+4*sizeof(void*)); p = hd->buf; #ifdef BIG_ENDIAN_HOST |