1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7#[non_exhaustive]
8pub enum RngOutputKind {
9 Generic,
11 AeadNonce12,
13 Argon2Salt16,
15 Argon2Salt32,
17 Aes256GcmKey,
19 MlKem1024Seed,
21 MlDsa87Seed,
23 Ed25519Seed,
25 SlhDsaSha2_128sSeed,
27}
28
29impl core::fmt::Display for RngOutputKind {
30 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
31 let detail = match self {
32 RngOutputKind::Generic => "random bytes",
33 RngOutputKind::AeadNonce12 => "AEAD nonce",
34 RngOutputKind::Argon2Salt16 => "Argon2 16-byte salt",
35 RngOutputKind::Argon2Salt32 => "Argon2 32-byte salt",
36 RngOutputKind::Aes256GcmKey => "AES-256-GCM key",
37 RngOutputKind::MlKem1024Seed => "ML-KEM-1024 seed",
38 RngOutputKind::MlDsa87Seed => "ML-DSA-87 seed",
39 RngOutputKind::Ed25519Seed => "Ed25519 seed",
40 RngOutputKind::SlhDsaSha2_128sSeed => "SLH-DSA-SHA2-128s seed",
41 };
42 write!(f, "{detail}")
43 }
44}
45
46#[derive(Debug, Clone, Copy, PartialEq, Eq)]
48#[non_exhaustive]
49pub enum RngFailureKind {
50 EntropyUnavailable,
52 InvalidOutputLength,
54}
55
56impl core::fmt::Display for RngFailureKind {
57 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
58 let detail = match self {
59 RngFailureKind::EntropyUnavailable => "entropy unavailable",
60 RngFailureKind::InvalidOutputLength => "invalid output length",
61 };
62 write!(f, "{detail}")
63 }
64}
65
66#[derive(Debug, Clone, Copy, PartialEq, Eq)]
68#[non_exhaustive]
69pub enum ConstantTimeFailureKind {
70 LengthMismatch,
72 NotEqual,
74}
75
76impl core::fmt::Display for ConstantTimeFailureKind {
77 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
78 let detail = match self {
79 ConstantTimeFailureKind::LengthMismatch => "length mismatch",
80 ConstantTimeFailureKind::NotEqual => "not equal",
81 };
82 write!(f, "{detail}")
83 }
84}