pub enum KemAlgorithm {
Rsa(RsaBits, HashAlgorithm),
Kyber(KyberSecurityLevel),
}
Expand description
Key Encapsulation Mechanism algorithm enumeration.
密钥封装机制算法枚举。
§Algorithm Types | 算法类型
This enum supports both traditional and post-quantum KEM algorithms, allowing applications to choose based on their security and compatibility requirements.
此枚举支持传统和后量子 KEM 算法, 允许应用程序根据其安全性和兼容性要求进行选择。
Variants§
Rsa(RsaBits, HashAlgorithm)
RSA-based Key Encapsulation Mechanism.
基于 RSA 的密钥封装机制。
Traditional public-key cryptosystem with configurable key size and hash function. Widely supported but vulnerable to quantum attacks.
具有可配置密钥大小和哈希函数的传统公钥密码系统。 广泛支持但易受量子攻击。
Kyber(KyberSecurityLevel)
Kyber post-quantum Key Encapsulation Mechanism.
Kyber 后量子密钥封装机制。
NIST-standardized lattice-based KEM providing security against quantum computers. Offers excellent performance and smaller ciphertext sizes compared to RSA.
NIST 标准化的基于格的 KEM,提供对量子计算机的安全性。 与 RSA 相比提供出色的性能和更小的密文大小。
Implementations§
Source§impl KemAlgorithm
impl KemAlgorithm
Sourcepub fn build() -> KemAlgorithmBuilder
pub fn build() -> KemAlgorithmBuilder
Creates a new KEM algorithm builder.
创建新的 KEM 算法构建器。
§Examples | 示例
use seal_crypto_wrapper::algorithms::asymmetric::kem::KemAlgorithm;
// Post-quantum KEM
let kyber = KemAlgorithm::build().kyber512();
// Traditional KEM
let rsa = KemAlgorithm::build().rsa2048().sha256();
Source§impl KemAlgorithm
impl KemAlgorithm
Sourcepub fn into_wrapper(self) -> KemAlgorithmWrapper
pub fn into_wrapper(self) -> KemAlgorithmWrapper
Converts the algorithm enum into a concrete wrapper implementation.
将算法枚举转换为具体的包装器实现。
§Purpose | 目的
This method creates a wrapper that implements the KEM algorithm trait, enabling actual cryptographic operations like key encapsulation and decapsulation with type safety guarantees.
此方法创建一个实现 KEM 算法 trait 的包装器, 启用实际的密码操作,如密钥封装和解封装,并提供类型安全保证。
§Returns | 返回值
A KemAlgorithmWrapper
that can perform:
- Key pair generation
- Key encapsulation (encryption)
- Key decapsulation (decryption)
- Algorithm introspection
可以执行以下操作的 KemAlgorithmWrapper
:
- 密钥对生成
- 密钥封装(加密)
- 密钥解封装(解密)
- 算法内省
§Examples | 示例
use seal_crypto_wrapper::algorithms::asymmetric::kem::KemAlgorithm;
let algorithm = KemAlgorithm::build().kyber512();
let kem = algorithm.into_wrapper();
// Generate key pair
let keypair = kem.generate_keypair()?;
let (public_key, private_key) = keypair.into_keypair();
// Encapsulate a shared secret
let (shared_secret, ciphertext) = kem.encapsulate_key(&public_key)?;
// Decapsulate to recover the shared secret
let recovered_secret = kem.decapsulate_key(&private_key, &ciphertext)?;
assert_eq!(shared_secret, recovered_secret);
Trait Implementations§
Source§impl<'__de, __Context> BorrowDecode<'__de, __Context> for KemAlgorithm
impl<'__de, __Context> BorrowDecode<'__de, __Context> for KemAlgorithm
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 KemAlgorithm
impl Clone for KemAlgorithm
Source§fn clone(&self) -> KemAlgorithm
fn clone(&self) -> KemAlgorithm
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more