feat: v1.0.1

This commit is contained in:
2022-03-29 23:10:52 +08:00
parent add73f086d
commit f342925902
5 changed files with 30 additions and 15 deletions

1
.gitignore vendored
View File

@@ -3,6 +3,7 @@ enc.txt
enc_key.pem
sign_key.pem
test_key.asc
test_gpg.asc
.idea/
# ---> Rust
# Generated by Cargo

2
Cargo.lock generated
View File

@@ -292,7 +292,7 @@ dependencies = [
[[package]]
name = "card-cli"
version = "1.0.0"
version = "1.0.1"
dependencies = [
"authenticator",
"base64 0.13.0",

View File

@@ -1,6 +1,6 @@
[package]
name = "card-cli"
version = "1.0.0"
version = "1.0.1"
authors = ["Hatter Jiang <jht5945@gmail.com>"]
edition = "2018"

View File

@@ -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

View File

@@ -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),