Skip to content

Commit

Permalink
fix: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
skyf0l committed Jun 25, 2024
1 parent 42b307e commit 2bab500
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tools/gen_keys/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::{fs, str::FromStr};

use rug::{integer::Order, Integer};

const KEY_PASSPHRASE: &'static [u8] = b"Skyf0l";
const OUT_PATH: &'static str = "../../tests/keys";
const KEY_PASSPHRASE: &[u8] = b"Skyf0l";
const OUT_PATH: &str = "../../tests/keys";

lazy_static::lazy_static!(
static ref EXPONENT: Integer = 65537.into();
Expand Down Expand Up @@ -77,7 +77,7 @@ fn rsa_keys() -> openssl::rsa::Rsa<openssl::pkey::Private> {
// Encrypted RSA private key
fs::write(
format!("{OUT_PATH}/private_rsa_passphrase.pem"),
rsa.private_key_to_pem_passphrase(openssl::symm::Cipher::aes_256_cbc(), &KEY_PASSPHRASE)
rsa.private_key_to_pem_passphrase(openssl::symm::Cipher::aes_256_cbc(), KEY_PASSPHRASE)
.unwrap(),
)
.unwrap();
Expand Down Expand Up @@ -117,7 +117,7 @@ fn openssl_keys(
format!("{OUT_PATH}/private_openssl_passphrase.pem"),
pkey.private_key_to_pem_pkcs8_passphrase(
openssl::symm::Cipher::aes_256_cbc(),
&KEY_PASSPHRASE,
KEY_PASSPHRASE,
)
.unwrap(),
)
Expand All @@ -128,14 +128,14 @@ fn openssl_keys(

fn openssh_keys() {
let public_data = ssh_key::public::RsaPublicKey {
e: ssh_key::MPInt::from_bytes(&EXPONENT.to_digits(rug::integer::Order::Msf)).unwrap(),
n: ssh_key::MPInt::from_bytes(&MODULUS.to_digits(rug::integer::Order::Msf)).unwrap(),
e: ssh_key::Mpint::from_bytes(&EXPONENT.to_digits(rug::integer::Order::Msf)).unwrap(),
n: ssh_key::Mpint::from_bytes(&MODULUS.to_digits(rug::integer::Order::Msf)).unwrap(),
};
let private_data = ssh_key::private::RsaPrivateKey {
d: ssh_key::MPInt::from_bytes(&D.to_digits(rug::integer::Order::Msf)).unwrap(),
p: ssh_key::MPInt::from_bytes(&PRIME_P.to_digits(rug::integer::Order::Msf)).unwrap(),
q: ssh_key::MPInt::from_bytes(&PRIME_Q.to_digits(rug::integer::Order::Msf)).unwrap(),
iqmp: ssh_key::MPInt::from_bytes(&QINV.to_digits(rug::integer::Order::Msf)).unwrap(),
d: ssh_key::Mpint::from_bytes(&D.to_digits(rug::integer::Order::Msf)).unwrap(),
p: ssh_key::Mpint::from_bytes(&PRIME_P.to_digits(rug::integer::Order::Msf)).unwrap(),
q: ssh_key::Mpint::from_bytes(&PRIME_Q.to_digits(rug::integer::Order::Msf)).unwrap(),
iqmp: ssh_key::Mpint::from_bytes(&QINV.to_digits(rug::integer::Order::Msf)).unwrap(),
};
let keypair = ssh_key::private::KeypairData::Rsa(ssh_key::private::RsaKeypair {
public: public_data,
Expand Down Expand Up @@ -171,7 +171,7 @@ fn openssh_keys() {

// Encrypted OpenSSH private key
let private_key = private_key
.encrypt(&mut rand_core::OsRng, &KEY_PASSPHRASE)
.encrypt(&mut rand_core::OsRng, KEY_PASSPHRASE)
.unwrap();
fs::write(
format!("{OUT_PATH}/private_openssh_passphrase.pem"),
Expand Down

0 comments on commit 2bab500

Please sign in to comment.