From 79c8ad7e5a19c57ea3c084676b8e8308c30d1844 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Tue, 29 Mar 2022 23:41:15 +0800 Subject: [PATCH] feat: challconfig --- src/cmd_challconfig.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cmd_challconfig.rs b/src/cmd_challconfig.rs index 77ace9a..4803167 100644 --- a/src/cmd_challconfig.rs +++ b/src/cmd_challconfig.rs @@ -22,14 +22,13 @@ impl Command for CommandImpl { if !sub_arg_matches.is_present("yes-config-chall") { return simple_error!("--yes-config-chall is not configed"); } - let secret_bytes: Vec; - if let Some(secret) = sub_arg_matches.value_of("secret") { - secret_bytes = secret.as_bytes().to_vec(); + let secret_bytes: Vec = if let Some(secret) = sub_arg_matches.value_of("secret") { + secret.as_bytes().to_vec() } else if let Some(secret_hex) = sub_arg_matches.value_of("secret-hex") { - secret_bytes = hex::decode(secret_hex)?; + opt_result!(hex::decode(secret_hex), "Decode secret-hex failed: {}") } else { return simple_error!("Secret must assigned"); - } + }; // Secret must have 20 bytes if secret_bytes.len() != 20 { @@ -47,6 +46,7 @@ impl Command for CommandImpl { let hmac_key: HmacKey = HmacKey::from_slice(&secret_bytes); let button_press = sub_arg_matches.is_present("button-press"); + information!("Button press: {}", button_press); let mut device_config = DeviceModeConfig::default(); device_config.challenge_response_hmac(&hmac_key, false, button_press);