pub struct KeyAgreementAlgorithmBuilder;
Expand description
Builder for constructing key agreement algorithm instances.
用于构建密钥协商算法实例的构建器。
§Usage Pattern | 使用模式
use seal_crypto_wrapper::algorithms::asymmetric::key_agreement::KeyAgreementAlgorithm;
// Select ECDH P-256 algorithm
let algorithm = KeyAgreementAlgorithm::build().ecdh_p256();
§Security Considerations | 安全考虑
When selecting a key agreement algorithm, consider:
- Required security level
- Performance requirements
- Compatibility with other systems
- Forward secrecy requirements
选择密钥协商算法时,考虑:
- 所需的安全级别
- 性能要求
- 与其他系统的兼容性
- 前向保密要求
Implementations§
Source§impl KeyAgreementAlgorithmBuilder
impl KeyAgreementAlgorithmBuilder
Sourcepub fn ecdh_p256(self) -> KeyAgreementAlgorithm
pub fn ecdh_p256(self) -> KeyAgreementAlgorithm
Selects ECDH P-256 key agreement algorithm.
选择 ECDH P-256 密钥协商算法。
§Algorithm Details | 算法详情
ECDH (Elliptic Curve Diffie-Hellman) over the NIST P-256 curve provides:
- 128-bit security level
- Efficient computation
- Wide industry support
- FIPS 140-2 compliance
基于 NIST P-256 曲线的 ECDH(椭圆曲线 Diffie-Hellman)提供:
- 128 位安全级别
- 高效计算
- 广泛的行业支持
- FIPS 140-2 合规性
§Performance | 性能
- Key Generation: Very fast (~0.1ms)
- Key Agreement: Fast (~0.2ms)
- Memory Usage: Low (64 bytes per key pair)
- Hardware Support: Available on many platforms
§Use Cases | 使用场景
Ideal for applications requiring:
- High performance key exchange
- Standards compliance
- Interoperability
- Moderate security requirements
适用于需要以下功能的应用:
- 高性能密钥交换
- 标准合规性
- 互操作性
- 中等安全要求
§Examples | 示例
use seal_crypto_wrapper::algorithms::asymmetric::key_agreement::KeyAgreementAlgorithm;
let algorithm = KeyAgreementAlgorithm::build().ecdh_p256();
let ka = algorithm.into_wrapper();
// Generate key pairs for Alice and Bob
let alice_keypair = ka.generate_keypair()?;
let bob_keypair = ka.generate_keypair()?;
// Derive shared secrets
let (alice_public, alice_private) = alice_keypair.into_keypair();
let (bob_public, bob_private) = bob_keypair.into_keypair();
let alice_shared = ka.agree(&alice_private, &bob_public)?;
let bob_shared = ka.agree(&bob_private, &alice_public)?;
assert_eq!(alice_shared, bob_shared);
Auto Trait Implementations§
impl Freeze for KeyAgreementAlgorithmBuilder
impl RefUnwindSafe for KeyAgreementAlgorithmBuilder
impl Send for KeyAgreementAlgorithmBuilder
impl Sync for KeyAgreementAlgorithmBuilder
impl Unpin for KeyAgreementAlgorithmBuilder
impl UnwindSafe for KeyAgreementAlgorithmBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more