diff --git a/lib/encryption/cross_signing.dart b/lib/encryption/cross_signing.dart index a163c510..c3e809b9 100644 --- a/lib/encryption/cross_signing.dart +++ b/lib/encryption/cross_signing.dart @@ -69,9 +69,9 @@ class CrossSigning { (await encryption.ssss.getCached(USER_SIGNING_KEY)) != null; } - Future selfSign({String password, String recoveryKey}) async { + Future selfSign({String passphrase, String recoveryKey}) async { final handle = encryption.ssss.open(MASTER_KEY); - await handle.unlock(password: password, recoveryKey: recoveryKey); + await handle.unlock(passphrase: passphrase, recoveryKey: recoveryKey); await handle.maybeCacheAll(); final masterPrivateKey = base64.decode(await handle.getStored(MASTER_KEY)); final keyObj = olm.PkSigning(); diff --git a/lib/encryption/ssss.dart b/lib/encryption/ssss.dart index 43da3ca4..6785f3dc 100644 --- a/lib/encryption/ssss.dart +++ b/lib/encryption/ssss.dart @@ -126,12 +126,12 @@ class SSSS { OLM_RECOVERY_KEY_PREFIX.length + OLM_PRIVATE_KEY_LENGTH)); } - static Uint8List keyFromPassword(String password, _PasswordInfo info) { + static Uint8List keyFromPassphrase(String passphrase, _PassphraseInfo info) { if (info.algorithm != 'm.pbkdf2') { throw 'Unknown algorithm'; } final generator = PBKDF2(hashAlgorithm: sha512); - return Uint8List.fromList(generator.generateKey(password, info.salt, + return Uint8List.fromList(generator.generateKey(passphrase, info.salt, info.iterations, info.bits != null ? info.bits / 8 : 32)); } @@ -428,13 +428,13 @@ class _DerivedKeys { _DerivedKeys({this.aesKey, this.hmacKey}); } -class _PasswordInfo { +class _PassphraseInfo { final String algorithm; final String salt; final int iterations; final int bits; - _PasswordInfo({this.algorithm, this.salt, this.iterations, this.bits}); + _PassphraseInfo({this.algorithm, this.salt, this.iterations, this.bits}); } class OpenSSSS { @@ -446,11 +446,11 @@ class OpenSSSS { bool get isUnlocked => privateKey != null; - void unlock({String password, String recoveryKey}) { - if (password != null) { - privateKey = SSSS.keyFromPassword( - password, - _PasswordInfo( + void unlock({String passphrase, String recoveryKey}) { + if (passphrase != null) { + privateKey = SSSS.keyFromPassphrase( + passphrase, + _PassphraseInfo( algorithm: keyData.content['passphrase']['algorithm'], salt: keyData.content['passphrase']['salt'], iterations: keyData.content['passphrase']['iterations'], diff --git a/lib/encryption/utils/key_verification.dart b/lib/encryption/utils/key_verification.dart index d21b6380..567d0b8b 100644 --- a/lib/encryption/utils/key_verification.dart +++ b/lib/encryption/utils/key_verification.dart @@ -314,7 +314,7 @@ class KeyVerification { } Future openSSSS( - {String password, String recoveryKey, bool skip = false}) async { + {String passphrase, String recoveryKey, bool skip = false}) async { final next = () { if (_nextAction == 'request') { sendStart(); @@ -331,7 +331,7 @@ class KeyVerification { return; } final handle = encryption.ssss.open('m.cross_signing.user_signing'); - await handle.unlock(password: password, recoveryKey: recoveryKey); + await handle.unlock(passphrase: passphrase, recoveryKey: recoveryKey); await handle.maybeCacheAll(); next(); }