Skip to content

Commit

Permalink
Fix: explicitly cast to uint32_t to mitigate endian-ness problems
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxwolf committed May 16, 2018
1 parent b122181 commit d251396
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/concatkdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static uint8_t *_apply_lendata(const uint8_t *data, const size_t len, uint8_t *b
{
uint8_t *ptr = buffer;

ptr =_apply_uint32(len, ptr);
ptr =_apply_uint32((uint32_t)len, ptr);
if (0 < len)
{
memcpy(ptr, data, len);
Expand Down Expand Up @@ -92,7 +92,7 @@ bool cjose_concatkdf_create_otherinfo(const char *alg,
ptr = _apply_lendata((const uint8_t *)alg, algLen, ptr);
ptr = _apply_lendata(apu, apuLen, ptr);
ptr = _apply_lendata(apv, apvLen, ptr);
ptr = _apply_uint32(keylen, ptr);
ptr = _apply_uint32((uint32_t)keylen, ptr);

*otherinfoLen = bufferLen;
*otherinfo = buffer;
Expand Down Expand Up @@ -134,7 +134,7 @@ uint8_t *cjose_concatkdf_derive(const size_t keylen,
}

size_t offset = 0, amt = keylen;
for (int idx = 1; N >= idx; idx++)
for (uint32_t idx = 1; N >= idx; idx++)
{
uint8_t counter[4];
_apply_uint32(idx, counter);
Expand Down

0 comments on commit d251396

Please sign in to comment.