29 lines
860 B
JavaScript
Raw Normal View History

2016-05-19 18:47:48 +02:00
'use strict'
exports.utils = require('./utils')
2016-05-19 20:18:31 +02:00
const keys = exports.keys = require('./keys')
2016-05-19 18:47:48 +02:00
// Generates a keypair of the given type and bitsize
2016-05-19 20:18:31 +02:00
exports.generateKeyPair = (type, bits, cb) => {
let key = keys[type.toLowerCase()]
if (!key) {
2016-05-19 18:47:48 +02:00
throw new Error('invalid or unsupported key type')
}
2016-05-19 20:18:31 +02:00
key.generateKeyPair(bits, cb)
2016-05-19 18:47:48 +02:00
}
// Generates an ephemeral public key and returns a function that will compute
// the shared secret key.
//
// Focuses only on ECDH now, but can be made more general in the future.
exports.generateEphemeralKeyPair = (curveName, cb) => {
throw new Error('Not implemented')
}
// Generates a set of keys for each party by stretching the shared key.
// (myIV, theirIV, myCipherKey, theirCipherKey, myMACKey, theirMACKey)
exports.keyStretcher = (cipherType, hashType, secret) => {
throw new Error('Not implemented')
}