extract static method

Uint8List extract({
  1. required Uint8List ikm,
  2. Uint8List? salt,
})

Computes the Extract step: PRK = HMAC(salt, ikm).

ikm Input keying material (secret), any length. salt Optional salt; if null or empty, uses a zero array of length hashLen.

RETURNS: 32-byte PRK.

SECURITY:

  • Provide a non-empty random salt where feasible (protocol-level constant).

Implementation

static Uint8List extract({
  required Uint8List ikm,
  Uint8List? salt,
}) {
  final Uint8List usedSalt = (salt == null || salt.isEmpty)
      ? Uint8List(hashLen) // RFC: zeros if salt is not provided
      : salt;
  final prk = HmacSha256.compute(usedSalt, ikm);
  return prk; // 32 bytes
}