diff options
author | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2019-03-31 18:21:20 +0300 |
---|---|---|
committer | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2019-03-31 18:21:20 +0300 |
commit | 0fe918fa897cca9e01cbdb80d14106cfe5af680e (patch) | |
tree | bc38e691a6734ef4578adfbb47daa16b7c8aa711 /cipher/serpent.c | |
parent | efd700e31dc8e1e386d367d1b682000977e0c810 (diff) | |
download | libgcrypt-0fe918fa897cca9e01cbdb80d14106cfe5af680e.tar.gz |
Add helper function for adding value to cipher block
* cipher/cipher-internal.h (cipher_block_add): New.
* cipher/blowfish.c (_gcry_blowfish_ctr_enc): Use new helper function
for CTR block increment.
* cipher/camellia-glue.c (_gcry_camellia_ctr_enc): Ditto.
* cipher/cast5.c (_gcry_cast5_ctr_enc): Ditto.
* cipher/cipher-ctr.c (_gcry_cipher_ctr_encrypt): Ditto.
* cipher/des.c (_gcry_3des_ctr_enc): Ditto.
* cipher/rijndael.c (_gcry_aes_ctr_enc): Ditto.
* cipher/serpent.c (_gcry_serpent_ctr_enc): Ditto.
* cipher/twofish.c (_gcry_twofish_ctr_enc): Ditto.
--
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/serpent.c')
-rw-r--r-- | cipher/serpent.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/cipher/serpent.c b/cipher/serpent.c index 8e3faa7c..71d843d0 100644 --- a/cipher/serpent.c +++ b/cipher/serpent.c @@ -912,7 +912,6 @@ _gcry_serpent_ctr_enc(void *context, unsigned char *ctr, const unsigned char *inbuf = inbuf_arg; unsigned char tmpbuf[sizeof(serpent_block_t)]; int burn_stack_depth = 2 * sizeof (serpent_block_t); - int i; #ifdef USE_AVX2 if (ctx->use_avx2) @@ -1006,12 +1005,7 @@ _gcry_serpent_ctr_enc(void *context, unsigned char *ctr, outbuf += sizeof(serpent_block_t); inbuf += sizeof(serpent_block_t); /* Increment the counter. */ - for (i = sizeof(serpent_block_t); i > 0; i--) - { - ctr[i-1]++; - if (ctr[i-1]) - break; - } + cipher_block_add(ctr, 1, sizeof(serpent_block_t)); } wipememory(tmpbuf, sizeof(tmpbuf)); |