mirror of
https://github.com/fluencelabs/js-libp2p-crypto
synced 2025-06-27 16:01:47 +00:00
first pass at stretchKey
This commit is contained in:
25
test/key-stretcher.spec.js
Normal file
25
test/key-stretcher.spec.js
Normal file
@ -0,0 +1,25 @@
|
||||
/* eslint-env mocha */
|
||||
'use strict'
|
||||
|
||||
const expect = require('chai').expect
|
||||
|
||||
const crypto = require('../src')
|
||||
|
||||
describe('keyStretcher', () => {
|
||||
describe('generate', () => {
|
||||
const ciphers = ['AES-128', 'AES-256', 'Blowfish']
|
||||
const hashes = ['SHA1', 'SHA256'/*, 'SHA512'*/]
|
||||
const res = crypto.generateEphemeralKeyPair('P-256')
|
||||
const secret = res.genSharedKey(res.key)
|
||||
|
||||
ciphers.forEach((cipher) => {
|
||||
hashes.forEach((hash) => {
|
||||
it(`${cipher} - ${hash}`, () => {
|
||||
const keys = crypto.keyStretcher(cipher, hash, secret)
|
||||
expect(keys.k1).to.exist
|
||||
expect(keys.k2).to.exist
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user