summaryrefslogtreecommitdiff
path: root/cipher/sha1.c
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2019-10-14 22:08:29 +0300
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2019-10-14 22:08:29 +0300
commitf9d8b5a0369cc94e125d36d9c8864d5cd2eaa1d2 (patch)
tree67a58ad7a8d040946964ac1753c00144ba4f9066 /cipher/sha1.c
parentff0f1782560eb45458d9a8dd97088dabeddb34e7 (diff)
downloadlibgcrypt-f9d8b5a0369cc94e125d36d9c8864d5cd2eaa1d2.tar.gz
hash-common: avoid integer division to reduce call overhead
* cipher/hash-common.h (gcry_md_block_ctx): Replace 'blocksize' with 'blocksize_shift'. * cipher/hash-common.c (_gcry_md_block_write): Use bit-level operations instead of division to get number of blocks. * cipher/gostr2411-94.c (gost3411_init): Initialize 'blocksize_shift' instead of 'blocksize'. * cipher/md2.c (md2_init): Ditto. * cipher/md4.c (md4_init): Ditto. * cipher/md5.c (md5_init): Ditto. * cipher/rmd160.c (rmd160_init): Ditto. * cipher/sha1.c (sha1_init): Ditto. * cipher/sha256.c (sha256_common_init): Ditto. * cipher/sha512.c (sha512_init_common): Ditto. * cipher/sm3.c (sm3_init): Ditto. * cipher/stribog.c (stribog_init_512): Ditto. * cipher/tiger.c (do_init): Ditto. * cipher/whirlpool.c (whirlpool_init): Ditto. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/sha1.c')
-rw-r--r--cipher/sha1.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/cipher/sha1.c b/cipher/sha1.c
index 23aceef3..d3ee982b 100644
--- a/cipher/sha1.c
+++ b/cipher/sha1.c
@@ -274,7 +274,7 @@ sha1_init (void *context, unsigned int flags)
hd->bctx.nblocks = 0;
hd->bctx.nblocks_high = 0;
hd->bctx.count = 0;
- hd->bctx.blocksize = 64;
+ hd->bctx.blocksize_shift = _gcry_ctz(64);
/* Order of feature checks is important here; last match will be
* selected. Keep slower implementations at the top and faster at