1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Fixed-length cryptographic key generation.
//!
//! This module provides secure generation of fixed-length Data Encryption Keys (DEKs)
//! using the operating system's cryptographically secure random number generator.
//! It ensures:
//!
//! - Cryptographic security
//! - Consistent key lengths
//! - System-level entropy
//! - Thread safety
use OsRng;
use RngCore;
use crateDEKKeyGenerator;
use crateGenerateKeyError;
/// A key generator that produces cryptographically secure random keys
/// of a fixed length using the operating system's random number generator.
///
/// This generator:
/// - Uses the system's secure RNG
/// - Produces keys of consistent length
/// - Ensures cryptographic quality
/// - Provides thread-safe operation
///
/// # Security
///
/// This implementation:
/// - Uses OS-provided entropy
/// - Generates cryptographically secure random bytes
/// - Maintains key length consistency
///
/// # Example
/// ```no_run
/// use hyokashi::FixedLengthGenerator;
///
/// // Create a generator for 32-byte keys
/// let generator = FixedLengthGenerator::new(32);
/// let key = generator.generate_key()?;
/// assert_eq!(key.len(), 32);
/// ```
usize);