diff --git a/Cargo.toml b/Cargo.toml index 2e67df4..0c3ca4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "script-sign" -version = "0.1.1" +version = "0.1.2" edition = "2021" authors = ["Hatter Jiang "] description = "Script Sign" diff --git a/src/lib.rs b/src/lib.rs index eb75189..c7aac3f 100644 --- a/src/lib.rs +++ b/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) -> 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: {}"