Skip to content

Commit

Permalink
reduce sani warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
SciLor committed Sep 14, 2024
1 parent d260a95 commit 714a00e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
60 changes: 30 additions & 30 deletions src/cyclone/cyclone_crypto/cipher/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,17 @@ __weak_func error_t aesInit(AesContext *context, const uint8_t *key,
if((i % keyLen) == 0)
{
context->ek[i] = sbox[(temp >> 8) & 0xFF];
context->ek[i] |= (sbox[(temp >> 16) & 0xFF] << 8);
context->ek[i] |= (sbox[(temp >> 24) & 0xFF] << 16);
context->ek[i] |= (sbox[temp & 0xFF] << 24);
context->ek[i] |= ((uint64_t)sbox[(temp >> 16) & 0xFF] << 8);
context->ek[i] |= ((uint64_t)sbox[(temp >> 24) & 0xFF] << 16);
context->ek[i] |= ((uint64_t)sbox[temp & 0xFF] << 24);
context->ek[i] ^= rcon[i / keyLen];
}
else if(keyLen > 6 && (i % keyLen) == 4)
{
context->ek[i] = sbox[temp & 0xFF];
context->ek[i] |= (sbox[(temp >> 8) & 0xFF] << 8);
context->ek[i] |= (sbox[(temp >> 16) & 0xFF] << 16);
context->ek[i] |= (sbox[(temp >> 24) & 0xFF] << 24);
context->ek[i] |= ((uint64_t)sbox[(temp >> 8) & 0xFF] << 8);
context->ek[i] |= ((uint64_t)sbox[(temp >> 16) & 0xFF] << 16);
context->ek[i] |= ((uint64_t)sbox[(temp >> 24) & 0xFF] << 24);
}
else
{
Expand Down Expand Up @@ -380,24 +380,24 @@ __weak_func void aesEncryptBlock(AesContext *context, const uint8_t *input,

//The last round differs slightly from the first rounds
t0 = sbox[s0 & 0xFF];
t0 |= sbox[(s1 >> 8) & 0xFF] << 8;
t0 |= sbox[(s2 >> 16) & 0xFF] << 16;
t0 |= sbox[(s3 >> 24) & 0xFF] << 24;
t0 |= (uint64_t)sbox[(s1 >> 8) & 0xFF] << 8;
t0 |= (uint64_t)sbox[(s2 >> 16) & 0xFF] << 16;
t0 |= (uint64_t)sbox[(s3 >> 24) & 0xFF] << 24;

t1 = sbox[s1 & 0xFF];
t1 |= sbox[(s2 >> 8) & 0xFF] << 8;
t1 |= sbox[(s3 >> 16) & 0xFF] << 16;
t1 |= sbox[(s0 >> 24) & 0xFF] << 24;
t1 |= (uint64_t)sbox[(s2 >> 8) & 0xFF] << 8;
t1 |= (uint64_t)sbox[(s3 >> 16) & 0xFF] << 16;
t1 |= (uint64_t)sbox[(s0 >> 24) & 0xFF] << 24;

t2 = sbox[s2 & 0xFF];
t2 |= sbox[(s3 >> 8) & 0xFF] << 8;
t2 |= sbox[(s0 >> 16) & 0xFF] << 16;
t2 |= sbox[(s1 >> 24) & 0xFF] << 24;
t2 |= (uint64_t)sbox[(s3 >> 8) & 0xFF] << 8;
t2 |= (uint64_t)sbox[(s0 >> 16) & 0xFF] << 16;
t2 |= (uint64_t)sbox[(s1 >> 24) & 0xFF] << 24;

t3 = sbox[s3 & 0xFF];
t3 |= sbox[(s0 >> 8) & 0xFF] << 8;
t3 |= sbox[(s1 >> 16) & 0xFF] << 16;
t3 |= sbox[(s2 >> 24) & 0xFF] << 24;
t3 |= (uint64_t)sbox[(s0 >> 8) & 0xFF] << 8;
t3 |= (uint64_t)sbox[(s1 >> 16) & 0xFF] << 16;
t3 |= (uint64_t)sbox[(s2 >> 24) & 0xFF] << 24;

//Last round key addition
s0 = t0 ^ context->ek[context->nr * 4];
Expand Down Expand Up @@ -491,24 +491,24 @@ __weak_func void aesDecryptBlock(AesContext *context, const uint8_t *input,

//The last round differs slightly from the first rounds
t0 = isbox[s0 & 0xFF];
t0 |= isbox[(s3 >> 8) & 0xFF] << 8;
t0 |= isbox[(s2 >> 16) & 0xFF] << 16;
t0 |= isbox[(s1 >> 24) & 0xFF] << 24;
t0 |= (uint64_t)isbox[(s3 >> 8) & 0xFF] << 8;
t0 |= (uint64_t)isbox[(s2 >> 16) & 0xFF] << 16;
t0 |= (uint64_t)isbox[(s1 >> 24) & 0xFF] << 24;

t1 = isbox[s1 & 0xFF];
t1 |= isbox[(s0 >> 8) & 0xFF] << 8;
t1 |= isbox[(s3 >> 16) & 0xFF] << 16;
t1 |= isbox[(s2 >> 24) & 0xFF] << 24;
t1 |= (uint64_t)isbox[(s0 >> 8) & 0xFF] << 8;
t1 |= (uint64_t)isbox[(s3 >> 16) & 0xFF] << 16;
t1 |= (uint64_t)isbox[(s2 >> 24) & 0xFF] << 24;

t2 = isbox[s2 & 0xFF];
t2 |= isbox[(s1 >> 8) & 0xFF] << 8;
t2 |= isbox[(s0 >> 16) & 0xFF] << 16;
t2 |= isbox[(s3 >> 24) & 0xFF] << 24;
t2 |= (uint64_t)isbox[(s1 >> 8) & 0xFF] << 8;
t2 |= (uint64_t)isbox[(s0 >> 16) & 0xFF] << 16;
t2 |= (uint64_t)isbox[(s3 >> 24) & 0xFF] << 24;

t3 = isbox[s3 & 0xFF];
t3 |= isbox[(s2 >> 8) & 0xFF] << 8;
t3 |= isbox[(s1 >> 16) & 0xFF] << 16;
t3 |= isbox[(s0 >> 24) & 0xFF] << 24;
t3 |= (uint64_t)isbox[(s2 >> 8) & 0xFF] << 8;
t3 |= (uint64_t)isbox[(s1 >> 16) & 0xFF] << 16;
t3 |= (uint64_t)isbox[(s0 >> 24) & 0xFF] << 24;

//Last round key addition
s0 = t0 ^ context->dk[0];
Expand Down
2 changes: 1 addition & 1 deletion src/cyclone/cyclone_crypto/mpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ error_t mpiImport(Mpi *r, const uint8_t *data, uint_t length, MpiFormat format)
// Import data
for (i = 0; i < length; i++, data--)
{
r->data[i / MPI_INT_SIZE] |= *data << ((i % MPI_INT_SIZE) * 8);
r->data[i / MPI_INT_SIZE] |= (uint64_t)*data << ((i % MPI_INT_SIZE) * 8);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/handler_rtnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,17 @@ int32_t read_little_endian32(const uint8_t *buf)

int64_t read_little_endian64(const uint8_t *buf)
{
return ((int64_t)read_little_endian32(&buf[4])) | (((int64_t)read_little_endian32(buf)) << 32);
return ((int64_t)read_little_endian32(&buf[4])) | (((uint64_t)read_little_endian32(buf)) << 32);
}

int32_t read_big_endian32(const uint8_t *buf)
{
return (int32_t)(buf[3] | (buf[2] << 8) | (buf[1] << 16) | (buf[0] << 24));
return (int32_t)((uint32_t)buf[3] | ((uint32_t)buf[2] << 8) | ((uint32_t)buf[1] << 16) | ((uint32_t)buf[0] << 24));
}

int64_t read_big_endian64(const uint8_t *buf)
{
return ((int64_t)read_big_endian32(buf)) | (((int64_t)read_big_endian32(&buf[4])) << 32);
return ((int64_t)read_big_endian32(buf)) | (((uint64_t)read_big_endian32(&buf[4])) << 32);
}

static char *absolute_url(const char *url_or_path)
Expand Down

0 comments on commit 714a00e

Please sign in to comment.