Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop ReceivedMessage and handle sending decoys in handshake #66

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions protocol/src/fschacha20poly1305.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub enum Error {
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Decryption(e) => write!(f, "Unable to dycrypt {}", e),
Error::Decryption(e) => write!(f, "Unable to dycrypt: {}.", e),
}
}
}
Expand All @@ -42,7 +42,7 @@ impl std::error::Error for Error {
/// nonces and re-keying, providing forward secrecy within the session.
///
/// FSChaCha20Poly1305 is used for message packets in BIP324.
#[derive(Clone, Debug)]
rustaceanrob marked this conversation as resolved.
Show resolved Hide resolved
#[derive(Clone)]
pub struct FSChaCha20Poly1305 {
key: [u8; 32],
message_counter: u64,
Expand Down Expand Up @@ -89,8 +89,8 @@ impl FSChaCha20Poly1305 {
///
/// # Arguments
///
/// - `content` - Plaintext to be encrypted in place.
/// - `aad` - Optional metadata covered by the authentication tag.
/// * `content` - Plaintext to be encrypted in place.
/// * `aad` - Optional associated authenticated data covered by the authentication tag.
///
/// # Returns
///
Expand All @@ -109,9 +109,9 @@ impl FSChaCha20Poly1305 {
///
/// # Arguments
///
/// - `content` - Ciphertext to be decrypted in place.
/// - `tag` - 16-byte authentication tag.
/// - `aad` - Optional metadata covered by the authentication tag.
/// * `content` - Ciphertext to be decrypted in place.
/// * `tag` - 16-byte authentication tag.
/// * `aad` - Optional associated authenticated data covered by the authentication tag.
pub fn decrypt(&mut self, aad: &[u8], content: &mut [u8], tag: [u8; 16]) -> Result<(), Error> {
let cipher = ChaCha20Poly1305::new(self.key, self.nonce());

Expand All @@ -130,7 +130,7 @@ impl FSChaCha20Poly1305 {
///
/// FSChaCha20 is used for lengths in BIP324. Should be noted that the lengths are still
/// implicitly authenticated by the message packets.
#[derive(Clone, Debug)]
#[derive(Clone)]
pub struct FSChaCha20 {
key: [u8; 32],
block_counter: u32,
Expand Down
Loading
Loading