summaryrefslogtreecommitdiffstats
path: root/sq
diff options
context:
space:
mode:
authorNora Widdecke <nora@sequoia-pgp.org>2022-08-09 14:54:32 +0200
committerNora Widdecke <nora@sequoia-pgp.org>2022-08-11 11:52:38 +0200
commit73531db090f97f67eef714e29b26d1b88a5f5701 (patch)
tree94b5598a777a2747e3a9e263c68f00b29307139e /sq
parentc9477e05d3c96aa6fb2e1783c329ec80bbfa760f (diff)
sq: Remove prefix Cli from names.
Diffstat (limited to 'sq')
-rw-r--r--sq/src/commands/decrypt.rs2
-rw-r--r--sq/src/commands/dump.rs4
-rw-r--r--sq/src/sq_cli/armor.rs22
-rw-r--r--sq/src/sq_cli/decrypt.rs4
-rw-r--r--sq/src/sq_cli/encrypt.rs4
-rw-r--r--sq/src/sq_cli/key.rs6
-rw-r--r--sq/src/sq_cli/mod.rs66
-rw-r--r--sq/src/sq_cli/packet.rs6
-rw-r--r--sq/src/sq_cli/revoke.rs8
-rw-r--r--sq/src/sq_cli/sign.rs4
10 files changed, 63 insertions, 63 deletions
diff --git a/sq/src/commands/decrypt.rs b/sq/src/commands/decrypt.rs
index af766a04..25aecbe3 100644
--- a/sq/src/commands/decrypt.rs
+++ b/sq/src/commands/decrypt.rs
@@ -25,7 +25,7 @@ use crate::{
dump::PacketDumper,
VHelper,
},
- sq_cli::CliSessionKey,
+ sq_cli::SessionKey as CliSessionKey,
};
trait PrivateKey {
diff --git a/sq/src/commands/dump.rs b/sq/src/commands/dump.rs
index 130cafd4..606f5fc3 100644
--- a/sq/src/commands/dump.rs
+++ b/sq/src/commands/dump.rs
@@ -12,7 +12,7 @@ use self::openpgp::packet::signature::subpacket::{Subpacket, SubpacketValue};
use self::openpgp::crypto::S2K;
use self::openpgp::parse::{map::Map, Parse, PacketParserResult};
-use crate::sq_cli::CliSessionKey;
+use crate::sq_cli::SessionKey;
#[derive(Debug)]
pub enum Kind {
@@ -58,7 +58,7 @@ impl Convert<chrono::DateTime<chrono::offset::Utc>> for Timestamp {
pub fn dump<W>(input: &mut (dyn io::Read + Sync + Send),
output: &mut dyn io::Write,
mpis: bool, hex: bool,
- sk: Option<&CliSessionKey>,
+ sk: Option<&SessionKey>,
width: W)
-> Result<Kind>
where W: Into<Option<usize>>
diff --git a/sq/src/sq_cli/armor.rs b/sq/src/sq_cli/armor.rs
index 096f9b58..78d05de7 100644
--- a/sq/src/sq_cli/armor.rs
+++ b/sq/src/sq_cli/armor.rs
@@ -36,15 +36,15 @@ pub struct Command {
long = "label",
value_name = "LABEL",
help = "Selects the kind of armor header",
- default_value_t = CliArmorKind::Auto,
+ default_value_t = ArmorKind::Auto,
arg_enum
)]
- pub kind: CliArmorKind,
+ pub kind: ArmorKind,
}
#[derive(ArgEnum)]
#[derive(Debug, Clone)]
-pub enum CliArmorKind {
+pub enum ArmorKind {
Auto,
Message,
#[clap(name = "cert")]
@@ -57,15 +57,15 @@ pub enum CliArmorKind {
}
use sequoia_openpgp::armor::Kind as OpenPGPArmorKind;
-impl From<CliArmorKind> for Option<OpenPGPArmorKind> {
- fn from(c: CliArmorKind) -> Self {
+impl From<ArmorKind> for Option<OpenPGPArmorKind> {
+ fn from(c: ArmorKind) -> Self {
match c {
- CliArmorKind::Auto => None,
- CliArmorKind::Message => Some(OpenPGPArmorKind::Message),
- CliArmorKind::PublicKey => Some(OpenPGPArmorKind::PublicKey),
- CliArmorKind::SecretKey => Some(OpenPGPArmorKind::SecretKey),
- CliArmorKind::Signature => Some(OpenPGPArmorKind::Signature),
- CliArmorKind::File => Some(OpenPGPArmorKind::File),
+ ArmorKind::Auto => None,
+ ArmorKind::Message => Some(OpenPGPArmorKind::Message),
+ ArmorKind::PublicKey => Some(OpenPGPArmorKind::PublicKey),
+ ArmorKind::SecretKey => Some(OpenPGPArmorKind::SecretKey),
+ ArmorKind::Signature => Some(OpenPGPArmorKind::Signature),
+ ArmorKind::File => Some(OpenPGPArmorKind::File),
}
}
}
diff --git a/sq/src/sq_cli/decrypt.rs b/sq/src/sq_cli/decrypt.rs
index 17efa836..aa09f575 100644
--- a/sq/src/sq_cli/decrypt.rs
+++ b/sq/src/sq_cli/decrypt.rs
@@ -1,6 +1,6 @@
use clap::Parser;
-use super::{CliSessionKey, IoArgs};
+use super::{SessionKey, IoArgs};
#[derive(Parser, Debug)]
#[clap(
@@ -85,7 +85,7 @@ pub struct Command {
value_name = "SESSION-KEY",
help = "Decrypts an encrypted message using SESSION-KEY",
)]
- pub session_key: Vec<CliSessionKey>,
+ pub session_key: Vec<SessionKey>,
#[clap(
long = "dump",
help = "Prints a packet dump to stderr",
diff --git a/sq/src/sq_cli/encrypt.rs b/sq/src/sq_cli/encrypt.rs
index dc4b4f20..1e7a32ab 100644
--- a/sq/src/sq_cli/encrypt.rs
+++ b/sq/src/sq_cli/encrypt.rs
@@ -1,6 +1,6 @@
use clap::{ArgEnum, Parser};
-use super::{IoArgs, CliTime};
+use super::{IoArgs, Time};
#[derive(Parser, Debug)]
#[clap(
@@ -96,7 +96,7 @@ pub struct Command {
help = "Chooses keys valid at the specified time and \
sets the signature's creation time",
)]
- pub time: Option<CliTime>,
+ pub time: Option<Time>,
#[clap(
long = "use-expired-subkey",
help = "Falls back to expired encryption subkeys",
diff --git a/sq/src/sq_cli/key.rs b/sq/src/sq_cli/key.rs
index 9d81a56d..93684304 100644
--- a/sq/src/sq_cli/key.rs
+++ b/sq/src/sq_cli/key.rs
@@ -1,6 +1,6 @@
use clap::{ArgEnum, ArgGroup, Args, Parser, Subcommand};
-use super::{IoArgs, CliTime};
+use super::{IoArgs, Time};
#[derive(Parser, Debug)]
#[clap(
@@ -115,7 +115,7 @@ default timezone is UTC):
$ sq key generate --creation-time 20110609T1938+0200 --export noam.pgp
",
)]
- pub creation_time: Option<CliTime>,
+ pub creation_time: Option<Time>,
#[clap(
long = "expires",
value_name = "TIME",
@@ -355,7 +355,7 @@ $ sq key userid add --userid \"Juliet\" --creation-time 20210628T1137+0200 \\
juliet.key.pgp --output juliet-new.key.pgp
",
)]
- pub creation_time: Option<CliTime>,
+ pub creation_time: Option<Time>,
#[clap(
long = "private-key-store",
value_name = "KEY_STORE",
diff --git a/sq/src/sq_cli/mod.rs b/sq/src/sq_cli/mod.rs
index acbceb13..30c68da8 100644
--- a/sq/src/sq_cli/mod.rs
+++ b/sq/src/sq_cli/mod.rs
@@ -3,7 +3,7 @@ use clap::{Command, ArgEnum, Args, Subcommand};
use clap::{CommandFactory, Parser};
use sequoia_openpgp as openpgp;
-use openpgp::crypto::SessionKey;
+use openpgp::crypto::SessionKey as OpenPGPSessionKey;
use openpgp::types::SymmetricAlgorithm;
use openpgp::fmt::hex;
@@ -147,21 +147,21 @@ pub enum SqSubcommands {
use chrono::{offset::Utc, DateTime};
#[derive(Debug)]
-pub struct CliTime {
+pub struct Time {
pub time: DateTime<Utc>,
}
-impl std::str::FromStr for CliTime {
+impl std::str::FromStr for Time {
type Err = anyhow::Error;
- fn from_str(s: &str) -> anyhow::Result<CliTime> {
+ fn from_str(s: &str) -> anyhow::Result<Time> {
let time =
- CliTime::parse_iso8601(s, chrono::NaiveTime::from_hms(0, 0, 0))?;
- Ok(CliTime { time })
+ Time::parse_iso8601(s, chrono::NaiveTime::from_hms(0, 0, 0))?;
+ Ok(Time { time })
}
}
-impl CliTime {
+impl Time {
/// Parses the given string depicting a ISO 8601 timestamp.
fn parse_iso8601(
s: &str,
@@ -221,7 +221,7 @@ pub struct IoArgs {
pub output: Option<String>,
}
-// TODO: reuse CliArmorKind, requires changes in sq.rs
+// TODO: reuse ArmorKind, requires changes in sq.rs
#[derive(ArgEnum, Clone, Debug)]
pub enum PacketKind {
Auto,
@@ -277,12 +277,12 @@ impl From<NetworkPolicy> for sequoia_net::Policy {
/// [`Display`]: std::fmt::Display
/// [`display_sensitive`]: CliSessionKey::display_sensitive
#[derive(Debug, Clone)]
-pub struct CliSessionKey {
- pub session_key: SessionKey,
+pub struct SessionKey {
+ pub session_key: OpenPGPSessionKey,
pub symmetric_algo: Option<SymmetricAlgorithm>,
}
-impl std::str::FromStr for CliSessionKey {
+impl std::str::FromStr for SessionKey {
type Err = anyhow::Error;
/// Parse a session key. The format is: an optional prefix specifying the
@@ -292,13 +292,13 @@ impl std::str::FromStr for CliSessionKey {
let result = if let Some((algo, sk)) = sk.split_once(':') {
let algo = SymmetricAlgorithm::from(algo.parse::<u8>()?);
let dsk = hex::decode_pretty(sk)?.into();
- CliSessionKey {
+ SessionKey {
session_key: dsk,
symmetric_algo: Some(algo),
}
} else {
let dsk = hex::decode_pretty(sk)?.into();
- CliSessionKey {
+ SessionKey {
session_key: dsk,
symmetric_algo: None,
}
@@ -307,12 +307,12 @@ impl std::str::FromStr for CliSessionKey {
}
}
-impl CliSessionKey {
+impl SessionKey {
/// Returns an object that implements Display for explicitly opting into
/// printing a `SessionKey`.
- pub fn display_sensitive(&self) -> CliSessionKeyDisplay {
- CliSessionKeyDisplay { csk: self }
+ pub fn display_sensitive(&self) -> SessionKeyDisplay {
+ SessionKeyDisplay { csk: self }
}
}
@@ -323,12 +323,12 @@ impl CliSessionKey {
/// [`CliSessionKey::display_sensitive`]. By requiring the user to opt-in, this
/// will hopefully reduce that the chance that the session key is inadvertently
/// leaked, e.g., in a log that may be publicly posted.
-pub struct CliSessionKeyDisplay<'a> {
- csk: &'a CliSessionKey,
+pub struct SessionKeyDisplay<'a> {
+ csk: &'a SessionKey,
}
/// Print the session key without prefix in hexadecimal representation.
-impl<'a> std::fmt::Display for CliSessionKeyDisplay<'a> {
+impl<'a> std::fmt::Display for SessionKeyDisplay<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
let sk = self.csk;
write!(f, "{}", hex::encode(&sk.session_key))
@@ -342,26 +342,26 @@ mod test {
#[test]
fn test_parse_iso8601() -> anyhow::Result<()> {
let z = chrono::NaiveTime::from_hms(0, 0, 0);
- CliTime::parse_iso8601("2017-03-04T13:25:35Z", z)?;
- CliTime::parse_iso8601("2017-03-04T13:25:35+08:30", z)?;
- CliTime::parse_iso8601("2017-03-04T13:25:35", z)?;
- CliTime::parse_iso8601("2017-03-04T13:25Z", z)?;
- CliTime::parse_iso8601("2017-03-04T13:25", z)?;
+ Time::parse_iso8601("2017-03-04T13:25:35Z", z)?;
+ Time::parse_iso8601("2017-03-04T13:25:35+08:30", z)?;
+ Time::parse_iso8601("2017-03-04T13:25:35", z)?;
+ Time::parse_iso8601("2017-03-04T13:25Z", z)?;
+ Time::parse_iso8601("2017-03-04T13:25", z)?;
// CliTime::parse_iso8601("2017-03-04T13Z", z)?; // XXX: chrono doesn't like
// CliTime::parse_iso8601("2017-03-04T13", z)?; // ditto
- CliTime::parse_iso8601("2017-03-04", z)?;
+ Time::parse_iso8601("2017-03-04", z)?;
// CliTime::parse_iso8601("2017-03", z)?; // ditto
- CliTime::parse_iso8601("2017-031", z)?;
- CliTime::parse_iso8601("20170304T132535Z", z)?;
- CliTime::parse_iso8601("20170304T132535+0830", z)?;
- CliTime::parse_iso8601("20170304T132535", z)?;
- CliTime::parse_iso8601("20170304T1325Z", z)?;
- CliTime::parse_iso8601("20170304T1325", z)?;
+ Time::parse_iso8601("2017-031", z)?;
+ Time::parse_iso8601("20170304T132535Z", z)?;
+ Time::parse_iso8601("20170304T132535+0830", z)?;
+ Time::parse_iso8601("20170304T132535", z)?;
+ Time::parse_iso8601("20170304T1325Z", z)?;
+ Time::parse_iso8601("20170304T1325", z)?;
// CliTime::parse_iso8601("20170304T13Z", z)?; // ditto
// CliTime::parse_iso8601("20170304T13", z)?; // ditto
- CliTime::parse_iso8601("20170304", z)?;
+ Time::parse_iso8601("20170304", z)?;
// CliTime::parse_iso8601("201703", z)?; // ditto
- CliTime::parse_iso8601("2017031", z)?;
+ Time::parse_iso8601("2017031", z)?;
// CliTime::parse_iso8601("2017", z)?; // ditto
Ok(())
}
diff --git a/sq/src/sq_cli/packet.rs b/sq/src/sq_cli/packet.rs
index 1672e613..02933322 100644
--- a/sq/src/sq_cli/packet.rs
+++ b/sq/src/sq_cli/packet.rs
@@ -1,6 +1,6 @@
use clap::{Args, Parser, Subcommand};
-use super::{IoArgs, CliSessionKey, PacketKind};
+use super::{IoArgs, SessionKey, PacketKind};
#[derive(Parser, Debug)]
#[clap(
@@ -70,7 +70,7 @@ pub struct DumpCommand {
value_name = "SESSION-KEY",
help = "Decrypts an encrypted message using SESSION-KEY",
)]
- pub session_key: Option<CliSessionKey>,
+ pub session_key: Option<SessionKey>,
#[clap(
long = "mpis",
help = "Prints cryptographic artifacts",
@@ -126,7 +126,7 @@ pub struct DecryptCommand {
value_name = "SESSION-KEY",
help = "Decrypts an encrypted message using SESSION-KEY",
)]
- pub session_key: Vec<CliSessionKey>,
+ pub session_key: Vec<SessionKey>,
#[clap(
long = "dump-session-key",
help = "Prints the session key to stderr",
diff --git a/sq/src/sq_cli/revoke.rs b/sq/src/sq_cli/revoke.rs
index 3ec26e14..10e54ed6 100644
--- a/sq/src/sq_cli/revoke.rs
+++ b/sq/src/sq_cli/revoke.rs
@@ -3,7 +3,7 @@ use clap::{ArgEnum, Args, Subcommand};
use sequoia_openpgp as openpgp;
-use super::CliTime;
+use super::Time;
#[derive(Parser, Debug)]
#[clap(
@@ -162,7 +162,7 @@ that in the future.\"",
"Chooses keys valid at the specified time and sets the revocation \
certificate's creation time",
)]
- pub time: Option<CliTime>,
+ pub time: Option<Time>,
#[clap(
long,
value_names = &["NAME", "VALUE"],
@@ -315,7 +315,7 @@ the message \"I've created a new subkey, please refresh the certificate."
"Chooses keys valid at the specified time and sets the revocation \
certificate's creation time",
)]
- pub time: Option<CliTime>,
+ pub time: Option<Time>,
#[clap(
long,
value_names = &["NAME", "VALUE"],
@@ -436,7 +436,7 @@ that in the future.\"",
"Chooses keys valid at the specified time and sets the revocation \
certificate's creation time",
)]
- pub time: Option<CliTime>,
+ pub time: Option<Time>,
#[clap(
long,
value_names = &["NAME", "VALUE"],
diff --git a/sq/src/sq_cli/sign.rs b/sq/src/sq_cli/sign.rs
index 5086c94f..13c45c41 100644
--- a/sq/src/sq_cli/sign.rs
+++ b/sq/src/sq_cli/sign.rs
@@ -1,6 +1,6 @@
use clap::Parser;
-use super::{IoArgs, CliTime};
+use super::{IoArgs, Time};
#[derive(Parser, Debug)]
#[clap(
@@ -97,7 +97,7 @@ pub struct Command {
help = "Chooses keys valid at the specified time and sets the \
signature's creation time",
)]
- pub time: Option<CliTime>,
+ pub time: Option<Time>,
#[clap(
long,
value_names = &["NAME", "VALUE"],