summaryrefslogtreecommitdiff
path: root/cipher/gostr3411-94.c
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2013-12-17 15:35:38 +0200
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2013-12-17 15:35:38 +0200
commit50b8c8342d023038a4b528af83153293dd2756ea (patch)
tree603423305ea81754f728c85814d0dc908e6e96d6 /cipher/gostr3411-94.c
parent210b7237706f6ad5cbc1a3362707f63db2c8a780 (diff)
downloadlibgcrypt-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/gostr3411-94.c')
-rw-r--r--cipher/gostr3411-94.c21
1 files changed, 19 insertions, 2 deletions
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