diff --git a/lib/src/key_manager.dart b/lib/src/key_manager.dart index 6e9d710..5ac075d 100644 --- a/lib/src/key_manager.dart +++ b/lib/src/key_manager.dart @@ -63,7 +63,6 @@ class KeyManager { return; } - // TODO: check if pubkey is valid for (final roomEntries in payload['rooms'].entries) { final roomId = roomEntries.key; if (!(roomEntries.value is Map) || !(roomEntries.value['sessions'] is Map)) { diff --git a/lib/src/ssss.dart b/lib/src/ssss.dart index b639af9..5eca4a4 100644 --- a/lib/src/ssss.dart +++ b/lib/src/ssss.dart @@ -70,16 +70,15 @@ class SSSS { static String decryptAes(_Encrypted data, Uint8List key, String name) { final keys = deriveKeys(key, name); + final cipher = base64.decode(data.ciphertext); final hmac = base64 .encode(Hmac(sha256, keys.hmacKey) - .convert(base64.decode(data.ciphertext)) + .convert(cipher) .bytes) .replaceAll(RegExp(r'=+$'), ''); if (hmac != data.mac.replaceAll(RegExp(r'=+$'), '')) { throw 'Bad MAC'; } - // workaround for https://github.com/leocavalcante/encrypt/issues/136 - final cipher = base64.decode(data.ciphertext); final decipher = AES(Key(keys.aesKey), mode: AESMode.ctr, padding: null) .decrypt(Encrypted(cipher), iv: IV(base64.decode(data.iv))); return String.fromCharCodes(decipher);