24 #ifndef _CX_INLINE_U32
25 unsigned long int cx_rotl(
unsigned long int x,
unsigned char n)
27 return (((x) << (n)) | ((x) >> (32 - (n))));
30 unsigned long int cx_rotr(
unsigned long int x,
unsigned char n)
32 return (((x) >> (n)) | ((x) << ((32) - (n))));
35 unsigned long int cx_shr(
unsigned long int x,
unsigned char n)
43 return (((v) << 24) & 0xFF000000U) | (((v) << 8) & 0x00FF0000U) | (((v) >> 8) & 0x0000FF00U)
44 | (((v) >> 24) & 0x000000FFU);
52 tmp = ((
unsigned char *) v)[len * 4 + 3];
53 ((
unsigned char *) v)[len * 4 + 3] = ((
unsigned char *) v)[len * 4];
54 ((
unsigned char *) v)[len * 4] = tmp;
55 tmp = ((
unsigned char *) v)[len * 4 + 2];
56 ((
unsigned char *) v)[len * 4 + 2] = ((
unsigned char *) v)[len * 4 + 1];
57 ((
unsigned char *) v)[len * 4 + 1] = tmp;
70 unsigned long int sl_rot, sh_rot;
77 sh_rot = ((((x->
h) & 0xFFFFFFFF) << (32 - n)));
78 sl_rot = ((((x->
l) & 0xFFFFFFFF) << (32 - n)));
80 x->
h = ((x->
h >> n) | sl_rot);
81 x->
l = ((x->
l >> n) | sh_rot);
85 unsigned long int sl_shr;
93 sl_shr = ((((x->
h) & 0xFFFFFFFF) << (32 - n)));
94 x->
l = ((x->
l) >> n) | sl_shr;
100 #ifndef _CX_INLINE_U64
103 return (((x) >> (n)) | ((x) << ((64) - (n))));
107 return (((x) << (n)) | ((x) >> ((64) - (n))));
117 #ifndef NATIVE_64BITS
120 unsigned long int h, l;
132 h = (uint32_t) ((v >> 32) & 0xFFFFFFFF);
133 l = (uint32_t) (v & 0xFFFFFFFF);
142 #ifndef NATIVE_64BITS
155 #ifndef NATIVE_64BITS
159 unsigned long int addl;
163 carry = ((((x->
l & y->
l) | (x->
l & ~y->
l & addl) | (~x->
l & y->
l & addl)) >> 31) & 1);
176 for (i = 0; i < len; i++) {
186 for (diff = 0, i = 0; i < len; i++) {
187 diff |= buf1[i] ^ buf2[i];
189 is_eq = ((diff | -diff) >> 7) & 1;
void cx_swap_buffer64(uint64bits_t *v, int len)
void cx_shr64(uint64bits_t *x, unsigned char n)
void cx_rotr64(uint64bits_t *x, unsigned int n)
uint32_t cx_swap_uint32(uint32_t v)
uint8_t cx_constant_time_eq(const uint8_t *buf1, uint8_t *buf2, size_t len)
void cx_add_64(uint64bits_t *x, uint64bits_t *y)
void cx_swap_uint64(uint64bits_t *v)
void cx_memxor(uint8_t *buf1, const uint8_t *buf2, size_t len)
void cx_swap_buffer32(uint32_t *v, size_t len)
struct uint64_s uint64bits_t
64-bit types, native or by-hands, depending on target and/or compiler support.
uint32_t l
32 least significant bits
uint32_t h
32 most significant bits