Skip to content

Commit 0a75b01

Browse files
committed
Add debug asserts on output lengths
1 parent b99e78d commit 0a75b01

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

aws-lc-rs/src/cipher/streaming.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ impl StreamingEncryptingKey {
136136
return Err(Unspecified);
137137
}
138138
let outlen: usize = outlen.try_into()?;
139+
debug_assert!(outlen <= min_outsize);
139140
Ok(BufferUpdate::new(output, outlen))
140141
}
141142

@@ -167,6 +168,7 @@ impl StreamingEncryptingKey {
167168
return Err(Unspecified);
168169
}
169170
let outlen: usize = outlen.try_into()?;
171+
debug_assert!(outlen <= self.algorithm().block_len());
170172
Ok((self.context.into(), BufferUpdate::new(output, outlen)))
171173
}
172174

@@ -322,6 +324,7 @@ impl StreamingDecryptingKey {
322324
return Err(Unspecified);
323325
}
324326
let outlen: usize = outlen.try_into()?;
327+
debug_assert!(outlen <= min_outsize);
325328
Ok(BufferUpdate::new(output, outlen))
326329
}
327330

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

0 commit comments

Comments
 (0)