just a pass of 'cargo fmt'

This commit is contained in:
Paolo Asperti 2022-07-15 21:39:19 +02:00
parent 06409279f4
commit 913de8515e
No known key found for this signature in database
GPG Key ID: 06D46905D19D5182

View File

@ -1,7 +1,7 @@
use sodiumoxide::crypto::sign; use sodiumoxide::crypto::sign;
use std::str;
use std::env; use std::env;
use std::process; use std::process;
use std::str;
fn print_help() { fn print_help() {
println!("Usage:"); println!("Usage:");
@ -28,41 +28,41 @@ fn gen_keypair() {
fn validate_keypair(pk: &str, sk: &str) { fn validate_keypair(pk: &str, sk: &str) {
let sk1 = base64::decode(&sk); let sk1 = base64::decode(&sk);
match sk1 { match sk1 {
Ok(_) => {}, Ok(_) => {}
Err(_) => { Err(_) => {
println!("Invalid secret key"); println!("Invalid secret key");
process::exit(0x0001); process::exit(0x0001);
}, }
} }
let sk1 = sk1.unwrap(); let sk1 = sk1.unwrap();
let secret_key = sign::SecretKey::from_slice(sk1.as_slice()); let secret_key = sign::SecretKey::from_slice(sk1.as_slice());
match secret_key { match secret_key {
Some(_) => {}, Some(_) => {}
None => { None => {
println!("Invalid Secret key"); println!("Invalid Secret key");
process::exit(0x0001); process::exit(0x0001);
}, }
} }
let secret_key = secret_key.unwrap(); let secret_key = secret_key.unwrap();
let pk1 = base64::decode(&pk); let pk1 = base64::decode(&pk);
match pk1 { match pk1 {
Ok(_) => {}, Ok(_) => {}
Err(_) => { Err(_) => {
println!("Invalid public key"); println!("Invalid public key");
process::exit(0x0001); process::exit(0x0001);
}, }
} }
let pk1 = pk1.unwrap(); let pk1 = pk1.unwrap();
let public_key = sign::PublicKey::from_slice(pk1.as_slice()); let public_key = sign::PublicKey::from_slice(pk1.as_slice());
match public_key { match public_key {
Some(_) => {}, Some(_) => {}
None => { None => {
println!("Invalid Public key"); println!("Invalid Public key");
process::exit(0x0001); process::exit(0x0001);
}, }
} }
let public_key = public_key.unwrap(); let public_key = public_key.unwrap();
@ -70,11 +70,11 @@ fn validate_keypair(pk: &str, sk: &str) {
let signed_data = sign::sign(random_data_to_test, &secret_key); let signed_data = sign::sign(random_data_to_test, &secret_key);
let verified_data = sign::verify(&signed_data, &public_key); let verified_data = sign::verify(&signed_data, &public_key);
match verified_data { match verified_data {
Ok(_) => {}, Ok(_) => {}
Err(_) => { Err(_) => {
println!("Key pair is INVALID"); println!("Key pair is INVALID");
process::exit(0x0001); process::exit(0x0001);
}, }
} }
let verified_data = verified_data.unwrap(); let verified_data = verified_data.unwrap();
@ -99,8 +99,8 @@ fn main() {
if args.len() <= 3 { if args.len() <= 3 {
error_then_help("You must supply both the public and the secret key"); error_then_help("You must supply both the public and the secret key");
} }
validate_keypair(args[2].as_str(),args[3].as_str()); validate_keypair(args[2].as_str(), args[3].as_str());
}, }
_=>print_help(), _ => print_help(),
} }
} }