chore(crypto): Zero-initialize stack variables in AES code.

Andrew Kozlik 1 month ago
parent fa7b3a7f7f
commit 10644d4f3d

@ -107,7 +107,7 @@ aligned_array(unsigned long, dec_hybrid_table, 12, 16) = NEH_DEC_HYBRID_DATA;
/* test the code for detecting and setting pointer alignment */
AES_RETURN aes_test_alignment_detection(unsigned int n) /* 4 <= n <= 16 */
{ uint8_t p[16];
{ uint8_t p[16] = {0};
uint32_t i = 0, count_eq = 0, count_neq = 0;
if(n < 4 || n > 16)
@ -357,7 +357,7 @@ AES_RETURN aes_cbc_encrypt(const unsigned char *ibuf, unsigned char *obuf,
AES_RETURN aes_cbc_decrypt(const unsigned char *ibuf, unsigned char *obuf,
int len, unsigned char *iv, const aes_decrypt_ctx ctx[1])
{ unsigned char tmp[AES_BLOCK_SIZE];
{ unsigned char tmp[AES_BLOCK_SIZE] = {0};
int nb = len >> AES_BLOCK_SIZE_P2;
if(len & (AES_BLOCK_SIZE - 1))
@ -456,7 +456,7 @@ AES_RETURN aes_cbc_decrypt(const unsigned char *ibuf, unsigned char *obuf,
AES_RETURN aes_cfb_encrypt(const unsigned char *ibuf, unsigned char *obuf,
int len, unsigned char *iv, aes_encrypt_ctx ctx[1])
{ int cnt = 0, b_pos = (int)ctx->inf.b[2], nb;
{ int cnt = 0, b_pos = (int)ctx->inf.b[2], nb = 0;
if(b_pos) /* complete any partial block */
{
@ -474,7 +474,7 @@ AES_RETURN aes_cfb_encrypt(const unsigned char *ibuf, unsigned char *obuf,
#if defined( USE_VIA_ACE_IF_PRESENT )
if(ctx->inf.b[1] == 0xff)
{ int m;
{ int m = 0;
uint8_t *ksp = (uint8_t*)(ctx->ks), *ivp = iv;
aligned_auto(uint8_t, liv, AES_BLOCK_SIZE, 16);
via_cwd(cwd, hybrid, enc, 2 * ctx->inf.b[0] - 192);
@ -581,10 +581,10 @@ AES_RETURN aes_cfb_encrypt(const unsigned char *ibuf, unsigned char *obuf,
AES_RETURN aes_cfb_decrypt(const unsigned char *ibuf, unsigned char *obuf,
int len, unsigned char *iv, aes_encrypt_ctx ctx[1])
{ int cnt = 0, b_pos = (int)ctx->inf.b[2], nb;
{ int cnt = 0, b_pos = (int)ctx->inf.b[2], nb = 0;
if(b_pos) /* complete any partial block */
{ uint8_t t;
{ uint8_t t = 0;
while(b_pos < AES_BLOCK_SIZE && cnt < len)
{
@ -602,7 +602,7 @@ AES_RETURN aes_cfb_decrypt(const unsigned char *ibuf, unsigned char *obuf,
#if defined( USE_VIA_ACE_IF_PRESENT )
if(ctx->inf.b[1] == 0xff)
{ int m;
{ int m = 0;
uint8_t *ksp = (uint8_t*)(ctx->ks), *ivp = iv;
aligned_auto(uint8_t, liv, AES_BLOCK_SIZE, 16);
via_cwd(cwd, hybrid, dec, 2 * ctx->inf.b[0] - 192);
@ -655,7 +655,7 @@ AES_RETURN aes_cfb_decrypt(const unsigned char *ibuf, unsigned char *obuf,
# ifdef FAST_BUFFER_OPERATIONS
if(!ALIGN_OFFSET( ibuf, 4 ) && !ALIGN_OFFSET( obuf, 4 ) &&!ALIGN_OFFSET( iv, 4 ))
while(cnt + AES_BLOCK_SIZE <= len)
{ uint32_t t;
{ uint32_t t = 0;
assert(b_pos == 0);
if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS)
@ -671,7 +671,7 @@ AES_RETURN aes_cfb_decrypt(const unsigned char *ibuf, unsigned char *obuf,
else
# endif
while(cnt + AES_BLOCK_SIZE <= len)
{ uint8_t t;
{ uint8_t t = 0;
assert(b_pos == 0);
if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS)
@ -700,7 +700,7 @@ AES_RETURN aes_cfb_decrypt(const unsigned char *ibuf, unsigned char *obuf,
}
while(cnt < len)
{ uint8_t t;
{ uint8_t t = 0;
if(!b_pos && aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS)
return EXIT_FAILURE;
@ -722,7 +722,7 @@ AES_RETURN aes_cfb_decrypt(const unsigned char *ibuf, unsigned char *obuf,
AES_RETURN aes_ofb_crypt(const unsigned char *ibuf, unsigned char *obuf,
int len, unsigned char *iv, aes_encrypt_ctx ctx[1])
{ int cnt = 0, b_pos = (int)ctx->inf.b[2], nb;
{ int cnt = 0, b_pos = (int)ctx->inf.b[2], nb = 0;
if(b_pos) /* complete any partial block */
{
@ -740,7 +740,7 @@ AES_RETURN aes_ofb_crypt(const unsigned char *ibuf, unsigned char *obuf,
#if defined( USE_VIA_ACE_IF_PRESENT )
if(ctx->inf.b[1] == 0xff)
{ int m;
{ int m = 0;
uint8_t *ksp = (uint8_t*)(ctx->ks), *ivp = iv;
aligned_auto(uint8_t, liv, AES_BLOCK_SIZE, 16);
via_cwd(cwd, hybrid, enc, 2 * ctx->inf.b[0] - 192);
@ -849,7 +849,7 @@ AES_RETURN aes_ofb_crypt(const unsigned char *ibuf, unsigned char *obuf,
AES_RETURN aes_ctr_crypt(const unsigned char *ibuf, unsigned char *obuf,
int len, unsigned char *cbuf, cbuf_inc ctr_inc, aes_encrypt_ctx ctx[1])
{ unsigned char *ip;
{ unsigned char *ip = NULL;
int i = 0, blen = 0, b_pos = (int)(ctx->inf.b[2]);
#if defined( USE_VIA_ACE_IF_PRESENT )

@ -37,9 +37,9 @@ extern "C"
#define so(y,x,c) word_out(y, c, s(x,c))
#if defined(ARRAYS)
#define locals(y,x) x[4],y[4]
#define locals(y,x) x[4] = {0}, y[4] = {0}
#else
#define locals(y,x) x##0,x##1,x##2,x##3,y##0,y##1,y##2,y##3
#define locals(y,x) x##0=0,x##1=0,x##2=0,x##3=0,y##0=0,y##1=0,y##2=0,y##3=0
#endif
#define l_copy(y, x) s(y,0) = s(x,0); s(y,1) = s(x,1); \
@ -138,7 +138,7 @@ AES_RETURN aes_xi(encrypt)(const unsigned char *in, unsigned char *out, const ae
#else
#if (ENC_UNROLL == PARTIAL)
{ uint32_t rnd;
{ uint32_t rnd = 0;
for(rnd = 0; rnd < (cx->inf.b[0] >> 5) - 1; ++rnd)
{
kp += N_COLS;
@ -149,7 +149,7 @@ AES_RETURN aes_xi(encrypt)(const unsigned char *in, unsigned char *out, const ae
kp += N_COLS;
round(fwd_rnd, b1, b0, kp);
#else
{ uint32_t rnd;
{ uint32_t rnd = 0;
for(rnd = 0; rnd < (cx->inf.b[0] >> 4) - 1; ++rnd)
{
kp += N_COLS;
@ -272,7 +272,7 @@ AES_RETURN aes_xi(decrypt)(const unsigned char *in, unsigned char *out, const ae
#else
#if (DEC_UNROLL == PARTIAL)
{ uint32_t rnd;
{ uint32_t rnd = 0;
for(rnd = 0; rnd < (cx->inf.b[0] >> 5) - 1; ++rnd)
{
kp = rnd_key(1);
@ -283,7 +283,7 @@ AES_RETURN aes_xi(decrypt)(const unsigned char *in, unsigned char *out, const ae
kp = rnd_key(1);
round(inv_rnd, b1, b0, kp);
#else
{ uint32_t rnd;
{ uint32_t rnd = 0;
for(rnd = 0; rnd < (cx->inf.b[0] >> 4) - 1; ++rnd)
{
kp = rnd_key(1);

@ -129,7 +129,7 @@ ret_type gcm_init_and_key( /* initialise mode and set key */
void gf_mul_hh(gf_t a, gcm_ctx ctx[1])
{
#if defined( GF_REPRESENTATION ) || !defined( NO_TABLES )
gf_t scr;
gf_t scr = {0};
#endif
#if defined( GF_REPRESENTATION )
convert_representation(a, a, GF_REPRESENTATION);
@ -161,8 +161,8 @@ ret_type gcm_init_message( /* initialise a new message */
const unsigned char iv[], /* the initialisation vector */
unsigned long iv_len, /* and its length in bytes */
gcm_ctx ctx[1]) /* the mode context */
{ uint32_t i, n_pos = 0;
uint8_t *p;
{ uint32_t i = 0, n_pos = 0;
uint8_t *p = NULL;
memset(ctx->ctr_val, 0, BLOCK_SIZE);
if(iv_len == CTR_POS)
@ -379,8 +379,8 @@ ret_type gcm_compute_tag( /* compute authentication tag */
unsigned char tag[], /* the buffer for the tag */
unsigned long tag_len, /* and its length in bytes */
gcm_ctx ctx[1]) /* the mode context */
{ uint32_t i, ln;
gf_t tbuf;
{ uint32_t i = 0, ln = 0;
gf_t tbuf = {0};
if(ctx->txt_acnt != ctx->txt_ccnt && ctx->txt_ccnt > 0)
return RETURN_ERROR;
@ -532,8 +532,8 @@ ret_type gcm_decrypt_message( /* decrypt an entire message */
const unsigned char tag[], /* the buffer for the tag */
unsigned long tag_len, /* and its length in bytes */
gcm_ctx ctx[1]) /* the mode context */
{ uint8_t local_tag[BLOCK_SIZE];
ret_type rr;
{ uint8_t local_tag[BLOCK_SIZE] = {0};
ret_type rr = 0;
gcm_init_message(iv, iv_len, ctx);
gcm_auth_header(hdr, hdr_len, ctx);

@ -80,7 +80,7 @@ extern "C"
}
AES_RETURN aes_xi(encrypt_key128)(const unsigned char *key, aes_encrypt_ctx cx[1])
{ uint32_t ss[4];
{ uint32_t ss[4] = {0};
cx->ks[0] = ss[0] = word_in(key, 0);
cx->ks[1] = ss[1] = word_in(key, 1);
@ -94,7 +94,7 @@ AES_RETURN aes_xi(encrypt_key128)(const unsigned char *key, aes_encrypt_ctx cx[1
ke4(cx->ks, 6); ke4(cx->ks, 7);
ke4(cx->ks, 8);
#else
{ uint32_t i;
{ uint32_t i = 0;
for(i = 0; i < 9; ++i)
ke4(cx->ks, i);
}
@ -128,7 +128,7 @@ AES_RETURN aes_xi(encrypt_key128)(const unsigned char *key, aes_encrypt_ctx cx[1
}
AES_RETURN aes_xi(encrypt_key192)(const unsigned char *key, aes_encrypt_ctx cx[1])
{ uint32_t ss[6];
{ uint32_t ss[6] = {0};
cx->ks[0] = ss[0] = word_in(key, 0);
cx->ks[1] = ss[1] = word_in(key, 1);
@ -143,7 +143,7 @@ AES_RETURN aes_xi(encrypt_key192)(const unsigned char *key, aes_encrypt_ctx cx[1
ke6(cx->ks, 4); ke6(cx->ks, 5);
ke6(cx->ks, 6);
#else
{ uint32_t i;
{ uint32_t i = 0;
for(i = 0; i < 7; ++i)
ke6(cx->ks, i);
}
@ -179,7 +179,7 @@ AES_RETURN aes_xi(encrypt_key192)(const unsigned char *key, aes_encrypt_ctx cx[1
}
AES_RETURN aes_xi(encrypt_key256)(const unsigned char *key, aes_encrypt_ctx cx[1])
{ uint32_t ss[8];
{ uint32_t ss[8] = {0};
cx->ks[0] = ss[0] = word_in(key, 0);
cx->ks[1] = ss[1] = word_in(key, 1);
@ -195,7 +195,7 @@ AES_RETURN aes_xi(encrypt_key256)(const unsigned char *key, aes_encrypt_ctx cx[1
ke8(cx->ks, 2); ke8(cx->ks, 3);
ke8(cx->ks, 4); ke8(cx->ks, 5);
#else
{ uint32_t i;
{ uint32_t i = 0;
for(i = 0; i < 6; ++i)
ke8(cx->ks, i);
}
@ -302,7 +302,7 @@ AES_RETURN aes_xi(encrypt_key256)(const unsigned char *key, aes_encrypt_ctx cx[1
#endif
AES_RETURN aes_xi(decrypt_key128)(const unsigned char *key, aes_decrypt_ctx cx[1])
{ uint32_t ss[5];
{ uint32_t ss[5] = {0};
#if defined( d_vars )
d_vars;
#endif
@ -319,7 +319,7 @@ AES_RETURN aes_xi(decrypt_key128)(const unsigned char *key, aes_decrypt_ctx cx[1
kd4(cx->ks, 6); kd4(cx->ks, 7);
kd4(cx->ks, 8); kdl4(cx->ks, 9);
#else
{ uint32_t i;
{ uint32_t i = 0;
for(i = 0; i < 10; ++i)
k4e(cx->ks, i);
#if !(DEC_ROUND == NO_TABLES)
@ -382,7 +382,7 @@ AES_RETURN aes_xi(decrypt_key128)(const unsigned char *key, aes_decrypt_ctx cx[1
}
AES_RETURN aes_xi(decrypt_key192)(const unsigned char *key, aes_decrypt_ctx cx[1])
{ uint32_t ss[7];
{ uint32_t ss[7] = {0};
#if defined( d_vars )
d_vars;
#endif
@ -404,7 +404,7 @@ AES_RETURN aes_xi(decrypt_key192)(const unsigned char *key, aes_decrypt_ctx cx[1
#else
cx->ks[v(48,(4))] = ss[4] = word_in(key, 4);
cx->ks[v(48,(5))] = ss[5] = word_in(key, 5);
{ uint32_t i;
{ uint32_t i = 0;
for(i = 0; i < 7; ++i)
k6e(cx->ks, i);
@ -476,7 +476,7 @@ AES_RETURN aes_xi(decrypt_key192)(const unsigned char *key, aes_decrypt_ctx cx[1
}
AES_RETURN aes_xi(decrypt_key256)(const unsigned char *key, aes_decrypt_ctx cx[1])
{ uint32_t ss[9];
{ uint32_t ss[9] = {0};
#if defined( d_vars )
d_vars;
#endif
@ -504,7 +504,7 @@ AES_RETURN aes_xi(decrypt_key256)(const unsigned char *key, aes_decrypt_ctx cx[1
cx->ks[v(56,(5))] = ss[5] = word_in(key, 5);
cx->ks[v(56,(6))] = ss[6] = word_in(key, 6);
cx->ks[v(56,(7))] = ss[7] = word_in(key, 7);
{ uint32_t i;
{ uint32_t i = 0;
for(i = 0; i < 6; ++i)
k8e(cx->ks, i);

@ -268,7 +268,7 @@ uint8_t inv_affine(const uint8_t x)
static int init = 0;
AES_RETURN aes_init(void)
{ uint32_t i, w;
{ uint32_t i = 0, w = 0;
#if defined(FF_TABLES)
@ -303,7 +303,7 @@ AES_RETURN aes_init(void)
}
for(i = 0; i < 256; ++i)
{ uint8_t b;
{ uint8_t b = 0;
b = fwd_affine(gf_inv((uint8_t)i));
w = bytes2word(f2(b), b, b, f3(b));

@ -57,7 +57,7 @@ void out_state(long s0, long s1, long s2, long s3)
}
void oblk(char m[], unsigned char v[], unsigned long n)
{ unsigned long i;
{ unsigned long i = 0;
printf("\n%s", m);
@ -117,9 +117,9 @@ void cycles(volatile uint64_t *rtn)
}
int main(void)
{ unsigned char out[32], ret[32], err = 0;
f_ectx alge[1];
f_dctx algd[1];
{ unsigned char out[32] = {0}, ret[32] = {0}, err = 0;
f_ectx alge[1] = {0};
f_dctx algd[1] = {0};
aes_init();

@ -52,9 +52,9 @@ Issue Date: 20/12/2007
/* A slow field multiplier */
void gf_mul(gf_t a, const gf_t b)
{ gf_t p[8];
uint8_t *q, ch;
int i;
{ gf_t p[8] = {0};
uint8_t *q = NULL, ch = 0;
int i = 0;
copy_block_aligned(p[0], a);
for(i = 0; i < 7; ++i)
@ -103,7 +103,7 @@ void gf_mul(gf_t a, const gf_t b)
*/
void init_64k_table(const gf_t g, gf_t64k_t t)
{ int i = 0, j, k;
{ int i = 0, j = 0, k = 0;
/*
depending on the representation we have to process bits
@ -189,7 +189,7 @@ void gf_mul_64k(gf_t a, const gf_t64k_t t, gf_t r)
#else
void gf_mul_64k(gf_t a, const gf_t64k_t t, gf_t r)
{ int i;
{ int i = 0;
uint8_t *ap = (uint8_t*)a;
memset(r, 0, GF_BYTE_LEN);
for(i = 15; i >= 0; --i)
@ -216,7 +216,7 @@ void gf_mul_64k(gf_t a, const gf_t64k_t t, gf_t r)
in total.
*/
void init_8k_table(const gf_t g, gf_t8k_t t)
{ int i = 0, j, k;
{ int i = 0, j = 0, k = 0;
/* do the low 4-bit nibble first - t[0][16] - and note
that the unit multiplier sits at 0x01 - t[0][1] in
@ -293,7 +293,7 @@ void gf_mul_8k(gf_t a, const gf_t8k_t t, gf_t r)
#else
void gf_mul_8k(gf_t a, const gf_t8k_t t, gf_t r)
{ int i;
{ int i = 0;
uint8_t *ap = (uint8_t*)a;
memset(r, 0, GF_BYTE_LEN);
for(i = 15; i >= 0; --i)
@ -330,7 +330,7 @@ void gf_mul_8k(gf_t a, const gf_t8k_t t, gf_t r)
*/
void init_4k_table(const gf_t g, gf_t4k_t t)
{ int j, k;
{ int j = 0, k = 0;
memset(t[0], 0, GF_BYTE_LEN);
@ -407,7 +407,7 @@ void gf_mul_4k(gf_t a, const gf_t4k_t t, gf_t r)
*/
void init_256_table(const gf_t g, gf_t256_t t)
{ int j, k;
{ int j = 0, k = 0;
memset(t[0], 0, GF_BYTE_LEN);
@ -456,7 +456,7 @@ void gf_mul_256(gf_t a, const gf_t256_t t, gf_t r)
#else
void gf_mul_256(gf_t a, const gf_t256_t t, gf_t r)
{ int i;
{ int i = 0;
uint8_t *ap = (uint8_t*)a;
memset(r, 0, GF_BYTE_LEN);
for(i = 15; i >= 0; --i)

@ -197,7 +197,7 @@ ms ls ms ls ms ls ms ls ms ls ms ls ms ls ms ls
#endif
gf_decl void gf_mulx1_ll(gf_t r, const gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = gf_tab[(UNIT_PTR(x)[1] >> 63) & 0x01];
#else
@ -208,7 +208,7 @@ gf_decl void gf_mulx1_ll(gf_t r, const gf_t x)
}
gf_decl void gf_mulx4_ll(gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = gf_tab[(UNIT_PTR(x)[1] >> 60) & 0x0f];
#else
@ -219,7 +219,7 @@ gf_decl void gf_mulx4_ll(gf_t x)
}
gf_decl void gf_mulx8_ll(gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = gf_tab[UNIT_PTR(x)[1] >> 56];
#else
@ -244,7 +244,7 @@ gf_decl void gf_mulx8_ll(gf_t x)
#endif
gf_decl void gf_mulx1_ll(gf_t r, const gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = gf_tab[(UNIT_PTR(x)[3] >> 31) & 0x01];
#else
@ -255,7 +255,7 @@ gf_decl void gf_mulx1_ll(gf_t r, const gf_t x)
}
gf_decl void gf_mulx4_ll(gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = gf_tab[(UNIT_PTR(x)[3] >> 28) & 0x0f];
#else
@ -266,7 +266,7 @@ gf_decl void gf_mulx4_ll(gf_t x)
}
gf_decl void gf_mulx8_ll(gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = gf_tab[UNIT_PTR(x)[3] >> 24];
#else
@ -282,7 +282,7 @@ gf_decl void gf_mulx8_ll(gf_t x)
#define f4_ll(n,r,x) r[n] = (x[n] << 4) | (n ? x[n-1] >> 4 : 0)
gf_decl void gf_mulx1_ll(gf_t r, const gf_t x)
{ uint16_t _tt;
{ uint16_t _tt = 0;
_tt = gf_tab[(UNIT_PTR(x)[15] >> 7) & 0x01];
rep2_d16(f1_ll, UNIT_PTR(r), UNIT_PTR(x));
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
@ -293,7 +293,7 @@ gf_decl void gf_mulx1_ll(gf_t r, const gf_t x)
}
gf_decl void gf_mulx4_ll(gf_t x)
{ uint16_t _tt;
{ uint16_t _tt = 0;
_tt = gf_tab[(UNIT_PTR(x)[15] >> 4) & 0x0f];
rep2_d16(f4_ll, UNIT_PTR(x), UNIT_PTR(x));
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
@ -306,7 +306,7 @@ gf_decl void gf_mulx4_ll(gf_t x)
}
gf_decl void gf_mulx8_ll(gf_t x)
{ uint16_t _tt;
{ uint16_t _tt = 0;
_tt = gf_tab[UNIT_PTR(x)[15]];
memmove(UNIT_PTR(x) + 1, UNIT_PTR(x), 15);
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
@ -347,7 +347,7 @@ ms ls ms ls ms ls ms ls ms ls ms ls ms ls ms ls
#endif
gf_decl void gf_mulx1_bl(gf_t r, const gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = ((gf_unit_t)(gf_tab[(UNIT_PTR(x)[0] >> 7) & 0x01])) << 48;
#else
@ -358,7 +358,7 @@ gf_decl void gf_mulx1_bl(gf_t r, const gf_t x)
}
gf_decl void gf_mulx4_bl(gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = ((gf_unit_t)(gf_tab[(UNIT_PTR(x)[0] >> 4) & 0x0f])) << 48;
#else
@ -369,7 +369,7 @@ gf_decl void gf_mulx4_bl(gf_t x)
}
gf_decl void gf_mulx8_bl(gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = ((gf_unit_t)(gf_tab[UNIT_PTR(x)[0] & 0xff])) << 48;
#else
@ -394,7 +394,7 @@ gf_decl void gf_mulx8_bl(gf_t x)
#endif
gf_decl void gf_mulx1_bl(gf_t r, const gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = ((gf_unit_t)(gf_tab[(UNIT_PTR(x)[0] >> 7) & 0x01])) << 16;
#else
@ -405,7 +405,7 @@ gf_decl void gf_mulx1_bl(gf_t r, const gf_t x)
}
gf_decl void gf_mulx4_bl(gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = ((gf_unit_t)(gf_tab[(UNIT_PTR(x)[0] >> 4) & 0x0f])) << 16;
#else
@ -416,7 +416,7 @@ gf_decl void gf_mulx4_bl(gf_t x)
}
gf_decl void gf_mulx8_bl(gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = ((gf_unit_t)(gf_tab[UNIT_PTR(x)[0] & 0xff])) << 16;
#else
@ -432,7 +432,7 @@ gf_decl void gf_mulx8_bl(gf_t x)
#define f4_bl(n,r,x) r[n] = (x[n] << 4) | (n < 15 ? x[n+1] >> 4 : 0)
gf_decl void gf_mulx1_bl(gf_t r, const gf_t x)
{ uint16_t _tt;
{ uint16_t _tt = 0;
_tt = gf_tab[(UNIT_PTR(x)[0] >> 7) & 0x01];
rep2_u16(f1_bl, UNIT_PTR(r), UNIT_PTR(x));
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
@ -443,7 +443,7 @@ gf_decl void gf_mulx1_bl(gf_t r, const gf_t x)
}
gf_decl void gf_mulx4_bl(gf_t x)
{ uint16_t _tt;
{ uint16_t _tt = 0;
_tt = gf_tab[(UNIT_PTR(x)[0] >> 4) & 0x0f];
rep2_u16(f4_bl, UNIT_PTR(x), UNIT_PTR(x));
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
@ -456,7 +456,7 @@ gf_decl void gf_mulx4_bl(gf_t x)
}
gf_decl void gf_mulx8_bl(gf_t x)
{ uint16_t _tt;
{ uint16_t _tt = 0;
_tt = gf_tab[UNIT_PTR(x)[0]];
memmove(UNIT_PTR(x), UNIT_PTR(x) + 1, 15);
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
@ -497,7 +497,7 @@ ms ls ms ls ms ls ms ls ms ls ms ls ms ls ms ls
#endif
gf_decl void gf_mulx1_lb(gf_t r, const gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = gf_tab[(UNIT_PTR(x)[1] >> 49) & MASK(0x80)];
#else
@ -508,7 +508,7 @@ gf_decl void gf_mulx1_lb(gf_t r, const gf_t x)
}
gf_decl void gf_mulx4_lb(gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = gf_tab[(UNIT_PTR(x)[1] >> 52) & MASK(0xf0)];
#else
@ -519,7 +519,7 @@ gf_decl void gf_mulx4_lb(gf_t x)
}
gf_decl void gf_mulx8_lb(gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = gf_tab[UNIT_PTR(x)[1] >> 56];
#else
@ -544,7 +544,7 @@ gf_decl void gf_mulx8_lb(gf_t x)
#endif
gf_decl void gf_mulx1_lb(gf_t r, const gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = gf_tab[(UNIT_PTR(x)[3] >> 17) & MASK(0x80)];
#else
@ -555,7 +555,7 @@ gf_decl void gf_mulx1_lb(gf_t r, const gf_t x)
}
gf_decl void gf_mulx4_lb(gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = gf_tab[(UNIT_PTR(x)[3] >> 20) & MASK(0xf0)];
#else
@ -566,7 +566,7 @@ gf_decl void gf_mulx4_lb(gf_t x)
}
gf_decl void gf_mulx8_lb(gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = gf_tab[UNIT_PTR(x)[3] >> 24];
#else
@ -582,7 +582,7 @@ gf_decl void gf_mulx8_lb(gf_t x)
#define f4_lb(n,r,x) r[n] = (x[n] >> 4) | (n ? x[n-1] << 4 : 0)
gf_decl void gf_mulx1_lb(gf_t r, const gf_t x)
{ uint16_t _tt;
{ uint16_t _tt = 0;
_tt = gf_tab[(UNIT_PTR(x)[15] << 7) & 0x80];
rep2_d16(f1_lb, UNIT_PTR(r), UNIT_PTR(x));
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
@ -593,7 +593,7 @@ gf_decl void gf_mulx1_lb(gf_t r, const gf_t x)
}
gf_decl void gf_mulx4_lb(gf_t x)
{ uint16_t _tt;
{ uint16_t _tt = 0;
_tt = gf_tab[(UNIT_PTR(x)[15] << 4) & 0xf0];
rep2_d16(f4_lb, UNIT_PTR(x), UNIT_PTR(x));
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
@ -606,7 +606,7 @@ gf_decl void gf_mulx4_lb(gf_t x)
}
gf_decl void gf_mulx8_lb(gf_t x)
{ uint16_t _tt;
{ uint16_t _tt = 0;
_tt = gf_tab[UNIT_PTR(x)[15]];
memmove(UNIT_PTR(x) + 1, UNIT_PTR(x), 15);
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
@ -647,7 +647,7 @@ ms ls ms ls ms ls ms ls ms ls ms ls ms ls ms ls
#endif
gf_decl void gf_mulx1_bb(gf_t r, const gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = (( gf_unit_t)(gf_tab[(UNIT_PTR(x)[0] << 7) & 0x80])) << 48;
#else
@ -658,7 +658,7 @@ gf_decl void gf_mulx1_bb(gf_t r, const gf_t x)
}
gf_decl void gf_mulx4_bb(gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = ((gf_unit_t)(gf_tab[(UNIT_PTR(x)[0] << 4) & 0xf0])) << 48;
#else
@ -669,7 +669,7 @@ gf_decl void gf_mulx4_bb(gf_t x)
}
gf_decl void gf_mulx8_bb(gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = ((gf_unit_t)(gf_tab[UNIT_PTR(x)[0] & 0xff])) << 48;
#else
@ -694,7 +694,7 @@ gf_decl void gf_mulx8_bb(gf_t x)
#endif
gf_decl void gf_mulx1_bb(gf_t r, const gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = ((gf_unit_t)(gf_tab[(UNIT_PTR(x)[0] << 7) & 0x80])) << 16;
#else
@ -705,7 +705,7 @@ gf_decl void gf_mulx1_bb(gf_t r, const gf_t x)
}
gf_decl void gf_mulx4_bb(gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = ((gf_unit_t)(gf_tab[(UNIT_PTR(x)[0] << 4) & 0xf0])) << 16;
#else
@ -716,7 +716,7 @@ gf_decl void gf_mulx4_bb(gf_t x)
}
gf_decl void gf_mulx8_bb(gf_t x)
{ gf_unit_t _tt;
{ gf_unit_t _tt = 0;
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
_tt = ((gf_unit_t)(gf_tab[UNIT_PTR(x)[0] & 0xff])) << 16;
#else
@ -732,7 +732,7 @@ gf_decl void gf_mulx8_bb(gf_t x)
#define f4_bb(n,r,x) r[n] = (x[n] >> 4) | (n < 15 ? x[n+1] << 4 : 0)
gf_decl void gf_mulx1_bb(gf_t r, const gf_t x)
{ uint16_t _tt;
{ uint16_t _tt = 0;
_tt = gf_tab[(UNIT_PTR(x)[0] << 7) & 0x80];
rep2_u16(f1_bb, UNIT_PTR(r), UNIT_PTR(x));
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
@ -743,7 +743,7 @@ gf_decl void gf_mulx1_bb(gf_t r, const gf_t x)
}
gf_decl void gf_mulx4_bb(gf_t x)
{ uint16_t _tt;
{ uint16_t _tt = 0;
_tt = gf_tab[(UNIT_PTR(x)[0] << 4) & 0xf0];
rep2_u16(f4_bb, UNIT_PTR(x), UNIT_PTR(x));
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
@ -756,7 +756,7 @@ gf_decl void gf_mulx4_bb(gf_t x)
}
gf_decl void gf_mulx8_bb(gf_t x)
{ uint16_t _tt;
{ uint16_t _tt = 0;
_tt = gf_tab[UNIT_PTR(x)[0]];
memmove(UNIT_PTR(x), UNIT_PTR(x) + 1, 15);
#if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN

@ -243,7 +243,7 @@ mh_decl void xor_block_aligned(void *r, const void *p, const void *q)
mh_decl void bswap32_block(void *d, const void* s)
{
#if UNIT_BITS == 8
uint8_t t;
uint8_t t = 0;
t = UNIT_PTR(s)[ 0]; UNIT_PTR(d)[ 0] = UNIT_PTR(s)[ 3]; UNIT_PTR(d)[ 3] = t;
t = UNIT_PTR(s)[ 1]; UNIT_PTR(d)[ 1] = UNIT_PTR(s)[ 2]; UNIT_PTR(d)[ 2] = t;
t = UNIT_PTR(s)[ 4]; UNIT_PTR(d)[ 4] = UNIT_PTR(s)[ 7]; UNIT_PTR(d)[ 7] = t;
@ -265,7 +265,7 @@ mh_decl void bswap32_block(void *d, const void* s)
mh_decl void bswap64_block(void *d, const void* s)
{
#if UNIT_BITS == 8
uint8_t t;
uint8_t t = 0;
t = UNIT_PTR(s)[ 0]; UNIT_PTR(d)[ 0] = UNIT_PTR(s)[ 7]; UNIT_PTR(d)[ 7] = t;
t = UNIT_PTR(s)[ 1]; UNIT_PTR(d)[ 1] = UNIT_PTR(s)[ 6]; UNIT_PTR(d)[ 6] = t;
t = UNIT_PTR(s)[ 2]; UNIT_PTR(d)[ 2] = UNIT_PTR(s)[ 5]; UNIT_PTR(d)[ 5] = t;
@ -275,7 +275,7 @@ mh_decl void bswap64_block(void *d, const void* s)
t = UNIT_PTR(s)[10]; UNIT_PTR(d)[10] = UNIT_PTR(s)[13]; UNIT_PTR(d)[13] = t;
t = UNIT_PTR(s)[11]; UNIT_PTR(d)[11] = UNIT_PTR(s)[12]; UNIT_PTR(d)[12] = t;
#elif UNIT_BITS == 32
uint32_t t;
uint32_t t = 0;
t = bswap_32(UNIT_PTR(s)[0]); UNIT_PTR(d)[0] = bswap_32(UNIT_PTR(s)[1]); UNIT_PTR(d)[1] = t;
t = bswap_32(UNIT_PTR(s)[2]); UNIT_PTR(d)[2] = bswap_32(UNIT_PTR(s)[2]); UNIT_PTR(d)[3] = t;
#else
@ -286,7 +286,7 @@ mh_decl void bswap64_block(void *d, const void* s)
mh_decl void bswap128_block(void *d, const void* s)
{
#if UNIT_BITS == 8
uint8_t t;
uint8_t t = 0;
t = UNIT_PTR(s)[0]; UNIT_PTR(d)[0] = UNIT_PTR(s)[15]; UNIT_PTR(d)[15] = t;
t = UNIT_PTR(s)[1]; UNIT_PTR(d)[1] = UNIT_PTR(s)[14]; UNIT_PTR(d)[14] = t;
t = UNIT_PTR(s)[2]; UNIT_PTR(d)[2] = UNIT_PTR(s)[13]; UNIT_PTR(d)[13] = t;
@ -296,11 +296,11 @@ mh_decl void bswap128_block(void *d, const void* s)
t = UNIT_PTR(s)[6]; UNIT_PTR(d)[6] = UNIT_PTR(s)[ 9]; UNIT_PTR(d)[ 9] = t;
t = UNIT_PTR(s)[7]; UNIT_PTR(d)[7] = UNIT_PTR(s)[ 8]; UNIT_PTR(d)[ 8] = t;
#elif UNIT_BITS == 32
uint32_t t;
uint32_t t = 0;
t = bswap_32(UNIT_PTR(s)[0]); UNIT_PTR(d)[0] = bswap_32(UNIT_PTR(s)[3]); UNIT_PTR(d)[3] = t;
t = bswap_32(UNIT_PTR(s)[1]); UNIT_PTR(d)[1] = bswap_32(UNIT_PTR(s)[2]); UNIT_PTR(d)[2] = t;
#else
uint64_t t;
uint64_t t = 0;
t = bswap_64(UNIT_PTR(s)[0]); UNIT_PTR(d)[0] = bswap_64(UNIT_PTR(s)[1]); UNIT_PTR(d)[1] = t;
#endif
}

Loading…
Cancel
Save