make cppcheck happy

raytac-diy
Thomas Göttgens 2022-04-26 21:24:21 +02:00
rodzic 76e48178c8
commit aaea2e7456
1 zmienionych plików z 12 dodań i 19 usunięć

Wyświetl plik

@ -43,10 +43,9 @@ static const uint8_t Rcon[11] = {
static void KeyExpansion(uint8_t* RoundKey, const uint8_t* Key)
{
unsigned i, j, k;
uint8_t tempa[4];
for (i = 0; i < Nk; ++i)
for (unsigned i = 0; i < Nk; ++i)
{
RoundKey[(i * 4) + 0] = Key[(i * 4) + 0];
RoundKey[(i * 4) + 1] = Key[(i * 4) + 1];
@ -57,7 +56,7 @@ static void KeyExpansion(uint8_t* RoundKey, const uint8_t* Key)
for (i = Nk; i < Nb * (Nr + 1); ++i)
{
{
k = (i - 1) * 4;
unsigned k = (i - 1) * 4;
tempa[0]=RoundKey[k + 0];
tempa[1]=RoundKey[k + 1];
tempa[2]=RoundKey[k + 2];
@ -89,7 +88,7 @@ static void KeyExpansion(uint8_t* RoundKey, const uint8_t* Key)
tempa[3] = getSBoxValue(tempa[3]);
}
j = i * 4; k=(i - Nk) * 4;
unsigned j = i * 4; k=(i - Nk) * 4;
RoundKey[j + 0] = RoundKey[k + 0] ^ tempa[0];
RoundKey[j + 1] = RoundKey[k + 1] ^ tempa[1];
RoundKey[j + 2] = RoundKey[k + 2] ^ tempa[2];
@ -113,10 +112,9 @@ void AES_ctx_set_iv(struct AES_ctx* ctx, const uint8_t* iv)
static void AddRoundKey(uint8_t round, state_t* state, const uint8_t* RoundKey)
{
uint8_t i,j;
for (i = 0; i < 4; ++i)
for (uint8_t i = 0; i < 4; ++i)
{
for (j = 0; j < 4; ++j)
for (uint8_t j = 0; j < 4; ++j)
{
(*state)[i][j] ^= RoundKey[(round * Nb * 4) + (i * Nb) + j];
}
@ -125,10 +123,9 @@ static void AddRoundKey(uint8_t round, state_t* state, const uint8_t* RoundKey)
static void SubBytes(state_t* state)
{
uint8_t i, j;
for (i = 0; i < 4; ++i)
for (uint8_t i = 0; i < 4; ++i)
{
for (j = 0; j < 4; ++j)
for (uint8_t j = 0; j < 4; ++j)
{
(*state)[j][i] = getSBoxValue((*state)[j][i]);
}
@ -137,9 +134,7 @@ static void SubBytes(state_t* state)
static void ShiftRows(state_t* state)
{
uint8_t temp;
temp = (*state)[0][1];
uint8_t temp = (*state)[0][1];
(*state)[0][1] = (*state)[1][1];
(*state)[1][1] = (*state)[2][1];
(*state)[2][1] = (*state)[3][1];
@ -167,13 +162,11 @@ static uint8_t xtime(uint8_t x)
static void MixColumns(state_t* state)
{
uint8_t i;
uint8_t Tmp, Tm, t;
for (i = 0; i < 4; ++i)
for (uint8_t i = 0; i < 4; ++i)
{
t = (*state)[i][0];
Tmp = (*state)[i][0] ^ (*state)[i][1] ^ (*state)[i][2] ^ (*state)[i][3] ;
Tm = (*state)[i][0] ^ (*state)[i][1] ; Tm = xtime(Tm); (*state)[i][0] ^= Tm ^ Tmp ;
uint8_t t = (*state)[i][0];
uint8_t Tmp = (*state)[i][0] ^ (*state)[i][1] ^ (*state)[i][2] ^ (*state)[i][3] ;
uint8_t Tm = (*state)[i][0] ^ (*state)[i][1] ; Tm = xtime(Tm); (*state)[i][0] ^= Tm ^ Tmp ;
Tm = (*state)[i][1] ^ (*state)[i][2] ; Tm = xtime(Tm); (*state)[i][1] ^= Tm ^ Tmp ;
Tm = (*state)[i][2] ^ (*state)[i][3] ; Tm = xtime(Tm); (*state)[i][2] ^= Tm ^ Tmp ;
Tm = (*state)[i][3] ^ t ; Tm = xtime(Tm); (*state)[i][3] ^= Tm ^ Tmp ;