Skip to content

Commit 67ec1e5

Browse files
authored
call check_length early on AesSiv::encrypt (#14792)
This is an optimization to early exit before allocating a PyBytes when the buffer is too large and would error inside the encrypt_into (which also calls check_length)
1 parent b2da57a commit 67ec1e5

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

src/rust/src/backend/aead.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,7 @@ impl AesSiv {
11351135
data: CffiBuf<'_>,
11361136
associated_data: Option<pyo3::Bound<'p, pyo3::types::PyList>>,
11371137
) -> CryptographyResult<pyo3::Bound<'p, pyo3::types::PyBytes>> {
1138+
check_length(data.as_bytes())?;
11381139
Ok(pyo3::types::PyBytes::new_with(
11391140
py,
11401141
data.as_bytes().len() + self.ctx.tag_len,

0 commit comments

Comments
 (0)