Fix padding in AES-CTR native module
@@ -102,10 +102,7 @@ impl AesCounterModeService {
let block_size = cypher.block_size();
// For some reason, the length of the output buffer needs to be
// a multiple of the block size and at least two blocks:
- let padded_size = std::cmp::max(
- 2 * block_size,
- (input.len() + block_size - 1) / block_size * block_size,
- );
+ let padded_size = (input.len() + 2 * block_size - 1) / block_size * block_size;
output.resize(padded_size, 0);
cypher
@@ -124,10 +121,7 @@ impl AesCounterModeService {
let block_size = cypher.block_size();
// For some reason, the length of the output buffer needs to be
// a multiple of the block size and at least two blocks:
- let padded_size = std::cmp::max(
- 2 * block_size,
- (input.len() + block_size - 1) / block_size * block_size,
- );
+ let padded_size = (input.len() + 2 * block_size - 1) / block_size * block_size;
output.resize(padded_size, 0);
cypher
