chore: make clippy happy

This commit is contained in:
2022-04-10 22:31:35 +08:00
parent be2e014638
commit 3cf62cb687
6 changed files with 14 additions and 14 deletions

View File

@@ -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() {
key.clone()
} 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 {
if let SecretKeyMaterial::Unencrypted(unencrypted) = private_key4.secret() {

View File

@@ -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);
}
};
let buf = cert.as_ref().clone();
let buf = cert.as_ref();
if !buf.is_empty() {
information!("{}", "-".repeat(88));
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));
}
match parse_x509_certificate(&buf) {
match parse_x509_certificate(buf) {
Ok((_rem, cert)) => {
information!("Algorithm: {}", cert.tbs_certificate.subject_pki.algorithm.algorithm);

View File

@@ -75,9 +75,10 @@ fn pkcs1_padding_for_sign(bs: &[u8], bit_len: usize) -> XResult<Vec<u8>> {
output.push(0x00);
output.push(0x01);
let ps_len = byte_len - bs.len() - (1 + 1 + 1);
for _ in 0..ps_len {
output.push(0xff);
}
// for _ in 0..ps_len {
// output.push(0xff);
// }
output.extend_from_slice(&vec![0xff_u8; ps_len]);
output.push(0x00);
output.extend_from_slice(bs);
Ok(output)

View File

@@ -50,12 +50,12 @@ impl Command for CommandImpl {
};
rust_util::util_msg::when(MessageType::DEBUG, || {
let rsa = keypair.rsa().clone().unwrap();
let rsa = keypair.rsa().unwrap();
let n = rsa.n();
let e = rsa.e();
let m = BigNum::from_slice(&signature).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()));
});

View File

@@ -126,10 +126,10 @@ impl Command for CommandImpl {
success!("Parse authorization success, counter: {}", authorization.counter);
// PKey::public_key_from_der()
let ec_group = EcGroup::from_curve_name(Nid::X9_62_PRIME256V1).unwrap();
let ec_point = EcPoint::from_bytes(&ec_group, &public_key, &mut BigNumContext::new().unwrap()).unwrap();
let ec_key = EcKey::from_public_key(&ec_group, &ec_point).unwrap();
let ec_pkey = PKey::from_ec_key(ec_key).unwrap();
let ec_group = opt_result!(EcGroup::from_curve_name(Nid::X9_62_PRIME256V1), "New secp256r1 EC group failed: {}");
let ec_point = opt_result!(EcPoint::from_bytes(&ec_group, &public_key, &mut BigNumContext::new().unwrap()), "Parse from secp256r1 point failed: {}");
let ec_key = opt_result!(EcKey::from_public_key(&ec_group, &ec_point), "Parse secp256r1 public key failed: {}");
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: {}");
verifier.update(&signed_message)?;
let verify_result = opt_result!(verifier.verify(signature), "Verifier verify failed: {}");

View File

@@ -72,7 +72,7 @@ impl U2fRegistrationData {
"Parse registration data failed: {}");
Ok(Self {
app_id: app_id.to_string(),
device_info: U2FDeviceInfo::from(&register_result),
device_info: U2FDeviceInfo::from(register_result),
device_name: registration.device_name,
client_data: client_data.into(),
registration_data: base64::encode(&register_result.0),