summaryrefslogtreecommitdiff
path: root/cipher/serpent.c
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2013-11-09 22:39:19 +0200
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2013-11-09 22:39:19 +0200
commitdf29831d008e32faf74091d080a415731418d158 (patch)
tree384cc216ede33e8aacb2363de307b171c36ed1d3 /cipher/serpent.c
parent51501b638546665163bbb85a14308fdb99211a28 (diff)
downloadlibgcrypt-df29831d008e32faf74091d080a415731418d158.tar.gz
Fix Serpent-AVX2 and Camellia-AVX2 counter modes
* cipher/camellia-aesni-avx2-amd64.S (_gcry_camellia_aesni_avx2_ctr_enc): Byte-swap before checking for overflow handling. * cipher/camellia-glue.c (selftest_ctr_128, selftest_cfb_128) (selftest_cbc_128): Add 16 to nblocks. * cipher/cipher-selftest.c (_gcry_selftest_helper_ctr): Add test with non-overflowing IV and modify overflow IV to detect broken endianness handling. * cipher/serpent-avx2-amd64.S (_gcry_serpent_avx2_ctr_enc): Byte-swap before checking for overflow handling; Fix crazy-mixed-endian IV construction to big-endian. * cipher/serpent.c (selftest_ctr_128, selftest_cfb_128) (selftest_cbc_128): Add 8 to nblocks. -- The selftest for CTR was setting counter-IV to all '0xff' except last byte. This had the effect that even with broken endianness handling Serpent-AVX2 and Camellia-AVX2 passed the tests. Patch corrects the CTR selftest and fixes the broken implementations. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/serpent.c')
-rw-r--r--cipher/serpent.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/cipher/serpent.c b/cipher/serpent.c
index 4a24ddd6..915cc956 100644
--- a/cipher/serpent.c
+++ b/cipher/serpent.c
@@ -1158,7 +1158,7 @@ _gcry_serpent_cfb_dec(void *context, unsigned char *iv,
static const char*
selftest_ctr_128 (void)
{
- const int nblocks = 16+1;
+ const int nblocks = 16+8+1;
const int blocksize = sizeof(serpent_block_t);
const int context_size = sizeof(serpent_context_t);
@@ -1173,7 +1173,7 @@ selftest_ctr_128 (void)
static const char*
selftest_cbc_128 (void)
{
- const int nblocks = 16+2;
+ const int nblocks = 16+8+2;
const int blocksize = sizeof(serpent_block_t);
const int context_size = sizeof(serpent_context_t);
@@ -1188,7 +1188,7 @@ selftest_cbc_128 (void)
static const char*
selftest_cfb_128 (void)
{
- const int nblocks = 16+2;
+ const int nblocks = 16+8+2;
const int blocksize = sizeof(serpent_block_t);
const int context_size = sizeof(serpent_context_t);