diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2018-10-16 15:06:10 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2018-10-16 16:25:39 +0200 |
commit | 3d996ff3bc0e939caa6c0edb81c75e763d8c8344 (patch) | |
tree | f1d32b1d1b6531c8708cbf0d7641a93ac9f636c6 /tool | |
parent | 09664cf092f19648c8d2a14ff1b76d418ed0a42f (diff) |
openpgp: Improve the streaming writer API.
- Also, improve documentation and doctests.
Diffstat (limited to 'tool')
-rw-r--r-- | tool/src/commands/mod.rs | 13 | ||||
-rw-r--r-- | tool/tests/sq-sign.rs | 5 |
2 files changed, 12 insertions, 6 deletions
diff --git a/tool/src/commands/mod.rs b/tool/src/commands/mod.rs index d7e0637c..1d1af435 100644 --- a/tool/src/commands/mod.rs +++ b/tool/src/commands/mod.rs @@ -20,7 +20,7 @@ use openpgp::parse::stream::{ }; use openpgp::serialize::Serialize; use openpgp::serialize::stream::{ - wrap, Signer, LiteralWriter, Encryptor, EncryptionMode, + Message, Signer, LiteralWriter, Encryptor, EncryptionMode, }; extern crate sequoia_store as store; @@ -61,8 +61,11 @@ pub fn encrypt(store: &mut store::Store, let passwords_: Vec<&openpgp::Password> = passwords.iter().collect(); + // Stream an OpenPGP message. + let message = Message::new(output); + // We want to encrypt a literal data packet. - let mut sink = Encryptor::new(wrap(output), + let mut sink = Encryptor::new(message, &passwords_, &recipients, EncryptionMode::AtRest) @@ -156,7 +159,9 @@ fn sign_data(input: &mut io::Read, output_path: Option<&str>, sig.serialize(&mut output)?; } - let sink = wrap(output); + // Stream an OpenPGP message. + let sink = Message::new(output); + // Build a vector of references to hand to Signer. let keys: Vec<&openpgp::TPK> = secrets.iter().collect(); let signer = if detached { @@ -202,7 +207,7 @@ fn sign_message(input: &mut io::Read, output_path: Option<&str>, output }; - let mut sink = wrap(output); + let mut sink = Message::new(output); // Build a vector of references to hand to Signer. let keys: Vec<&openpgp::TPK> = secrets.iter().collect(); diff --git a/tool/tests/sq-sign.rs b/tool/tests/sq-sign.rs index e69420f3..0f2e5e40 100644 --- a/tool/tests/sq-sign.rs +++ b/tool/tests/sq-sign.rs @@ -9,7 +9,7 @@ use tempfile::TempDir; extern crate openpgp; use openpgp::{Packet, PacketPile, Reader, TPK}; use openpgp::constants::{CompressionAlgorithm, DataFormat, SignatureType}; -use openpgp::serialize::stream::{wrap, Signer, Compressor, LiteralWriter}; +use openpgp::serialize::stream::{Message, Signer, Compressor, LiteralWriter}; fn p(filename: &str) -> String { format!("../openpgp/tests/data/{}", filename) @@ -208,7 +208,8 @@ fn sq_sign_append_on_compress_then_sign() { // message by foot. let tsk = TPK::from_file(&p("keys/dennis-simon-anton-private.pgp")) .unwrap(); - let signer = Signer::new(wrap(File::create(&sig0).unwrap()), &[&tsk]) + let signer = Signer::new(Message::new(File::create(&sig0).unwrap()), + &[&tsk]) .unwrap(); let compressor = Compressor::new(signer, CompressionAlgorithm::Uncompressed) .unwrap(); |