feat: output public key
This commit is contained in:
@@ -2,6 +2,7 @@ use p256::{ecdh::EphemeralSecret, EncodedPoint, PublicKey};
|
||||
use p256::elliptic_curve::sec1::{FromEncodedPoint, ToEncodedPoint};
|
||||
use rand::rngs::OsRng;
|
||||
use rust_util::{failure_and_exit, information, warning, XResult};
|
||||
use yubikey::certificate::PublicKeyInfo;
|
||||
use yubikey::Context;
|
||||
use yubikey::piv::{AlgorithmId, decrypt_data, metadata, RetiredSlotId, SlotId};
|
||||
|
||||
@@ -60,7 +61,20 @@ fn main() -> XResult<()> {
|
||||
let meta_result = metadata(&mut yubikey, SlotId::Retired(RetiredSlotId::R1));
|
||||
match meta_result {
|
||||
Ok(meta) => {
|
||||
information!("{:?}", meta)
|
||||
information!("{:?}", meta);
|
||||
if let Some(public_key) = &meta.public {
|
||||
match public_key {
|
||||
PublicKeyInfo::Rsa { algorithm, pubkey } => {
|
||||
information!("RSA, {:?}, {:?}", algorithm, pubkey);
|
||||
}
|
||||
PublicKeyInfo::EcP256(pubkey) => {
|
||||
information!("EC-P256, {}", hex::encode(pubkey.as_bytes()));
|
||||
}
|
||||
PublicKeyInfo::EcP384(pubkey) => {
|
||||
information!("EC-P384, {}", hex::encode(pubkey.as_bytes()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => warning!("Get slot meta failed: {}", e)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user