ssss password --> passphrase
This commit is contained in:
parent
115cd9e5b3
commit
d4eabbb756
|
@ -69,9 +69,9 @@ class CrossSigning {
|
||||||
(await encryption.ssss.getCached(USER_SIGNING_KEY)) != null;
|
(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);
|
final handle = encryption.ssss.open(MASTER_KEY);
|
||||||
await handle.unlock(password: password, recoveryKey: recoveryKey);
|
await handle.unlock(passphrase: passphrase, recoveryKey: recoveryKey);
|
||||||
await handle.maybeCacheAll();
|
await handle.maybeCacheAll();
|
||||||
final masterPrivateKey = base64.decode(await handle.getStored(MASTER_KEY));
|
final masterPrivateKey = base64.decode(await handle.getStored(MASTER_KEY));
|
||||||
final keyObj = olm.PkSigning();
|
final keyObj = olm.PkSigning();
|
||||||
|
|
|
@ -126,12 +126,12 @@ class SSSS {
|
||||||
OLM_RECOVERY_KEY_PREFIX.length + OLM_PRIVATE_KEY_LENGTH));
|
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') {
|
if (info.algorithm != 'm.pbkdf2') {
|
||||||
throw 'Unknown algorithm';
|
throw 'Unknown algorithm';
|
||||||
}
|
}
|
||||||
final generator = PBKDF2(hashAlgorithm: sha512);
|
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));
|
info.iterations, info.bits != null ? info.bits / 8 : 32));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,13 +428,13 @@ class _DerivedKeys {
|
||||||
_DerivedKeys({this.aesKey, this.hmacKey});
|
_DerivedKeys({this.aesKey, this.hmacKey});
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PasswordInfo {
|
class _PassphraseInfo {
|
||||||
final String algorithm;
|
final String algorithm;
|
||||||
final String salt;
|
final String salt;
|
||||||
final int iterations;
|
final int iterations;
|
||||||
final int bits;
|
final int bits;
|
||||||
|
|
||||||
_PasswordInfo({this.algorithm, this.salt, this.iterations, this.bits});
|
_PassphraseInfo({this.algorithm, this.salt, this.iterations, this.bits});
|
||||||
}
|
}
|
||||||
|
|
||||||
class OpenSSSS {
|
class OpenSSSS {
|
||||||
|
@ -446,11 +446,11 @@ class OpenSSSS {
|
||||||
|
|
||||||
bool get isUnlocked => privateKey != null;
|
bool get isUnlocked => privateKey != null;
|
||||||
|
|
||||||
void unlock({String password, String recoveryKey}) {
|
void unlock({String passphrase, String recoveryKey}) {
|
||||||
if (password != null) {
|
if (passphrase != null) {
|
||||||
privateKey = SSSS.keyFromPassword(
|
privateKey = SSSS.keyFromPassphrase(
|
||||||
password,
|
passphrase,
|
||||||
_PasswordInfo(
|
_PassphraseInfo(
|
||||||
algorithm: keyData.content['passphrase']['algorithm'],
|
algorithm: keyData.content['passphrase']['algorithm'],
|
||||||
salt: keyData.content['passphrase']['salt'],
|
salt: keyData.content['passphrase']['salt'],
|
||||||
iterations: keyData.content['passphrase']['iterations'],
|
iterations: keyData.content['passphrase']['iterations'],
|
||||||
|
|
|
@ -314,7 +314,7 @@ class KeyVerification {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> openSSSS(
|
Future<void> openSSSS(
|
||||||
{String password, String recoveryKey, bool skip = false}) async {
|
{String passphrase, String recoveryKey, bool skip = false}) async {
|
||||||
final next = () {
|
final next = () {
|
||||||
if (_nextAction == 'request') {
|
if (_nextAction == 'request') {
|
||||||
sendStart();
|
sendStart();
|
||||||
|
@ -331,7 +331,7 @@ class KeyVerification {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final handle = encryption.ssss.open('m.cross_signing.user_signing');
|
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();
|
await handle.maybeCacheAll();
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue