Struct KdfKeyAlgorithmBuilder

Source
pub struct KdfKeyAlgorithmBuilder;
Expand description

Builder for constructing key-based KDF algorithm instances.

用于构建基于密钥的 KDF 算法实例的构建器。

§Usage Pattern | 使用模式

use seal_crypto_wrapper::algorithms::kdf::key::KdfKeyAlgorithm;

// Different hash functions for different security levels
let hkdf_sha256 = KdfKeyAlgorithm::build().hkdf_sha256(); // 128-bit security
let hkdf_sha384 = KdfKeyAlgorithm::build().hkdf_sha384(); // 192-bit security
let hkdf_sha512 = KdfKeyAlgorithm::build().hkdf_sha512(); // 256-bit security

§Hash Function Selection | 哈希函数选择

The choice of hash function affects both security and performance:

  • SHA-256: Fastest, suitable for most applications
  • SHA-384: Good balance of security and performance
  • SHA-512: Highest security, slower on 32-bit platforms

哈希函数的选择影响安全性和性能:

  • SHA-256: 最快,适用于大多数应用
  • SHA-384: 安全性和性能的良好平衡
  • SHA-512: 最高安全性,在 32 位平台上较慢

Implementations§

Source§

impl KdfKeyAlgorithmBuilder

Source

pub fn hkdf_sha256(self) -> KdfKeyAlgorithm

Selects HKDF with SHA-256 hash function.

选择使用 SHA-256 哈希函数的 HKDF。

§Properties | 属性
  • Hash Function: SHA-256
  • Security Level: 128-bit
  • Output Size: Up to 255 × 32 = 8160 bytes
  • Performance: High
§Use Cases | 使用场景
  • General-purpose key derivation

  • TLS/SSL key derivation

  • Aead key expansion

  • Protocol key derivation

  • 通用密钥派生

  • TLS/SSL 密钥派生

  • 对称密钥扩展

  • 协议密钥派生

§Examples | 示例
use seal_crypto_wrapper::algorithms::kdf::key::KdfKeyAlgorithm;

let algorithm = KdfKeyAlgorithm::build().hkdf_sha256();
let kdf = algorithm.into_wrapper();

// Derive keys from master key
let master_key = b"high-entropy-master-key-material";
let salt = Some(b"unique-salt".as_slice());
let info = Some(b"application-context".as_slice());
let derived_key = kdf.derive(master_key, salt, info, 32)?;
Source

pub fn hkdf_sha384(self) -> KdfKeyAlgorithm

Selects HKDF with SHA-384 hash function.

选择使用 SHA-384 哈希函数的 HKDF。

§Properties | 属性
  • Hash Function: SHA-384
  • Security Level: 192-bit
  • Output Size: Up to 255 × 48 = 12240 bytes
  • Performance: Medium
§Use Cases | 使用场景

Applications requiring higher security than SHA-256:

  • High-security protocols
  • Long-term key derivation
  • Government/military applications

需要比 SHA-256 更高安全性的应用:

  • 高安全性协议
  • 长期密钥派生
  • 政府/军事应用
Source

pub fn hkdf_sha512(self) -> KdfKeyAlgorithm

Selects HKDF with SHA-512 hash function.

选择使用 SHA-512 哈希函数的 HKDF。

§Properties | 属性
  • Hash Function: SHA-512
  • Security Level: 256-bit
  • Output Size: Up to 255 × 64 = 16320 bytes
  • Performance: Medium (fast on 64-bit platforms)
§Use Cases | 使用场景

Maximum security applications:

  • Top-secret data protection
  • Long-term archival security
  • Future-proofing against advances

最大安全性应用:

  • 绝密数据保护
  • 长期档案安全
  • 防范技术进步的未来保护
§Performance Note | 性能注意

SHA-512 is optimized for 64-bit platforms and may be slower on 32-bit systems. Consider SHA-256 for better performance on resource-constrained devices.

SHA-512 针对 64 位平台优化,在 32 位系统上可能较慢。 在资源受限的设备上考虑使用 SHA-256 以获得更好的性能。

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V