feat: v1.9.6

This commit is contained in:
2024-06-16 10:20:23 +08:00
parent d4b9b852c1
commit 7d5af78078
6 changed files with 36 additions and 13 deletions

View File

@@ -7,7 +7,7 @@ use yubikey::piv::AlgorithmId;
use yubikey::YubiKey;
use crate::pivutil;
use crate::util::try_decode;
use crate::util::{read_stdin, try_decode};
pub struct CommandImpl;
@@ -19,6 +19,7 @@ impl Command for CommandImpl {
.arg(Arg::with_name("slot").short("s").long("slot").takes_value(true).help("PIV slot, e.g. 82, 83 ... 95, 9a, 9c, 9d, 9e"))
.arg(Arg::with_name("pin").short("p").long("pin").takes_value(true).default_value("123456").help("OpenPGP card user pin"))
.arg(Arg::with_name("ciphertext").long("ciphertext").short("c").takes_value(true).help("Encrypted data (HEX or Base64)"))
.arg(Arg::with_name("stdin").long("stdin").help("Standard input (Ciphertext)"))
.arg(Arg::with_name("json").long("json").help("JSON output"))
}
@@ -33,6 +34,8 @@ impl Command for CommandImpl {
let encrypted_data = if let Some(ciphertext) = sub_arg_matches.value_of("ciphertext") {
opt_result!(try_decode(ciphertext), "Decode --ciphertext failed: {}")
} else if sub_arg_matches.is_present("stdin") {
read_stdin()?
} else {
return simple_error!("Argument --ciphertext must be assigned");
};