Skip to content

Commit

Permalink
Merge pull request #186 from str4d/dependency-updates
Browse files Browse the repository at this point in the history
Dependency updates
  • Loading branch information
str4d authored Jan 12, 2021
2 parents 5b38e29 + 6ce0942 commit 9c56470
Show file tree
Hide file tree
Showing 10 changed files with 472 additions and 451 deletions.
454 changes: 242 additions & 212 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions age-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ maintenance = { status = "experimental" }
[dependencies]
# Dependencies required by the age specification:
# - Base64 from RFC 4648
base64 = "0.12"
base64 = "0.13"

# - ChaCha20-Poly1305 from RFC 7539
c2-chacha = "0.3"
Expand All @@ -29,7 +29,7 @@ rand = "0.7"

# Parsing
cookie-factory = "0.3.1"
nom = "5"
nom = { version = "6", default-features = false, features = ["alloc"] }

# Secret management
secrecy = "0.7"
Expand Down
11 changes: 4 additions & 7 deletions age-core/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub mod read {
bytes::streaming::{tag, take_while, take_while1},
character::streaming::newline,
combinator::{map, map_opt, opt, verify},
multi::{many0, separated_nonempty_list},
multi::{many0, separated_list1},
sequence::{pair, preceded, terminated},
IResult,
};
Expand Down Expand Up @@ -189,7 +189,7 @@ pub mod read {
}

fn legacy_wrapped_encoded_data(input: &[u8]) -> IResult<&[u8], Vec<u8>> {
map_opt(separated_nonempty_list(newline, take_b64_line1), |chunks| {
map_opt(separated_list1(newline, take_b64_line1), |chunks| {
// Enforce that the only chunk allowed to be shorter than 64 characters
// is the last chunk.
if chunks.iter().rev().skip(1).any(|s| s.len() != 64)
Expand Down Expand Up @@ -218,7 +218,7 @@ pub mod read {
pair(
preceded(
tag(STANZA_TAG),
terminated(separated_nonempty_list(tag(" "), arbitrary_string), newline),
terminated(separated_list1(tag(" "), arbitrary_string), newline),
),
wrapped_encoded_data,
),
Expand All @@ -232,10 +232,7 @@ pub mod read {
fn legacy_age_stanza_inner<'a>(input: &'a [u8]) -> IResult<&'a [u8], AgeStanza<'a>> {
map(
pair(
preceded(
tag(STANZA_TAG),
separated_nonempty_list(tag(" "), arbitrary_string),
),
preceded(tag(STANZA_TAG), separated_list1(tag(" "), arbitrary_string)),
terminated(opt(preceded(newline, legacy_wrapped_encoded_data)), newline),
),
|(mut args, body)| {
Expand Down
12 changes: 6 additions & 6 deletions age/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ age-core = { version = "0.5.0", path = "../age-core" }

# Dependencies required by the age specification:
# - Base64 from RFC 4648
base64 = "0.12"
base64 = "0.13"

# - ChaCha20-Poly1305 from RFC 7539
c2-chacha = "0.3"
Expand Down Expand Up @@ -58,7 +58,7 @@ block-modes = { version = "0.7", optional = true }

# Parsing
cookie-factory = "0.3.1"
nom = "5"
nom = { version = "6", default-features = false, features = ["alloc"] }

# Secret management
secrecy = "0.7"
Expand All @@ -76,8 +76,8 @@ lazy_static = "1"
rust-embed = "5"

# Common CLI dependencies
console = { version = "0.13", optional = true }
pinentry = { version = "0.2", optional = true }
console = { version = "0.14", optional = true }
pinentry = { version = "0.3", optional = true }
rpassword = { version = "5", optional = true }

[target.'cfg(any(unix, windows))'.dependencies]
Expand All @@ -89,8 +89,8 @@ wsl = { version = "0.1", optional = true }
criterion = "0.3"
criterion-cycles-per-byte = "0.1"
futures-test = "0.3"
quickcheck = "0.9"
quickcheck_macros = "0.9"
quickcheck = "1"
quickcheck_macros = "1"

[features]
default = []
Expand Down
10 changes: 6 additions & 4 deletions age/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ impl Header {
// parser is constructed, because if we read more than we need, the
// remainder of the input will be truncated.
let m = data.len();
data.resize(m + n, 0);
input.read_exact(&mut data[m..m + n])?;
let new_len = m + n.get();
data.resize(new_len, 0);
input.read_exact(&mut data[m..new_len])?;
}
Err(_) => {
break Err(DecryptError::InvalidHeader);
Expand All @@ -105,8 +106,9 @@ impl Header {
// parser is constructed, because if we read more than we need, the
// remainder of the input will be truncated.
let m = data.len();
data.resize(m + n, 0);
input.read_exact(&mut data[m..m + n]).await?;
let new_len = m + n.get();
data.resize(new_len, 0);
input.read_exact(&mut data[m..new_len]).await?;
}
Err(_) => {
break Err(DecryptError::InvalidHeader);
Expand Down
4 changes: 2 additions & 2 deletions age/src/ssh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl EncryptedKey {
.cipher
.decrypt(&self.kdf, passphrase, &self.encrypted)?;

let parser = read_ssh::openssh_unencrypted_privkey(&self.ssh_key);
let mut parser = read_ssh::openssh_unencrypted_privkey(&self.ssh_key);
parser(&decrypted)
.map(|(_, sk)| sk)
.map_err(|_| DecryptError::KeyDecryptionFailed)
Expand Down Expand Up @@ -450,7 +450,7 @@ mod read_ssh {
#[allow(clippy::needless_lifetimes)]
pub(super) fn openssh_unencrypted_privkey<'a>(
ssh_key: &[u8],
) -> impl Fn(&'a [u8]) -> IResult<&'a [u8], UnencryptedKey> {
) -> impl FnMut(&'a [u8]) -> IResult<&'a [u8], UnencryptedKey> {
// We need to own, move, and clone these in order to keep them alive.
let ssh_key_rsa = ssh_key.to_vec();
let ssh_key_ed25519 = ssh_key.to_vec();
Expand Down
14 changes: 3 additions & 11 deletions age/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(crate) mod read {
use nom::{
combinator::map_res,
error::{make_error, ErrorKind},
multi::separated_nonempty_list,
multi::separated_list1,
IResult,
};

Expand All @@ -31,15 +31,7 @@ pub(crate) mod read {
let encoded_count = ((4 * count) + 2) / 3;

move |input: &str| {
// take() returns the total number of bytes it needs, not the
// additional number of bytes like other APIs.
let (i, data) = take(encoded_count)(input).map_err(|e| match e {
nom::Err::Incomplete(nom::Needed::Size(n)) if n == encoded_count => {
nom::Err::Incomplete(nom::Needed::Size(encoded_count - input.len()))
}
e => e,
})?;

let (i, data) = take(encoded_count)(input)?;
match base64::decode_config(data, config) {
Ok(decoded) => Ok((i, decoded)),
Err(_) => Err(nom::Err::Failure(make_error(input, ErrorKind::Eof))),
Expand Down Expand Up @@ -74,7 +66,7 @@ pub(crate) mod read {

move |input: &str| {
map_res(
separated_nonempty_list(
separated_list1(
line_ending,
take_while1(|c| {
let c = c as u8;
Expand Down
Loading

0 comments on commit 9c56470

Please sign in to comment.