Skip to content

Commit

Permalink
inout: Avoid implicit conversions to error::Unspecified.
Browse files Browse the repository at this point in the history
  • Loading branch information
briansmith committed Jan 1, 2025
1 parent 1d832d5 commit 1bce174
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
10 changes: 7 additions & 3 deletions src/aead/aes_gcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -276,7 +277,8 @@ pub(super) fn open(
src: RangeFrom<usize>,
) -> Result<Tag, error::Unspecified> {
#[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::<SrcIndexError>)?;

let mut ctr = Counter::one(nonce);
let tag_iv = ctr.increment();
Expand Down Expand Up @@ -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::<SrcIndexError>)?;
aes_key.ctr32_encrypt_within(whole, &mut ctr);

let in_out = match in_out.get_mut(whole_len..) {
Expand Down Expand Up @@ -452,7 +455,8 @@ fn open_strided<A: aes::EncryptBlock + aes::EncryptCtr32, G: gcm::UpdateBlocks +
let chunk = Overlapping::new(
&mut in_out[output..][..(chunk_len + in_prefix_len)],
in_prefix_len..,
)?;
)
.map_err(error::erase::<SrcIndexError>)?;
aes_key.ctr32_encrypt_within(chunk, &mut ctr);
output += chunk_len;
input += chunk_len;
Expand Down
2 changes: 1 addition & 1 deletion src/inout/overlapping/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
7 changes: 0 additions & 7 deletions src/inout/overlapping/overlapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -63,9 +62,3 @@ impl SrcIndexError {
Self(src)
}
}

impl From<SrcIndexError> for error::Unspecified {
fn from(_: SrcIndexError) -> Self {
Self
}
}

0 comments on commit 1bce174

Please sign in to comment.