diff --git a/src/libsodium/sodium/utils.c b/src/libsodium/sodium/utils.c index 3a5f835b..83bc04d3 100644 --- a/src/libsodium/sodium/utils.c +++ b/src/libsodium/sodium/utils.c @@ -695,7 +695,8 @@ sodium_pad(size_t *padded_buflen_p, unsigned char *buf, } mask = 0U; for (i = 0; i < blocksize; i++) { - barrier_mask = (unsigned char) (((i ^ xpadlen) - 1U) >> 8); + barrier_mask = (unsigned char) (((i ^ xpadlen) - 1U) + >> ((sizeof(size_t) - 1) * CHAR_BIT)); tail[-i] = (tail[-i] & mask) | (0x80 & barrier_mask); mask |= barrier_mask; } diff --git a/test/default/sodium_utils.c b/test/default/sodium_utils.c index db760cb1..24073f7a 100644 --- a/test/default/sodium_utils.c +++ b/test/default/sodium_utils.c @@ -144,7 +144,7 @@ main(void) for (i = 0; i < 2000U; i++) { bin_len = randombytes_uniform(200U); - blocksize = 1U + randombytes_uniform(100U); + blocksize = 1U + randombytes_uniform(500U); bin_padded_maxlen = bin_len + (blocksize - bin_len % blocksize); bin_padded = (unsigned char *) sodium_malloc(bin_padded_maxlen); randombytes_buf(bin_padded, bin_padded_maxlen);