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
69
70
71
72
73
74
75
//! Data Encryption Key (DEK) management and operations.
//!
//! This module provides core functionality for managing Data Encryption Keys,
//! including:
//!
//! - Key generation and persistence
//! - Scope-based key management
//! - Type-safe conversions
//!
//! DEKs are used throughout the library for encrypting and decrypting data
//! while being themselves protected by Customer Managed Keys (CMKs).
/// A Data Encryption Key (DEK) used for encrypting and decrypting data.
///
/// This type wraps the raw key bytes and provides safe conversion methods
/// to and from byte vectors. DEKs are typically:
///
/// - Generated using cryptographically secure random numbers
/// - Encrypted using a Customer Managed Key (CMK) for storage
/// - Associated with specific data scopes
///
/// # Security
///
/// When handling DEKs:
/// - Protect key material in memory
/// - Clear keys when no longer needed
/// - Use secure persistence methods
/// - Follow key rotation policies
///
/// # Example
/// ```no_run
/// use hyokashi::DEK;
///
/// // Create a DEK from bytes
/// let key_bytes = vec![1, 2, 3, 4];
/// let dek = DEK::from(key_bytes.clone());
///
/// // Convert back to bytes
/// let recovered: Vec<u8> = dek.into();
/// assert_eq!(key_bytes, recovered);
/// ```
;