diff --git a/src/assert.rs b/src/assert.rs index 027787c..b4f08a8 100644 --- a/src/assert.rs +++ b/src/assert.rs @@ -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(), )) } diff --git a/src/pkey.rs b/src/pkey.rs index d556118..75518b4 100644 --- a/src/pkey.rs +++ b/src/pkey.rs @@ -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, + } + } }