diff --git a/c8_remote/include/dev/types.h b/c8_remote/include/dev/types.h index d371813..d811ec3 100644 --- a/c8_remote/include/dev/types.h +++ b/c8_remote/include/dev/types.h @@ -12,9 +12,9 @@ struct event struct aes_constants { unsigned char sbox[16][16]; - unsigned char rc_lookup[11]; unsigned char mul2[256]; unsigned char mul3[256]; + unsigned char rc_lookup[11]; } __attribute__ ((packed)); struct bern_data diff --git a/c8_remote/lib/crypto/aes_sw_host.c b/c8_remote/lib/crypto/aes_sw_host.c index 31ebf2f..b3ac392 100644 --- a/c8_remote/lib/crypto/aes_sw_host.c +++ b/c8_remote/lib/crypto/aes_sw_host.c @@ -23,8 +23,6 @@ static const unsigned char sbox[256] = 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 }; -static const unsigned char rc_lookup[11] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c}; - static const unsigned char mul2_lookup[256] = { 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, @@ -65,14 +63,16 @@ static const unsigned char mul3_lookup[256] = 0x0b, 0x08, 0x0d, 0x0e, 0x07, 0x04, 0x01, 0x02, 0x13, 0x10, 0x15, 0x16, 0x1f, 0x1c, 0x19, 0x1a }; +static const unsigned char rc_lookup[11] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c}; + struct aes_constants *get_constants() { struct aes_constants *res = malloc(sizeof(struct aes_constants)); memcpy(res->sbox, sbox, sizeof(sbox)); - memcpy(res->rc_lookup, rc_lookup, sizeof(rc_lookup)); memcpy(res->mul2, mul2_lookup, sizeof(mul2_lookup)); memcpy(res->mul3, mul3_lookup, sizeof(mul3_lookup)); + memcpy(res->rc_lookup, rc_lookup, sizeof(rc_lookup)); return res; } \ No newline at end of file