Security Avancé

Dérivez des clés cryptographiques en utilisant l'API KDF standard.

✕ Java 8
SecretKeyFactory factory =
    SecretKeyFactory.getInstance(
        "PBKDF2WithHmacSHA256");
KeySpec spec = new PBEKeySpec(
    password, salt, 10000, 256);
SecretKey key =
    factory.generateSecret(spec);
✓ Java 25
var kdf = KDF.getInstance("HKDF-SHA256");
SecretKey key = kdf.deriveKey(
    "AES",
    KDF.HKDFParameterSpec
        .ofExtract()
        .addIKM(inputKey)
        .addSalt(salt)
        .thenExpand(info, 32)
        .build()
);
Un problème avec ce code ? Dites-le nous.
📐

API propre

Pattern builder au lieu de constructeurs encombrants de KeySpec.

🔧

Support HKDF

Algorithme HKDF moderne aux côtés de PBKDF2.

🛡️

Standard

API unifiée pour tous les algorithmes de dérivation de clés.

Ancienne Approche
PBKDF2 manuel
Approche Moderne
API KDF
Depuis JDK
25
Difficulté
Avancé
Fonctions de dérivation de clés
Disponible

Finalisé dans JDK 25 LTS (JEP 510, sept. 2025).

L'API KDF fournit une interface standard pour les fonctions de dérivation de clés, y compris HKDF. Elle remplace l'encombrant pattern SecretKeyFactory + PBEKeySpec par une API propre basée sur un builder.

Partager 𝕏 🦋 in