summaryrefslogtreecommitdiffstats
path: root/tool
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2018-05-29 15:16:11 +0200
committerJustus Winter <justus@sequoia-pgp.org>2018-05-29 15:20:43 +0200
commitbd94fc97de6911c447ab30e7b48a8e5d88bb4578 (patch)
tree63c353254c0d7f608f614775202a6d6a5663cf30 /tool
parentf984d7962cb38e8901de4a0aa994bfd617c98999 (diff)
tool: Transparently handle armored data.
Diffstat (limited to 'tool')
-rw-r--r--tool/src/cli.rs20
-rw-r--r--tool/src/sq-usage.rs8
-rw-r--r--tool/src/sq.rs32
-rw-r--r--tool/src/sqv.rs6
4 files changed, 16 insertions, 50 deletions
diff --git a/tool/src/cli.rs b/tool/src/cli.rs
index 26a8ecb8..64f69fa4 100644
--- a/tool/src/cli.rs
+++ b/tool/src/cli.rs
@@ -23,10 +23,6 @@ pub fn build() -> App<'static, 'static> {
.long("output")
.short("o")
.help("Sets the output file to use"))
- .arg(Arg::with_name("dearmor")
- .long("dearmor")
- .short("A")
- .help("Remove ASCII Armor from input"))
.arg(Arg::with_name("dump")
.long("dump")
.help("Print a packet dump to stderr"))
@@ -64,10 +60,6 @@ pub fn build() -> App<'static, 'static> {
.long("output")
.short("o")
.help("Sets the output file to use"))
- .arg(Arg::with_name("dearmor")
- .long("dearmor")
- .short("A")
- .help("Remove ASCII Armor from input"))
.arg(Arg::with_name("hex")
.long("hex")
.short("x")
@@ -96,11 +88,7 @@ pub fn build() -> App<'static, 'static> {
.arg(Arg::with_name("input").value_name("FILE")
.long("input")
.short("i")
- .help("Sets the input file to use"))
- .arg(Arg::with_name("dearmor")
- .long("dearmor")
- .short("A")
- .help("Remove ASCII Armor from input"))))
+ .help("Sets the input file to use"))))
.subcommand(SubCommand::with_name("store")
.about("Interacts with key stores")
.arg(Arg::with_name("name").value_name("NAME")
@@ -124,11 +112,7 @@ pub fn build() -> App<'static, 'static> {
.arg(Arg::with_name("input").value_name("FILE")
.long("input")
.short("i")
- .help("Sets the input file to use"))
- .arg(Arg::with_name("dearmor")
- .long("dearmor")
- .short("A")
- .help("Remove ASCII Armor from input")))
+ .help("Sets the input file to use")))
.subcommand(SubCommand::with_name("export")
.about("Exports a key")
.arg(Arg::with_name("label").value_name("LABEL")
diff --git a/tool/src/sq-usage.rs b/tool/src/sq-usage.rs
index 82a7d4b6..a9516d44 100644
--- a/tool/src/sq-usage.rs
+++ b/tool/src/sq-usage.rs
@@ -53,7 +53,6 @@
//! sq decrypt [FLAGS] [OPTIONS]
//!
//! FLAGS:
-//! -A, --dearmor Remove ASCII Armor from input
//! --dump Print a packet dump to stderr
//! -h, --help Prints help information
//! -x, --hex Print a hexdump (implies --dump)
@@ -73,7 +72,6 @@
//! sq dump [FLAGS] [OPTIONS]
//!
//! FLAGS:
-//! -A, --dearmor Remove ASCII Armor from input
//! -h, --help Prints help information
//! -x, --hex Print a hexdump
//! -V, --version Prints version information
@@ -147,10 +145,9 @@
//! Sends a key
//!
//! USAGE:
-//! sq keyserver send [FLAGS] [OPTIONS]
+//! sq keyserver send [OPTIONS]
//!
//! FLAGS:
-//! -A, --dearmor Remove ASCII Armor from input
//! -h, --help Prints help information
//! -V, --version Prints version information
//!
@@ -322,10 +319,9 @@
//! Imports a key
//!
//! USAGE:
-//! sq store <NAME> import [FLAGS] [OPTIONS] <LABEL>
+//! sq store <NAME> import [OPTIONS] <LABEL>
//!
//! FLAGS:
-//! -A, --dearmor Remove ASCII Armor from input
//! -h, --help Prints help information
//! -V, --version Prints version information
//!
diff --git a/tool/src/sq.rs b/tool/src/sq.rs
index 50eab105..a09a9ded 100644
--- a/tool/src/sq.rs
+++ b/tool/src/sq.rs
@@ -61,13 +61,9 @@ fn real_main() -> Result<(), failure::Error> {
match matches.subcommand() {
("decrypt", Some(m)) => {
- let mut input = open_or_stdin(m.value_of("input"))?;
+ let input = open_or_stdin(m.value_of("input"))?;
let mut output = create_or_stdout(m.value_of("output"))?;
- let mut input = if m.is_present("dearmor") {
- Box::new(armor::Reader::new(&mut input, armor::Kind::Any))
- } else {
- input
- };
+ let mut input = openpgp::Reader::from_reader(input)?;
commands::decrypt(&mut input, &mut output,
m.is_present("dump"), m.is_present("hex"))?;
},
@@ -84,13 +80,9 @@ fn real_main() -> Result<(), failure::Error> {
io::copy(&mut filter, &mut output)?;
},
("dump", Some(m)) => {
- let mut input = open_or_stdin(m.value_of("input"))?;
+ let input = open_or_stdin(m.value_of("input"))?;
let mut output = create_or_stdout(m.value_of("output"))?;
- let mut input = if m.is_present("dearmor") {
- Box::new(armor::Reader::new(&mut input, armor::Kind::Any))
- } else {
- input
- };
+ let mut input = openpgp::Reader::from_reader(input)?;
commands::dump(&mut input, &mut output, m.is_present("hex"))?;
},
("keyserver", Some(m)) => {
@@ -125,12 +117,8 @@ fn real_main() -> Result<(), failure::Error> {
.context("Failed to serialize key")?;
},
("send", Some(m)) => {
- let mut input = open_or_stdin(m.value_of("input"))?;
- let mut input = if m.is_present("dearmor") {
- Box::new(armor::Reader::new(&mut input, armor::Kind::Any))
- } else {
- input
- };
+ let input = open_or_stdin(m.value_of("input"))?;
+ let mut input = openpgp::Reader::from_reader(input)?;
let tpk = TPK::from_reader(&mut input).
context("Malformed key")?;
@@ -158,12 +146,8 @@ fn real_main() -> Result<(), failure::Error> {
store.add(m.value_of("label").unwrap(), &fp)?;
},
("import", Some(m)) => {
- let mut input = open_or_stdin(m.value_of("input"))?;
- let mut input = if m.is_present("dearmor") {
- Box::new(armor::Reader::new(&mut input, armor::Kind::Any))
- } else {
- input
- };
+ let input = open_or_stdin(m.value_of("input"))?;
+ let mut input = openpgp::Reader::from_reader(input)?;
let tpk = TPK::from_reader(&mut input)?;
store.import(m.value_of("label").unwrap(), &tpk)?;
diff --git a/tool/src/sqv.rs b/tool/src/sqv.rs
index e93f35b8..0236f95e 100644
--- a/tool/src/sqv.rs
+++ b/tool/src/sqv.rs
@@ -106,7 +106,8 @@ fn real_main() -> Result<(), failure::Error> {
// .unwrap() is safe, because "sig-file" is required.
let sig_file = matches.value_of_os("sig-file").unwrap();
- let mut ppo = PacketParser::from_file(sig_file)?;
+ let mut ppo = PacketParser::from_reader(
+ openpgp::Reader::from_file(sig_file)?)?;
let mut sigs : Vec<(Signature, KeyID, Option<TPK>)> = Vec::new();
@@ -175,7 +176,8 @@ fn real_main() -> Result<(), failure::Error> {
.expect("No keyring specified.")
{
// Load the keyring.
- let mut ppo = PacketParser::from_file(filename)?;
+ let mut ppo = PacketParser::from_reader(
+ openpgp::Reader::from_file(filename)?)?;
// We store packets in an accumulator until we are sure that
// we want to build and use a TPK.