mirror of
https://github.com/tlsnotary/tlsn.git
synced 2026-01-07 22:03:58 -05:00
fix: empty auth ranges (#1016)
This commit is contained in:
@@ -35,6 +35,11 @@ where
|
||||
Self { map }
|
||||
}
|
||||
|
||||
/// Returns `true` if the map is empty.
|
||||
pub(crate) fn is_empty(&self) -> bool {
|
||||
self.map.is_empty()
|
||||
}
|
||||
|
||||
/// Returns the keys of the map.
|
||||
pub(crate) fn keys(&self) -> impl Iterator<Item = Range<usize>> {
|
||||
self.map
|
||||
|
||||
@@ -168,6 +168,10 @@ fn alloc_plaintext(
|
||||
) -> Result<ReferenceMap, PlaintextAuthError> {
|
||||
let len = ranges.len();
|
||||
|
||||
if len == 0 {
|
||||
return Ok(ReferenceMap::default());
|
||||
}
|
||||
|
||||
let plaintext = vm.alloc_vec::<U8>(len).map_err(PlaintextAuthError::vm)?;
|
||||
|
||||
let mut pos = 0;
|
||||
@@ -189,6 +193,10 @@ fn alloc_ciphertext<'a>(
|
||||
plaintext: ReferenceMap,
|
||||
records: impl IntoIterator<Item = &'a RecordParams>,
|
||||
) -> Result<ReferenceMap, PlaintextAuthError> {
|
||||
if plaintext.is_empty() {
|
||||
return Ok(ReferenceMap::default());
|
||||
}
|
||||
|
||||
let ranges = RangeSet::from(plaintext.keys().collect::<Vec<_>>());
|
||||
|
||||
let keystream = alloc_keystream(vm, key, iv, &ranges, records)?;
|
||||
|
||||
Reference in New Issue
Block a user