Commit faed9ae6 authored by Dmitry Baryshkov's avatar Dmitry Baryshkov Committed by Niels Möller

gcm: use uint64_t member of nettle_block16

Remove last usage of unsigned long member of nettle_block16.
Signed-off-by: Dmitry Baryshkov's avatarDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
parent 7aa7ae63
...@@ -133,45 +133,22 @@ shift_table[0x10] = { ...@@ -133,45 +133,22 @@ shift_table[0x10] = {
static void static void
gcm_gf_shift_4(union nettle_block16 *x) gcm_gf_shift_4(union nettle_block16 *x)
{ {
unsigned long *w = x->w; uint64_t *u64 = x->u64;
unsigned long reduce; uint64_t reduce;
/* Shift uses big-endian representation. */ /* Shift uses big-endian representation. */
#if WORDS_BIGENDIAN #if WORDS_BIGENDIAN
# if SIZEOF_LONG == 4 reduce = shift_table[u64[1] & 0xf];
reduce = shift_table[w[3] & 0xf]; u64[1] = (u64[1] >> 4) | ((u64[0] & 0xf) << 60);
w[3] = (w[3] >> 4) | ((w[2] & 0xf) << 28); u64[0] = (u64[0] >> 4) ^ (reduce << 48);
w[2] = (w[2] >> 4) | ((w[1] & 0xf) << 28);
w[1] = (w[1] >> 4) | ((w[0] & 0xf) << 28);
w[0] = (w[0] >> 4) ^ (reduce << 16);
# elif SIZEOF_LONG == 8
reduce = shift_table[w[1] & 0xf];
w[1] = (w[1] >> 4) | ((w[0] & 0xf) << 60);
w[0] = (w[0] >> 4) ^ (reduce << 48);
# else
# error Unsupported word size. */
#endif
#else /* ! WORDS_BIGENDIAN */ #else /* ! WORDS_BIGENDIAN */
# if SIZEOF_LONG == 4 #define RSHIFT_WORD_4(x) \
#define RSHIFT_WORD(x) \ ((((x) & UINT64_C(0xf0f0f0f0f0f0f0f0)) >> 4) \
((((x) & 0xf0f0f0f0UL) >> 4) \ | (((x) & UINT64_C(0x000f0f0f0f0f0f0f)) << 12))
| (((x) & 0x000f0f0f) << 12)) reduce = shift_table[(u64[1] >> 56) & 0xf];
reduce = shift_table[(w[3] >> 24) & 0xf]; u64[1] = RSHIFT_WORD_4(u64[1]) | ((u64[0] >> 52) & 0xf0);
w[3] = RSHIFT_WORD(w[3]) | ((w[2] >> 20) & 0xf0); u64[0] = RSHIFT_WORD_4(u64[0]) ^ reduce;
w[2] = RSHIFT_WORD(w[2]) | ((w[1] >> 20) & 0xf0); # undef RSHIFT_WORD_4
w[1] = RSHIFT_WORD(w[1]) | ((w[0] >> 20) & 0xf0);
w[0] = RSHIFT_WORD(w[0]) ^ reduce;
# elif SIZEOF_LONG == 8
#define RSHIFT_WORD(x) \
((((x) & 0xf0f0f0f0f0f0f0f0UL) >> 4) \
| (((x) & 0x000f0f0f0f0f0f0fUL) << 12))
reduce = shift_table[(w[1] >> 56) & 0xf];
w[1] = RSHIFT_WORD(w[1]) | ((w[0] >> 52) & 0xf0);
w[0] = RSHIFT_WORD(w[0]) ^ reduce;
# else
# error Unsupported word size. */
# endif
# undef RSHIFT_WORD
#endif /* ! WORDS_BIGENDIAN */ #endif /* ! WORDS_BIGENDIAN */
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment