Interface KdfEngine
public interface KdfEngine
Key Derivation Function (KDF) engine interface - Provides unified API for various KDF algorithms
密钥派生函数引擎接口 - 为各种 KDF 算法提供统一的 API
Features | 主要功能:
- Key derivation from passwords or shared secrets - 从密码或共享密钥派生密钥
- Configurable output key length - 可配置的输出密钥长度
Usage Examples | 使用示例:
KdfEngine kdf = Hkdf.sha256();
byte[] derivedKey = kdf.deriveKey(inputKey, salt, info, 32);
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
- Null-safe: Partial - 空值安全: 部分
- Since:
- JDK 25, opencode-base-crypto V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]derive(byte[] inputKeyMaterial, byte[] salt, byte[] info, int length) Derives a key from input key material with salt and info parameters 使用盐值和信息参数从输入密钥材料派生密钥byte[]derive(byte[] inputKeyMaterial, int length) Derives a key from input key material with default parameters 使用默认参数从输入密钥材料派生密钥Returns the algorithm name of this KDF 返回此 KDF 的算法名称
-
Method Details
-
derive
byte[] derive(byte[] inputKeyMaterial, byte[] salt, byte[] info, int length) Derives a key from input key material with salt and info parameters 使用盐值和信息参数从输入密钥材料派生密钥- Parameters:
inputKeyMaterial- the input key material (IKM)salt- the salt value (can be null or empty for some algorithms)info- the context and application specific information (can be null)length- the desired output key length in bytes- Returns:
- the derived key
- Throws:
IllegalArgumentException- if length is invalidOpenCryptoException- if derivation fails
-
derive
byte[] derive(byte[] inputKeyMaterial, int length) Derives a key from input key material with default parameters 使用默认参数从输入密钥材料派生密钥- Parameters:
inputKeyMaterial- the input key material (IKM)length- the desired output key length in bytes- Returns:
- the derived key
- Throws:
IllegalArgumentException- if length is invalidOpenCryptoException- if derivation fails
-
getAlgorithm
String getAlgorithm()Returns the algorithm name of this KDF 返回此 KDF 的算法名称- Returns:
- the algorithm name
-