Skip to content

Commit

Permalink
Rename local variable in aes.c
Browse files Browse the repository at this point in the history
This changes local variable name RCON to round_constants.

RCON being definition in xc32 compiler headers for some PIC32 register.
Without this change mynewt project for PIC32 platform fails to build due to
macro redefinition.

This does not changes behavior of library in any way.

Signed-off-by: Jerzy Kasenberg <[email protected]>
  • Loading branch information
kasjer committed Oct 12, 2023
1 parent 44af436 commit 1222ae6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions library/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ static const uint32_t RT3[256] = { RT };
/*
* Round constants
*/
static const uint32_t RCON[10] =
static const uint32_t round_constants[10] =
{
0x00000001, 0x00000002, 0x00000004, 0x00000008,
0x00000010, 0x00000020, 0x00000040, 0x00000080,
Expand Down Expand Up @@ -381,7 +381,7 @@ static uint32_t RT3[256];
/*
* Round constants
*/
static uint32_t RCON[10];
static uint32_t round_constants[10];

/*
* Tables generation code
Expand Down Expand Up @@ -411,7 +411,7 @@ static void aes_gen_tables(void)
* calculate the round constants
*/
for (i = 0, x = 1; i < 10; i++) {
RCON[i] = (uint32_t) x;
round_constants[i] = (uint32_t) x;
x = MBEDTLS_BYTE_0(XTIME(x));
}

Expand Down Expand Up @@ -637,7 +637,7 @@ int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key,
case 10:

for (i = 0; i < 10; i++, RK += 4) {
RK[4] = RK[0] ^ RCON[i] ^
RK[4] = RK[0] ^ round_constants[i] ^
((uint32_t) FSb[MBEDTLS_BYTE_1(RK[3])]) ^
((uint32_t) FSb[MBEDTLS_BYTE_2(RK[3])] << 8) ^
((uint32_t) FSb[MBEDTLS_BYTE_3(RK[3])] << 16) ^
Expand All @@ -652,7 +652,7 @@ int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key,
case 12:

for (i = 0; i < 8; i++, RK += 6) {
RK[6] = RK[0] ^ RCON[i] ^
RK[6] = RK[0] ^ round_constants[i] ^
((uint32_t) FSb[MBEDTLS_BYTE_1(RK[5])]) ^
((uint32_t) FSb[MBEDTLS_BYTE_2(RK[5])] << 8) ^
((uint32_t) FSb[MBEDTLS_BYTE_3(RK[5])] << 16) ^
Expand All @@ -669,7 +669,7 @@ int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key,
case 14:

for (i = 0; i < 7; i++, RK += 8) {
RK[8] = RK[0] ^ RCON[i] ^
RK[8] = RK[0] ^ round_constants[i] ^
((uint32_t) FSb[MBEDTLS_BYTE_1(RK[7])]) ^
((uint32_t) FSb[MBEDTLS_BYTE_2(RK[7])] << 8) ^
((uint32_t) FSb[MBEDTLS_BYTE_3(RK[7])] << 16) ^
Expand Down

0 comments on commit 1222ae6

Please sign in to comment.