React Native Quick Crypto
API Reference

HKDF

HMAC-based Extract-and-Expand Key Derivation Function

Table of Contents

Theory

HKDF (RFC 5869) is a simple key derivation function based on HMAC. It is often used to derive multiple session keys from a single master secret.

It follows a standard "Extract-then-Expand" paradigm:

  1. Extract: Derives a fixed-length pseudorandom key (PRKPRK) from the input keying material (IKMIKM) and optional salt.
  2. Expand: Expands the PRKPRK into multiple cryptographically strong output keys.
PRK=HMAC-Hash(salt,IKM)PRK = \text{HMAC-Hash}(salt, IKM) OKM=HMAC-Hash(PRK,info0x01)OKM = \text{HMAC-Hash}(PRK, info \parallel 0x01) \parallel \dots

Module Methods

hkdfSync(digest, key, salt, info, keylen)

Synchronous HKDF derivation.

import QuickCrypto from 'react-native-quick-crypto';

// Combined Extract + Expand
const derived = QuickCrypto.hkdfSync(
  'sha256',       // Digest
  'ikm-secret',   // Input Key Material
  'salt',         // Salt
  'context-info', // Context Info
  64              // Output length
);

hkdf(digest, key, salt, info, keylen, callback)

Prop

Type

On this page