methods: do not unnecessarily zero padding of input data

We only support stream ciphers, so trailing garbage in the last block
isn't an issue.
This commit is contained in:
Matthias Schiffer 2020-06-13 12:57:07 +02:00
parent 4d25d50366
commit 9ddd40e5b6
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C
2 changed files with 0 additions and 6 deletions

View file

@ -194,9 +194,6 @@ static bool method_encrypt(
*out = fastd_buffer_alloc( *out = fastd_buffer_alloc(
sizeof(fastd_block128_t) + in.len, COMMON_HEADROOM, sizeof(fastd_block128_t) + tail_len); sizeof(fastd_block128_t) + in.len, COMMON_HEADROOM, sizeof(fastd_block128_t) + tail_len);
if (tail_len)
memset(in.data + in.len, 0, tail_len);
int n_blocks = block_count(in.len, sizeof(fastd_block128_t)); int n_blocks = block_count(in.len, sizeof(fastd_block128_t));
fastd_block128_t *inblocks = in.data; fastd_block128_t *inblocks = in.data;

View file

@ -165,9 +165,6 @@ static bool method_encrypt(
size_t tail_len = alignto(in.len, sizeof(fastd_block128_t)) - in.len; size_t tail_len = alignto(in.len, sizeof(fastd_block128_t)) - in.len;
*out = fastd_buffer_alloc(in.len, COMMON_HEADROOM, sizeof(fastd_block128_t) + tail_len); *out = fastd_buffer_alloc(in.len, COMMON_HEADROOM, sizeof(fastd_block128_t) + tail_len);
if (tail_len)
memset(in.data + in.len, 0, tail_len);
uint8_t nonce[session->method->cipher_info->iv_length] __attribute__((aligned(8))); uint8_t nonce[session->method->cipher_info->iv_length] __attribute__((aligned(8)));
fastd_method_expand_nonce(nonce, session->common.send_nonce, sizeof(nonce)); fastd_method_expand_nonce(nonce, session->common.send_nonce, sizeof(nonce));