pub struct AeadContext { /* private fields */ }Expand description
AEAD context for authenticated encryption operations
Implementations§
Source§impl AeadContext
impl AeadContext
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an AEAD context with no provider configured.
Operations return Error::ProviderNotConfigured
until you call set_provider or build via with_aead_operations.
The lib-q crate provides libq::aead::context() wired to lib-q-aead.
Sourcepub fn with_provider(provider: Box<dyn CryptoProvider>) -> Self
pub fn with_provider(provider: Box<dyn CryptoProvider>) -> Self
Create a new AEAD context with a provider
Sourcepub fn with_aead_operations(aead: Box<dyn AeadOperations + Send + Sync>) -> Self
pub fn with_aead_operations(aead: Box<dyn AeadOperations + Send + Sync>) -> Self
Create a new AEAD context backed by the given AEAD implementation only.
The lib-q facade typically injects lib_q_aead::LibQAeadProvider this way so lib-q-core
does not depend on lib-q-aead.
Sourcepub fn with_default_provider() -> Self
pub fn with_default_provider() -> Self
Create a new AEAD context with the default provider
Sourcepub fn set_provider(&mut self, provider: Box<dyn CryptoProvider>)
pub fn set_provider(&mut self, provider: Box<dyn CryptoProvider>)
Set the cryptographic provider
Sourcepub fn provider(&self) -> Option<&dyn CryptoProvider>
pub fn provider(&self) -> Option<&dyn CryptoProvider>
Get the current provider
Sourcepub fn encrypt(
&mut self,
algorithm: Algorithm,
key: &AeadKey,
nonce: &Nonce,
plaintext: &[u8],
associated_data: Option<&[u8]>,
) -> Result<Vec<u8>>
pub fn encrypt( &mut self, algorithm: Algorithm, key: &AeadKey, nonce: &Nonce, plaintext: &[u8], associated_data: Option<&[u8]>, ) -> Result<Vec<u8>>
Encrypt data using the specified algorithm
Sourcepub fn decrypt(
&self,
algorithm: Algorithm,
key: &AeadKey,
nonce: &Nonce,
ciphertext: &[u8],
associated_data: Option<&[u8]>,
) -> Result<Vec<u8>>
pub fn decrypt( &self, algorithm: Algorithm, key: &AeadKey, nonce: &Nonce, ciphertext: &[u8], associated_data: Option<&[u8]>, ) -> Result<Vec<u8>>
Decrypt data using the specified algorithm.
Dispatches through AeadOperations::decrypt (Layer A
Result only). Semantic decrypt (crate::AeadDecryptSemantic) is not part of this
context; see ADR docs/adr/003-aead-decrypt-layers.md.
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if the context is initialized