Skip to content

TICESoftware/hkdf.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HKDF

HMAC-based Extract-and-Expand Key Derivation Function (HKDF) as defined in RFC 5869. The HMAC is provided by libsodium which uses the HMAC-SHA-512/256 algorithm.

Installation

$ npm i --save sodium-hkdf
or
$ yarn add sodium-hkdf

Usage

For deriving a new key of length 32 bytes from some input keying material ikm:

const hkdfKey = deriveHKDFKey(ikm, 32);

A salt and some application specific info string (which is hashed into the HMAC) can additionally be provided:

const salt = new Uint8Array(32).fill(0);
const hkdfKey = deriveHKDFKey(input, 32, salt, "info");