feat: challconfig
This commit is contained in:
@@ -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<u8>;
|
||||
if let Some(secret) = sub_arg_matches.value_of("secret") {
|
||||
secret_bytes = secret.as_bytes().to_vec();
|
||||
let secret_bytes: Vec<u8> = 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);
|
||||
|
||||
Reference in New Issue
Block a user