bitwarden_crypto/traits/
mod.rs

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