Share helper reconciliation and verify Linux and Windows native fixtures
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
@@ -3,6 +3,7 @@ use anyhow::Result;
|
||||
use ed25519_dalek::{Signature, VerifyingKey};
|
||||
|
||||
pub trait Ed25519Verifier {
|
||||
fn validate_key(&self, public_key: &[u8]) -> Result<bool>;
|
||||
fn verify(&self, public_key: &[u8], message: &[u8], signature: &[u8]) -> Result<bool>;
|
||||
}
|
||||
|
||||
@@ -10,6 +11,13 @@ pub trait Ed25519Verifier {
|
||||
pub struct DalekVerifier;
|
||||
|
||||
impl Ed25519Verifier for DalekVerifier {
|
||||
fn validate_key(&self, public_key: &[u8]) -> Result<bool> {
|
||||
let Ok(raw): Result<&[u8; 32], _> = public_key.try_into() else {
|
||||
return Ok(false);
|
||||
};
|
||||
Ok(VerifyingKey::from_bytes(raw).is_ok_and(|key| !key.is_weak()))
|
||||
}
|
||||
|
||||
fn verify(&self, public_key: &[u8], message: &[u8], signature: &[u8]) -> Result<bool> {
|
||||
let Ok(raw): Result<&[u8; 32], _> = public_key.try_into() else {
|
||||
return Ok(false);
|
||||
@@ -33,6 +41,14 @@ pub struct OpenSslVerifier;
|
||||
|
||||
#[cfg(all(unix, feature = "openssl-verifier"))]
|
||||
impl Ed25519Verifier for OpenSslVerifier {
|
||||
fn validate_key(&self, public_key: &[u8]) -> Result<bool> {
|
||||
if public_key.len() != 32 {
|
||||
return Ok(false);
|
||||
}
|
||||
openssl::pkey::PKey::public_key_from_raw_bytes(public_key, openssl::pkey::Id::ED25519)?;
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn verify(&self, public_key: &[u8], message: &[u8], signature: &[u8]) -> Result<bool> {
|
||||
use openssl::{
|
||||
pkey::{Id, PKey},
|
||||
|
||||
Reference in New Issue
Block a user