Skip to content

The HDKF (HMAC-based Key Derivation Function) implemented with SM3.

Notifications You must be signed in to change notification settings

prot3in/hkdf_sm3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

A JavaScript library about the HDKF (HMAC-based Key Derivation Function) implemented with SM3.

Install

npm install hkdf_sm3   ##use npm
yarn add hkdf_sm3      ##use yarn
pnpm install hkdf_sm3  ##use pnpm

Usage

//es6 module
import { HKDF } from "hdkf_sm3";
//or
import HKDF from "hdkf_sm3";

//commonjs
const { HKDF } = require("hkdf_sm3");

const ikm = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
const salt = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
const info = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
const length = 16;
HKDF(ikm, salt, info, length);
//Uint8Array(16) [235, 161, 114, 43, 215, 157, 61, 0, 30, 241, 88, 42,210, 63, 248, 218]

Params

function HKDF(key: Uint8Array, salt?: Uint8Array, info?: Uint8Array, length?: number): Uint8Array;

Param Type Default Description
ikm Uint8Array Initial Keying Material
salt Uint8Array Uint8Array(32) [0,...,0] Optional salt (recommended)
info Uint8Array Uint8Array(0) [] Optional context (safe to skip)
length intenger 32 Required byte length of output

About

The HDKF (HMAC-based Key Derivation Function) implemented with SM3.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published