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/sha1.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/sha1.c')
-rw-r--r-- | cipher/sha1.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/cipher/sha1.c b/cipher/sha1.c index 18b6daa1..53f75381 100644 --- a/cipher/sha1.c +++ b/cipher/sha1.c @@ -70,7 +70,7 @@ typedef struct } SHA1_CONTEXT; static unsigned int -transform (void *c, const unsigned char *data); +transform (void *c, const unsigned char *data, size_t nblks); static void @@ -122,7 +122,7 @@ sha1_init (void *context) * Transform NBLOCKS of each 64 bytes (16 32-bit words) at DATA. */ static unsigned int -_transform (void *ctx, const unsigned char *data) +transform_blk (void *ctx, const unsigned char *data) { SHA1_CONTEXT *hd = ctx; const u32 *idata = (const void *)data; @@ -239,17 +239,33 @@ _gcry_sha1_transform_amd64_ssse3 (void *state, const unsigned char *data); static unsigned int -transform (void *ctx, const unsigned char *data) +transform (void *ctx, const unsigned char *data, size_t nblks) { SHA1_CONTEXT *hd = ctx; + unsigned int burn; #ifdef USE_SSSE3 if (hd->use_ssse3) - return _gcry_sha1_transform_amd64_ssse3 (&hd->h0, data) - + 4 * sizeof(void*); + { + do + { + burn = _gcry_sha1_transform_amd64_ssse3 (&hd->h0, data); + data += 64; + } + while (--nblks); + + return burn + 4 * sizeof(void*); + } #endif - return _transform (hd, data); + do + { + burn = transform_blk (ctx, data); + data += 64; + } + while (--nblks); + + return burn; } @@ -306,7 +322,7 @@ sha1_final(void *context) /* append the 64 bit count */ buf_put_be32(hd->bctx.buf + 56, msb); buf_put_be32(hd->bctx.buf + 60, lsb); - burn = transform( hd, hd->bctx.buf ); + burn = transform( hd, hd->bctx.buf, 1 ); _gcry_burn_stack (burn); p = hd->bctx.buf; |