feat: v1.0.8, direct init secure read password
This commit is contained in:
19
src/cli.rs
19
src/cli.rs
@@ -76,7 +76,24 @@ async fn do_direct_init(_arg_matches: &ArgMatches<'_>, sub_arg_matches: &ArgMatc
|
||||
} else if let Some(value_base64) = value_base64 {
|
||||
body_map.insert("clear_master_key_base64".to_string(), value_base64.into());
|
||||
} else {
|
||||
return simple_error!("Requires value hex or value base64");
|
||||
let pin = match pinentry_util::read_pin(
|
||||
Some("Input your clear master key, starts with hex: or base64:"),
|
||||
Some("Clear master key: ")) {
|
||||
Ok(pin) => pin,
|
||||
Err(e) => return simple_error!("Read clear master key failed: {}", e),
|
||||
};
|
||||
let pin_str = pin.get_pin();
|
||||
let clear_master_key = if pin_str.starts_with("hex:") {
|
||||
let hex: String = pin_str.chars().skip(4).collect();
|
||||
hex::decode(&hex)?
|
||||
} else if pin_str.starts_with("base64:") {
|
||||
let base64: String = pin_str.chars().skip(7).collect();
|
||||
STANDARD.decode(&base64)?
|
||||
} else {
|
||||
return simple_error!("Clear master key must starts with hex: or base64:");
|
||||
};
|
||||
|
||||
body_map.insert("clear_master_key_hex".to_string(), hex::encode(&clear_master_key).into());
|
||||
}
|
||||
if let Some(yubikey_challenge) = yubikey_challenge {
|
||||
body_map.insert("yubikey_challenge".to_string(), yubikey_challenge.into());
|
||||
|
||||
Reference in New Issue
Block a user