ssh_key/certificate/signing_key.rs
1//! Certificate signing key trait.
2
3use crate::{public, Signature};
4use signature::Signer;
5
6#[cfg(doc)]
7use super::Builder;
8
9/// Certificate signing key trait for the certificate [`Builder`].
10///
11/// This trait is automatically impl'd for any types which impl the
12/// [`Signer`] trait for the OpenSSH certificate [`Signature`] type and also
13/// support a [`From`] conversion for [`public::KeyData`].
14pub trait SigningKey: Signer<Signature> {
15 /// Get the [`public::KeyData`] for this signing key.
16 fn public_key(&self) -> public::KeyData;
17}
18
19impl<T> SigningKey for T
20where
21 T: Signer<Signature>,
22 public::KeyData: for<'a> From<&'a T>,
23{
24 fn public_key(&self) -> public::KeyData {
25 self.into()
26 }
27}