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