feat: v1.7.7, add pk_point_hex_compressed

This commit is contained in:
2023-10-10 23:56:08 +08:00
parent 7b79f6aa18
commit 69529b1813
3 changed files with 10 additions and 3 deletions

2
Cargo.lock generated
View File

@@ -326,7 +326,7 @@ dependencies = [
[[package]]
name = "card-cli"
version = "1.7.6"
version = "1.7.7"
dependencies = [
"authenticator",
"base64 0.21.4",

View File

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

View File

@@ -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])),
);
}
}
_ => {}
}