add hkdf script
This commit is contained in:
parent
c6a1b64d49
commit
96622f8081
3 changed files with 21 additions and 2 deletions
18
bin/hkdf
Executable file
18
bin/hkdf
Executable file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const HKDF = require('node-hkdf-sync')
|
||||||
|
|
||||||
|
const label = process.argv[2]
|
||||||
|
const masterSeedHex = process.argv[3].trim()
|
||||||
|
|
||||||
|
if (process.argv.length !== 4) {
|
||||||
|
console.log('hdkf <label> <masterKey>')
|
||||||
|
console.log('masterKey should be in hex encoding.')
|
||||||
|
process.exit(3)
|
||||||
|
}
|
||||||
|
|
||||||
|
const masterSeed = new Buffer(masterSeedHex, 'hex')
|
||||||
|
const hkdf = new HKDF('sha256', 'lamassu-server-salt', masterSeed)
|
||||||
|
console.log(hkdf.derive(label, 32).toString('hex'))
|
||||||
|
|
@ -60,7 +60,7 @@ let alertFingerprint = null
|
||||||
let lastAlertTime = null
|
let lastAlertTime = null
|
||||||
|
|
||||||
exports.init = function init (connectionString) {
|
exports.init = function init (connectionString) {
|
||||||
const masterSeed = fs.readFileSync('seeds/seed.txt', 'utf8').trim()
|
const masterSeed = new Buffer(fs.readFileSync('seeds/seed.txt', 'utf8').trim(), 'hex')
|
||||||
hkdf = new HKDF('sha256', 'lamassu-server-salt', masterSeed)
|
hkdf = new HKDF('sha256', 'lamassu-server-salt', masterSeed)
|
||||||
|
|
||||||
db.init(connectionString)
|
db.init(connectionString)
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,8 @@
|
||||||
"bin": {
|
"bin": {
|
||||||
"lamassu-server": "./bin/lamassu-server",
|
"lamassu-server": "./bin/lamassu-server",
|
||||||
"ssu-raqia": "./bin/ssu-raqia",
|
"ssu-raqia": "./bin/ssu-raqia",
|
||||||
"ssu": "./bin/ssu"
|
"ssu": "./bin/ssu",
|
||||||
|
"hkdf": "./bin/hkdf"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha --recursive test"
|
"test": "mocha --recursive test"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue