Skip to content

Commit

Permalink
Add debug asserts on output lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Jun 17, 2024
1 parent b99e78d commit 0a75b01
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions aws-lc-rs/src/cipher/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ impl StreamingEncryptingKey {
return Err(Unspecified);
}
let outlen: usize = outlen.try_into()?;
debug_assert!(outlen <= min_outsize);
Ok(BufferUpdate::new(output, outlen))
}

Expand Down Expand Up @@ -167,6 +168,7 @@ impl StreamingEncryptingKey {
return Err(Unspecified);
}
let outlen: usize = outlen.try_into()?;
debug_assert!(outlen <= self.algorithm().block_len());
Ok((self.context.into(), BufferUpdate::new(output, outlen)))
}

Expand Down Expand Up @@ -322,6 +324,7 @@ impl StreamingDecryptingKey {
return Err(Unspecified);
}
let outlen: usize = outlen.try_into()?;
debug_assert!(outlen <= min_outsize);
Ok(BufferUpdate::new(output, outlen))
}

Expand All @@ -345,6 +348,7 @@ impl StreamingDecryptingKey {
return Err(Unspecified);
}
let outlen: usize = outlen.try_into()?;
debug_assert!(outlen <= self.algorithm().block_len());
Ok(BufferUpdate::new(output, outlen))
}

Expand Down

0 comments on commit 0a75b01

Please sign in to comment.