feat: v0.1.2
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "script-sign"
|
name = "script-sign"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||||
description = "Script Sign"
|
description = "Script Sign"
|
||||||
|
|||||||
20
src/lib.rs
20
src/lib.rs
@@ -199,12 +199,24 @@ impl Script {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn sign(&mut self) -> XResult<()> {
|
pub fn sign(&mut self) -> XResult<()> {
|
||||||
|
self.sign_with_pin(None)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn sign_with_pin(&mut self, pin: Option<String>) -> XResult<()> {
|
||||||
let (time, digest_sha256) = self.normalize_content_lines_and_sha256_with_current_time();
|
let (time, digest_sha256) = self.normalize_content_lines_and_sha256_with_current_time();
|
||||||
let digest_sha256_hex = hex::encode(&digest_sha256);
|
let digest_sha256_hex = hex::encode(&digest_sha256);
|
||||||
let output = util_cmd::run_command_or_exit(
|
let mut args = Vec::new();
|
||||||
"card-cli",
|
args.push("piv-ecsign");
|
||||||
&["piv-ecsign", "--json", "-s", "r1", "-x", &digest_sha256_hex],
|
args.push("--json");
|
||||||
);
|
args.push("-s");
|
||||||
|
args.push("r1");
|
||||||
|
args.push("-x");
|
||||||
|
args.push(&digest_sha256_hex);
|
||||||
|
if let Some(pin) = &pin {
|
||||||
|
args.push("--pin");
|
||||||
|
args.push(pin);
|
||||||
|
}
|
||||||
|
let output = util_cmd::run_command_or_exit("card-cli", &args);
|
||||||
let ecsign_result: CardEcSignResult = opt_result!(
|
let ecsign_result: CardEcSignResult = opt_result!(
|
||||||
serde_json::from_slice(&output.stdout),
|
serde_json::from_slice(&output.stdout),
|
||||||
"Parse card piv-ecsign failed: {}"
|
"Parse card piv-ecsign failed: {}"
|
||||||
|
|||||||
Reference in New Issue
Block a user