diff --git a/.gitignore b/.gitignore index 45ae1a8..5e5bde1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ enc.txt enc_key.pem sign_key.pem test_key.asc +test_gpg.asc .idea/ # ---> Rust # Generated by Cargo diff --git a/Cargo.lock b/Cargo.lock index db92919..4c405af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -292,7 +292,7 @@ dependencies = [ [[package]] name = "card-cli" -version = "1.0.0" +version = "1.0.1" dependencies = [ "authenticator", "base64 0.13.0", diff --git a/Cargo.toml b/Cargo.toml index 3902d7b..a408d58 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "card-cli" -version = "1.0.0" +version = "1.0.1" authors = ["Hatter Jiang "] edition = "2018" diff --git a/README.md b/README.md index a94a5c0..079c4ff 100644 --- a/README.md +++ b/README.md @@ -7,16 +7,6 @@ Install: cargo install --git https://git.hatter.ink/hatter/card-cli.git ``` -TODO: -Update openpgp-card versions: -``` -// URL: https://gitlab.com/hkos/openpgp-card -openpgp-card = { path = "../openpgp-card", version = "0.2" } -openpgp-card-pcsc = { path = "../pcsc", version = "0.2" } -openpgp-card-sequoia = { path = "../openpgp-card-sequoia", version = "0.0.8" } -``` - - # PGP ## decrypt text diff --git a/src/cmd_pgp.rs b/src/cmd_pgp.rs index 3f3e4d4..8209b7f 100644 --- a/src/cmd_pgp.rs +++ b/src/cmd_pgp.rs @@ -7,7 +7,7 @@ use rust_util::util_clap::{Command, CommandError}; use sequoia_openpgp::crypto::mpi::PublicKey; use sequoia_openpgp::Packet; use sequoia_openpgp::packet::{Key, Signature}; -use sequoia_openpgp::packet::signature::subpacket::SubpacketTag; +use sequoia_openpgp::packet::signature::subpacket::{SubpacketTag, SubpacketValue}; use sequoia_openpgp::parse::{PacketParser, PacketParserResult}; use sequoia_openpgp::parse::Parse; @@ -20,12 +20,14 @@ impl Command for CommandImpl { SubCommand::with_name(self.name()).about("OpenPGP subcommand") .arg(Arg::with_name("in").short("i").long("in").takes_value(true).help("File input, *.pgp or *.asc")) .arg(Arg::with_name("detail").long("detail").help("Detail output")) + .arg(Arg::with_name("verbose").long("verbose").help("Verbose output")) .arg(Arg::with_name("json").long("json").help("JSON output")) } fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError { let in_file = sub_arg_matches.value_of("in"); - let show_detail = sub_arg_matches.is_present("detail"); + let show_verbose = sub_arg_matches.is_present("verbose"); + let show_detail = show_verbose || sub_arg_matches.is_present("detail"); let in_file = opt_value_result!(in_file, "Input file must assined"); @@ -39,8 +41,30 @@ impl Command for CommandImpl { match signature { Signature::V4(sig) => { // information!("-----> {:?}", sig.hashed_area()); + if show_verbose { + sig.hashed_area().iter().for_each(|sub_package| { + information!("Hashed area, sub package: {:?}", sub_package); + }); + sig.unhashed_area().iter().for_each(|sub_package| { + information!("Unhashed area, sub package: {:?}", sub_package); + }); + } if let Some(sub_package) = sig.hashed_area().subpacket(SubpacketTag::KeyFlags) { - information!("Found sub key flags: {:?}", sub_package); + if let SubpacketValue::KeyFlags(key_flags) = sub_package.value() { + let mut key_flags_vec = vec![]; + if key_flags.for_certification() { key_flags_vec.push("Certificate") } + if key_flags.for_signing() { key_flags_vec.push("Signing") } + if key_flags.for_transport_encryption() { key_flags_vec.push("TransportEncryption") } + if key_flags.for_storage_encryption() { key_flags_vec.push("StorageEncryption") } + if key_flags.for_authentication() { key_flags_vec.push("Authentication") } + if key_flags.is_split_key() { key_flags_vec.push("SplitKey") } + if key_flags.is_group_key() { key_flags_vec.push("GroupKey") } + debugging!("Found sub key flags: {:?}", sub_package); + let authenticated = sub_package.authenticated(); + information!("Found sub key flags: [{}], {} authenticated", key_flags_vec.join(", "), iff!(authenticated, "is", "not")); + } else { + information!("Found sub key flags: {:?}", sub_package); + } } } unknown => warning!("Unknown signature: {:?}", unknown),