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