dcrypt_kem/error/
validate.rs1use super::{Error, Result};
4
5pub fn key_generation(
7 condition: bool,
8 algorithm: &'static str,
9 details: &'static str,
10) -> Result<()> {
11 if !condition {
12 return Err(Error::KeyGeneration { algorithm, details });
13 }
14 Ok(())
15}
16
17pub fn encapsulation(
19 condition: bool,
20 algorithm: &'static str,
21 details: &'static str,
22) -> Result<()> {
23 if !condition {
24 return Err(Error::Encapsulation { algorithm, details });
25 }
26 Ok(())
27}
28
29pub fn decapsulation(
31 condition: bool,
32 algorithm: &'static str,
33 details: &'static str,
34) -> Result<()> {
35 if !condition {
36 return Err(Error::Decapsulation { algorithm, details });
37 }
38 Ok(())
39}
40
41pub fn key(condition: bool, key_type: &'static str, reason: &'static str) -> Result<()> {
43 if !condition {
44 return Err(Error::InvalidKey { key_type, reason });
45 }
46 Ok(())
47}
48
49pub fn ciphertext(condition: bool, algorithm: &'static str, reason: &'static str) -> Result<()> {
51 if !condition {
52 return Err(Error::InvalidCiphertext { algorithm, reason });
53 }
54 Ok(())
55}
56
57pub fn serialization(condition: bool, context: &'static str, details: &'static str) -> Result<()> {
59 if !condition {
60 return Err(Error::Serialization { context, details });
61 }
62 Ok(())
63}
64
65pub use dcrypt_api::error::validate::{length, max_length, min_length, parameter};