feat: v1.7.4
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -320,7 +320,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "card-cli"
|
name = "card-cli"
|
||||||
version = "1.7.3"
|
version = "1.7.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"authenticator",
|
"authenticator",
|
||||||
"base64 0.21.4",
|
"base64 0.21.4",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "card-cli"
|
name = "card-cli"
|
||||||
version = "1.7.3"
|
version = "1.7.4"
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ impl Command for CommandImpl {
|
|||||||
.arg(Arg::with_name("pass").long("pass").takes_value(true).help("[deprecated] now OpenPGP card user pin"))
|
.arg(Arg::with_name("pass").long("pass").takes_value(true).help("[deprecated] now OpenPGP card user pin"))
|
||||||
.arg(Arg::with_name("cipher").short("c").long("cipher").takes_value(true).help("Cipher text HEX"))
|
.arg(Arg::with_name("cipher").short("c").long("cipher").takes_value(true).help("Cipher text HEX"))
|
||||||
.arg(Arg::with_name("cipher-base64").short("b").long("cipher-base64").takes_value(true).help("Cipher text base64"))
|
.arg(Arg::with_name("cipher-base64").short("b").long("cipher-base64").takes_value(true).help("Cipher text base64"))
|
||||||
|
.arg(Arg::with_name("algo").long("algo").takes_value(true).help("Algo: RSA, X25519/ECDH"))
|
||||||
.arg(Arg::with_name("json").long("json").help("JSON output"))
|
.arg(Arg::with_name("json").long("json").help("JSON output"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +34,8 @@ impl Command for CommandImpl {
|
|||||||
let cipher = sub_arg_matches.value_of("cipher");
|
let cipher = sub_arg_matches.value_of("cipher");
|
||||||
let cipher_base64 = sub_arg_matches.value_of("cipher-base64");
|
let cipher_base64 = sub_arg_matches.value_of("cipher-base64");
|
||||||
|
|
||||||
|
let algo = sub_arg_matches.value_of("algo").unwrap_or("rsa").to_lowercase();
|
||||||
|
|
||||||
let cipher_bytes = if let Some(cipher) = cipher {
|
let cipher_bytes = if let Some(cipher) = cipher {
|
||||||
opt_result!(hex::decode(cipher), "Decode cipher failed: {}")
|
opt_result!(hex::decode(cipher), "Decode cipher failed: {}")
|
||||||
} else if let Some(cipher_base64) = cipher_base64 {
|
} else if let Some(cipher_base64) = cipher_base64 {
|
||||||
@@ -48,7 +51,12 @@ impl Command for CommandImpl {
|
|||||||
opt_result!(trans.verify_pw1_user(pin.as_ref()), "User pin verify failed: {}");
|
opt_result!(trans.verify_pw1_user(pin.as_ref()), "User pin verify failed: {}");
|
||||||
success!("User pin verify success!");
|
success!("User pin verify success!");
|
||||||
|
|
||||||
let text = trans.decipher(Cryptogram::RSA(&cipher_bytes))?;
|
let text = match algo.as_str() {
|
||||||
|
"rsa" => trans.decipher(Cryptogram::RSA(&cipher_bytes))?,
|
||||||
|
"x25519" | "ecdh" => trans.decipher(Cryptogram::ECDH(&cipher_bytes))?,
|
||||||
|
_ => return simple_error!("Unknown algo: {}", &algo),
|
||||||
|
};
|
||||||
|
// let text = trans.decipher(Cryptogram::RSA(&cipher_bytes))?;
|
||||||
success!("Clear text HEX: {}", hex::encode(&text));
|
success!("Clear text HEX: {}", hex::encode(&text));
|
||||||
success!("Clear text base64: {}", base64_encode(&text));
|
success!("Clear text base64: {}", base64_encode(&text));
|
||||||
success!("Clear text UTF-8: {}", String::from_utf8_lossy(&text));
|
success!("Clear text UTF-8: {}", String::from_utf8_lossy(&text));
|
||||||
|
|||||||
Reference in New Issue
Block a user