pub enum AeadAlgorithm {
AesGcm(AesKeySize),
ChaCha20Poly1305,
XChaCha20Poly1305,
}
Expand description
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
Variants§
AesGcm(AesKeySize)
AES in Galois/Counter Mode with configurable key size.
具有可配置密钥大小的 Galois/Counter 模式 AES。
Provides excellent performance on systems with AES hardware acceleration. Industry standard with extensive analysis and widespread adoption.
在具有 AES 硬件加速的系统上提供出色的性能。 行业标准,经过广泛分析和广泛采用。
ChaCha20Poly1305
ChaCha20 stream cipher with Poly1305 authenticator.
ChaCha20 流密码与 Poly1305 认证器。
Designed for high performance in software implementations. Provides excellent security with constant-time operations.
专为软件实现中的高性能而设计。 通过常数时间操作提供出色的安全性。
XChaCha20Poly1305
Extended-nonce ChaCha20-Poly1305 variant.
扩展 nonce 的 ChaCha20-Poly1305 变体。
Uses 192-bit nonces, reducing the risk of nonce collisions. Ideal for applications generating many encrypted messages.
使用 192 位 nonce,降低 nonce 碰撞的风险。 适用于生成许多加密消息的应用。
Implementations§
Source§impl AeadAlgorithm
impl AeadAlgorithm
Sourcepub fn build() -> AeadAlgorithmBuilder
pub fn build() -> AeadAlgorithmBuilder
Creates a new aead algorithm builder.
创建新的对称算法构建器。
§Examples | 示例
use seal_crypto_wrapper::algorithms::aead::AeadAlgorithm;
let algorithm = AeadAlgorithm::build().aes256_gcm();
Source§impl AeadAlgorithm
impl AeadAlgorithm
Sourcepub fn into_wrapper(self) -> AeadAlgorithmWrapper
pub fn into_wrapper(self) -> AeadAlgorithmWrapper
Converts the algorithm enum into a concrete wrapper implementation.
将算法枚举转换为具体的包装器实现。
§Purpose | 目的
This method bridges the gap between algorithm selection and actual cryptographic operations. It returns a wrapper that implements the aead algorithm trait, enabling type-safe encryption and decryption operations.
此方法在算法选择和实际密码操作之间架起桥梁。 它返回一个实现对称算法 trait 的包装器,启用类型安全的加密和解密操作。
§Returns | 返回值
A AeadAlgorithmWrapper
that can perform:
- Key generation
- Encryption with authentication
- Decryption with verification
- Algorithm introspection
可以执行以下操作的 AeadAlgorithmWrapper
:
- 密钥生成
- 带认证的加密
- 带验证的解密
- 算法内省
§Examples | 示例
use seal_crypto_wrapper::algorithms::aead::AeadAlgorithm;
let algorithm = AeadAlgorithm::build().aes256_gcm();
let cipher = algorithm.into_wrapper();
// Now you can use the cipher for encryption/decryption
let key = cipher.generate_typed_key()?;
Trait Implementations§
Source§impl<'__de, __Context> BorrowDecode<'__de, __Context> for AeadAlgorithm
impl<'__de, __Context> BorrowDecode<'__de, __Context> for AeadAlgorithm
Source§fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>(
decoder: &mut __D,
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>
Source§impl Clone for AeadAlgorithm
impl Clone for AeadAlgorithm
Source§fn clone(&self) -> AeadAlgorithm
fn clone(&self) -> AeadAlgorithm
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more