mirror of https://github.com/vector-im/riot-web
Megolm export: fix Android incompatibility
I'd carefully added a workaround to maintain compatibility with the Android AES-CTR implementation... to the wrong thing.pull/21833/head
parent
9c99e78099
commit
62c8c20268
|
@ -107,14 +107,14 @@ export function encryptMegolmKeyFile(data, password, options) {
|
||||||
const salt = new Uint8Array(16);
|
const salt = new Uint8Array(16);
|
||||||
window.crypto.getRandomValues(salt);
|
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);
|
const iv = new Uint8Array(16);
|
||||||
window.crypto.getRandomValues(iv);
|
window.crypto.getRandomValues(iv);
|
||||||
|
|
||||||
|
// clear bit 63 of the IV 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 iv is a price we have to pay.
|
||||||
|
iv[9] &= 0x7f;
|
||||||
|
|
||||||
return deriveKeys(salt, kdf_rounds, password).then((keys) => {
|
return deriveKeys(salt, kdf_rounds, password).then((keys) => {
|
||||||
const [aes_key, hmac_key] = keys;
|
const [aes_key, hmac_key] = keys;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue