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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
//! Aead encryption algorithms with Authenticated Encryption with Associated Data (AEAD).
//!
//! 带关联数据认证加密 (AEAD) 的对称加密算法。
//!
//! ## Overview | 概述
//!
//! This module provides aead encryption algorithms that combine confidentiality
//! and authenticity in a single operation. All algorithms implement AEAD (Authenticated
//! Encryption with Associated Data), providing both encryption and authentication.
//!
//! 此模块提供在单个操作中结合机密性和真实性的对称加密算法。
//! 所有算法都实现 AEAD(带关联数据的认证加密),提供加密和认证。
//!
//! ## Supported Algorithms | 支持的算法
//!
//! ### AES-GCM (Advanced Encryption Standard - Galois/Counter Mode)
//! - **AES-128-GCM**: 128-bit key, high performance, widely supported
//! - **AES-256-GCM**: 256-bit key, maximum security, future-proof
//!
//! ### ChaCha20-Poly1305
//! - **ChaCha20-Poly1305**: 256-bit key, software-optimized, constant-time
//! - **XChaCha20-Poly1305**: Extended nonce variant, 192-bit nonce
//!
//! ## Performance Comparison | 性能对比
//!
//! | Algorithm | Key Size | Nonce Size | Performance | Hardware Support |
//! |-----------|----------|------------|-------------|------------------|
//! | AES-128-GCM | 128-bit | 96-bit | Very High* | AES-NI |
//! | AES-256-GCM | 256-bit | 96-bit | Very High* | AES-NI |
//! | ChaCha20-Poly1305 | 256-bit | 96-bit | High | Software |
//! | XChaCha20-Poly1305 | 256-bit | 192-bit | High | Software |
//!
//! *With hardware acceleration
//!
//! ## Security Considerations | 安全考虑
//!
//! - **Nonce Reuse**: Never reuse nonces with the same key
//! - **Key Management**: Use cryptographically secure random keys
//! - **Associated Data**: Use for context binding when available
//! - **Implementation**: All algorithms are constant-time and side-channel resistant
//!
//! - **Nonce 重用**: 永远不要在同一密钥下重用 nonce
//! - **密钥管理**: 使用密码学安全的随机密钥
//! - **关联数据**: 可用时用于上下文绑定
//! - **实现**: 所有算法都是常数时间且抗侧信道的
use ;
/// Aead encryption algorithm enumeration.
///
/// 对称加密算法枚举。
///
/// ## Algorithm Selection Guide | 算法选择指南
///
/// Choose based on your requirements:
///
/// 根据您的要求选择:
///
/// - **High Performance + Hardware**: AES-128-GCM or AES-256-GCM
/// - **Software Implementation**: ChaCha20-Poly1305
/// - **Large Nonces**: XChaCha20-Poly1305
/// - **Maximum Security**: AES-256-GCM or ChaCha20-Poly1305
///
/// - **高性能 + 硬件**: AES-128-GCM 或 AES-256-GCM
/// - **软件实现**: ChaCha20-Poly1305
/// - **大 Nonce**: XChaCha20-Poly1305
/// - **最大安全性**: AES-256-GCM 或 ChaCha20-Poly1305
/// AES key size variants.
///
/// AES 密钥大小变体。
///
/// ## Security Levels | 安全级别
///
/// Both variants provide strong security, with AES-256 offering higher
/// theoretical security margin for long-term protection.
///
/// 两种变体都提供强大的安全性,AES-256 为长期保护提供更高的理论安全边际。
/// Builder for constructing aead algorithm instances.
///
/// 用于构建对称算法实例的构建器。
///
/// ## Usage Pattern | 使用模式
///
/// The builder provides a fluent interface for algorithm selection:
///
/// 构建器为算法选择提供流畅的接口:
///
/// ```rust
/// use seal_crypto_wrapper::algorithms::aead::AeadAlgorithm;
///
/// // High performance with hardware acceleration
/// let aes = AeadAlgorithm::build().aes256_gcm();
///
/// // Software-optimized
/// let chacha = AeadAlgorithm::build().chacha20_poly1305();
///
/// // Extended nonce support
/// let xchacha = AeadAlgorithm::build().xchacha20_poly1305();
/// ```
;
use crateAeadAlgorithmWrapper;