Skip to content

Commit

Permalink
Fix codebase to allow Encryptor to implement Send
Browse files Browse the repository at this point in the history
Fixes #344.
  • Loading branch information
str4d committed Oct 26, 2022
1 parent 20c9542 commit 9ccbf3c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
5 changes: 4 additions & 1 deletion age/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ to 1.0.0 are beta releases.
### Changed
- `age::Encryptor::with_recipients` now returns `Option<Encryptor>`, with `None`
returned if the provided list of recipients is empty (to prevent files being
encrypted to no recipients).
encrypted to no recipients). The `recipients` argument is also now
`Vec<Box<dyn age::Recipient + Send>>`.
- `age::encrypted::Identity::recipients` now returns
`Vec<Box<dyn age::Recipient + Send>>`.

### Fixed
- `age::Decryptor` now rejects invalid or non-canonical `scrypt` recipient
Expand Down
2 changes: 1 addition & 1 deletion age/benches/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn bench(c: &mut Criterion) {
.iter()
.take(count)
.cloned()
.map(|r| r as Box<dyn Recipient>)
.map(|r| r as Box<dyn Recipient + Send>)
.collect(),
)
.unwrap()
Expand Down
2 changes: 1 addition & 1 deletion age/src/encrypted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl<R: io::Read, C: Callbacks> Identity<R, C> {
///
/// If this encrypted identity has not been decrypted yet, calling this method will
/// trigger a passphrase request.
pub fn recipients(&self) -> Result<Vec<Box<dyn crate::Recipient>>, EncryptError> {
pub fn recipients(&self) -> Result<Vec<Box<dyn crate::Recipient + Send>>, EncryptError> {
match self
.state
.take()
Expand Down
2 changes: 1 addition & 1 deletion age/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl IdentityFileEntry {
pub(crate) fn to_recipient(
&self,
callbacks: impl Callbacks,
) -> Result<Box<dyn crate::Recipient>, EncryptError> {
) -> Result<Box<dyn crate::Recipient + Send>, EncryptError> {
match self {
IdentityFileEntry::Native(i) => Ok(Box::new(i.to_public())),
#[cfg(feature = "plugin")]
Expand Down
4 changes: 2 additions & 2 deletions age/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ mod tests {
use futures_test::task::noop_context;

fn recipient_round_trip<'a>(
recipients: Vec<Box<dyn Recipient>>,
recipients: Vec<Box<dyn Recipient + Send>>,
identities: impl Iterator<Item = &'a dyn Identity>,
) {
let test_msg = b"This is a test message. For testing.";
Expand All @@ -264,7 +264,7 @@ mod tests {

#[cfg(feature = "async")]
fn recipient_async_round_trip<'a>(
recipients: Vec<Box<dyn Recipient>>,
recipients: Vec<Box<dyn Recipient + Send>>,
identities: impl Iterator<Item = &'a dyn Identity>,
) {
let test_msg = b"This is a test message. For testing.";
Expand Down
8 changes: 4 additions & 4 deletions rage/src/bin/rage/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ macro_rules! warning {
fn parse_recipient(
filename: &str,
s: String,
recipients: &mut Vec<Box<dyn Recipient>>,
recipients: &mut Vec<Box<dyn Recipient + Send>>,
plugin_recipients: &mut Vec<plugin::Recipient>,
) -> Result<(), error::EncryptError> {
if let Ok(pk) = s.parse::<age::x25519::Recipient>() {
Expand Down Expand Up @@ -93,7 +93,7 @@ fn parse_recipient(
fn read_recipients_list<R: BufRead>(
filename: &str,
buf: R,
recipients: &mut Vec<Box<dyn Recipient>>,
recipients: &mut Vec<Box<dyn Recipient + Send>>,
plugin_recipients: &mut Vec<plugin::Recipient>,
) -> io::Result<()> {
for (line_number, line) in buf.lines().enumerate() {
Expand Down Expand Up @@ -130,8 +130,8 @@ fn read_recipients(
recipients_file_strings: Vec<String>,
identity_strings: Vec<String>,
max_work_factor: Option<u8>,
) -> Result<Vec<Box<dyn Recipient>>, error::EncryptError> {
let mut recipients: Vec<Box<dyn Recipient>> = vec![];
) -> Result<Vec<Box<dyn Recipient + Send>>, error::EncryptError> {
let mut recipients: Vec<Box<dyn Recipient + Send>> = vec![];
let mut plugin_recipients: Vec<plugin::Recipient> = vec![];
let mut plugin_identities: Vec<plugin::Identity> = vec![];

Expand Down

0 comments on commit 9ccbf3c

Please sign in to comment.