zvault/src/util/encryption.rs

55 lines
1.1 KiB
Rust

use std::collections::HashMap;
#[derive(Clone)]
pub enum EncryptionMethod {
Dummy
}
serde_impl!(EncryptionMethod(u64) {
Dummy => 0
});
pub type EncryptionKey = Vec<u8>;
pub type EncryptionKeyId = u64;
pub type Encryption = (EncryptionMethod, EncryptionKeyId);
#[derive(Clone)]
pub struct Crypto {
keys: HashMap<EncryptionKeyId, EncryptionKey>
}
impl Crypto {
#[inline]
pub fn new() -> Self {
Crypto { keys: Default::default() }
}
#[inline]
pub fn register_key(&mut self, key: EncryptionKey, id: EncryptionKeyId) {
self.keys.insert(id, key);
}
#[inline]
pub fn contains_key(&mut self, id: EncryptionKeyId) -> bool {
self.keys.contains_key(&id)
}
#[inline]
pub fn encrypt(&self, _enc: Encryption, _data: &[u8]) -> Result<Vec<u8>, &'static str> {
unimplemented!()
}
#[inline]
pub fn decrypt(&self, _enc: Encryption, _data: &[u8]) -> Result<Vec<u8>, &'static str> {
unimplemented!()
}
}
impl Default for Crypto {
#[inline]
fn default() -> Self {
Crypto::new()
}
}