From eebc7539f9bdeee7d11a693649ea559ea424a49e Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 2 Feb 2017 16:38:19 +0000 Subject: [PATCH] Megolm export: Increase to 500000 PBKDF rounds This takes 370ms on my machine (100000 only took 100ms). --- src/utils/MegolmExportEncryption.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/MegolmExportEncryption.js b/src/utils/MegolmExportEncryption.js index 27c6ede937..c98c467e1c 100644 --- a/src/utils/MegolmExportEncryption.js +++ b/src/utils/MegolmExportEncryption.js @@ -102,7 +102,7 @@ export function decryptMegolmKeyFile(data, password) { */ export function encryptMegolmKeyFile(data, password, options) { options = options || {}; - const kdf_rounds = options.kdf_rounds || 100000; + const kdf_rounds = options.kdf_rounds || 500000; const salt = new Uint8Array(16); window.crypto.getRandomValues(salt); @@ -164,6 +164,7 @@ export function encryptMegolmKeyFile(data, password, options) { * @return {Promise<[CryptoKey, CryptoKey]>} promise for [aes key, hmac key] */ function deriveKeys(salt, iterations, password) { + const start = new Date(); return subtleCrypto.importKey( 'raw', new TextEncoder().encode(password), @@ -182,6 +183,9 @@ function deriveKeys(salt, iterations, password) { 512 ); }).then((keybits) => { + const now = new Date(); + console.log("E2e import/export: deriveKeys took " + (now - start) + "ms"); + const aes_key = keybits.slice(0, 32); const hmac_key = keybits.slice(32);