chore: make clippy happy
This commit is contained in:
@@ -243,7 +243,7 @@ fn parse_security_sub_key_to_pgp_rsa_private_key(key: &Key<SecretParts, Subordin
|
|||||||
let private_key = if key.has_unencrypted_secret() {
|
let private_key = if key.has_unencrypted_secret() {
|
||||||
key.clone()
|
key.clone()
|
||||||
} else {
|
} else {
|
||||||
opt_result!(key.clone().decrypt_secret(&password), "Decrypt private key failed: {}")
|
opt_result!(key.clone().decrypt_secret(password), "Decrypt private key failed: {}")
|
||||||
};
|
};
|
||||||
let (p, q) = if let Key::V4(private_key4) = private_key {
|
let (p, q) = if let Key::V4(private_key4) = private_key {
|
||||||
if let SecretKeyMaterial::Unencrypted(unencrypted) = private_key4.secret() {
|
if let SecretKeyMaterial::Unencrypted(unencrypted) = private_key4.secret() {
|
||||||
|
|||||||
@@ -78,8 +78,7 @@ fn print_cert_info(yubikey: &mut YubiKey, slot: SlotId, detail_output: bool) ->
|
|||||||
return simple_error!("error reading certificate in slot {:?}: {}", slot, e);
|
return simple_error!("error reading certificate in slot {:?}: {}", slot, e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let buf = cert.as_ref().clone();
|
let buf = cert.as_ref();
|
||||||
|
|
||||||
if !buf.is_empty() {
|
if !buf.is_empty() {
|
||||||
information!("{}", "-".repeat(88));
|
information!("{}", "-".repeat(88));
|
||||||
let certificate_fingerprint_sha256 = Sha256::digest(buf);
|
let certificate_fingerprint_sha256 = Sha256::digest(buf);
|
||||||
@@ -91,7 +90,7 @@ fn print_cert_info(yubikey: &mut YubiKey, slot: SlotId, detail_output: bool) ->
|
|||||||
information!("{}", bytes_to_pem("CERTIFICATE", buf));
|
information!("{}", bytes_to_pem("CERTIFICATE", buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
match parse_x509_certificate(&buf) {
|
match parse_x509_certificate(buf) {
|
||||||
Ok((_rem, cert)) => {
|
Ok((_rem, cert)) => {
|
||||||
information!("Algorithm: {}", cert.tbs_certificate.subject_pki.algorithm.algorithm);
|
information!("Algorithm: {}", cert.tbs_certificate.subject_pki.algorithm.algorithm);
|
||||||
|
|
||||||
|
|||||||
@@ -75,9 +75,10 @@ fn pkcs1_padding_for_sign(bs: &[u8], bit_len: usize) -> XResult<Vec<u8>> {
|
|||||||
output.push(0x00);
|
output.push(0x00);
|
||||||
output.push(0x01);
|
output.push(0x01);
|
||||||
let ps_len = byte_len - bs.len() - (1 + 1 + 1);
|
let ps_len = byte_len - bs.len() - (1 + 1 + 1);
|
||||||
for _ in 0..ps_len {
|
// for _ in 0..ps_len {
|
||||||
output.push(0xff);
|
// output.push(0xff);
|
||||||
}
|
// }
|
||||||
|
output.extend_from_slice(&vec![0xff_u8; ps_len]);
|
||||||
output.push(0x00);
|
output.push(0x00);
|
||||||
output.extend_from_slice(bs);
|
output.extend_from_slice(bs);
|
||||||
Ok(output)
|
Ok(output)
|
||||||
|
|||||||
@@ -50,12 +50,12 @@ impl Command for CommandImpl {
|
|||||||
};
|
};
|
||||||
|
|
||||||
rust_util::util_msg::when(MessageType::DEBUG, || {
|
rust_util::util_msg::when(MessageType::DEBUG, || {
|
||||||
let rsa = keypair.rsa().clone().unwrap();
|
let rsa = keypair.rsa().unwrap();
|
||||||
let n = rsa.n();
|
let n = rsa.n();
|
||||||
let e = rsa.e();
|
let e = rsa.e();
|
||||||
let m = BigNum::from_slice(&signature).unwrap();
|
let m = BigNum::from_slice(&signature).unwrap();
|
||||||
let mut r = BigNum::new().unwrap();
|
let mut r = BigNum::new().unwrap();
|
||||||
r.mod_exp(&m, &e, &n, &mut BigNumContext::new().unwrap()).unwrap();
|
r.mod_exp(&m, e, n, &mut BigNumContext::new().unwrap()).unwrap();
|
||||||
debugging!("Signature raw HEX: {}", hex::encode(&r.to_vec()));
|
debugging!("Signature raw HEX: {}", hex::encode(&r.to_vec()));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -126,10 +126,10 @@ impl Command for CommandImpl {
|
|||||||
success!("Parse authorization success, counter: {}", authorization.counter);
|
success!("Parse authorization success, counter: {}", authorization.counter);
|
||||||
|
|
||||||
// PKey::public_key_from_der()
|
// PKey::public_key_from_der()
|
||||||
let ec_group = EcGroup::from_curve_name(Nid::X9_62_PRIME256V1).unwrap();
|
let ec_group = opt_result!(EcGroup::from_curve_name(Nid::X9_62_PRIME256V1), "New secp256r1 EC group failed: {}");
|
||||||
let ec_point = EcPoint::from_bytes(&ec_group, &public_key, &mut BigNumContext::new().unwrap()).unwrap();
|
let ec_point = opt_result!(EcPoint::from_bytes(&ec_group, &public_key, &mut BigNumContext::new().unwrap()), "Parse from secp256r1 point failed: {}");
|
||||||
let ec_key = EcKey::from_public_key(&ec_group, &ec_point).unwrap();
|
let ec_key = opt_result!(EcKey::from_public_key(&ec_group, &ec_point), "Parse secp256r1 public key failed: {}");
|
||||||
let ec_pkey = PKey::from_ec_key(ec_key).unwrap();
|
let ec_pkey = opt_result!(PKey::from_ec_key(ec_key), "EC secp256r1 key to PKey failed: {}");
|
||||||
let mut verifier = opt_result!(Verifier::new(MessageDigest::sha256(), &ec_pkey), "Verifier new failed: {}");
|
let mut verifier = opt_result!(Verifier::new(MessageDigest::sha256(), &ec_pkey), "Verifier new failed: {}");
|
||||||
verifier.update(&signed_message)?;
|
verifier.update(&signed_message)?;
|
||||||
let verify_result = opt_result!(verifier.verify(signature), "Verifier verify failed: {}");
|
let verify_result = opt_result!(verifier.verify(signature), "Verifier verify failed: {}");
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ impl U2fRegistrationData {
|
|||||||
"Parse registration data failed: {}");
|
"Parse registration data failed: {}");
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
app_id: app_id.to_string(),
|
app_id: app_id.to_string(),
|
||||||
device_info: U2FDeviceInfo::from(®ister_result),
|
device_info: U2FDeviceInfo::from(register_result),
|
||||||
device_name: registration.device_name,
|
device_name: registration.device_name,
|
||||||
client_data: client_data.into(),
|
client_data: client_data.into(),
|
||||||
registration_data: base64::encode(®ister_result.0),
|
registration_data: base64::encode(®ister_result.0),
|
||||||
|
|||||||
Reference in New Issue
Block a user