diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index 04f5f0d..2c1da40 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -229,6 +229,26 @@ impl PkiPathSignatureVerifier { } } +pub fn verify_signature( + alias: &Certificate, + hash: &[u8], + signature: &[u8; 64], +) -> Result<()> { + use ed25519_dalek::{Signature, Verifier, VerifyingKey}; + + let signature = Signature::from_bytes(signature); + + let alias = alias + .tbs_certificate + .subject_public_key_info + .subject_public_key + .as_bytes() + .ok_or_else(|| anyhow!("Invalid / unaligned public key"))?; + + let verifying_key = VerifyingKey::from_bytes(alias.try_into()?)?; + Ok(verifying_key.verify(&hash, &signature)?) +} + pub fn verify_attestation( alias: &Certificate, attestation: &Attestation,