diff --git a/Cargo.lock b/Cargo.lock index 1ddc0ee1..ac9117c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -739,7 +739,7 @@ dependencies = [ [[package]] name = "inout" version = "0.2.0-rc.2" -source = "git+/~https://github.com/RustCrypto/utils#8bb6c50988ba6c32d92e4a8e640027ab3c0920cd" +source = "git+/~https://github.com/RustCrypto/utils#794835232842098d2003acb5b12f8218e5a1fe01" dependencies = [ "hybrid-array", ] diff --git a/aead/src/lib.rs b/aead/src/lib.rs index 9c0dcc4a..c8e26a52 100644 --- a/aead/src/lib.rs +++ b/aead/src/lib.rs @@ -5,7 +5,7 @@ html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg", html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg" )] -// #![forbid(unsafe_code)] +#![forbid(unsafe_code)] #![warn( clippy::unwrap_used, // missing_docs, @@ -169,7 +169,7 @@ pub trait Aead { associated_data: &[u8], mut buffer: InOutBufReserved<'_, 'out, u8>, ) -> Result<&'out mut [u8]> { - let (msg, tail) = split_reserved(&mut buffer); + let (msg, tail) = buffer.split_reserved(); let tag_len = Self::TagSize::USIZE; let tag_dst = tail.get_mut(..tag_len).ok_or(Error)?; let res_len = msg.len() + tag_len; @@ -459,21 +459,6 @@ pub trait Aead { } } -// TODO: move to `inout` -fn split_reserved<'a>( - buf: &'a mut InOutBufReserved<'_, '_, u8>, -) -> (InOutBuf<'a, 'a, u8>, &'a mut [u8]) { - let in_len = buf.get_in_len(); - let out_len = buf.get_out_len(); - let in_ptr = buf.get_in().as_ptr(); - let out_ptr = buf.get_out().as_mut_ptr(); - unsafe { - let body = InOutBuf::from_raw(in_ptr, out_ptr, in_len); - let tail = core::slice::from_raw_parts_mut(out_ptr.add(in_len), out_len - in_len); - (body, tail) - } -} - /// AEAD payloads (message + AAD). /// /// Combination of a message (plaintext or ciphertext) and