From 22d78afeab094c7f3575debbe31e1d1036ab8ce5 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Tue, 31 Dec 2024 16:18:05 -0800 Subject: [PATCH] aes_gcm internals: Clarify `in_out` processing in `open_strided`. Use `in_out` for `Overlapping` values and `in_out_slice` for slices. Use `Overlapping::new` as the sole way of bounds checking `src`. --- src/aead/aes_gcm.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/aead/aes_gcm.rs b/src/aead/aes_gcm.rs index 3ec133b15..fabaef95f 100644 --- a/src/aead/aes_gcm.rs +++ b/src/aead/aes_gcm.rs @@ -422,12 +422,14 @@ pub(super) fn open( fn open_strided( Combo { aes_key, gcm_key }: &Combo, aad: Aad<&[u8]>, - in_out: &mut [u8], + in_out_slice: &mut [u8], src: RangeFrom, mut ctr: Counter, tag_iv: aes::Iv, ) -> Result { - let input = in_out.get(src.clone()).ok_or(error::Unspecified)?; + let in_out = + Overlapping::new(in_out_slice, src.clone()).map_err(error::erase::)?; + let input = in_out.input(); let input_len = input.len(); let mut auth = gcm::Context::new(gcm_key, aad, input_len)?; @@ -445,7 +447,7 @@ fn open_strided)?; @@ -464,7 +466,14 @@ fn open_strided(