feat: v1.12.1

This commit is contained in:
2025-05-01 10:30:24 +08:00
parent fcb10f5efa
commit 9a749b63eb
4 changed files with 11 additions and 6 deletions

2
Cargo.lock generated
View File

@@ -508,7 +508,7 @@ dependencies = [
[[package]] [[package]]
name = "card-cli" name = "card-cli"
version = "1.12.0" version = "1.12.1"
dependencies = [ dependencies = [
"aes-gcm-stream", "aes-gcm-stream",
"authenticator 0.3.1", "authenticator 0.3.1",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "card-cli" name = "card-cli"
version = "1.12.0" version = "1.12.1"
authors = ["Hatter Jiang <jht5945@gmail.com>"] authors = ["Hatter Jiang <jht5945@gmail.com>"]
edition = "2018" edition = "2018"

View File

@@ -12,6 +12,10 @@ pub fn get_sha256_digest_or_hash(sub_arg_matches: &ArgMatches) -> XResult<Vec<u8
get_sha256_digest_or_hash_with_file_opt(sub_arg_matches, &None) get_sha256_digest_or_hash_with_file_opt(sub_arg_matches, &None)
} }
pub fn get_digest_or_hash(sub_arg_matches: &ArgMatches, digest: DigestAlgorithm) -> XResult<Vec<u8>> {
get_digest_or_hash_with_file_opt(sub_arg_matches, &None, digest)
}
pub fn get_sha256_digest_or_hash_with_file_opt(sub_arg_matches: &ArgMatches, file_opt: &Option<String>) -> XResult<Vec<u8>> { pub fn get_sha256_digest_or_hash_with_file_opt(sub_arg_matches: &ArgMatches, file_opt: &Option<String>) -> XResult<Vec<u8>> {
get_digest_or_hash_with_file_opt(sub_arg_matches, file_opt, DigestAlgorithm::Sha256) get_digest_or_hash_with_file_opt(sub_arg_matches, file_opt, DigestAlgorithm::Sha256)
} }

View File

@@ -8,6 +8,7 @@ use yubikey::YubiKey;
use crate::util::base64_encode; use crate::util::base64_encode;
use crate::{argsutil, cmdutil, pivutil, util}; use crate::{argsutil, cmdutil, pivutil, util};
use crate::digestutil::DigestAlgorithm;
pub struct CommandImpl; pub struct CommandImpl;
@@ -32,12 +33,12 @@ impl Command for CommandImpl {
let mut json = BTreeMap::<&'_ str, String>::new(); let mut json = BTreeMap::<&'_ str, String>::new();
let slot = opt_value_result!(sub_arg_matches.value_of("slot"), "--slot must assigned, e.g. 82, 83 ... 95, 9a, 9c, 9d, 9e"); let slot = opt_value_result!(sub_arg_matches.value_of("slot"), "--slot must assigned, e.g. 82, 83 ... 95, 9a, 9c, 9d, 9e");
let hash_bytes = argsutil::get_sha256_digest_or_hash(sub_arg_matches)?; let (algorithm, algorithm_str, digest_algorithm) = match sub_arg_matches.value_of("algorithm") {
let (algorithm, algorithm_str) = match sub_arg_matches.value_of("algorithm") { None | Some("p256") => (AlgorithmId::EccP256, "ecdsa_p256_with_sha256", DigestAlgorithm::Sha256),
None | Some("p256") => (AlgorithmId::EccP256, "ecdsa_p256_with_sha256"), Some("p384") => (AlgorithmId::EccP384, "ecdsa_p384_with_sha384", DigestAlgorithm::Sha384),
Some("p384") => (AlgorithmId::EccP384, "ecdsa_p384_with_sha256"),
Some(unknown_algorithm) => return simple_error!("Unknown algorithm {}, e.g. p256 or p384", unknown_algorithm), Some(unknown_algorithm) => return simple_error!("Unknown algorithm {}, e.g. p256 or p384", unknown_algorithm),
}; };
let hash_bytes = argsutil::get_digest_or_hash(sub_arg_matches, digest_algorithm)?;
let mut yk = opt_result!(YubiKey::open(), "YubiKey not found: {}"); let mut yk = opt_result!(YubiKey::open(), "YubiKey not found: {}");
let slot_id = pivutil::get_slot_id(slot)?; let slot_id = pivutil::get_slot_id(slot)?;