feat: v1.11.4, support hmac encrypt in generate-keypair
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -511,7 +511,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "card-cli"
|
name = "card-cli"
|
||||||
version = "1.11.3"
|
version = "1.11.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes-gcm-stream",
|
"aes-gcm-stream",
|
||||||
"authenticator 0.3.1",
|
"authenticator 0.3.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "card-cli"
|
name = "card-cli"
|
||||||
version = "1.11.3"
|
version = "1.11.4"
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::ecdsautil;
|
use crate::{ecdsautil, hmacutil};
|
||||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||||
use rust_util::util_clap::{Command, CommandError};
|
use rust_util::util_clap::{Command, CommandError};
|
||||||
use rust_util::util_msg;
|
use rust_util::util_msg;
|
||||||
@@ -21,10 +21,16 @@ impl Command for CommandImpl {
|
|||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.help("Key type (e.g. p256, p384)"),
|
.help("Key type (e.g. p256, p384)"),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("with-hmac-encrypt")
|
||||||
|
.long("with-hmac-encrypt")
|
||||||
|
.help("With HMAC encrypt"),
|
||||||
|
)
|
||||||
.arg(Arg::with_name("json").long("json").help("JSON output"))
|
.arg(Arg::with_name("json").long("json").help("JSON output"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError {
|
fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError {
|
||||||
|
let with_hmac_encrypt = sub_arg_matches.is_present("with-hmac-encrypt");
|
||||||
let key_type = sub_arg_matches.value_of("type").unwrap().to_lowercase();
|
let key_type = sub_arg_matches.value_of("type").unwrap().to_lowercase();
|
||||||
|
|
||||||
let json_output = sub_arg_matches.is_present("json");
|
let json_output = sub_arg_matches.is_present("json");
|
||||||
@@ -39,6 +45,14 @@ impl Command for CommandImpl {
|
|||||||
return simple_error!("Key type must be p256 or p384");
|
return simple_error!("Key type must be p256 or p384");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
let (pkcs8_base64, secret_key_pem) = if with_hmac_encrypt {
|
||||||
|
(
|
||||||
|
hmacutil::hmac_encrypt_from_string(&pkcs8_base64)?,
|
||||||
|
hmacutil::hmac_encrypt_from_string(&secret_key_pem)?,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
(pkcs8_base64, secret_key_pem)
|
||||||
|
};
|
||||||
|
|
||||||
if json_output {
|
if json_output {
|
||||||
let mut json = BTreeMap::<&'_ str, String>::new();
|
let mut json = BTreeMap::<&'_ str, String>::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user