diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-03-16 16:18:11 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-03-16 16:18:11 +0100 |
commit | 249c557f1a9e3d796e3f195872acef41a4029f38 (patch) | |
tree | 206b4b6567fa70c09149e7932050a36cabce5923 /openpgp/examples | |
parent | d8b3ac96daed4bc6939c3c2bb3df47247624bda5 (diff) |
openpgp: Fix examples.
- Properly finalize the armor writer.
Diffstat (limited to 'openpgp/examples')
-rw-r--r-- | openpgp/examples/encrypt-for.rs | 8 | ||||
-rw-r--r-- | openpgp/examples/notarize.rs | 8 | ||||
-rw-r--r-- | openpgp/examples/pad.rs | 8 | ||||
-rw-r--r-- | openpgp/examples/sign-detached.rs | 8 | ||||
-rw-r--r-- | openpgp/examples/sign.rs | 8 | ||||
-rw-r--r-- | openpgp/examples/wrap-literal.rs | 8 |
6 files changed, 36 insertions, 12 deletions
diff --git a/openpgp/examples/encrypt-for.rs b/openpgp/examples/encrypt-for.rs index 557e648f..ef6486eb 100644 --- a/openpgp/examples/encrypt-for.rs +++ b/openpgp/examples/encrypt-for.rs @@ -50,11 +50,11 @@ fn main() { // Compose a writer stack corresponding to the output format and // packet structure we want. First, we want the output to be // ASCII armored. - let sink = armor::Writer::new(io::stdout(), armor::Kind::Message, &[]) + let mut sink = armor::Writer::new(io::stdout(), armor::Kind::Message, &[]) .expect("Failed to create an armored writer"); // Stream an OpenPGP message. - let message = Message::new(sink); + let message = Message::new(&mut sink); // We want to encrypt a literal data packet. let mut encryptor = Encryptor::for_recipient( @@ -74,4 +74,8 @@ fn main() { // Finally, finalize the OpenPGP message by tearing down the // writer stack. literal_writer.finalize().unwrap(); + + // Finalize the armor writer. + sink.finalize() + .expect("Failed to write data"); } diff --git a/openpgp/examples/notarize.rs b/openpgp/examples/notarize.rs index b6c71dab..f7a9842a 100644 --- a/openpgp/examples/notarize.rs +++ b/openpgp/examples/notarize.rs @@ -58,11 +58,11 @@ fn main() { // Compose a writer stack corresponding to the output format and // packet structure we want. First, we want the output to be // ASCII armored. - let sink = armor::Writer::new(io::stdout(), armor::Kind::Message, &[]) + let mut sink = armor::Writer::new(io::stdout(), armor::Kind::Message, &[]) .expect("Failed to create an armored writer."); // Stream an OpenPGP message. - let message = Message::new(sink); + let message = Message::new(&mut sink); // Now, create a signer that emits the signature(s). let mut signer = @@ -121,4 +121,8 @@ fn main() { // Finally, teardown the stack to ensure all the data is written. signer.finalize() .expect("Failed to write data"); + + // Finalize the armor writer. + sink.finalize() + .expect("Failed to write data"); } diff --git a/openpgp/examples/pad.rs b/openpgp/examples/pad.rs index c1c341c8..6f49cbf3 100644 --- a/openpgp/examples/pad.rs +++ b/openpgp/examples/pad.rs @@ -51,11 +51,11 @@ fn main() { // Compose a writer stack corresponding to the output format and // packet structure we want. First, we want the output to be // ASCII armored. - let sink = armor::Writer::new(io::stdout(), armor::Kind::Message, &[]) + let mut sink = armor::Writer::new(io::stdout(), armor::Kind::Message, &[]) .expect("Failed to create an armored writer"); // Stream an OpenPGP message. - let message = Message::new(sink); + let message = Message::new(&mut sink); // We want to encrypt a literal data packet. let mut encryptor = Encryptor::for_recipient( @@ -78,4 +78,8 @@ fn main() { // Finally, finalize the OpenPGP message by tearing down the // writer stack. literal_writer.finalize().unwrap(); + + // Finalize the armor writer. + sink.finalize() + .expect("Failed to write data"); } diff --git a/openpgp/examples/sign-detached.rs b/openpgp/examples/sign-detached.rs index 2d576808..a185cef9 100644 --- a/openpgp/examples/sign-detached.rs +++ b/openpgp/examples/sign-detached.rs @@ -54,11 +54,11 @@ fn main() { // Compose a writer stack corresponding to the output format and // packet structure we want. First, we want the output to be // ASCII armored. - let sink = armor::Writer::new(io::stdout(), armor::Kind::Signature, &[]) + let mut sink = armor::Writer::new(io::stdout(), armor::Kind::Signature, &[]) .expect("Failed to create armored writer."); // Stream an OpenPGP message. - let message = Message::new(sink); + let message = Message::new(&mut sink); // Now, create a signer that emits the detached signature(s). let mut signer = @@ -76,4 +76,8 @@ fn main() { // Finally, teardown the stack to ensure all the data is written. signer.finalize() .expect("Failed to write data"); + + // Finalize the armor writer. + sink.finalize() + .expect("Failed to write data"); } diff --git a/openpgp/examples/sign.rs b/openpgp/examples/sign.rs index 1a0f61dd..bfef64de 100644 --- a/openpgp/examples/sign.rs +++ b/openpgp/examples/sign.rs @@ -53,11 +53,11 @@ fn main() { // Compose a writer stack corresponding to the output format and // packet structure we want. First, we want the output to be // ASCII armored. - let sink = armor::Writer::new(io::stdout(), armor::Kind::Message, &[]) + let mut sink = armor::Writer::new(io::stdout(), armor::Kind::Message, &[]) .expect("Failed to create an armored writer."); // Stream an OpenPGP message. - let message = Message::new(sink); + let message = Message::new(&mut sink); // Now, create a signer that emits the signature(s). let mut signer = @@ -79,4 +79,8 @@ fn main() { // Finally, teardown the stack to ensure all the data is written. literal.finalize() .expect("Failed to write data"); + + // Finalize the armor writer. + sink.finalize() + .expect("Failed to write data"); } diff --git a/openpgp/examples/wrap-literal.rs b/openpgp/examples/wrap-literal.rs index 567ba3b5..07cad384 100644 --- a/openpgp/examples/wrap-literal.rs +++ b/openpgp/examples/wrap-literal.rs @@ -20,11 +20,11 @@ fn main() { // Compose a writer stack corresponding to the output format and // packet structure we want. First, we want the output to be // ASCII armored. - let sink = armor::Writer::new(io::stdout(), armor::Kind::Message, &[]) + let mut sink = armor::Writer::new(io::stdout(), armor::Kind::Message, &[]) .expect("Failed to create armored writer."); // Stream an OpenPGP message. - let message = Message::new(sink); + let message = Message::new(&mut sink); // Then, create a literal writer to wrap the data in a literal // message packet. @@ -38,4 +38,8 @@ fn main() { // Finally, teardown the stack to ensure all the data is written. literal.finalize() .expect("Failed to write data"); + + // Finalize the armor writer. + sink.finalize() + .expect("Failed to write data"); } |