Ind.ie is now Small Technology Foundation.
Commit 8ac844f2 authored by wim-vantomme's avatar wim-vantomme

Added encryptPrivateKey.

parent 7d471fa1
......@@ -6,6 +6,7 @@ class Keys {
this.publicKey
this.salt
this.password
this.encryptedPrivateKey
this.keySettings = {
keyLength: sodium.crypto_pwhash_BYTES_MIN,
opslimit: sodium.crypto_pwhash_OPSLIMIT_MODERATE,
......@@ -25,6 +26,10 @@ class Keys {
this.salt = sodium.randombytes_buf(this.keySettings.saltBytes)
this.password = sodium.crypto_pwhash(this.keySettings.keyLength, password, this.salt, this.keySettings.opslimit, this.keySettings.memlimit, this.keySettings.algorithm)
}
encryptPrivateKey () {
this.encryptedPrivateKey = sodium.crypto_pwhash(this.keySettings.keyLength, this.privateKey, this.password, this.keySettings.opslimit, this.keySettings.memlimit, this.keySettings.algorithm)
}
}
module.exports = Keys
......@@ -16,7 +16,7 @@ function loadedKeyPair () {
})
}
//loadedKeyPair()
// loadedKeyPair()
form.addEventListener('submit', (e) => {
e.preventDefault()
......@@ -24,18 +24,17 @@ form.addEventListener('submit', (e) => {
const keyPair = new Keys()
keyPair.generateKeys()
keyPair.encryptPassword(password)
const encryptedPrivateKey = sodium.crypto_pwhash(keyLength, keyPair.privateKey, encryptPassword, opslimit, memlimit, algorithm)
keyPair.encryptPrivateKey()
console.log(keyPair)
const postKeys = axios.post('register',
{
salt: salt,
salt: keyPair.salt,
publicKey: keyPair.publicKey,
privateKey: encryptedPrivateKey
privateKey: keyPair.encryptedPrivateKey
})
postKeys.then((values) => {
indexedDB.callOnStore('libsodium_testkeystore', 'keyStore', (store) => {
indexedDB.callOnStore('Indienet', 'keyStore', (store) => {
store.put({
id: 1,
keys: keyPair.privateKey
......
......@@ -7,6 +7,7 @@ class Keys {
this.publicKey
this.salt
this.password
this.encryptedPrivateKey
this.keySettings = {
keyLength: sodium.crypto_pwhash_BYTES_MIN,
opslimit: sodium.crypto_pwhash_OPSLIMIT_MODERATE,
......@@ -26,6 +27,10 @@ class Keys {
this.salt = sodium.randombytes_buf(this.keySettings.saltBytes)
this.password = sodium.crypto_pwhash(this.keySettings.keyLength, password, this.salt, this.keySettings.opslimit, this.keySettings.memlimit, this.keySettings.algorithm)
}
encryptPrivateKey () {
this.encryptedPrivateKey = sodium.crypto_pwhash(this.keySettings.keyLength, this.privateKey, this.password, this.keySettings.opslimit, this.keySettings.memlimit, this.keySettings.algorithm)
}
}
module.exports = Keys
......@@ -38,6 +38,7 @@ class Keys {
this.publicKey
this.salt
this.password
this.encryptedPrivateKey
this.keySettings = {
keyLength: sodium.crypto_pwhash_BYTES_MIN,
opslimit: sodium.crypto_pwhash_OPSLIMIT_MODERATE,
......@@ -57,6 +58,10 @@ class Keys {
this.salt = sodium.randombytes_buf(this.keySettings.saltBytes)
this.password = sodium.crypto_pwhash(this.keySettings.keyLength, password, this.salt, this.keySettings.opslimit, this.keySettings.memlimit, this.keySettings.algorithm)
}
encryptPrivateKey () {
this.encryptedPrivateKey = sodium.crypto_pwhash(this.keySettings.keyLength, this.privateKey, this.password, this.keySettings.opslimit, this.keySettings.memlimit, this.keySettings.algorithm)
}
}
module.exports = Keys
......@@ -80,7 +85,7 @@ function loadedKeyPair () {
})
}
//loadedKeyPair()
// loadedKeyPair()
form.addEventListener('submit', (e) => {
e.preventDefault()
......@@ -88,18 +93,17 @@ form.addEventListener('submit', (e) => {
const keyPair = new Keys()
keyPair.generateKeys()
keyPair.encryptPassword(password)
const encryptedPrivateKey = sodium.crypto_pwhash(keyLength, keyPair.privateKey, encryptPassword, opslimit, memlimit, algorithm)
keyPair.encryptPrivateKey()
console.log(keyPair)
const postKeys = axios.post('register',
{
salt: salt,
salt: keyPair.salt,
publicKey: keyPair.publicKey,
privateKey: encryptedPrivateKey
privateKey: keyPair.encryptedPrivateKey
})
postKeys.then((values) => {
indexedDB.callOnStore('libsodium_testkeystore', 'keyStore', (store) => {
indexedDB.callOnStore('Indienet', 'keyStore', (store) => {
store.put({
id: 1,
keys: keyPair.privateKey
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment