@@ -556,11 +556,8 @@ impl CipherCtxRef {
556
556
output : Option < & mut [ u8 ] > ,
557
557
) -> Result < usize , ErrorStack > {
558
558
if let Some ( output) = & output {
559
- let mut block_size = self . block_size ( ) ;
560
- if block_size == 1 {
561
- block_size = 0 ;
562
- }
563
- let min_output_size = input. len ( ) + block_size;
559
+ let block_size = self . block_size ( ) ;
560
+ let min_output_size = input. len ( ) + block_size - 1 ;
564
561
assert ! (
565
562
output. len( ) >= min_output_size,
566
563
"Output buffer size should be at least {} bytes." ,
@@ -910,19 +907,19 @@ mod test {
910
907
}
911
908
912
909
#[ test]
913
- #[ should_panic( expected = "Output buffer size should be at least 33 bytes." ) ]
910
+ #[ should_panic( expected = "Output buffer size should be at least 32 bytes." ) ]
914
911
fn full_block_updates_aes_128 ( ) {
915
912
output_buffer_too_small ( Cipher :: aes_128_cbc ( ) ) ;
916
913
}
917
914
918
915
#[ test]
919
- #[ should_panic( expected = "Output buffer size should be at least 33 bytes." ) ]
916
+ #[ should_panic( expected = "Output buffer size should be at least 32 bytes." ) ]
920
917
fn full_block_updates_aes_256 ( ) {
921
918
output_buffer_too_small ( Cipher :: aes_256_cbc ( ) ) ;
922
919
}
923
920
924
921
#[ test]
925
- #[ should_panic( expected = "Output buffer size should be at least 17 bytes." ) ]
922
+ #[ should_panic( expected = "Output buffer size should be at least 16 bytes." ) ]
926
923
fn full_block_updates_3des ( ) {
927
924
output_buffer_too_small ( Cipher :: des_ede3_cbc ( ) ) ;
928
925
}
0 commit comments