Derive attestation algorithim from public key

This commit is contained in:
pjht 2023-08-29 10:45:37 -05:00
parent 29fc403d81
commit e6cbc8f7af
Signed by: pjht
GPG Key ID: CA239FC6934E6F3A
2 changed files with 12 additions and 2 deletions

View File

@ -295,13 +295,13 @@ impl AssertionRef {
}
}
pub fn verify(&self, idx: usize, alg: CoseAlg, pubkey: PubKey) -> Result<()> {
pub fn verify(&self, idx: usize, pubkey: PubKey) -> Result<()> {
assert!(idx < self.count());
unsafe {
check(fido_assert_verify(
self.as_ptr(),
idx,
alg as i32,
pubkey.alg() as i32,
pubkey.as_ptr(),
))
}

View File

@ -2,6 +2,7 @@ use std::ffi::c_void;
use libfido2_sys::*;
use crate::CoseAlg;
use crate::error::Result;
use crate::util::check_initialized;
@ -94,4 +95,13 @@ impl PubKey {
PubKey::Rsa256PubKey(pk) => pk.as_ptr() as *const c_void,
}
}
pub(crate) fn alg(&self) -> CoseAlg {
match self {
PubKey::Ec25519(_) => CoseAlg::Ed25519,
PubKey::Ecdsa256(_) => CoseAlg::Ecdsa256,
PubKey::Ecdsa384(_) => CoseAlg::Ecdsa384,
PubKey::Rsa256PubKey(_) => CoseAlg::Rsa,
}
}
}