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-30 20:26:16 +0300 |
commit | a96d622e1a36d40d1504b7ada567e90ec9957443 (patch) | |
tree | e7b97ac23767954140f657ab79b54e1b30d129d9 /cipher/whirlpool.c | |
parent | 10d7351411f19bb2c03d2e24ca5a38dabe45023b (diff) | |
download | libgcrypt-a96d622e1a36d40d1504b7ada567e90ec9957443.tar.gz |
whirlpool: add stack burning after transform
* cipher/whirlpool.c (whirlpool_transform): Return burn stack depth.
(whirlpool_add): Do burn_stack.
--
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/whirlpool.c')
-rw-r--r-- | cipher/whirlpool.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/cipher/whirlpool.c b/cipher/whirlpool.c index 1ee89162..6b5f1a9a 100644 --- a/cipher/whirlpool.c +++ b/cipher/whirlpool.c @@ -1173,7 +1173,7 @@ whirlpool_init (void *ctx) /* * Transform block. */ -static void +static unsigned int whirlpool_transform (whirlpool_context_t *context, const unsigned char *data) { whirlpool_block_t data_block; @@ -1267,6 +1267,9 @@ whirlpool_transform (whirlpool_context_t *context, const unsigned char *data) block_xor (context->hash_state, data_block, i); block_xor (context->hash_state, state, i); + + return /*burn_stack*/ 4 * sizeof(whirlpool_block_t) + 2 * sizeof(int) + + 3 * sizeof(void*); } static void @@ -1274,12 +1277,14 @@ whirlpool_add (whirlpool_context_t *context, const void *buffer_arg, size_t buffer_n) { const unsigned char *buffer = buffer_arg; + unsigned int burn = 0; if (context->count == BLOCK_SIZE) { /* Flush the buffer. */ - whirlpool_transform (context, context->buffer); - /*_gcry_burn_stack (80+6*sizeof(void*));*/ /* FIXME */ + burn = whirlpool_transform (context, context->buffer); + _gcry_burn_stack (burn); + burn = 0; context->count = 0; context->nblocks++; } @@ -1298,11 +1303,10 @@ whirlpool_add (whirlpool_context_t *context, if (!buffer_n) return; } - /*_gcry_burn_stack (80+6*sizeof(void*));*/ /* FIXME */ while (buffer_n >= BLOCK_SIZE) { - whirlpool_transform (context, buffer); + burn = whirlpool_transform (context, buffer); context->count = 0; context->nblocks++; buffer_n -= BLOCK_SIZE; @@ -1313,6 +1317,8 @@ whirlpool_add (whirlpool_context_t *context, context->buffer[context->count++] = *buffer++; buffer_n--; } + + _gcry_burn_stack (burn); } static void |