feat: update se-generate
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use crate::pkiutil::bytes_to_pem;
|
||||
use crate::seutil;
|
||||
use crate::util::base64_encode;
|
||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||
use rust_util::util_clap::{Command, CommandError};
|
||||
use rust_util::util_msg;
|
||||
@@ -46,7 +47,7 @@ impl Command for CommandImpl {
|
||||
let sign = match ty {
|
||||
"signing" | "ecsign" | "sign" => true,
|
||||
"key_agreement" | "ecdh" | "dh" => false,
|
||||
_ => return simple_error!("Invalie type: {}", ty),
|
||||
_ => return simple_error!("Invalid type: {}", ty),
|
||||
};
|
||||
|
||||
let (public_key_point, public_key_der, private_key) =
|
||||
@@ -54,17 +55,22 @@ impl Command for CommandImpl {
|
||||
|
||||
let public_key_point_hex = hex::encode(&public_key_point);
|
||||
let public_key_pem = bytes_to_pem("PUBLIC KEY", &*public_key_der);
|
||||
let key = format!("key://{}:se/p256:{}:{}",
|
||||
host, iff!(sign, "signing", "key_agreement"), private_key,
|
||||
let key = format!(
|
||||
"key://{}:se/p256:{}:{}",
|
||||
host,
|
||||
iff!(sign, "signing", "key_agreement"),
|
||||
private_key,
|
||||
);
|
||||
if json_output {
|
||||
let mut json = BTreeMap::<&'_ str, String>::new();
|
||||
json.insert("public_key_point", public_key_point_hex);
|
||||
json.insert("public_key_pem", public_key_pem);
|
||||
json.insert("public_key_pem", base64_encode(&*public_key_der));
|
||||
json.insert("key", key);
|
||||
|
||||
println!("{}", serde_json::to_string_pretty(&json).unwrap());
|
||||
} else {
|
||||
success!("Public key(point): {}", public_key_point_hex);
|
||||
success!("Public key PEM: {}", public_key_pem);
|
||||
success!("Public key PEM: \n{}", public_key_pem);
|
||||
success!("Key: {}", key);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user