Skip to content

Commit

Permalink
Rename b2b methods
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Nov 18, 2024
1 parent 36e01a5 commit 93e0723
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions aead/src/dyn_aead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ pub trait DynAead: sealed::Sealed {
buffer: &'out mut [u8],
) -> Result<&'out mut [u8]>;

fn postfix_encrypt_b2b<'out>(
fn postfix_encrypt_to_buf<'out>(
&self,
nonce: &[u8],
associated_data: &[u8],
plaintext: &[u8],
buffer: &'out mut [u8],
) -> Result<&'out mut [u8]>;

fn postfix_decrypt_b2b<'out>(
fn postfix_decrypt_to_buf<'out>(
&self,
nonce: &[u8],
associated_data: &[u8],
Expand Down Expand Up @@ -116,26 +116,26 @@ impl<T: Aead> DynAead for T {
Aead::postfix_decrypt_inplace(self, nonce, associated_data, buffer)
}

fn postfix_encrypt_b2b<'out>(
fn postfix_encrypt_to_buf<'out>(
&self,
nonce: &[u8],
associated_data: &[u8],
plaintext: &[u8],
buffer: &'out mut [u8],
) -> Result<&'out mut [u8]> {
let nonce = nonce.try_into().map_err(|_| Error)?;
Aead::postfix_encrypt_b2b(self, nonce, associated_data, plaintext, buffer)
Aead::postfix_encrypt_to_buf(self, nonce, associated_data, plaintext, buffer)
}

fn postfix_decrypt_b2b<'out>(
fn postfix_decrypt_to_buf<'out>(
&self,
nonce: &[u8],
associated_data: &[u8],
ciphertext: &[u8],
buffer: &'out mut [u8],
) -> Result<&'out mut [u8]> {
let nonce = nonce.try_into().map_err(|_| Error)?;
Aead::postfix_decrypt_b2b(self, nonce, associated_data, ciphertext, buffer)
Aead::postfix_decrypt_to_buf(self, nonce, associated_data, ciphertext, buffer)
}

#[cfg(feature = "alloc")]
Expand Down
12 changes: 6 additions & 6 deletions aead/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub trait Aead {

/// Encrypt the data buffer-to-buffer, returning the authentication tag.
#[inline]
fn detached_encrypt_b2b(
fn detached_encrypt_to_buf(
&self,
nonce: &Nonce<Self>,
associated_data: &[u8],
Expand All @@ -146,7 +146,7 @@ pub trait Aead {
/// Encrypt the data buffer-to-buffer, returning an error in the event the provided
/// authentication tag does not match the given ciphertext.
#[inline]
fn detached_decrypt_b2b(
fn detached_decrypt_to_buf(
&self,
nonce: &Nonce<Self>,
associated_data: &[u8],
Expand Down Expand Up @@ -228,7 +228,7 @@ pub trait Aead {
}

#[inline]
fn postfix_encrypt_b2b<'out>(
fn postfix_encrypt_to_buf<'out>(
&self,
nonce: &Nonce<Self>,
associated_data: &[u8],
Expand All @@ -248,7 +248,7 @@ pub trait Aead {
/// Encrypt the data buffer-to-buffer, returning an error in the event the provided
/// authentication tag does not match the given ciphertext.
#[inline]
fn postfix_decrypt_b2b<'out>(
fn postfix_decrypt_to_buf<'out>(
&self,
nonce: &Nonce<Self>,
associated_data: &[u8],
Expand Down Expand Up @@ -363,7 +363,7 @@ pub trait Aead {
} else {
res.as_mut().split_at_mut(tag_len)
};
let tag = self.detached_encrypt_b2b(nonce, aad, pt, ct_dst)?;
let tag = self.detached_encrypt_to_buf(nonce, aad, pt, ct_dst)?;
tag_dst.copy_from_slice(&tag);
Ok(res)
}
Expand All @@ -384,7 +384,7 @@ pub trait Aead {
ct_tag.split_at(tag_len)
};
let tag = tag.try_into().expect("tag has correct length");
self.detached_decrypt_b2b(nonce, aad, ct, pt_dst.as_mut(), tag)?;
self.detached_decrypt_to_buf(nonce, aad, ct, pt_dst.as_mut(), tag)?;
Ok(pt_dst)
}

Expand Down

0 comments on commit 93e0723

Please sign in to comment.