summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cipher/ChangeLog37
-rw-r--r--cipher/arcfour.c20
-rw-r--r--cipher/blowfish.c20
-rw-r--r--cipher/cast5.c20
-rw-r--r--cipher/cipher.c2
-rw-r--r--cipher/des.c36
-rw-r--r--cipher/md.c3
-rw-r--r--cipher/md4.c19
-rw-r--r--cipher/md5.c20
-rw-r--r--cipher/random.c15
-rw-r--r--cipher/rijndael.c21
-rw-r--r--cipher/rmd160.c20
-rw-r--r--cipher/sha1.c20
-rw-r--r--cipher/sha256.c18
-rw-r--r--cipher/tiger.c20
-rw-r--r--cipher/twofish.c19
16 files changed, 94 insertions, 216 deletions
diff --git a/cipher/ChangeLog b/cipher/ChangeLog
index 6f7dfa70..95149bbc 100644
--- a/cipher/ChangeLog
+++ b/cipher/ChangeLog
@@ -1,3 +1,40 @@
+2003-02-23 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c: Remove (bogus) `digitp' macro definition.
+ * md.c: Likewise.
+
+ * blowfish.c (burn_stack): Removed.
+ * arcfour.c (burn_stack): Likewise.
+ * cast5.c (burn_stack): Likewise.
+ * des.c (burn_stack): Likewise.
+ * md4.c (burn_stack): Likewise.
+ * md5.c (burn_stack): Likewise.
+ * random.c (burn_stack): Likewise.
+ * rijndael.c (burn_stack): Likewise.
+ * rmd160.c (burn_stack): Likewise.
+ * sha1.c (burn_stack): Likewise.
+ * sha256.c (burn_stack): Likewise.
+ * tiger.c (burn_stack): Likewise.
+ * twofish.c (burn_stack): Likewise.
+
+ * blowfish.c: Changed all occurences of burn_stack to
+ _gcry_burn_stack.
+ * arcfour.c: Likewise.
+ * cast5.c: Likewise.
+ * des.c: Likewise.
+ * md4.c: Likewise.
+ * md5.c: Likewise.
+ * random.c: Likewise.
+ * rijndael.c: Likewise.
+ * rmd160.c: Likewise.
+ * sha1.c: Likewise.
+ * sha256.c: Likewise.
+ * tiger.c: Likewise.
+ * twofish.c: Likewise.
+
+ * arcfour.c (_gcry_arcfour_get_info): Use GCRY_CIPHER_ARCFOUR
+ instead of hard-coded value `301'.
+
2003-01-24 Werner Koch <wk@gnupg.org>
* random.c (_gcry_register_random_progress): New.
diff --git a/cipher/arcfour.c b/cipher/arcfour.c
index 66017b08..702d0a75 100644
--- a/cipher/arcfour.c
+++ b/cipher/arcfour.c
@@ -1,5 +1,5 @@
/* arcfour.c - The arcfour stream cipher
- * Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+ * Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
*
* This file is part of Libgcrypt.
*
@@ -41,18 +41,6 @@ typedef struct {
static void
-burn_stack (int bytes)
-{
- char buf[64];
-
- memset (buf, 0, sizeof buf);
- bytes -= sizeof buf;
- if (bytes > 0)
- burn_stack (bytes);
-}
-
-
-static void
do_encrypt_stream( ARCFOUR_context *ctx,
byte *outbuf, const byte *inbuf, unsigned int length )
{
@@ -81,7 +69,7 @@ encrypt_stream( ARCFOUR_context *ctx,
{
do_encrypt_stream (ctx, outbuf, inbuf, length );
- burn_stack (64);
+ _gcry_burn_stack (64);
}
@@ -126,7 +114,7 @@ static int
arcfour_setkey ( ARCFOUR_context *ctx, const byte *key, unsigned int keylen )
{
int rc = do_arcfour_setkey (ctx, key, keylen );
- burn_stack (300);
+ _gcry_burn_stack (300);
return rc;
}
@@ -188,7 +176,7 @@ _gcry_arcfour_get_info( int algo, size_t *keylen, size_t *blocksize,
= encrypt_stream;
- if( algo == 301 )
+ if( algo == GCRY_CIPHER_ARCFOUR )
return "ARCFOUR";
return NULL;
}
diff --git a/cipher/blowfish.c b/cipher/blowfish.c
index af4f4978..a911c5b3 100644
--- a/cipher/blowfish.c
+++ b/cipher/blowfish.c
@@ -1,5 +1,5 @@
/* blowfish.c - Blowfish encryption
- * Copyright (C) 1998, 2001, 2002 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
*
* This file is part of Libgcrypt.
*
@@ -282,18 +282,6 @@ function_F( BLOWFISH_context *bc, u32 x )
#define R(l,r,i) do { l ^= p[i]; r ^= F(l); } while(0)
static void
-burn_stack (int bytes)
-{
- char buf[64];
-
- memset (buf, 0, sizeof buf);
- bytes -= sizeof buf;
- if (bytes > 0)
- burn_stack (bytes);
-}
-
-
-static void
do_encrypt( BLOWFISH_context *bc, u32 *ret_xl, u32 *ret_xr )
{
#if BLOWFISH_ROUNDS == 16
@@ -448,7 +436,7 @@ static void
encrypt_block ( BLOWFISH_context *bc, byte *outbuf, byte *inbuf )
{
do_encrypt_block (bc, outbuf, inbuf);
- burn_stack (64);
+ _gcry_burn_stack (64);
}
@@ -474,7 +462,7 @@ static void
decrypt_block( BLOWFISH_context *bc, byte *outbuf, byte *inbuf )
{
do_decrypt_block (bc, outbuf, inbuf);
- burn_stack (64);
+ _gcry_burn_stack (64);
}
@@ -596,7 +584,7 @@ static int
bf_setkey( BLOWFISH_context *c, byte *key, unsigned keylen )
{
int rc = do_bf_setkey (c, key, keylen);
- burn_stack (64);
+ _gcry_burn_stack (64);
return rc;
}
diff --git a/cipher/cast5.c b/cipher/cast5.c
index fbed819e..e3788541 100644
--- a/cipher/cast5.c
+++ b/cipher/cast5.c
@@ -1,5 +1,5 @@
/* cast5.c - CAST5 cipher (RFC2144)
- * Copyright (C) 1998, 2001, 2002 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
*
* This file is part of Libgcrypt.
*
@@ -358,18 +358,6 @@ rol(int n, u32 x)
(((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff]) )
static void
-burn_stack (int bytes)
-{
- char buf[64];
-
- memset (buf, 0, sizeof buf);
- bytes -= sizeof buf;
- if (bytes > 0)
- burn_stack (bytes);
-}
-
-
-static void
do_encrypt_block( CAST5_context *c, byte *outbuf, byte *inbuf )
{
u32 l, r, t;
@@ -427,7 +415,7 @@ static void
encrypt_block( CAST5_context *c, byte *outbuf, byte *inbuf )
{
do_encrypt_block (c, outbuf, inbuf);
- burn_stack (20+4*sizeof(void*));
+ _gcry_burn_stack (20+4*sizeof(void*));
}
@@ -477,7 +465,7 @@ static void
decrypt_block( CAST5_context *c, byte *outbuf, byte *inbuf )
{
do_decrypt_block (c, outbuf, inbuf);
- burn_stack (20+4*sizeof(void*));
+ _gcry_burn_stack (20+4*sizeof(void*));
}
@@ -624,7 +612,7 @@ static int
cast_setkey( CAST5_context *c, byte *key, unsigned keylen )
{
int rc = do_cast_setkey (c, key, keylen);
- burn_stack (96+7*sizeof(void*));
+ _gcry_burn_stack (96+7*sizeof(void*));
return rc;
}
diff --git a/cipher/cipher.c b/cipher/cipher.c
index 3aff308f..4a1b5158 100644
--- a/cipher/cipher.c
+++ b/cipher/cipher.c
@@ -38,8 +38,6 @@
#define CTX_MAGIC_NORMAL 0x24091964
#define CTX_MAGIC_SECURE 0x46919042
-#define digitp(p) (*(p) >= 0 && *(p) <= '9')
-
static struct {
const char *oidstring;
int algo;
diff --git a/cipher/des.c b/cipher/des.c
index bb196f4a..7ec86443 100644
--- a/cipher/des.c
+++ b/cipher/des.c
@@ -1,5 +1,5 @@
/* des.c - DES and Triple-DES encryption/decryption Algorithm
- * Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
*
* This file is part of Libgcrypt.
*
@@ -135,18 +135,6 @@ working_memcmp( const char *a, const char *b, size_t n )
}
#endif
-static void
-burn_stack (int bytes)
-{
- char buf[64];
-
- memset (buf, 0, sizeof buf);
- bytes -= sizeof buf;
- if (bytes > 0)
- burn_stack (bytes);
-}
-
-
/* Some defines/checks to support standalone modules */
@@ -610,7 +598,7 @@ des_setkey (struct _des_ctx *ctx, const byte * key)
return GCRYERR_SELFTEST;
des_key_schedule (key, ctx->encrypt_subkeys);
- burn_stack (32);
+ _gcry_burn_stack (32);
for(i=0; i<32; i+=2)
{
@@ -669,7 +657,7 @@ tripledes_set2keys (struct _tripledes_ctx *ctx,
des_key_schedule (key1, ctx->encrypt_subkeys);
des_key_schedule (key2, &(ctx->decrypt_subkeys[32]));
- burn_stack (32);
+ _gcry_burn_stack (32);
for(i=0; i<32; i+=2)
{
@@ -707,7 +695,7 @@ tripledes_set3keys (struct _tripledes_ctx *ctx,
des_key_schedule (key1, ctx->encrypt_subkeys);
des_key_schedule (key2, &(ctx->decrypt_subkeys[32]));
des_key_schedule (key3, &(ctx->encrypt_subkeys[64]));
- burn_stack (32);
+ _gcry_burn_stack (32);
for(i=0; i<32; i+=2)
{
@@ -1016,10 +1004,10 @@ do_tripledes_setkey ( struct _tripledes_ctx *ctx, byte *key, unsigned keylen )
tripledes_set3keys ( ctx, key, key+8, key+16);
if( is_weak_key( key ) || is_weak_key( key+8 ) || is_weak_key( key+16 ) ) {
- burn_stack (64);
+ _gcry_burn_stack (64);
return GCRYERR_WEAK_KEY;
}
- burn_stack (64);
+ _gcry_burn_stack (64);
return 0;
}
@@ -1029,14 +1017,14 @@ static void
do_tripledes_encrypt( struct _tripledes_ctx *ctx, byte *outbuf, byte *inbuf )
{
tripledes_ecb_encrypt ( ctx, inbuf, outbuf );
- burn_stack (32);
+ _gcry_burn_stack (32);
}
static void
do_tripledes_decrypt( struct _tripledes_ctx *ctx, byte *outbuf, byte *inbuf )
{
tripledes_ecb_decrypt ( ctx, inbuf, outbuf );
- burn_stack (32);
+ _gcry_burn_stack (32);
}
@@ -1053,10 +1041,10 @@ do_des_setkey ( struct _des_ctx *ctx, byte *key, unsigned keylen )
des_setkey (ctx, key);
if( is_weak_key( key ) ) {
- burn_stack (64);
+ _gcry_burn_stack (64);
return GCRYERR_WEAK_KEY;
}
- burn_stack (64);
+ _gcry_burn_stack (64);
return 0;
}
@@ -1066,14 +1054,14 @@ static void
do_des_encrypt( struct _des_ctx *ctx, byte *outbuf, byte *inbuf )
{
des_ecb_encrypt ( ctx, inbuf, outbuf );
- burn_stack (32);
+ _gcry_burn_stack (32);
}
static void
do_des_decrypt( struct _des_ctx *ctx, byte *outbuf, byte *inbuf )
{
des_ecb_decrypt ( ctx, inbuf, outbuf );
- burn_stack (32);
+ _gcry_burn_stack (32);
}
diff --git a/cipher/md.c b/cipher/md.c
index e80cb7c5..40bf6e64 100644
--- a/cipher/md.c
+++ b/cipher/md.c
@@ -114,9 +114,6 @@ struct md_digest_list_s {
static struct md_digest_list_s *digest_list;
-#define digitp(p) (*(p) >= 0 && *(p) <= '9')
-
-
static struct md_digest_list_s *
diff --git a/cipher/md4.c b/cipher/md4.c
index d649f68e..7bb31a8e 100644
--- a/cipher/md4.c
+++ b/cipher/md4.c
@@ -1,5 +1,5 @@
/* md4.c - MD4 Message-Digest Algorithm
- * Copyright (C) 2002 Free Software Foundation, Inc.
+ * Copyright (C) 2002, 2003 Free Software Foundation, Inc.
*
* This file is part of Libgcrypt.
*
@@ -79,17 +79,6 @@ md4_init( MD4_CONTEXT *ctx )
ctx->count = 0;
}
-static void
-burn_stack (int bytes)
-{
- char buf[128];
-
- memset (buf, 0, sizeof buf);
- bytes -= sizeof buf;
- if (bytes > 0)
- burn_stack (bytes);
-}
-
#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
@@ -203,7 +192,7 @@ md4_write( MD4_CONTEXT *hd, byte *inbuf, size_t inlen)
{
if( hd->count == 64 ) { /* flush the buffer */
transform( hd, hd->buf );
- burn_stack (80+6*sizeof(void*));
+ _gcry_burn_stack (80+6*sizeof(void*));
hd->count = 0;
hd->nblocks++;
}
@@ -216,7 +205,7 @@ md4_write( MD4_CONTEXT *hd, byte *inbuf, size_t inlen)
if( !inlen )
return;
}
- burn_stack (80+6*sizeof(void*));
+ _gcry_burn_stack (80+6*sizeof(void*));
while( inlen >= 64 ) {
transform( hd, inbuf );
@@ -282,7 +271,7 @@ md4_final( MD4_CONTEXT *hd )
hd->buf[62] = msb >> 16;
hd->buf[63] = msb >> 24;
transform( hd, hd->buf );
- burn_stack (80+6*sizeof(void*));
+ _gcry_burn_stack (80+6*sizeof(void*));
p = hd->buf;
#ifdef BIG_ENDIAN_HOST
diff --git a/cipher/md5.c b/cipher/md5.c
index f03a301d..9d2f7c88 100644
--- a/cipher/md5.c
+++ b/cipher/md5.c
@@ -1,5 +1,5 @@
/* md5.c - MD5 Message-Digest Algorithm
- * Copyright (C) 1995,1996,1998,1999,2001,2002 Free Software Foundation, Inc.
+ * Copyright (C) 1995,1996,1998,1999,2001,2002,2003 Free Software Foundation, Inc.
*
* This file is part of Libgcrypt.
*
@@ -62,18 +62,6 @@ md5_init( MD5_CONTEXT *ctx )
ctx->count = 0;
}
-static void
-burn_stack (int bytes)
-{
- char buf[128];
-
- memset (buf, 0, sizeof buf);
- bytes -= sizeof buf;
- if (bytes > 0)
- burn_stack (bytes);
-}
-
-
/* These are the four functions used in the four steps of the MD5 algorithm
and defined in the RFC 1321. The first function is a little bit optimized
@@ -229,7 +217,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*));
+ _gcry_burn_stack (80+6*sizeof(void*));
hd->count = 0;
hd->nblocks++;
}
@@ -242,7 +230,7 @@ md5_write( MD5_CONTEXT *hd, byte *inbuf, size_t inlen)
if( !inlen )
return;
}
- burn_stack (80+6*sizeof(void*));
+ _gcry_burn_stack (80+6*sizeof(void*));
while( inlen >= 64 ) {
transform( hd, inbuf );
@@ -308,7 +296,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*));
+ _gcry_burn_stack (80+6*sizeof(void*));
p = hd->buf;
#ifdef BIG_ENDIAN_HOST
diff --git a/cipher/random.c b/cipher/random.c
index f7b23787..60445fba 100644
--- a/cipher/random.c
+++ b/cipher/random.c
@@ -188,19 +188,6 @@ _gcry_random_initialize ()
initialize ();
}
-
-static void
-burn_stack (int bytes)
-{
- char buf[128];
-
- memset (buf, 0, sizeof buf);
- bytes -= sizeof buf;
- if (bytes > 0)
- burn_stack (bytes);
-}
-
-
void
_gcry_random_dump_stats()
{
@@ -461,7 +448,7 @@ mix_pool(byte *pool)
_gcry_rmd160_hash_buffer (failsafe_digest, pool, POOLSIZE);
failsafe_digest_valid = 1;
}
- burn_stack (384); /* for the rmd160_mixblock(), rmd160_hash_buffer */
+ _gcry_burn_stack (384); /* for the rmd160_mixblock(), rmd160_hash_buffer */
}
void
diff --git a/cipher/rijndael.c b/cipher/rijndael.c
index f4b1fdd9..b7c7d18b 100644
--- a/cipher/rijndael.c
+++ b/cipher/rijndael.c
@@ -1,5 +1,5 @@
/* Rijndael (AES) for GnuPG
- * Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+ * Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
*
* This file is part of Libgcrypt.
*
@@ -1707,17 +1707,6 @@ static const u32 rcon[30] = {
-static void
-burn_stack (int bytes)
-{
- char buf[64];
-
- memset (buf, 0, sizeof buf);
- bytes -= sizeof buf;
- if (bytes > 0)
- burn_stack (bytes);
-}
-
/* Perform the key setup.
*/
@@ -1825,7 +1814,7 @@ static int
rijndael_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
{
int rc = do_setkey (ctx, key, keylen);
- burn_stack ( 100 + 16*sizeof(int));
+ _gcry_burn_stack ( 100 + 16*sizeof(int));
return rc;
}
@@ -1950,7 +1939,7 @@ static void
rijndael_encrypt (const RIJNDAEL_context *ctx, byte *b, const byte *a)
{
do_encrypt (ctx, b, a);
- burn_stack (16 + 2*sizeof(int));
+ _gcry_burn_stack (16 + 2*sizeof(int));
}
@@ -1966,7 +1955,7 @@ do_decrypt (RIJNDAEL_context *ctx, byte *b, const byte *a)
if ( !ctx->decryption_prepared ) {
prepare_decryption ( ctx );
- burn_stack (64);
+ _gcry_burn_stack (64);
ctx->decryption_prepared = 1;
}
@@ -2045,7 +2034,7 @@ static void
rijndael_decrypt (RIJNDAEL_context *ctx, byte *b, const byte *a)
{
do_decrypt (ctx, b, a);
- burn_stack (16+2*sizeof(int));
+ _gcry_burn_stack (16+2*sizeof(int));
}
/* Test a single encryption and decryption with each key size. */
diff --git a/cipher/rmd160.c b/cipher/rmd160.c
index 3680f0ad..4cf52c51 100644
--- a/cipher/rmd160.c
+++ b/cipher/rmd160.c
@@ -1,5 +1,5 @@
/* rmd160.c - RIPE-MD160
- * Copyright (C) 1998, 2001, 2002 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
*
* This file is part of Libgcrypt.
*
@@ -141,18 +141,6 @@
* 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 )
@@ -414,7 +402,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*));
+ _gcry_burn_stack (108+5*sizeof(void*));
hd->count = 0;
hd->nblocks++;
}
@@ -435,7 +423,7 @@ rmd160_write( RMD160_CONTEXT *hd, byte *inbuf, size_t inlen)
inlen -= 64;
inbuf += 64;
}
- burn_stack (108+5*sizeof(void*));
+ _gcry_burn_stack (108+5*sizeof(void*));
for( ; inlen && hd->count < 64; inlen-- )
hd->buf[hd->count++] = *inbuf++;
}
@@ -508,7 +496,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*));
+ _gcry_burn_stack (108+5*sizeof(void*));
p = hd->buf;
#ifdef BIG_ENDIAN_HOST
diff --git a/cipher/sha1.c b/cipher/sha1.c
index b1caf218..a6339b38 100644
--- a/cipher/sha1.c
+++ b/cipher/sha1.c
@@ -1,5 +1,5 @@
/* sha1.c - SHA1 hash function
- * Copyright (C) 1998, 2001, 2002 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
*
* This file is part of Libgcrypt.
*
@@ -49,18 +49,6 @@ typedef struct {
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
sha1_init( SHA1_CONTEXT *hd )
{
hd->h0 = 0x67452301;
@@ -222,7 +210,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*));
+ _gcry_burn_stack (88+4*sizeof(void*));
hd->count = 0;
hd->nblocks++;
}
@@ -243,7 +231,7 @@ sha1_write( SHA1_CONTEXT *hd, byte *inbuf, size_t inlen)
inlen -= 64;
inbuf += 64;
}
- burn_stack (88+4*sizeof(void*));
+ _gcry_burn_stack (88+4*sizeof(void*));
for( ; inlen && hd->count < 64; inlen-- )
hd->buf[hd->count++] = *inbuf++;
}
@@ -300,7 +288,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*));
+ _gcry_burn_stack (88+4*sizeof(void*));
p = hd->buf;
#ifdef BIG_ENDIAN_HOST
diff --git a/cipher/sha256.c b/cipher/sha256.c
index 9eb2bbe2..1aafd334 100644
--- a/cipher/sha256.c
+++ b/cipher/sha256.c
@@ -53,18 +53,6 @@ typedef struct {
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
sha256_init (SHA256_CONTEXT *hd)
{
hd->h0 = 0x6a09e667;
@@ -190,7 +178,7 @@ sha256_write (SHA256_CONTEXT *hd, byte *inbuf, size_t inlen)
if (hd->count == 64)
{ /* flush the buffer */
transform (hd, hd->buf);
- burn_stack (74*4+32);
+ _gcry_burn_stack (74*4+32);
hd->count = 0;
hd->nblocks++;
}
@@ -213,7 +201,7 @@ sha256_write (SHA256_CONTEXT *hd, byte *inbuf, size_t inlen)
inlen -= 64;
inbuf += 64;
}
- burn_stack (74*4+32);
+ _gcry_burn_stack (74*4+32);
for (; inlen && hd->count < 64; inlen--)
hd->buf[hd->count++] = *inbuf++;
}
@@ -270,7 +258,7 @@ sha256_final(SHA256_CONTEXT *hd)
hd->buf[62] = lsb >> 8;
hd->buf[63] = lsb;
transform (hd, hd->buf);
- burn_stack (74*4+32);
+ _gcry_burn_stack (74*4+32);
p = hd->buf;
#ifdef BIG_ENDIAN_HOST
diff --git a/cipher/tiger.c b/cipher/tiger.c
index 7ee60bd7..432948b8 100644
--- a/cipher/tiger.c
+++ b/cipher/tiger.c
@@ -1,5 +1,5 @@
/* tiger.c - The TIGER hash function
- * Copyright (C) 1998, 2001, 2002 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
*
* This file is part of Libgcrypt.
*
@@ -589,18 +589,6 @@ static u64 sbox4[256] = {
};
-static void
-burn_stack (int bytes)
-{
- char buf[256];
-
- memset (buf, 0, sizeof buf);
- bytes -= sizeof buf;
- if (bytes > 0)
- burn_stack (bytes);
-}
-
-
static void
tiger_init( TIGER_CONTEXT *hd )
@@ -734,7 +722,7 @@ tiger_write( TIGER_CONTEXT *hd, byte *inbuf, size_t inlen)
{
if( hd->count == 64 ) { /* flush the buffer */
transform( hd, hd->buf );
- burn_stack (21*8+11*sizeof(void*));
+ _gcry_burn_stack (21*8+11*sizeof(void*));
hd->count = 0;
hd->nblocks++;
}
@@ -755,7 +743,7 @@ tiger_write( TIGER_CONTEXT *hd, byte *inbuf, size_t inlen)
inlen -= 64;
inbuf += 64;
}
- burn_stack (21*8+11*sizeof(void*));
+ _gcry_burn_stack (21*8+11*sizeof(void*));
for( ; inlen && hd->count < 64; inlen-- )
hd->buf[hd->count++] = *inbuf++;
}
@@ -809,7 +797,7 @@ tiger_final( TIGER_CONTEXT *hd )
hd->buf[62] = msb >> 16;
hd->buf[63] = msb >> 24;
transform( hd, hd->buf );
- burn_stack (21*8+11*sizeof(void*));
+ _gcry_burn_stack (21*8+11*sizeof(void*));
p = hd->buf;
#ifdef BIG_ENDIAN_HOST
diff --git a/cipher/twofish.c b/cipher/twofish.c
index 4898b4ba..8fb5f4b4 100644
--- a/cipher/twofish.c
+++ b/cipher/twofish.c
@@ -1,5 +1,5 @@
/* Twofish for GPG
- * Copyright (C) 1998, 2002 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 2002, 2003 Free Software Foundation, Inc.
* Written by Matthew Skala <mskala@ansuz.sooke.bc.ca>, July 26, 1998
* 256-bit key length added March 20, 1999
* Some modifications to reduce the text size by Werner Koch, April, 1998
@@ -560,17 +560,6 @@ static byte calc_sb_tbl[512] = {
ctx->a[(j) + 1] = (y << 9) + (y >> 23)
-static void
-burn_stack (int bytes)
-{
- char buf[64];
-
- memset (buf, 0, sizeof buf);
- bytes -= sizeof buf;
- if (bytes > 0)
- burn_stack (bytes);
-}
-
/* Perform the key setup. Note that this works only with 128- and 256-bit
* keys, despite the API that looks like it might support other sizes. */
@@ -714,7 +703,7 @@ static int
twofish_setkey (TWOFISH_context *ctx, const byte *key, unsigned int keylen)
{
int rc = do_twofish_setkey (ctx, key, keylen);
- burn_stack (23+6*sizeof(void*));
+ _gcry_burn_stack (23+6*sizeof(void*));
return rc;
}
@@ -816,7 +805,7 @@ static void
twofish_encrypt (const TWOFISH_context *ctx, byte *out, const byte *in)
{
do_twofish_encrypt (ctx, out, in);
- burn_stack (24+3*sizeof (void*));
+ _gcry_burn_stack (24+3*sizeof (void*));
}
@@ -858,7 +847,7 @@ static void
twofish_decrypt (const TWOFISH_context *ctx, byte *out, const byte *in)
{
do_twofish_decrypt (ctx, out, in);
- burn_stack (24+3*sizeof (void*));
+ _gcry_burn_stack (24+3*sizeof (void*));
}