09
Baeldung
作者:Bhaskar Ghosh
發布:05-11 23:20
Key Derivation Function API in Java 25
Java 25 introduces a clean, extensible model for deriving cryptographic keys from initial key material using established algorithms.
重點摘要
Adds a standard KDF API in javax.crypto for Java 25
Supports HKDF-SHA256, HKDF-SHA384, and HKDF-SHA512 via SunJCE
Simplifies key derivation compared with manual Mac-based implementations
Java 25 introduces the Key Derivation Function (KDF) API, first previewed in JDK 24, to provide a standard and extensible way to derive cryptographic keys from initial key material. The article explains why KDFs matter for TLS handshakes, password-based encryption, and key diversification, and how the new javax.crypto KDF class fits into the JCA factory-model architecture. It also covers deriveKey() and deriveData(), the HKDFParameterSpec variants for extract, expand, and combined flows, and built-in support for HKDF-SHA256, HKDF-SHA384, and HKDF-SHA512. Compared with older manual Mac-based HKDF code, the new API is shorter, clearer, safer, and provider-extensible.
Java 25 的密钥派生函数 API
Java 25 引入了一个简洁、可扩展的模型,可使用成熟算法从初始密钥材料派生加密密钥。
重點摘要
Java 25 在 javax.crypto 中新增标准 KDF API
支持 HKDF-SHA256、HKDF-SHA384、HKDF-SHA512
比手动用 Mac 实现 HKDF 更简洁、更安全
Java 25 新增密钥派生函数(KDF)API,并在 JDK 24 首次预览后正式推出。文章解释了 KDF 的用途:在 TLS 握手中将共享秘密转换为会话密钥,在基于密码的加密中强化弱密码,以及把主密钥安全扩展为多个子密钥。新的 API 位于 javax.crypto,沿用 JCA 的工厂方法模式,提供 deriveKey() 和 deriveData() 两种派生方式,并通过 HKDFParameterSpec 表达 Extract、Expand 及组合流程。与过去手动编写基于 Mac 的 HKDF 代码相比,新 API 更短、更清晰、更不易出错,也支持可替换的提供者实现。
Java 25 的金鑰衍生函式 API
Java 25 以一個乾淨且可擴充的模型,透過成熟演算法從初始金鑰材料衍生加密金鑰。
重點摘要
Java 25 在 javax.crypto 中新增標準 KDF API
支援 HKDF-SHA256、HKDF-SHA384、HKDF-SHA512
比手動以 Mac 實作 HKDF 更簡潔且不易出錯
Java 25 新增金鑰衍生函式(KDF)API,並在 JDK 24 首次預覽後正式推出。文章說明 KDF 為何重要:可用於 TLS 握手後衍生會談金鑰、密碼式加密,以及將單一主金鑰分化為多個用途專用子金鑰。新 API 位於 javax.crypto,延續 JCA 的工廠方法風格,提供 deriveKey() 與 deriveData() 兩種主要用法,並以 HKDFParameterSpec 描述 Extract、Expand 與組合流程。相較於過去手動撰寫 Mac 程式碼,新 API 更簡潔、可驗證、可替換供應商實作,也更利於維護與稽核。