From cae68947dfad7f9ce091572c5b7b510c50fa565f Mon Sep 17 00:00:00 2001 From: Jiiks Date: Sun, 12 Aug 2018 21:46:59 +0300 Subject: [PATCH] add bad key handler --- client/src/builtin/E2EE.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/src/builtin/E2EE.js b/client/src/builtin/E2EE.js index 55ba056f..d7fbb7dc 100644 --- a/client/src/builtin/E2EE.js +++ b/client/src/builtin/E2EE.js @@ -135,6 +135,11 @@ export default new class E2EE extends BuiltinModule { const cached = Cache.find('e2ee:images', item => item.src === src); if (cached) { + if (cached.invalidKey) { + component.props.className = 'bd-encryptedImageBadKey'; + component.props.readyState = 'READY'; + return; + } Logger.info('E2EE', 'Returning encrypted image from cache'); try { const decrypt = this.decrypt(this.decrypt(this.decrypt(seed, this.master), haveKey), cached.image); @@ -159,6 +164,7 @@ export default new class E2EE extends BuiltinModule { const data = image.slice(0, -64); const validateHmac = await this.createHmac(data); if (hmac !== validateHmac) { + Cache.push('e2ee:images', { src, invalidKey: true }); console.log('INVALID HMAC!'); return; }