ssh/algorithm/public_key/
ed25519.rs1use crate::algorithm::public_key::PublicKey;
2use crate::model::Data;
3use crate::SshError;
4use ring::signature;
5
6pub(super) struct Ed25519;
7
8impl PublicKey for Ed25519 {
9 fn new() -> Self
10 where
11 Self: Sized,
12 {
13 Self
14 }
15
16 fn verify_signature(&self, ks: &[u8], message: &[u8], sig: &[u8]) -> Result<bool, SshError> {
17 let mut data = Data::from(ks[4..].to_vec());
18 data.get_u8s();
19 let host_key = data.get_u8s();
20 let pub_key = signature::UnparsedPublicKey::new(&signature::ED25519, host_key);
21 Ok(pub_key.verify(message, sig).is_ok())
22 }
23}