From 69529b1813fd62f201eae859a92a5a96055a015d Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Tue, 10 Oct 2023 23:56:08 +0800 Subject: [PATCH] feat: v1.7.7, add pk_point_hex_compressed --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/cmd_pivmeta.rs | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 388fea2..353c4d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -326,7 +326,7 @@ dependencies = [ [[package]] name = "card-cli" -version = "1.7.6" +version = "1.7.7" dependencies = [ "authenticator", "base64 0.21.4", diff --git a/Cargo.toml b/Cargo.toml index cbf2868..2b28eb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "card-cli" -version = "1.7.6" +version = "1.7.7" authors = ["Hatter Jiang "] edition = "2018" diff --git a/src/cmd_pivmeta.rs b/src/cmd_pivmeta.rs index eb638f4..4e4a8f7 100644 --- a/src/cmd_pivmeta.rs +++ b/src/cmd_pivmeta.rs @@ -85,7 +85,14 @@ impl Command for CommandImpl { let public_key_bit_string = &cert.subject_public_key_info.subject_public_key; match algorithm_id { AlgorithmId::EccP256 | AlgorithmId::EccP384 => { - json.insert("pk_point_hex", hex::encode(public_key_bit_string.raw_bytes())); + let pk_point_hex = public_key_bit_string.raw_bytes(); + json.insert("pk_point_hex", hex::encode(pk_point_hex)); + if pk_point_hex[0] == 0x04 { + json.insert( + "pk_point_hex_compressed", + format!("02{}", hex::encode(&pk_point_hex[1..(pk_point_hex.len() / 2) + 1])), + ); + } } _ => {} }