File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -99,8 +99,10 @@ fn main() -> anyhow::Result<()> {
99
99
) ?;
100
100
101
101
let block_size = cipher. block_size ( ) ;
102
- let padded_size = ( input. len ( ) + 2 * block_size - 1 ) / block_size * block_size;
103
-
102
+ // Mbed TLS requires the output buffer to be at least
103
+ // `ilen + block_size` long.
104
+ // Cf. the documentation of `mbedtls_cipher_update()`
105
+ let padded_size = input. len ( ) + block_size;
104
106
output. resize ( padded_size, 0 ) ;
105
107
106
108
cipher
@@ -134,7 +136,10 @@ fn main() -> anyhow::Result<()> {
134
136
) ?;
135
137
136
138
let block_size = cipher. block_size ( ) ;
137
- let padded_size = ( input. len ( ) + 2 * block_size - 1 ) / block_size * block_size;
139
+ // Mbed TLS requires the output buffer to be at least
140
+ // `ilen + block_size` long.
141
+ // Cf. the documentation of `mbedtls_cipher_update()`
142
+ let padded_size = input. len ( ) + block_size;
138
143
output. resize ( padded_size, 0 ) ;
139
144
140
145
cipher
You can’t perform that action at this time.
0 commit comments