From d2729043571cf2ece911bd67d8baa08e13694e42 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sun, 29 Jun 2025 00:11:10 +0800 Subject: [PATCH] feat: v1.13.14 --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/cmd_hmac_encrypt.rs | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a23e14e..a3154e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -519,7 +519,7 @@ dependencies = [ [[package]] name = "card-cli" -version = "1.13.13" +version = "1.13.14" dependencies = [ "aes-gcm-stream", "authenticator 0.3.1", diff --git a/Cargo.toml b/Cargo.toml index 13654ad..6772f37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "card-cli" -version = "1.13.13" +version = "1.13.14" authors = ["Hatter Jiang "] edition = "2018" diff --git a/src/cmd_hmac_encrypt.rs b/src/cmd_hmac_encrypt.rs index d652d32..e5b2b18 100644 --- a/src/cmd_hmac_encrypt.rs +++ b/src/cmd_hmac_encrypt.rs @@ -3,6 +3,7 @@ use rust_util::util_clap::{Command, CommandError}; use std::collections::BTreeMap; use rust_util::XResult; use crate::{cmdutil, hmacutil, pbeutil, util}; +use crate::pinutil::get_pin; pub struct CommandImpl; @@ -14,7 +15,7 @@ impl Command for CommandImpl { fn subcommand<'a>(&self) -> App<'a, 'a> { SubCommand::with_name(self.name()) .about("YubiKey HMAC encrypt") - .arg(Arg::with_name("plaintext").long("plaintext").short("t").takes_value(true).required(true).help("Plaintext")) + .arg(Arg::with_name("plaintext").long("plaintext").short("t").takes_value(true).required(true).help("Plaintext, @@PIN_ENTRY@@ means read from pin entry")) .arg(Arg::with_name("password").long("password").short("P").takes_value(true).help("Password")) .arg(cmdutil::build_with_pbe_encrypt_arg()) .arg(cmdutil::build_double_pin_check_arg()) @@ -31,6 +32,14 @@ impl Command for CommandImpl { } let text = sub_arg_matches.value_of("plaintext").unwrap().to_string(); + let text = if text == "@@PIN_ENTRY@@" { + match get_pin(None) { + None => return simple_error!(""), + Some(text) => text, + } + } else { + text + }; let mut pin_opt = sub_arg_matches.value_of("password").map(|p| p.to_string()); let ciphertext = do_encrypt(&text, &mut pin_opt, sub_arg_matches)?;