1use ed25519_dalek::{SigningKey, VerifyingKey};
2use rsa::{RsaPrivateKey, RsaPublicKey};
3
4#[derive(Debug, Clone)]
6pub enum Key {
7 Bytes(Vec<u8>),
8 RsaPrivate(RsaPrivateKey),
9 RsaPublic(RsaPublicKey),
10 Ed25519Private(SigningKey),
11 Ed25519Public(VerifyingKey),
12}
13
14impl Key {
15 pub fn from_bytes(bytes: impl AsRef<[u8]>) -> Self {
17 Self::Bytes(bytes.as_ref().to_vec())
18 }
19
20 pub fn rsa_private(key: RsaPrivateKey) -> Self {
22 Self::RsaPrivate(key)
23 }
24
25 pub fn rsa_public(key: RsaPublicKey) -> Self {
27 Self::RsaPublic(key)
28 }
29
30 pub fn ed25519_private(key: SigningKey) -> Self {
32 Self::Ed25519Private(key)
33 }
34
35 pub fn ed25519_public(key: VerifyingKey) -> Self {
37 Self::Ed25519Public(key)
38 }
39}