Skip to content
Open
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: 5 additions & 5 deletions age/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Error type.

use std::collections::HashSet;
use std::collections::BTreeSet;
use std::fmt;
use std::io;

Expand Down Expand Up @@ -173,15 +173,15 @@ pub enum EncryptError {
/// The encryptor was given recipients that declare themselves incompatible.
IncompatibleRecipients {
/// The set of labels from the first recipient provided to the encryptor.
l_labels: HashSet<String>,
l_labels: BTreeSet<String>,
/// The set of labels from the first non-matching recipient.
r_labels: HashSet<String>,
r_labels: BTreeSet<String>,
},
/// One or more of the labels from the first recipient provided to the encryptor are
/// invalid.
///
/// Labels must be valid age "arbitrary string"s (`1*VCHAR` in ABNF).
InvalidRecipientLabels(HashSet<String>),
InvalidRecipientLabels(BTreeSet<String>),
/// An I/O error occurred during encryption.
Io(io::Error),
/// The encryptor was not given any recipients.
Expand Down Expand Up @@ -226,7 +226,7 @@ impl Clone for EncryptError {
}
}

fn print_labels(labels: &HashSet<String>) -> String {
fn print_labels(labels: &BTreeSet<String>) -> String {
let mut s = String::new();
for (i, label) in labels.iter().enumerate() {
s.push_str(label);
Expand Down
4 changes: 2 additions & 2 deletions age/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
#![deny(rustdoc::broken_intra_doc_links)]
#![deny(missing_docs)]

use std::collections::HashSet;
use std::collections::BTreeSet;

// Re-export crates that are used in our public API.
pub use age_core::secrecy;
Expand Down Expand Up @@ -372,7 +372,7 @@ pub trait Recipient {
fn wrap_file_key(
&self,
file_key: &FileKey,
) -> Result<(Vec<Stanza>, HashSet<String>), EncryptError>;
) -> Result<(Vec<Stanza>, BTreeSet<String>), EncryptError>;
}

/// Callbacks that might be triggered during encryption or decryption.
Expand Down
4 changes: 2 additions & 2 deletions age/src/native.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashSet;
use std::collections::BTreeSet;

use hkdf::Hkdf;
use sha2::{Digest, Sha256};
Expand All @@ -20,6 +20,6 @@ fn stanza_tag(ikm: &[u8], salt: &str) -> [u8; 4] {
tag[..4].try_into().expect("correct length")
}

fn label_pq_only() -> HashSet<String> {
fn label_pq_only() -> BTreeSet<String> {
["postquantum".into()].into_iter().collect()
}
4 changes: 2 additions & 2 deletions age/src/native/scrypt.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! The "scrypt" passphrase-based recipient type, native to age.

use std::collections::HashSet;
use std::collections::BTreeSet;
use std::iter;
use std::time::Duration;

Expand Down Expand Up @@ -138,7 +138,7 @@ impl crate::Recipient for Recipient {
fn wrap_file_key(
&self,
file_key: &FileKey,
) -> Result<(Vec<Stanza>, HashSet<String>), EncryptError> {
) -> Result<(Vec<Stanza>, BTreeSet<String>), EncryptError> {
let mut rng = OsRng;

let mut salt = [0; SALT_LEN];
Expand Down
6 changes: 3 additions & 3 deletions age/src/native/tag.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! The "tag" recipient type, native to age.

use std::collections::HashSet;
use std::collections::BTreeSet;
use std::fmt;

use age_core::{
Expand Down Expand Up @@ -91,7 +91,7 @@ impl crate::Recipient for Recipient {
fn wrap_file_key(
&self,
file_key: &FileKey,
) -> Result<(Vec<Stanza>, HashSet<String>), EncryptError> {
) -> Result<(Vec<Stanza>, BTreeSet<String>), EncryptError> {
let (enc, ct) = hpke_seal::<Kem, _>(
&self.pk_recip,
P256TAG_SALT.as_bytes(),
Expand All @@ -115,7 +115,7 @@ impl crate::Recipient for Recipient {
args: vec![encoded_tag, encoded_enc],
body: ct,
}],
HashSet::new(),
BTreeSet::new(),
))
}
}
Expand Down
4 changes: 2 additions & 2 deletions age/src/native/tagpq.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! The "tagpq" recipient type, native to age.

use std::collections::HashSet;
use std::collections::BTreeSet;
use std::fmt;

use age_core::{
Expand Down Expand Up @@ -91,7 +91,7 @@ impl crate::Recipient for Recipient {
fn wrap_file_key(
&self,
file_key: &FileKey,
) -> Result<(Vec<Stanza>, HashSet<String>), EncryptError> {
) -> Result<(Vec<Stanza>, BTreeSet<String>), EncryptError> {
let (enc, ct) = hpke_seal::<Kem, _>(
&self.0,
MLKEM768P256TAG_SALT.as_bytes(),
Expand Down
6 changes: 3 additions & 3 deletions age/src/native/x25519.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! The classic recipient type, native to age.

use std::collections::HashSet;
use std::collections::BTreeSet;
use std::fmt;

use age_core::{
Expand Down Expand Up @@ -192,7 +192,7 @@ impl crate::Recipient for Recipient {
fn wrap_file_key(
&self,
file_key: &FileKey,
) -> Result<(Vec<Stanza>, HashSet<String>), EncryptError> {
) -> Result<(Vec<Stanza>, BTreeSet<String>), EncryptError> {
let rng = OsRng;
let esk = EphemeralSecret::random_from_rng(rng);
let epk: PublicKey = (&esk).into();
Expand Down Expand Up @@ -227,7 +227,7 @@ impl crate::Recipient for Recipient {
args: vec![encoded_epk],
body: encrypted_file_key,
}],
HashSet::new(),
BTreeSet::new(),
))
}
}
Expand Down
6 changes: 3 additions & 3 deletions age/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use base64::{prelude::BASE64_STANDARD_NO_PAD, Engine};
use bech32::Hrp;

use std::borrow::Borrow;
use std::collections::HashSet;
use std::collections::BTreeSet;
use std::fmt;
use std::io;
use std::iter;
Expand Down Expand Up @@ -414,7 +414,7 @@ impl<C: Callbacks> crate::Recipient for RecipientPluginV1<C> {
fn wrap_file_key(
&self,
file_key: &FileKey,
) -> Result<(Vec<Stanza>, HashSet<String>), EncryptError> {
) -> Result<(Vec<Stanza>, BTreeSet<String>), EncryptError> {
// Open connection
let mut conn = self.plugin.connect(RECIPIENT_V1)?;

Expand Down Expand Up @@ -502,7 +502,7 @@ impl<C: Callbacks> crate::Recipient for RecipientPluginV1<C> {
CMD_LABELS => {
if labels.is_none() {
let labels_count = command.args.len();
let label_set = command.args.into_iter().collect::<HashSet<_>>();
let label_set = command.args.into_iter().collect::<BTreeSet<_>>();
if label_set.len() == labels_count {
labels = Some(label_set);
} else {
Expand Down
4 changes: 2 additions & 2 deletions age/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ impl<R: AsyncBufRead + Unpin> Decryptor<R> {

#[cfg(test)]
mod tests {
use std::collections::HashSet;
use std::collections::BTreeSet;
use std::io::{BufReader, Read, Write};
use std::iter;

Expand Down Expand Up @@ -558,7 +558,7 @@ mod tests {
fn wrap_file_key(
&self,
file_key: &age_core::format::FileKey,
) -> Result<(Vec<age_core::format::Stanza>, HashSet<String>), EncryptError> {
) -> Result<(Vec<age_core::format::Stanza>, BTreeSet<String>), EncryptError> {
self.0.wrap_file_key(file_key).map(|(stanzas, mut labels)| {
labels.insert("incompatible".into());
(stanzas, labels)
Expand Down
6 changes: 3 additions & 3 deletions age/src/ssh/recipient.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashSet;
use std::collections::BTreeSet;
use std::fmt;

use age_core::{
Expand Down Expand Up @@ -150,7 +150,7 @@ impl crate::Recipient for Recipient {
fn wrap_file_key(
&self,
file_key: &FileKey,
) -> Result<(Vec<Stanza>, HashSet<String>), EncryptError> {
) -> Result<(Vec<Stanza>, BTreeSet<String>), EncryptError> {
let mut rng = OsRng;

let stanzas = match self {
Expand Down Expand Up @@ -204,7 +204,7 @@ impl crate::Recipient for Recipient {
}
};

Ok((stanzas, HashSet::new()))
Ok((stanzas, BTreeSet::new()))
}
}

Expand Down