From 50b8c8342d023038a4b528af83153293dd2756ea Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Tue, 17 Dec 2013 15:35:38 +0200 Subject: 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 --- cipher/gostr3411-94.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'cipher/gostr3411-94.c') diff --git a/cipher/gostr3411-94.c b/cipher/gostr3411-94.c index 12672165..b3326aa5 100644 --- a/cipher/gostr3411-94.c +++ b/cipher/gostr3411-94.c @@ -41,7 +41,7 @@ typedef struct { } GOSTR3411_CONTEXT; static unsigned int -transform (void *c, const unsigned char *data); +transform (void *c, const unsigned char *data, size_t nblks); static void gost3411_init (void *context) @@ -211,7 +211,7 @@ do_hash_step (GOST28147_context *hd, unsigned char *h, unsigned char *m) static unsigned int -transform (void *ctx, const unsigned char *data) +transform_blk (void *ctx, const unsigned char *data) { GOSTR3411_CONTEXT *hd = ctx; byte m[32]; @@ -224,6 +224,23 @@ transform (void *ctx, const unsigned char *data) return /* burn_stack */ burn + 3 * sizeof(void*) + 32 + 2 * sizeof(void*); } + +static unsigned int +transform ( void *c, const unsigned char *data, size_t nblks ) +{ + unsigned int burn; + + do + { + burn = transform_blk (c, data); + data += 32; + } + while (--nblks); + + return burn; +} + + /* The routine finally terminates the computation and returns the digest. The handle is prepared for a new cycle, but adding bytes -- cgit v1.2.1