From 54e5f2149bdf70fcce3cda3b6799461380de1b5c Mon Sep 17 00:00:00 2001 From: Jiiks Date: Tue, 14 Aug 2018 11:02:29 +0300 Subject: [PATCH] Suite B --- client/src/builtin/E2EE.js | 3 ++- client/src/modules/security.js | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/client/src/builtin/E2EE.js b/client/src/builtin/E2EE.js index b47822b6..dae5b9f4 100644 --- a/client/src/builtin/E2EE.js +++ b/client/src/builtin/E2EE.js @@ -31,6 +31,7 @@ export default new class E2EE extends BuiltinModule { constructor() { super(); + window.nodecrypto = nodecrypto; this.encryptNewMessages = true; this.ecdhDate = START_DATE; } @@ -117,7 +118,7 @@ export default new class E2EE extends BuiltinModule { try { const secret = Security.computeECDHSecret(this.ecdhStorage[dmChannelID], otherKey); delete this.ecdhStorage[dmChannelID]; - return Security.sha256(secret); + return Security.hash('sha384', secret, 'hex'); } catch (e) { throw e; } diff --git a/client/src/modules/security.js b/client/src/modules/security.js index ab255027..c014c634 100644 --- a/client/src/modules/security.js +++ b/client/src/modules/security.js @@ -80,8 +80,14 @@ export default class Security { }); } - static createECDH() { - return nodecrypto.createECDH('secp521r1'); + static createECDH(curve = 'secp384r1') { + return nodecrypto.createECDH(curve); + } + + static hash(algorithm, data, encoding) { + const hash = nodecrypto.createHash(algorithm); + hash.update(data); + return hash.digest(encoding); } static sha256(text) {