bitwarden_crypto/traits/
mod.rs

1mod encryptable;
2pub use encryptable::Encryptable;
3mod decryptable;
4pub use decryptable::Decryptable;
5
6pub(crate) mod key_id;
7pub use key_id::{KeyId, KeyIds};
8
9/// Types implementing [IdentifyKey] are capable of knowing which cryptographic key is
10/// needed to encrypt/decrypt them.
11pub trait IdentifyKey<Key: KeyId> {
12    #[allow(missing_docs)]
13    fn key_identifier(&self) -> Key;
14}
15
16#[cfg(test)]
17pub(crate) mod tests {
18    use crate::key_ids;
19    key_ids! {
20        #[symmetric]
21        pub enum TestSymmKey {
22            A(u8),
23
24            // We only support one variant value,
25            // but that value can be a tuple
26            B((u8, u8)),
27
28            #[local]
29            C(u8),
30        }
31
32        #[asymmetric]
33        pub enum TestAsymmKey {
34            A(u8),
35            B,
36            #[local]
37            C(&'static str),
38        }
39
40        #[signing]
41        pub enum TestSigningKey {
42            A(u8),
43            B,
44            #[local]
45            C(&'static str),
46        }
47
48       pub TestIds => TestSymmKey, TestAsymmKey, TestSigningKey;
49    }
50}