1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-30 02:21:17 +03:00

Megolm export: Clear bit 63 of the salt

This commit is contained in:
Richard van der Hoff
2017-01-19 10:43:41 +00:00
parent 31df78f946
commit 8b60cb9df0

View File

@ -106,6 +106,12 @@ export function encryptMegolmKeyFile(data, password, options) {
const salt = new Uint8Array(16);
window.crypto.getRandomValues(salt);
// clear bit 63 of the salt to stop us hitting the 64-bit counter boundary
// (which would mean we wouldn't be able to decrypt on Android). The loss
// of a single bit of salt is a price we have to pay.
salt[9] &= 0x7f;
const iv = new Uint8Array(16);
window.crypto.getRandomValues(iv);