diff --git a/src/cmd_pgp.rs b/src/cmd_pgp.rs index 1c90d55..a937755 100644 --- a/src/cmd_pgp.rs +++ b/src/cmd_pgp.rs @@ -92,7 +92,7 @@ impl Command for CommandImpl { public_key4.push_str(&format!("\n\tPublic key PEM: {}", pubkey_pem)); } } - information!("Found public key: {}", public_key4); + information!("Found public sub key: {}", public_key4); } unknown => warning!("Unknown key: {:?}", unknown), } @@ -166,24 +166,18 @@ impl Command for CommandImpl { fn public_key_pem(public_key: &PublicKey) -> Option { match public_key { PublicKey::RSA { e, n } => { - let rr = Rsa::from_public_components( + let rsa_pub_key = Rsa::from_public_components( BigNum::from_slice(n.value()).unwrap(), BigNum::from_slice(e.value()).unwrap(), ); - // let from = b"hello"; - // let mut to = vec![0_u8; 4096/8]; - // let mut_to = to.as_mut_slice(); - // let rt = rr.clone().unwrap().public_encrypt(from, mut_to, Padding::PKCS1); - // println!("!!! {:?}", rt); - // println!("??? {}", hex::encode(mut_to)); - let pubkey_pem_obj = Pem { + let pub_key_pem_obj = Pem { tag: String::from("PUBLIC KEY"), - contents: rr.unwrap().public_key_to_der().unwrap(), + contents: rsa_pub_key.unwrap().public_key_to_der().unwrap(), }; - Some(pem::encode(&pubkey_pem_obj)) + Some(pem::encode(&pub_key_pem_obj)) } _ => { - warning!("Not rsa public key: {:?}", public_key); + warning!("Not RSA public key: {:?}", public_key); None } }