summaryrefslogtreecommitdiff
path: root/cipher/stribog.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/stribog.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/stribog.c')
-rw-r--r--cipher/stribog.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/cipher/stribog.c b/cipher/stribog.c
index a3cab362..6d1d3422 100644
--- a/cipher/stribog.c
+++ b/cipher/stribog.c
@@ -1194,7 +1194,7 @@ static inline void g (u64 *h, u64 *m, u64 *N)
static unsigned int
-transform64 (void *context, const unsigned char *inbuf_arg);
+transform (void *context, const unsigned char *inbuf_arg, size_t datalen);
static void
@@ -1205,7 +1205,7 @@ stribog_init_512 (void *context)
memset (hd, 0, sizeof (*hd));
hd->bctx.blocksize = 64;
- hd->bctx.bwrite = transform64;
+ hd->bctx.bwrite = transform;
}
static void
@@ -1217,7 +1217,7 @@ stribog_init_256 (void *context)
}
static void
-transform (STRIBOG_CONTEXT *hd, const unsigned char *data, unsigned count)
+transform_bits (STRIBOG_CONTEXT *hd, const unsigned char *data, unsigned count)
{
u64 M[8];
u64 l;
@@ -1248,15 +1248,30 @@ transform (STRIBOG_CONTEXT *hd, const unsigned char *data, unsigned count)
}
static unsigned int
-transform64 (void *context, const unsigned char *inbuf_arg)
+transform_blk (void *context, const unsigned char *inbuf_arg)
{
STRIBOG_CONTEXT *hd = context;
- transform (hd, inbuf_arg, 64 * 8);
+ transform_bits (hd, inbuf_arg, 64 * 8);
return /* burn_stack */ 768;
}
+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 finally terminates the computation and returns the
digest. The handle is prepared for a new cycle, but adding bytes
@@ -1276,7 +1291,7 @@ stribog_final (void *context)
hd->bctx.buf[i++] = 1;
while (i < 64)
hd->bctx.buf[i++] = 0;
- transform (hd, hd->bctx.buf, hd->bctx.count * 8);
+ transform_bits (hd, hd->bctx.buf, hd->bctx.count * 8);
g (hd->h, hd->N, Z);
g (hd->h, hd->Sigma, Z);