diff options
author | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2013-12-17 15:35:38 +0200 |
---|---|---|
committer | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2013-12-17 15:35:38 +0200 |
commit | 50b8c8342d023038a4b528af83153293dd2756ea (patch) | |
tree | 603423305ea81754f728c85814d0dc908e6e96d6 /cipher/md4.c | |
parent | 210b7237706f6ad5cbc1a3362707f63db2c8a780 (diff) | |
download | libgcrypt-50b8c8342d023038a4b528af83153293dd2756ea.tar.gz |
Add bulk processing for hash transform functions
* cipher/hash-common.c (_gcry_md_block_write): Preload 'hd->blocksize'
to stack, pass number of blocks to 'hd->bwrite'.
* cipher/hash-common.c (_gcry_md_block_write_t): Add 'nblks'.
* cipher/gostr3411-94.c: Rename 'transform' function to
'transform_blk', add new 'transform' function with 'nblks' as
additional input.
* cipher/md4.c: Ditto.
* cipher/md5.c: Ditto.
* cipher/md4.c: Ditto.
* cipher/rmd160.c: Ditto.
* cipher/sha1.c: Ditto.
* cipher/sha256.c: Ditto.
* cipher/sha512.c: Ditto.
* cipher/stribog.c: Ditto.
* cipher/tiger.c: Ditto.
* cipher/whirlpool.c: Ditto.
--
Pass number of blocks to algorithm for futher optimizations.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/md4.c')
-rw-r--r-- | cipher/md4.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/cipher/md4.c b/cipher/md4.c index b9a1a95a..40dc0586 100644 --- a/cipher/md4.c +++ b/cipher/md4.c @@ -66,7 +66,7 @@ typedef struct { } MD4_CONTEXT; static unsigned int -transform ( void *c, const unsigned char *data ); +transform ( void *c, const unsigned char *data, size_t nblks ); static void md4_init( void *context ) @@ -94,7 +94,7 @@ md4_init( void *context ) * transform 64 bytes */ static unsigned int -transform ( void *c, const unsigned char *data ) +transform_blk ( void *c, const unsigned char *data ) { MD4_CONTEXT *ctx = c; u32 in[16]; @@ -181,6 +181,21 @@ transform ( void *c, const unsigned char *data ) } +static unsigned int +transform ( void *c, const unsigned char *data, size_t nblks ) +{ + unsigned int burn; + + do + { + burn = transform_blk (c, data); + data += 64; + } + while (--nblks); + + return burn; +} + /* The routine final terminates the message-digest computation and * ends with the desired message digest in mdContext->digest[0...15]. @@ -234,7 +249,7 @@ md4_final( void *context ) /* append the 64 bit count */ buf_put_le32(hd->bctx.buf + 56, lsb); buf_put_le32(hd->bctx.buf + 60, msb); - burn = transform( hd, hd->bctx.buf ); + burn = transform ( hd, hd->bctx.buf, 1 ); _gcry_burn_stack (burn); p = hd->bctx.buf; |