use crate::algorithm::{Cipher, Hash};
use crate::ffi;
mod decryptor;
mod encryptor;
pub use decryptor::{decrypt, decrypt_to, DecryptResult, Decryptor};
pub use encryptor::Encryptor;
#[derive(Clone, Copy, Debug, Default)]
pub struct EncryptFlags(pub u32);
impl EncryptFlags {
pub const NOWRAP: Self = Self(ffi::RNP_ENCRYPT_NOWRAP as u32);
pub fn bits(self) -> u32 {
self.0
}
}
impl std::ops::BitOr for EncryptFlags {
type Output = Self;
fn bitor(self, rhs: Self) -> Self {
Self(self.0 | rhs.0)
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum AeadType {
Ocb,
Eax,
Gcm,
}
impl AeadType {
pub fn as_str(self) -> &'static str {
match self {
AeadType::Ocb => "OCB",
AeadType::Eax => "EAX",
AeadType::Gcm => "GCM",
}
}
}
#[derive(Default)]
pub struct AddPasswordOptions {
pub(crate) hash: Option<Hash>,
pub(crate) iterations: Option<usize>,
pub(crate) cipher: Option<Cipher>,
}
impl AddPasswordOptions {
pub fn hash(mut self, h: Hash) -> Self {
self.hash = Some(h);
self
}
pub fn iterations(mut self, n: usize) -> Self {
self.iterations = Some(n);
self
}
pub fn cipher(mut self, c: Cipher) -> Self {
self.cipher = Some(c);
self
}
}