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

Switch to c2-chacha crate for ChaCha20-IETF #84

Merged
merged 1 commit into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 7 additions & 3 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion age/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ age-core = { version = "0.3.1", path = "../age-core" }
base64 = "0.11"

# - ChaCha20-Poly1305 from RFC 7539
chacha20poly1305 = "0.3"
c2-chacha = "0.2"
chacha20poly1305 = "0.4"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, you should be able to do:

chacha20poly1305 = { version = "0.4", default = false }

...which will eliminate the chacha20 dependency, which is redundant if you're using c2-chacha

/cc @cryptocorrosion


# - X25519 from RFC 7748
x25519-dalek = "0.6"
Expand Down
6 changes: 3 additions & 3 deletions age/src/primitives/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use chacha20poly1305::{
aead::{Aead, NewAead},
ChaCha20Poly1305,
ChaChaPoly1305,
};
use secrecy::{ExposeSecret, SecretVec};
use std::io::{self, Read, Seek, SeekFrom, Write};
Expand All @@ -20,14 +20,14 @@ const ENCRYPTED_CHUNK_SIZE: usize = CHUNK_SIZE + TAG_SIZE;
/// Instantiated with ChaCha20-Poly1305 in 64KiB chunks, and a nonce structure of 11 bytes
/// of big endian counter, and 1 byte of last block flag (0x00 / 0x01).
pub struct Stream {
aead: ChaCha20Poly1305,
aead: ChaChaPoly1305<c2_chacha::Ietf>,
nonce: [u8; 12],
}

impl Stream {
fn new(key: &[u8; 32]) -> Self {
Stream {
aead: ChaCha20Poly1305::new((*key).into()),
aead: ChaChaPoly1305::new((*key).into()),
nonce: [0; 12],
}
}
Expand Down