Skip to content

Commit

Permalink
chacha20poly1305: Migrate to universal-hash 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
str4d committed Apr 24, 2022
1 parent 2482bcb commit 485e789
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
40 changes: 34 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion chacha20poly1305/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ categories = ["cryptography", "no-std"]
aead = { version = "0.4", default-features = false }
chacha20 = { version = "0.9", features = ["zeroize"] }
cipher = "0.4"
poly1305 = "0.7"
poly1305 = { git = "https://github.com/str4d/universal-hashes", rev = "e62c24184c52084fa538f227175e3934b3bc1e75" }
zeroize = { version = "1", default-features = false }

[dev-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions chacha20poly1305/src/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use aead::generic_array::GenericArray;
use aead::Error;
use core::convert::TryInto;
use poly1305::{
universal_hash::{NewUniversalHash, UniversalHash},
universal_hash::{KeyInit, UniversalHash},
Poly1305,
};
use zeroize::Zeroize;
Expand Down Expand Up @@ -64,7 +64,7 @@ where
self.mac.update_padded(buffer);

self.authenticate_lengths(associated_data, buffer)?;
Ok(self.mac.finalize().into_bytes())
Ok(self.mac.finalize())
}

/// Decrypt the given message, first authenticating ciphertext integrity
Expand Down Expand Up @@ -102,7 +102,7 @@ where
let mut block = GenericArray::default();
block[..8].copy_from_slice(&associated_data_len.to_le_bytes());
block[8..].copy_from_slice(&buffer_len.to_le_bytes());
self.mac.update(&block);
self.mac.update(&[block]);

Ok(())
}
Expand Down

0 comments on commit 485e789

Please sign in to comment.