Compare commits

...

2 Commits

Author SHA1 Message Date
Kgothatso
de7bd68872 Adding the cryptography stuff
This is probably the wrong way to use the cryptography.
2019-11-24 23:03:27 +02:00
Kgothatso
2bd61cf4c6 Bug fix... yargs argv.js thingy... 2019-11-24 22:58:27 +02:00
2 changed files with 17 additions and 15 deletions

View File

@ -18,9 +18,9 @@ module.exports.builder = (yargs) => {
module.exports.handler = (argv) => { module.exports.handler = (argv) => {
console.log("Add lock which we will use our keys on."); console.log("Add lock which we will use our keys on.");
console.log("Lock Definition: ", argv["lock-definition"]);
const lockDefintion = argv["lock-definition"].js || argv["lock-definition"];
const lockDefintion = argv["lock-definition"] || argv["lock-definition"].js;
const challenge = JSON.parse(lockDefintion); const challenge = JSON.parse(lockDefintion);
const registerationMessage = JSON.parse(challenge.message); const registerationMessage = JSON.parse(challenge.message);

View File

@ -1,26 +1,28 @@
const crypto = require('crypto'); const crypto = require('crypto');
const algorithm = 'aes-256-ctr'; const algorithm = 'aes-256-ecb';
const bip32 = require('bip32'); const bip32 = require('bip32');
// NOTE I'm not a cryptographer... so don't be reusing any code from below as I don't have no idea what I'm doing
const iv = null; // If I knew what I was doing I would have a value assigned here...
module.exports.encrypt = (plainText, password) => { module.exports.encrypt = (plainText, password) => {
// TODO encrypt text const key = crypto.createHash('sha256').update(password, 'utf8').digest();
// const cipher = crypto.createCipheriv(algorithm, password); const cipher = crypto.createCipheriv(algorithm, key, iv);
// var cipherText = cipher.update(plainText, 'utf8', 'hex'); var cipherText = cipher.update(plainText, 'utf8', 'hex');
// cipher += cipher.final('hex'); cipherText += cipher.final('hex');
return cipherText;
// console.log("CipherText: ", cipherText);
return plainText;
} }
module.exports.decrypt = (cipherText, password) => { module.exports.decrypt = (cipherText, password) => {
// TODO decrypt cipherText const key = crypto.createHash('sha256').update(password, 'utf8').digest();
// const decipher = crypto.createDecipheriv(algorithm, password) const decipher = crypto.createDecipheriv(algorithm, key, iv);
// var plainText = decipher.update(cipherText, 'hex', 'utf8'); var plainText = decipher.update(cipherText, 'hex', 'utf8');
// plainText += decipher.final('utf8'); plainText += decipher.final('utf8');
return cipherText; return plainText;
} }
module.exports.randomDerivationPath = function(hardenedDerivation) { module.exports.randomDerivationPath = function(hardenedDerivation) {