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

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