js-libp2p-crypto/test/hmac.spec.js
Friedel Ziegelmayer 08c5df5e79 feat: use webcrypto in favor of node-forge
BREAKING CHANGE: generateKeyPair is now async
2016-11-01 12:47:58 +01:00

25 lines
608 B
JavaScript

/* eslint max-nested-callbacks: ["error", 8] */
/* eslint-env mocha */
'use strict'
const expect = require('chai').expect
const crypto = require('../src')
const hashes = ['SHA1', 'SHA256', 'SHA512']
describe('HMAC', () => {
hashes.forEach((hash) => {
it(`${hash} - sign and verify`, (done) => {
crypto.hmac.create(hash, new Buffer('secret'), (err, hmac) => {
expect(err).to.not.exist
hmac.digest(new Buffer('hello world'), (err, sig) => {
expect(err).to.not.exist
expect(sig).to.have.length(hmac.length)
done()
})
})
})
})
})