feat: add back --pass argument

This commit is contained in:
2022-03-29 00:29:14 +08:00
parent 4c98af9c01
commit 25edf965e1
6 changed files with 14 additions and 6 deletions

2
Cargo.lock generated
View File

@@ -2221,7 +2221,7 @@ dependencies = [
[[package]]
name = "webauthn-cli"
version = "0.1.3"
version = "0.1.4"
dependencies = [
"authenticator",
"base64 0.13.0",

View File

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

View File

@@ -10,6 +10,7 @@ impl Command for CommandImpl {
fn subcommand<'a>(&self) -> App<'a, 'a> {
SubCommand::with_name(self.name()).about("OpenPGP Card Admin subcommand")
.arg(Arg::with_name("pin").short("p").long("pin").takes_value(true).default_value("12345678").help("OpenPGP card admin pin"))
.arg(Arg::with_name("pass").long("pass").takes_value(true).help("[deprecated] now OpenPGP card admin pin"))
.arg(Arg::with_name("name").short("n").long("name").takes_value(true).required(false).help("Set name"))
.arg(Arg::with_name("url").long("url").takes_value(true).required(false).help("Set URL"))
.arg(Arg::with_name("lang").long("lang").takes_value(true).required(false).help("Set lang"))
@@ -17,7 +18,8 @@ impl Command for CommandImpl {
}
fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError {
let pin = opt_value_result!(sub_arg_matches.value_of("pin"), "Pass must be assigned");
let pin_opt = sub_arg_matches.value_of("pass").or(sub_arg_matches.value_of("pin"));
let pin = opt_value_result!(pin_opt, "Pass must be assigned");
if pin.len() < 8 { return simple_error!("Admin pin length:{}, must >= 8!", pin.len()); }
let card_admin = crate::pgpcardutil::get_card_admin(pin)?;

View File

@@ -12,6 +12,7 @@ impl Command for CommandImpl {
fn subcommand<'a>(&self) -> App<'a, 'a> {
SubCommand::with_name(self.name()).about("OpenPGP Card Decrypt subcommand")
.arg(Arg::with_name("pin").short("p").long("pin").takes_value(true).default_value("123456").help("OpenPGP card user pin"))
.arg(Arg::with_name("pass").long("pass").takes_value(true).help("[deprecated] now OpenPGP card user pin"))
.arg(Arg::with_name("cipher").short("c").long("cipher").takes_value(true).help("Cipher text HEX"))
.arg(Arg::with_name("cipher-base64").short("b").long("cipher-base64").takes_value(true).help("Cipher text base64"))
.arg(Arg::with_name("json").long("json").help("JSON output"))
@@ -21,7 +22,8 @@ impl Command for CommandImpl {
let json_output = sub_arg_matches.is_present("json");
if json_output { rust_util::util_msg::set_logger_std_out(false); }
let pin = opt_value_result!(sub_arg_matches.value_of("pin"), "User pin must be assigned");
let pin_opt = sub_arg_matches.value_of("pass").or(sub_arg_matches.value_of("pin"));
let pin = opt_value_result!(pin_opt, "User pin must be assigned");
if pin.len() < 6 { return simple_error!("User pin length:{}, must >= 6!", pin.len()); }
let cipher = sub_arg_matches.value_of("cipher");

View File

@@ -13,6 +13,7 @@ impl Command for CommandImpl {
fn subcommand<'a>(&self) -> App<'a, 'a> {
SubCommand::with_name(self.name()).about("OpenPGP Card Sign subcommand")
.arg(Arg::with_name("pin").short("p").long("pin").takes_value(true).default_value("123456").help("OpenPGP card user pin"))
.arg(Arg::with_name("pass").long("pass").takes_value(true).help("[deprecated] now OpenPGP card user pin"))
.arg(Arg::with_name("sha256").short("2").long("sha256").takes_value(true).help("Digest SHA256 HEX"))
.arg(Arg::with_name("sha384").short("3").long("sha384").takes_value(true).help("Digest SHA384 HEX"))
.arg(Arg::with_name("sha512").short("5").long("sha512").takes_value(true).help("Digest SHA512 HEX"))
@@ -23,7 +24,8 @@ impl Command for CommandImpl {
let json_output = sub_arg_matches.is_present("json");
if json_output { rust_util::util_msg::set_logger_std_out(false); }
let pin = opt_value_result!(sub_arg_matches.value_of("pin"), "User pin must be assigned");
let pin_opt = sub_arg_matches.value_of("pass").or(sub_arg_matches.value_of("pin"));
let pin = opt_value_result!(pin_opt, "User pin must be assigned");
if pin.len() < 6 { return simple_error!("User pin length:{}, must >= 6!", pin.len()); }
let sha256 = sub_arg_matches.value_of("sha256");

View File

@@ -13,6 +13,7 @@ impl Command for CommandImpl {
fn subcommand<'a>(&self) -> App<'a, 'a> {
SubCommand::with_name(self.name()).about("PIV Sign subcommand")
.arg(Arg::with_name("pin").short("p").long("pin").takes_value(true).default_value("123456").help("OpenPGP card user pin"))
.arg(Arg::with_name("pass").long("pass").takes_value(true).help("[deprecated] now OpenPGP card user pin"))
.arg(Arg::with_name("json").long("json").help("JSON output"))
}
@@ -22,7 +23,8 @@ impl Command for CommandImpl {
rust_util::util_msg::set_logger_std_out(false);
}
warning!("This feature is not complete");
let pin = opt_value_result!(sub_arg_matches.value_of("pin"), "User pin must be assigned");
let pin_opt = sub_arg_matches.value_of("pass").or(sub_arg_matches.value_of("pin"));
let pin = opt_value_result!(pin_opt, "User pin must be assigned");
let mut yk = opt_result!(YubiKey::open(), "YubiKey not found: {}");
opt_result!(yk.verify_pin(pin.as_bytes()), "YubiKey verify pin failed: {}");