v1.1.0, update openpgp-card versions
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||
use openpgp_card::Sex;
|
||||
use openpgp_card::{OpenPgp};
|
||||
use openpgp_card::card_do::{Lang, Sex};
|
||||
use rust_util::util_clap::{Command, CommandError};
|
||||
|
||||
pub struct CommandImpl;
|
||||
@@ -22,25 +23,30 @@ impl Command for CommandImpl {
|
||||
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)?;
|
||||
let mut card = crate::pgpcardutil::get_card()?;
|
||||
let mut pgp = OpenPgp::new(&mut card);
|
||||
let mut trans = opt_result!(pgp.transaction(), "Open card failed: {}");
|
||||
|
||||
opt_result!(trans.verify_pw3(pin.as_ref()), "Admin pin verify failed: {}");
|
||||
success!("Admin pin verify success!");
|
||||
|
||||
if let Some(name) = sub_arg_matches.value_of("name") {
|
||||
information!("Set name to: {}", name);
|
||||
let response = opt_result!(card_admin.set_name(name), "Set name failed: {}");
|
||||
success!("Set name success: {:?}", response);
|
||||
opt_result!(trans.set_name(name.as_bytes()), "Set name failed: {}");
|
||||
success!("Set name success");
|
||||
}
|
||||
|
||||
if let Some(url) = sub_arg_matches.value_of("url") {
|
||||
information!("Set URL to: {}", url);
|
||||
let response = opt_result!(card_admin.set_url(url), "Set URL failed: {}");
|
||||
success!("Set URL success: {:?}", response);
|
||||
opt_result!(trans.set_url(url.as_bytes()), "Set URL failed: {}");
|
||||
success!("Set URL success");
|
||||
}
|
||||
|
||||
if let Some(lang) = sub_arg_matches.value_of("lang") {
|
||||
information!("Set lang to: {}", lang);
|
||||
let response = opt_result!(card_admin.set_lang(lang), "Set lang failed: {}");
|
||||
success!("Set lang success: {:?}", response);
|
||||
let lang_bytes = lang.as_bytes();
|
||||
opt_result!(trans.set_lang(&vec![Lang::Value([lang_bytes[0], lang_bytes[1]])]), "Set lang failed: {}");
|
||||
success!("Set lang success");
|
||||
}
|
||||
|
||||
if let Some(sex) = sub_arg_matches.value_of("sex") {
|
||||
@@ -55,8 +61,8 @@ impl Command for CommandImpl {
|
||||
};
|
||||
if let Some(s) = s {
|
||||
information!("Set sex to: {:?}", s);
|
||||
let response = opt_result!(card_admin.set_sex(s), "Set sex failed: {}");
|
||||
success!("Set sex success: {:?}", response);
|
||||
opt_result!(trans.set_sex(s), "Set lang failed: {}");
|
||||
success!("Set sex success");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user