Skip to content

Commit

Permalink
Merge pull request #71 from cisco/70-bigendian-fails
Browse files Browse the repository at this point in the history
Fix: explicitly cast to uint32_t to mitigate endian-ness problems
  • Loading branch information
balthorium authored May 11, 2019
2 parents 3c86784 + d251396 commit 579732b
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 @@ -39,7 +39,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 @@ -99,7 +99,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 @@ -141,7 +141,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 579732b

Please sign in to comment.