Merge branch 'master' of github.com:jedisct1/libsodium

* 'master' of github.com:jedisct1/libsodium:
  Indent
  Fixes padding for blocksizes > 256
This commit is contained in:
Frank Denis 2018-08-29 14:02:38 +02:00
commit d754716599
2 changed files with 3 additions and 2 deletions

View File

@ -695,7 +695,8 @@ sodium_pad(size_t *padded_buflen_p, unsigned char *buf,
} }
mask = 0U; mask = 0U;
for (i = 0; i < blocksize; i++) { 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); tail[-i] = (tail[-i] & mask) | (0x80 & barrier_mask);
mask |= barrier_mask; mask |= barrier_mask;
} }

View File

@ -144,7 +144,7 @@ main(void)
for (i = 0; i < 2000U; i++) { for (i = 0; i < 2000U; i++) {
bin_len = randombytes_uniform(200U); 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_maxlen = bin_len + (blocksize - bin_len % blocksize);
bin_padded = (unsigned char *) sodium_malloc(bin_padded_maxlen); bin_padded = (unsigned char *) sodium_malloc(bin_padded_maxlen);
randombytes_buf(bin_padded, bin_padded_maxlen); randombytes_buf(bin_padded, bin_padded_maxlen);