Skip to content

Commit

Permalink
Merge #18: Fix overflow on 16 bit systems
Browse files Browse the repository at this point in the history
34d24e9 Fix overflow on 16 bit systems (Pieter Wuille)

Pull request description:

  Fixes #15

Top commit has no ACKs.

Tree-SHA512: 8c7c07b6f14835972811b1507034bba36f99a55fd7e5cfe0bd43049610925c3e9ae01d8b9371d9a17245e7e2796a652e822564d66c146323e402505131524e69
  • Loading branch information
sipa committed Aug 15, 2020
2 parents fd8fe83 + 34d24e9 commit 3d61b58
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ctaes.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
static void LoadByte(AES_state* s, unsigned char byte, int r, int c) {
int i;
for (i = 0; i < 8; i++) {
s->slice[i] |= (byte & 1) << (r * 4 + c);
s->slice[i] |= (uint16_t)(byte & 1) << (r * 4 + c);
byte >>= 1;
}
}
Expand Down Expand Up @@ -255,7 +255,7 @@ static void SubBytes(AES_state *s, int inv) {
}
}

#define BIT_RANGE(from,to) (((1 << ((to) - (from))) - 1) << (from))
#define BIT_RANGE(from,to) ((uint16_t)((1 << ((to) - (from))) - 1) << (from))

#define BIT_RANGE_LEFT(x,from,to,shift) (((x) & BIT_RANGE((from), (to))) << (shift))
#define BIT_RANGE_RIGHT(x,from,to,shift) (((x) & BIT_RANGE((from), (to))) >> (shift))
Expand Down

0 comments on commit 3d61b58

Please sign in to comment.