Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit eebc753

Browse files
committed
Megolm export: Increase to 500000 PBKDF rounds
This takes 370ms on my machine (100000 only took 100ms).
1 parent a0e4afc commit eebc753

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/utils/MegolmExportEncryption.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function decryptMegolmKeyFile(data, password) {
102102
*/
103103
export function encryptMegolmKeyFile(data, password, options) {
104104
options = options || {};
105-
const kdf_rounds = options.kdf_rounds || 100000;
105+
const kdf_rounds = options.kdf_rounds || 500000;
106106

107107
const salt = new Uint8Array(16);
108108
window.crypto.getRandomValues(salt);
@@ -164,6 +164,7 @@ export function encryptMegolmKeyFile(data, password, options) {
164164
* @return {Promise<[CryptoKey, CryptoKey]>} promise for [aes key, hmac key]
165165
*/
166166
function deriveKeys(salt, iterations, password) {
167+
const start = new Date();
167168
return subtleCrypto.importKey(
168169
'raw',
169170
new TextEncoder().encode(password),
@@ -182,6 +183,9 @@ function deriveKeys(salt, iterations, password) {
182183
512
183184
);
184185
}).then((keybits) => {
186+
const now = new Date();
187+
console.log("E2e import/export: deriveKeys took " + (now - start) + "ms");
188+
185189
const aes_key = keybits.slice(0, 32);
186190
const hmac_key = keybits.slice(32);
187191

0 commit comments

Comments
 (0)