summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2021-01-21 13:00:18 +0100
committerJustus Winter <justus@sequoia-pgp.org>2021-01-21 13:00:18 +0100
commit04aa0213ed1d0568f991b12d99ef6ebfefe0f03f (patch)
tree1f3acd1ecdf0838b2e8fa64e1a0ff7a93009d115
parent6e555106da58e943a7f2a3091c89c282232fc968 (diff)
sq: Move merge-signatures to sign --merge.
-rw-r--r--sq/src/commands/merge_signatures.rs6
-rw-r--r--sq/src/sq-usage.rs58
-rw-r--r--sq/src/sq.rs17
-rw-r--r--sq/src/sq_cli.rs25
4 files changed, 41 insertions, 65 deletions
diff --git a/sq/src/commands/merge_signatures.rs b/sq/src/commands/merge_signatures.rs
index d7d38bb7..7df3e2a3 100644
--- a/sq/src/commands/merge_signatures.rs
+++ b/sq/src/commands/merge_signatures.rs
@@ -2,7 +2,6 @@ use anyhow::Context as _;
use std::io;
extern crate sequoia_openpgp as openpgp;
-use crate::create_or_stdout;
use crate::openpgp::packet::Literal;
use crate::openpgp::packet::Tag;
use crate::openpgp::parse::{PacketParser, PacketParserResult, Parse};
@@ -13,15 +12,12 @@ use crate::openpgp::{Packet, Result};
pub fn merge_signatures(
input1: &mut (dyn io::Read + Send + Sync),
input2: &mut (dyn io::Read + Send + Sync),
- output_path: Option<&str>,
+ mut sink: Message,
) -> Result<()> {
let parser1 =
PacketParser::from_reader(input1).context("Failed to build parser")?;
let parser2 =
PacketParser::from_reader(input2).context("Failed to build parser")?;
- let mut output = create_or_stdout(output_path, false)?;
-
- let mut sink = Message::new(&mut output);
let (ops1, post_ops_parser1) = read_while_by_tag(parser1, Tag::OnePassSig)?;
let (ops2, post_ops_parser2) = read_while_by_tag(parser2, Tag::OnePassSig)?;
diff --git a/sq/src/sq-usage.rs b/sq/src/sq-usage.rs
index 4a8d5a2d..6a6df264 100644
--- a/sq/src/sq-usage.rs
+++ b/sq/src/sq-usage.rs
@@ -26,23 +26,21 @@
//! the critical bit set are considered invalid.
//!
//! SUBCOMMANDS:
-//! encrypt Encrypts a message
-//! decrypt Decrypts a message
-//! sign Signs messages or data files
-//! verify Verifies signed messages or detached signatures
-//! merge-signatures Merges two signatures
-//! key Manages keys
-//! certring Manages collections of certificates
-//! certify Certifies a User ID for a Certificate
-//! autocrypt Communicates certificates using Autocrypt
-//! keyserver Interacts with keyservers
-//! wkd Interacts with Web Key Directories
-//! armor Converts binary data to ASCII
-//! dearmor Converts ASCII to binary
-//! inspect Inspects data, like file(1)
-//! packet Low-level packet manipulation
-//! help Prints this message or the help of the given
-//! subcommand(s)
+//! encrypt Encrypts a message
+//! decrypt Decrypts a message
+//! sign Signs messages or data files
+//! verify Verifies signed messages or detached signatures
+//! key Manages keys
+//! certring Manages collections of certificates
+//! certify Certifies a User ID for a Certificate
+//! autocrypt Communicates certificates using Autocrypt
+//! keyserver Interacts with keyservers
+//! wkd Interacts with Web Key Directories
+//! armor Converts binary data to ASCII
+//! dearmor Converts ASCII to binary
+//! inspect Inspects data, like file(1)
+//! packet Low-level packet manipulation
+//! help Prints this message or the help of the given subcommand(s)
//! ```
//!
//! ## Subcommand encrypt
@@ -153,8 +151,11 @@
//! -n, --notarize Signs a message and all existing signatures
//!
//! OPTIONS:
-//! -o, --output <FILE> Writes to FILE or stdout if omitted
-//! --signer-key <KEY>... Signs using KEY
+//! --merge <SIGNED-MESSAGE>
+//! Merges signatures from the input and SIGNED-MESSAGE
+//!
+//! -o, --output <FILE> Writes to FILE or stdout if omitted
+//! --signer-key <KEY>... Signs using KEY
//! -t, --time <TIME>
//! Chooses keys valid at the specified time and sets the signature's
//! creation time
@@ -196,25 +197,6 @@
//! Reads from FILE or stdin if omitted
//! ```
//!
-//! ## Subcommand merge-signatures
-//!
-//! ```text
-//! Merges two signatures
-//!
-//! USAGE:
-//! sq merge-signatures [OPTIONS] [ARGS]
-//!
-//! FLAGS:
-//! -h, --help Prints help information
-//!
-//! OPTIONS:
-//! -o, --output <FILE> Writes to FILE or stdout if omitted
-//!
-//! ARGS:
-//! <FILE> Reads first message from FILE
-//! <FILE> Reads second message from FILE
-//! ```
-//!
//! ## Subcommand key
//!
//! ```text
diff --git a/sq/src/sq.rs b/sq/src/sq.rs
index 8f4707af..931fc24c 100644
--- a/sq/src/sq.rs
+++ b/sq/src/sq.rs
@@ -378,12 +378,6 @@ fn main() -> Result<()> {
m.is_present("use-expired-subkey"),
)?;
},
- ("merge-signatures", Some(m)) => {
- let mut input1 = open_or_stdin(m.value_of("input1"))?;
- let mut input2 = open_or_stdin(m.value_of("input2"))?;
- let output = m.value_of("output");
- commands::merge_signatures(&mut input1, &mut input2, output)?;
- },
("sign", Some(m)) => {
let mut input = open_or_stdin(m.value_of("input"))?;
let output = m.value_of("output");
@@ -401,8 +395,15 @@ fn main() -> Result<()> {
} else {
None
};
- commands::sign(policy, &mut input, output, secrets, detached, binary,
- append, notarize, time, force)?;
+ if let Some(merge) = m.value_of("merge") {
+ let output = create_or_stdout_pgp(output, force, binary,
+ armor::Kind::Message)?;
+ let mut input2 = open_or_stdin(Some(merge))?;
+ commands::merge_signatures(&mut input, &mut input2, output)?;
+ } else {
+ commands::sign(policy, &mut input, output, secrets, detached,
+ binary, append, notarize, time, force)?;
+ }
},
("verify", Some(m)) => {
let mut input = open_or_stdin(m.value_of("input"))?;
diff --git a/sq/src/sq_cli.rs b/sq/src/sq_cli.rs
index 239e2a84..c7de8cfe 100644
--- a/sq/src/sq_cli.rs
+++ b/sq/src/sq_cli.rs
@@ -132,20 +132,6 @@ pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> {
to using the one that expired last"))
)
- .subcommand(SubCommand::with_name("merge-signatures")
- .display_order(250)
- .about("Merges two signatures")
- .arg(Arg::with_name("input1")
- .value_name("FILE")
- .help("Reads first message from FILE"))
- .arg(Arg::with_name("input2")
- .value_name("FILE")
- .help("Reads second message from FILE"))
- .arg(Arg::with_name("output")
- .short("o").long("output").value_name("FILE")
- .help("Writes to FILE or stdout if omitted"))
- )
-
.subcommand(SubCommand::with_name("sign")
.display_order(200)
.about("Signs messages or data files")
@@ -169,6 +155,17 @@ pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> {
.short("n").long("notarize")
.conflicts_with("append")
.help("Signs a message and all existing signatures"))
+ .arg(Arg::with_name("merge")
+ .long("merge").value_name("SIGNED-MESSAGE")
+ .conflicts_with_all(&[
+ "append",
+ "detached",
+ "notarize",
+ "secret-key-file",
+ "time",
+ ])
+ .help("Merges signatures from the input and \
+ SIGNED-MESSAGE"))
.arg(Arg::with_name("secret-key-file")
.long("signer-key").value_name("KEY")
.multiple(true).number_of_values(1)