diff options
author | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2013-09-21 13:54:38 +0300 |
---|---|---|
committer | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2013-09-21 13:54:38 +0300 |
commit | 592c2ab3deeeccbb6d3b078ed7bf0e6627c8e1fb (patch) | |
tree | 067ff9ba60af04b9570da3f54c3ff6c992650a90 /cipher/rmd160.c | |
parent | 902ea6052c11108bd19333c31b03e084bed1fb86 (diff) | |
download | libgcrypt-592c2ab3deeeccbb6d3b078ed7bf0e6627c8e1fb.tar.gz |
Use hash transform function return type for passing burn stack depth
* cipher/gostr4311-94.c (transform): Return stack burn depth.
* cipher/hash-common.c (_gcry_md_block_write): Use stack burn depth
returned by 'hd->bwrite'.
* cipher/hash-common.h (_gcry_md_block_write_t): Change return type to
'unsigned int'.
(gry_md_block_ctx_t): Remove 'stack_burn'.
* cipher/md4.c (transform): Return stack burn depth.
(md4_final): Use stack burn depth from transform.
* cipher/md5.c (transform): Return stack burn depth.
(md5_final): Use stack burn depth from transform.
* cipher/rmd160.c (transform): Return stack burn depth.
(rmd160_final): Use stack burn depth from transform.
* cipher/sha1.c (transform): Return stack burn depth.
(sha1_final): Use stack burn depth from transform.
* cipher/sha256.c (transform): Return stack burn depth.
(sha256_final): Use stack burn depth from transform.
* cipher/sha512.c (__transform, transform): Return stack burn depth.
(sha512_final): Use stack burn depth from transform.
* cipher/stribog.c (transform64): Return stack burn depth.
* cipher/tiger.c (transform): Return stack burn depth.
(tiger_final): Use stack burn depth from transform.
--
Transform function might want different depth of stack burn depending on
detected CPU features (like in SHA-512 on ARM with NEON). So return
stack burn depth from transform functions as a request or a hint to
calling function.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/rmd160.c')
-rw-r--r-- | cipher/rmd160.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/cipher/rmd160.c b/cipher/rmd160.c index 5bb32a61..7f143dfa 100644 --- a/cipher/rmd160.c +++ b/cipher/rmd160.c @@ -139,7 +139,7 @@ * 1 million times "a" 52783243c1697bdbe16d37f97f68f08325dc1528 */ -static void +static unsigned int transform ( void *ctx, const unsigned char *data ); void @@ -152,10 +152,10 @@ _gcry_rmd160_init (void *context) hd->h2 = 0x98BADCFE; hd->h3 = 0x10325476; hd->h4 = 0xC3D2E1F0; + hd->bctx.nblocks = 0; hd->bctx.count = 0; hd->bctx.blocksize = 64; - hd->bctx.stack_burn = 108+5*sizeof(void*); hd->bctx.bwrite = transform; } @@ -164,7 +164,7 @@ _gcry_rmd160_init (void *context) /**************** * Transform the message X which consists of 16 32-bit-words */ -static void +static unsigned int transform ( void *ctx, const unsigned char *data ) { RMD160_CONTEXT *hd = ctx; @@ -400,6 +400,8 @@ transform ( void *ctx, const unsigned char *data ) hd->h3 = hd->h4 + b + aa; hd->h4 = hd->h0 + c + bb; hd->h0 = t; + + return /*burn_stack*/ 108+5*sizeof(void*); } @@ -434,6 +436,7 @@ rmd160_final( void *context ) RMD160_CONTEXT *hd = context; u32 t, msb, lsb; byte *p; + unsigned int burn; _gcry_md_block_write(hd, NULL, 0); /* flush */; @@ -474,8 +477,8 @@ rmd160_final( void *context ) hd->bctx.buf[61] = msb >> 8; hd->bctx.buf[62] = msb >> 16; hd->bctx.buf[63] = msb >> 24; - transform( hd, hd->bctx.buf ); - _gcry_burn_stack (108+5*sizeof(void*)); + burn = transform( hd, hd->bctx.buf ); + _gcry_burn_stack (burn); p = hd->bctx.buf; #ifdef WORDS_BIGENDIAN |