diff --git a/src/aead/aes_gcm.rs b/src/aead/aes_gcm.rs index b4bd6234e..566912ff1 100644 --- a/src/aead/aes_gcm.rs +++ b/src/aead/aes_gcm.rs @@ -18,6 +18,7 @@ use super::{ }; use crate::{ cpu, error, + inout::overlapping::SrcIndexError, polyfill::{slice, sliceutil::overwrite_at_start, usize_from_u64_saturated}, }; use core::ops::RangeFrom; @@ -276,7 +277,8 @@ pub(super) fn open( src: RangeFrom, ) -> Result { #[cfg(any(target_arch = "aarch64", target_arch = "x86_64"))] - let in_out = Overlapping::new(in_out_slice, src.clone())?; + let in_out = + Overlapping::new(in_out_slice, src.clone()).map_err(error::erase::)?; let mut ctr = Counter::one(nonce); let tag_iv = ctr.increment(); @@ -332,7 +334,8 @@ pub(super) fn open( let whole_len = slice::flatten(whole).len(); // Decrypt any remaining whole blocks. - let whole = Overlapping::new(&mut in_out[..(src.start + whole_len)], src.clone())?; + let whole = Overlapping::new(&mut in_out[..(src.start + whole_len)], src.clone()) + .map_err(error::erase::)?; aes_key.ctr32_encrypt_within(whole, &mut ctr); let in_out = match in_out.get_mut(whole_len..) { @@ -452,7 +455,8 @@ fn open_strided)?; aes_key.ctr32_encrypt_within(chunk, &mut ctr); output += chunk_len; input += chunk_len; diff --git a/src/inout/overlapping/mod.rs b/src/inout/overlapping/mod.rs index 35b00d1a7..2e7cde4b8 100644 --- a/src/inout/overlapping/mod.rs +++ b/src/inout/overlapping/mod.rs @@ -12,6 +12,6 @@ // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -pub use self::overlapping::Overlapping; +pub use self::overlapping::{Overlapping, SrcIndexError}; mod overlapping; diff --git a/src/inout/overlapping/overlapping.rs b/src/inout/overlapping/overlapping.rs index 25645dfca..dda091fb3 100644 --- a/src/inout/overlapping/overlapping.rs +++ b/src/inout/overlapping/overlapping.rs @@ -12,7 +12,6 @@ // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -use crate::error; use core::ops::RangeFrom; pub struct Overlapping<'o, T> { @@ -63,9 +62,3 @@ impl SrcIndexError { Self(src) } } - -impl From for error::Unspecified { - fn from(_: SrcIndexError) -> Self { - Self - } -}