Skip to content

Commit

Permalink
fixup! Always set IV length for ciphers that use an IV
Browse files Browse the repository at this point in the history
  • Loading branch information
lwestlund committed May 31, 2024
1 parent 551fd25 commit 20ce889
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions openssl/src/symm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,15 @@ impl Crypter {

ctx.set_key_length(key.len())?;

if let (Some(iv), Some(_iv_len)) = (iv, t.iv_len()) {
ctx.set_iv_length(iv.len())?;
if let (Some(iv), Some(iv_len)) = (iv, t.iv_len()) {
if iv.len() != iv_len
|| matches!(
t.nid(),
Nid::AES_128_CCM | Nid::AES_192_CCM | Nid::AES_256_CCM
)
{
ctx.set_iv_length(iv.len())?;
}
}

f(&mut ctx, None, Some(key), iv)?;
Expand Down

0 comments on commit 20ce889

Please sign in to comment.