diff options
author | Niels Möller <nisse@lysator.liu.se> | 2023-02-02 19:53:15 +0100 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2023-02-06 20:27:58 +0100 |
commit | 95ea729d6104b2e7de8608720940433a4a17ad06 (patch) | |
tree | 4c63eb921dedbbe64e724f1813ca21b664acdca5 | |
parent | 1839172702e6a54b3adfc7097ec926ea5b132c3f (diff) | |
download | nettle-95ea729d6104b2e7de8608720940433a4a17ad06.tar.gz |
Delete #if:ed out 2-way and 4-way code
-rw-r--r-- | ocb.c | 139 |
1 files changed, 0 insertions, 139 deletions
@@ -241,145 +241,6 @@ ocb_crypt_n (struct ocb_ctx *ctx, const struct ocb_key *key, } } -#if 0 -/* Process n complete blocks (encrypt or decrypt, checksum left to caller). */ -static void -ocb_crypt_n_2way (struct ocb_ctx *ctx, const struct ocb_key *key, - const void *cipher, nettle_cipher_func *f, - size_t n, uint8_t *dst, const uint8_t *src) -{ - if (n == 0) - return; - - if (!(ctx->message_count & 1)) - { - /* Do a single block to align block count. */ - union nettle_block16 block; - ++ctx->message_count; /* Always odd. */ - block16_xor (&ctx->offset, &key->L[2]); - - memxor3 (block.b, ctx->offset.b, src, OCB_BLOCK_SIZE); - f (cipher, OCB_BLOCK_SIZE, block.b, block.b); - - memxor3 (dst, ctx->offset.b, block.b, OCB_BLOCK_SIZE); - - n--; src += OCB_BLOCK_SIZE; dst += OCB_BLOCK_SIZE; - } - - for (; n >= 2; n -= 2, src += 2*OCB_BLOCK_SIZE, dst += 2*OCB_BLOCK_SIZE) - { - union nettle_block16 o[2], block[2]; - size_t i; - - ctx->message_count += 2; /* Always odd. */ - - /* Based on trailing zeros of ctx->message_count - 1, the - initial shift below discards a one bit. */ - block16_mulx_be (&o[0], &key->L[2]); - for (i = ctx->message_count >> 1; !(i&1); i >>= 1) - block16_mulx_be (&o[0], &o[0]); - - block16_xor (&o[0], &ctx->offset); - block16_xor3 (&o[1], &o[0], &key->L[2]); - - memxor3 (block[0].b, o[0].b, src, 2*OCB_BLOCK_SIZE); - f (cipher, 2*OCB_BLOCK_SIZE, block[0].b, block[0].b); - memxor3 (dst, o[0].b, block[0].b, 2*OCB_BLOCK_SIZE); - - ctx->offset.u64[0] = o[1].u64[0]; ctx->offset.u64[1] = o[1].u64[1]; - } - if (n > 0) - { - union nettle_block16 block; - update_offset (key, &ctx->offset, ++ctx->message_count); - - memxor3 (block.b, ctx->offset.b, src, OCB_BLOCK_SIZE); - f (cipher, OCB_BLOCK_SIZE, block.b, block.b); - memxor3 (dst, ctx->offset.b, block.b, OCB_BLOCK_SIZE); - } -} - -static void -ocb_crypt_n_4way (struct ocb_ctx *ctx, const struct ocb_key *key, - const void *cipher, nettle_cipher_func *f, - size_t n, uint8_t *dst, const uint8_t *src) -{ - union nettle_block16 l3, o[4], block[4]; - size_t i; - if (n >= 3) - { - if (!(ctx->message_count & 1)) - { - /* Do a single block to align block count. */ - ++ctx->message_count; /* Always odd. */ - block16_xor (&ctx->offset, &key->L[2]); - - memxor3 (block[0].b, ctx->offset.b, src, OCB_BLOCK_SIZE); - f (cipher, OCB_BLOCK_SIZE, block[0].b, block[0].b); - - memxor3 (dst, ctx->offset.b, block[0].b, OCB_BLOCK_SIZE); - - n--; src += OCB_BLOCK_SIZE; dst += OCB_BLOCK_SIZE; - } - if (!(ctx->message_count & 2)) - { - /* Do two more blocks, to align block count to a multiple of 4. */ - ctx->message_count += 2; /* Always = 3 (mod 4). */ - - /* Based on trailing zeros of ctx->message_count - 1, the - initial shift below discards a one bit. */ - block16_mulx_be (&o[0], &key->L[2]); - for (i = ctx->message_count >> 1; !(i&1); i >>= 1) - block16_mulx_be (&o[0], &o[0]); - - block16_xor (&o[0], &ctx->offset); - block16_xor3 (&o[1], &o[0], &key->L[2]); - - memxor3 (block[0].b, o[0].b, src, 2*OCB_BLOCK_SIZE); - f (cipher, 2*OCB_BLOCK_SIZE, block[0].b, block[0].b); - - memxor3 (dst, o[0].b, block[0].b, 2*OCB_BLOCK_SIZE); - ctx->offset.u64[0] = o[1].u64[0]; ctx->offset.u64[1] = o[1].u64[1]; - - n -= 2; src += 2*OCB_BLOCK_SIZE; dst += 2*OCB_BLOCK_SIZE; - } - block16_mulx_be (&l3, &key->L[2]); - - for (; n >= 4; n -= 4, src += 4*OCB_BLOCK_SIZE, dst += 4*OCB_BLOCK_SIZE) - { - ctx->message_count += 4; /* Always = 3 (mod 4). */ - - /* Based on trailing zeros of ctx->message_count - 3, the - initial shift below discards two one bits. */ - block16_mulx_be (&o[0], &l3); - for (i = ctx->message_count >> 2; !(i&1); i >>= 1) - block16_mulx_be (&o[0], &o[0]); - block16_xor (&o[0], &ctx->offset); - block16_xor3 (&o[1], &o[0], &key->L[2]); - block16_xor (&o[2], &l3); - block16_xor3 (&o[3], &o[0], &key->L[2]); - - memxor3 (block[0].b, o[0].b, src, 4*OCB_BLOCK_SIZE); - f (cipher, 4*OCB_BLOCK_SIZE, block[0].b, block[0].b); - memxor3 (dst, o[0].b, block[0].b, 4*OCB_BLOCK_SIZE); - - ctx->offset.u64[0] = o[3].u64[0]; ctx->offset.u64[1] = o[3].u64[1]; - } - } - if (!n) - return; - - for (i = 0; i < n; i++) - { - update_offset (key, &ctx->offset, ++ctx->message_count); - o[i].u64[0] = ctx->offset.u64[0]; o[i].u64[1] = ctx->offset.u64[1]; - } - memxor3 (block[0].b, o[0].b, src, n * OCB_BLOCK_SIZE); - f (cipher, n * OCB_BLOCK_SIZE, block[0].b, block[0].b); - memxor3 (dst, o[0].b, block[0].b, n * OCB_BLOCK_SIZE); -} -#endif - /* Rotate bytes c positions to the right, in memory order. */ #if WORDS_BIGENDIAN # define MEM_ROTATE_RIGHT(c, s0, s1) do { \ |