use super::{Error, Result};
pub fn key_generation(
condition: bool,
algorithm: &'static str,
details: &'static str,
) -> Result<()> {
if !condition {
return Err(Error::KeyGeneration { algorithm, details });
}
Ok(())
}
pub fn encapsulation(
condition: bool,
algorithm: &'static str,
details: &'static str,
) -> Result<()> {
if !condition {
return Err(Error::Encapsulation { algorithm, details });
}
Ok(())
}
pub fn decapsulation(
condition: bool,
algorithm: &'static str,
details: &'static str,
) -> Result<()> {
if !condition {
return Err(Error::Decapsulation { algorithm, details });
}
Ok(())
}
pub fn key(condition: bool, key_type: &'static str, reason: &'static str) -> Result<()> {
if !condition {
return Err(Error::InvalidKey { key_type, reason });
}
Ok(())
}
pub fn ciphertext(condition: bool, algorithm: &'static str, reason: &'static str) -> Result<()> {
if !condition {
return Err(Error::InvalidCiphertext { algorithm, reason });
}
Ok(())
}
pub fn serialization(condition: bool, context: &'static str, details: &'static str) -> Result<()> {
if !condition {
return Err(Error::Serialization { context, details });
}
Ok(())
}
pub use dcrypt_api::error::validate::{length, max_length, min_length, parameter};