feat: updates
This commit is contained in:
@@ -38,8 +38,6 @@ impl Command for CommandImpl {
|
||||
let padding = crate::rsautil::parse_padding(padding_opt)?;
|
||||
let padding_str = crate::rsautil::padding_to_string(padding);
|
||||
|
||||
let mut json = BTreeMap::new();
|
||||
|
||||
let keypair = opt_result!(Rsa::private_key_from_pem(&pri_key_bytes), "Parse RSA failed: {}");
|
||||
let keypair = opt_result!(PKey::from_rsa(keypair), "RSA to PKey failed: {}");
|
||||
|
||||
@@ -80,12 +78,11 @@ impl Command for CommandImpl {
|
||||
success!("Message HEX: {}", hex::encode(&data));
|
||||
success!("Message: {}", String::from_utf8_lossy(&data));
|
||||
if json_output {
|
||||
let mut json = BTreeMap::new();
|
||||
json.insert("data", hex::encode(&data));
|
||||
json.insert("padding", padding_str.to_string());
|
||||
json.insert("encrypted", encrypted_hex);
|
||||
}
|
||||
|
||||
if json_output {
|
||||
util::print_pretty_json(&json);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,6 @@ impl Command for CommandImpl {
|
||||
let padding = crate::rsautil::parse_padding(padding_opt)?;
|
||||
let padding_str = crate::rsautil::padding_to_string(padding);
|
||||
|
||||
let mut json = BTreeMap::new();
|
||||
|
||||
let keypair = opt_result!(Rsa::public_key_from_pem(&pub_key_bytes), "Parse RSA failed: {}");
|
||||
let pub_key_der = opt_result!(keypair.public_key_to_der(), "RSA public key to der failed: {}");
|
||||
let pub_key_fingerprint = hex::encode(sha256_bytes(&pub_key_der));
|
||||
@@ -64,13 +62,12 @@ impl Command for CommandImpl {
|
||||
information!("Public key fingerprint: {}", pub_key_fingerprint);
|
||||
success!("Encrypted message: {}", encrypted_hex);
|
||||
if json_output {
|
||||
let mut json = BTreeMap::new();
|
||||
json.insert("data", hex::encode(&data));
|
||||
json.insert("public_key_fingerprint", pub_key_fingerprint);
|
||||
json.insert("padding", padding_str.to_string());
|
||||
json.insert("encrypted", encrypted_hex);
|
||||
}
|
||||
|
||||
if json_output {
|
||||
util::print_pretty_json(&json);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,8 @@ impl Command for CommandImpl {
|
||||
fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError {
|
||||
let json_output = cmdutil::check_json_output(sub_arg_matches);
|
||||
|
||||
let mut json = BTreeMap::new();
|
||||
|
||||
if json_output {
|
||||
let mut json = BTreeMap::new();
|
||||
json.insert("se_supported", seutil::is_support_se());
|
||||
|
||||
util::print_pretty_json(&json);
|
||||
|
||||
@@ -27,9 +27,7 @@ impl Command for CommandImpl {
|
||||
fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError {
|
||||
let json_output = cmdutil::check_json_output(sub_arg_matches);
|
||||
|
||||
if !seutil::is_support_se() {
|
||||
return simple_error!("Secure Enclave is NOT supported.");
|
||||
}
|
||||
seutil::check_se_supported()?;
|
||||
let key_uri = sub_arg_matches.value_of("key").unwrap();
|
||||
|
||||
let KeyUri::SecureEnclaveKey(se_key_uri) = parse_key_uri(key_uri)?;
|
||||
|
||||
@@ -96,8 +96,8 @@ impl Command for CommandImpl {
|
||||
+ u2f_registration_data.attestation_cert.as_ref().map(|c| c.len()).unwrap_or(0);
|
||||
let sign = ®ister_result.0[sign_prefix_len..];
|
||||
|
||||
let mut json = BTreeMap::new();
|
||||
if json_output {
|
||||
let mut json = BTreeMap::new();
|
||||
// println!("{}", serde_json::to_string_pretty(&u2f_registration_data).unwrap());
|
||||
if let Some(device_name) = u2f_registration_data.device_name {
|
||||
json.insert("device_name", device_name);
|
||||
@@ -115,6 +115,8 @@ impl Command for CommandImpl {
|
||||
json.insert("app_id_hash", hex::encode(&app_id_hash));
|
||||
json.insert("challenge", u2fv2_challenge_str);
|
||||
json.insert("challenge_hash", hex::encode(&challenge_hash));
|
||||
|
||||
util::print_pretty_json(&json);
|
||||
} else {
|
||||
success!("Device info: {}", u2f_registration_data.device_info);
|
||||
information!("Register challenge: {}", u2fv2_challenge_str);
|
||||
@@ -147,9 +149,6 @@ impl Command for CommandImpl {
|
||||
warning!("Cannot find attestation cert!");
|
||||
}
|
||||
}
|
||||
if json_output {
|
||||
util::print_pretty_json(&json);
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user