Skip to content

Commit

Permalink
Merge pull request #66 from nyonson/error-names-and-docs
Browse files Browse the repository at this point in the history
Drop ReceivedMessage and handle sending decoys in handshake
  • Loading branch information
nyonson authored Sep 30, 2024
2 parents c01cfcb + ed6e361 commit cd584df
Show file tree
Hide file tree
Showing 5 changed files with 537 additions and 398 deletions.
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)]
#[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

0 comments on commit cd584df

Please sign in to comment.