From b9e9ab89f70ffab49b89187ee6a453cbbbf557de Mon Sep 17 00:00:00 2001 From: Mega-Mewthree Date: Sat, 11 Aug 2018 18:24:55 -0700 Subject: [PATCH 1/2] Rename variables to better describe what they represent. --- client/src/builtin/E2EE.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/client/src/builtin/E2EE.js b/client/src/builtin/E2EE.js index 0683f392..4f6c73fb 100644 --- a/client/src/builtin/E2EE.js +++ b/client/src/builtin/E2EE.js @@ -191,19 +191,19 @@ export default new class E2EE extends BuiltinModule { return this._ecdh; } - createKeyExchange(userID) { - this.ecdh[userID] = crypto.createECDH('secp521r1'); - return this.ecdh[userID].generateKeys('base64'); + createKeyExchange(dmChannelID) { + this.ecdh[dmChannelID] = crypto.createECDH('secp521r1'); + return this.ecdh[dmChannelID].generateKeys('base64'); } - publicKeyFor(userID) { - return this.ecdh[userID].getPublicKey('base64'); + publicKeyFor(dmChannelID) { + return this.ecdh[dmChannelID].getPublicKey('base64'); } - computeSecret(userID, otherKey) { + computeSecret(dmChannelID, otherKey) { try { - const secret = this.ecdh[userID].computeSecret(otherKey, 'base64', 'base64'); - delete this.ecdh[userID]; + const secret = this.ecdh[dmChannelID].computeSecret(otherKey, 'base64', 'base64'); + delete this.ecdh[dmChannelID]; const hash = crypto.createHash('sha256'); hash.update(secret); return hash.digest('base64'); From c421be9e918f1f18399503a66ecc9161c6077719 Mon Sep 17 00:00:00 2001 From: Mega-Mewthree Date: Sat, 11 Aug 2018 18:28:18 -0700 Subject: [PATCH 2/2] Fix merge --- client/src/builtin/E2EE.js | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/client/src/builtin/E2EE.js b/client/src/builtin/E2EE.js index dcced961..4f6c73fb 100644 --- a/client/src/builtin/E2EE.js +++ b/client/src/builtin/E2EE.js @@ -190,29 +190,6 @@ export default new class E2EE extends BuiltinModule { if (!this._ecdh) this._ecdh = {}; return this._ecdh; } - - get ecdh() { - if (!this._ecdh) this._ecdh = {}; - return this._ecdh; - } - - createKeyExchange(userID) { - this.ecdh[userID] = crypto.createECDH('secp521r1'); - return this.ecdh[userID].generateKeys('base64'); - } - - publicKeyFor(userID) { - return this.ecdh[userID].getPublicKey('base64'); - } - - computeSecret(userID, otherKey) { - const secret = this.ecdh[userID].computeSecret(otherKey, 'base64', 'base64'); - delete this.ecdh[userID]; - // Hashing the shared secret future-proofs against some possible attacks. - const hash = crypto.createHash('sha256'); - hash.update(secret); - return hash.digest('base64'); - } createKeyExchange(dmChannelID) { this.ecdh[dmChannelID] = crypto.createECDH('secp521r1');