|
34 | 34 | //! This crate has an optional `alloc` feature which can be disabled in e.g. |
35 | 35 | //! microcontroller environments that don't have a heap. |
36 | 36 | //! |
37 | | -//! The [`AeadInPlace::encrypt_in_place`] and [`AeadInPlace::decrypt_in_place`] |
| 37 | +//! The [`AeadInOut::encrypt_in_place`] and [`AeadInOut::decrypt_in_place`] |
38 | 38 | //! methods accept any type that impls the [`aead::Buffer`] trait which |
39 | 39 | //! contains the plaintext for encryption or ciphertext for decryption. |
40 | 40 | //! |
|
48 | 48 | #![cfg_attr(not(all(feature = "os_rng", feature = "heapless")), doc = "```ignore")] |
49 | 49 | //! # fn main() -> Result<(), Box<dyn core::error::Error>> { |
50 | 50 | //! use aes_siv::{ |
51 | | -//! aead::{AeadCore, AeadInPlace, KeyInit, rand_core::OsRng, heapless::Vec}, |
| 51 | +//! aead::{AeadCore, AeadInOut, KeyInit, rand_core::OsRng, heapless::Vec}, |
52 | 52 | //! Aes256SivAead, Nonce, // Or `Aes128SivAead` |
53 | 53 | //! }; |
54 | 54 | //! |
@@ -83,11 +83,11 @@ extern crate alloc; |
83 | 83 |
|
84 | 84 | pub mod siv; |
85 | 85 |
|
86 | | -pub use aead::{self, AeadCore, AeadInOut, AeadInPlace, Error, Key, KeyInit, KeySizeUser}; |
| 86 | +pub use aead::{self, Aead, AeadCore, AeadInOut, Error, Key, KeyInit, KeySizeUser}; |
87 | 87 |
|
88 | 88 | use crate::siv::Siv; |
89 | 89 | use aead::{ |
90 | | - Buffer, |
| 90 | + TagPosition, |
91 | 91 | array::Array, |
92 | 92 | consts::{U1, U16, U32, U64}, |
93 | 93 | inout::InOutBuf, |
@@ -205,39 +205,7 @@ where |
205 | 205 | // https://tools.ietf.org/html/rfc5297#section-6 |
206 | 206 | type NonceSize = NonceSize; |
207 | 207 | type TagSize = U16; |
208 | | -} |
209 | | - |
210 | | -impl<C, M, NonceSize> AeadInPlace for SivAead<C, M, NonceSize> |
211 | | -where |
212 | | - Self: KeySizeUser, |
213 | | - Siv<C, M>: KeyInit + KeySizeUser<KeySize = <Self as KeySizeUser>::KeySize>, |
214 | | - C: BlockSizeUser<BlockSize = U16> + BlockCipherEncrypt + KeyInit + KeySizeUser, |
215 | | - M: Mac<OutputSize = U16> + FixedOutputReset + KeyInit, |
216 | | - <C as KeySizeUser>::KeySize: Add, |
217 | | - NonceSize: ArraySize + IsGreaterOrEqual<U1>, |
218 | | -{ |
219 | | - fn encrypt_in_place( |
220 | | - &self, |
221 | | - nonce: &Array<u8, Self::NonceSize>, |
222 | | - associated_data: &[u8], |
223 | | - buffer: &mut dyn Buffer, |
224 | | - ) -> Result<(), Error> { |
225 | | - // "SIV performs nonce-based authenticated encryption when a component of |
226 | | - // the associated data is a nonce. For purposes of interoperability the |
227 | | - // final component -- i.e., the string immediately preceding the |
228 | | - // plaintext in the vector input to S2V -- is used for the nonce." |
229 | | - // https://tools.ietf.org/html/rfc5297#section-3 |
230 | | - Siv::<C, M>::new(&self.key).encrypt_in_place([associated_data, nonce.as_slice()], buffer) |
231 | | - } |
232 | | - |
233 | | - fn decrypt_in_place( |
234 | | - &self, |
235 | | - nonce: &Array<u8, Self::NonceSize>, |
236 | | - associated_data: &[u8], |
237 | | - buffer: &mut dyn Buffer, |
238 | | - ) -> Result<(), Error> { |
239 | | - Siv::<C, M>::new(&self.key).decrypt_in_place([associated_data, nonce.as_slice()], buffer) |
240 | | - } |
| 208 | + const TAG_POSITION: TagPosition = TagPosition::Prefix; |
241 | 209 | } |
242 | 210 |
|
243 | 211 | impl<C, M, NonceSize> AeadInOut for SivAead<C, M, NonceSize> |
|
0 commit comments