From 4be7e880c2ed0a2c51ade98796b7dd7fd218191d Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sun, 27 Mar 2022 12:11:12 +0800 Subject: [PATCH] chore: opt_result! --- src/chall.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/chall.rs b/src/chall.rs index e1db22b..9632212 100644 --- a/src/chall.rs +++ b/src/chall.rs @@ -23,7 +23,7 @@ impl Command for CommandImpl { fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError { let json_output = sub_arg_matches.is_present("json"); if json_output { rust_util::util_msg::set_logger_std_out(false); } - + let sha256_output = sub_arg_matches.is_present("sha256"); let sha384_output = sub_arg_matches.is_present("sha384"); let sha512_output = sub_arg_matches.is_present("sha512"); @@ -54,7 +54,7 @@ impl Command for CommandImpl { .set_slot(Slot::Slot2); // In HMAC Mode, the result will always be the SAME for the SAME provided challenge - let hmac_result = yubi.challenge_response_hmac(&challenge_bytes, config).unwrap(); + let hmac_result = opt_result!(yubi.challenge_response_hmac(&challenge_bytes, config), "Challenge HMAC failed: {}"); // Just for debug, lets check the hex let v: &[u8] = hmac_result.deref(); @@ -71,7 +71,7 @@ impl Command for CommandImpl { hex_sha384.map(|hex_sha384| json.insert("response_sha384_hex", hex::encode(hex_sha384))); hex_sha512.map(|hex_sha512| json.insert("response_sha512_hex", hex::encode(hex_sha512))); - println!("{}", serde_json::to_string_pretty(&json).unwrap()); + println!("{}", serde_json::to_string_pretty(&json).expect("Convert to JSON failed!")); } else { success!("Challenge HEX: {}", hex::encode(challenge_bytes)); success!("Response HEX: {}", hex_string);