feat: init commit

This commit is contained in:
2024-08-14 23:40:41 +08:00
parent e1e72ed097
commit 29a03ee225
11 changed files with 342 additions and 41 deletions

View File

@@ -19,6 +19,8 @@ use tracing::instrument;
use native_pkcs11_traits::{Backend, KeyAlgorithm, PrivateKey, PublicKey, SignatureAlgorithm};
use native_pkcs11_traits::Result as P11Result;
use crate::piv::util::sha1_bytes;
#[derive(Debug)]
pub enum Algorithm {
RSA,
@@ -107,6 +109,16 @@ pub struct YubikeyPivPublicKey {
}
impl YubikeyPivPublicKey {
#[instrument]
pub fn new(label: String, algorithm: KeyAlgorithm, public_key_der: Vec<u8>) -> P11Result<Self> {
let public_key_hash = sha1_bytes(&public_key_der);
Ok(Self {
label,
der: public_key_der,
public_key_hash,
algorithm,
})
}
// #[instrument]
// pub fn new(sec_key: SecKey, label: impl Into<String> + Debug) -> Result<Self> {
// let der = sec_key