ssss password --> passphrase

This commit is contained in:
Sorunome 2020-06-06 12:40:52 +02:00
parent 115cd9e5b3
commit d4eabbb756
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
3 changed files with 13 additions and 13 deletions

View File

@ -69,9 +69,9 @@ class CrossSigning {
(await encryption.ssss.getCached(USER_SIGNING_KEY)) != null;
}
Future<void> selfSign({String password, String recoveryKey}) async {
Future<void> 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();

View File

@ -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'],

View File

@ -314,7 +314,7 @@ class KeyVerification {
}
Future<void> 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();
}