diff options
author | Marvin Borner | 2019-01-28 20:51:39 +0100 |
---|---|---|
committer | Marvin Borner | 2019-01-28 20:51:39 +0100 |
commit | c0c579100e36d999559a7e34d25e4f45addc4830 (patch) | |
tree | f87e548f2602e15b9980d9591a9100992610cf51 | |
parent | 4b9d36039734a1b23d960ba215190860855b0141 (diff) |
Improved encryption security
-rw-r--r-- | public/scripts/encryption.js | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/public/scripts/encryption.js b/public/scripts/encryption.js index d1d4038..edbf11d 100644 --- a/public/scripts/encryption.js +++ b/public/scripts/encryption.js @@ -9,6 +9,9 @@ const Dexie = require('dexie'); const moment = require('moment'); const openpgp = require('openpgp'); +// compress encryption data +openpgp.config.compression = openpgp.enums.compression.zlib; + let db; /** @@ -42,14 +45,13 @@ function setupDatabase() { async function generateKeys(peerId, passphrase) { const options = { userIds: [{name: peerId}], - numBits: 4096, + curve: 'ed25519', passphrase: passphrase }; await openpgp.generateKey(options).then(async (key) => { await db.own_keys.put({key_type: 'private_key', key_data: key.privateKeyArmored}); - await db.own_keys.put({key_type: 'public_key', key_data: key.publicKeyArmored}); - await db.own_keys.put({key_type: 'revocation_certificate', key_data: key.revocationCertificate}).then(() => + await db.own_keys.put({key_type: 'public_key', key_data: key.publicKeyArmored}).then(() => console.log('[LOG] Successfully generated and stored keys!') ); }); @@ -74,15 +76,6 @@ async function getPublicKey() { } /** - * Gets the peers revocation certificate - * @returns {Promise<String>} - */ -async function getRevocationCertificate() { - return await db.own_keys.where('key_type').equals('public_key').limit(1).toArray() - .then(res => res.length > 0 ? res[0]['key_data'] : ''); -} - -/** * /** * Encrypts the data with a public key (e.g the one of the peer with which you're chatting) * @param data @@ -143,8 +136,7 @@ async function isEncrypted() { if (exists) { const hasPrivateKey = await getPrivateKey().then(res => res !== ''); const hasPublicKey = await getPublicKey().then(res => res !== ''); - const hasRevocationCertificate = await getRevocationCertificate().then(res => res !== ''); - return (hasPrivateKey && hasPublicKey && hasRevocationCertificate); + return (hasPrivateKey && hasPublicKey); } else return false; }); |