hkdf_sm3
v1.0.1
Published
The HDKF (HMAC-based Key Derivation Function) implemented with SM3.
Downloads
1
Readme
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 | integer | 32 | Required byte length of output |