Package Exports
- hmac-blake2b
- hmac-blake2b/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hmac-blake2b) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
hmac-blake2b
HMAC based on BLAKE2b
Even though BLAKE2b is designed to also work as a MAC, specifications like Noise call for a HMAC.
Usage
const { randombytes_buf } = require('sodium-universal/randombytes')
const hmac = require('.')
const mac = Buffer.alloc(hmac.BYTES)
const key = Buffer.alloc(hmac.KEYBYTES)
randombytes_buf(key)
const data = Buffer.from('some data')
hmac(mac, data, key)
API
hmac.BYTES
Size of the output MAC in bytes
hmac.KEYBYTES
RFC2104 recommended size of the key in bytes.
hmac(out, data, key)
Computes a HMAC from data with key and writes it into out.
outmust be aBufferorUint8Arrayof lengthhmac.BYTESdatamust be aBuffer,Uint8ArrayorArrayofBuffers orUint8Arrays.keymust be aBufferorUint8Array. Per the HMAC speckeycan be as small as 1 byte, in which case it is right-padded withNULbytes, or any size larger thanhmac.KEYBYTESin which case it is hashed down to fit. The recommended size by the spec ishmac.KEYBYTES
Install
npm install hmac-blake2b