mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-19 18:15:18 -07:00
Merge pull request #751 from 0xbf00/master
Fixes padding for blocksizes > 256
This commit is contained in:
commit
f3c49f3bda
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user