1
0
Fork 0
forked from Mirrors/gomuks

Use recovery code with all verification methods

The previous commit made one attempt at fixing an issue with verifying
keys, but was misguided: the issue at hand was not in attempting the
wrong method of authorization, but rather what was *passed* to the
method. Namely, the account password as opposed to the recovery phrase.
Regardless of terminology, the latter should be used. Certain code has
been restored, while the password parameter remains deleted.
This commit is contained in:
FIGBERT 2023-08-08 18:15:52 -07:00
parent b8a41425bd
commit 507aa3c61c
No known key found for this signature in database
GPG key ID: 67F1598D607A844B

View file

@ -147,12 +147,20 @@ func getSSSS(mach *crypto.OlmMachine, recoveryPhrase string) (*ssss.Key, error)
}
}
key, err := keyData.VerifyRecoveryKey(recoveryPhrase)
var key *ssss.Key
if keyData.Passphrase != nil && keyData.Passphrase.Algorithm == ssss.PassphraseAlgorithmPBKDF2 {
key, err = keyData.VerifyPassphrase(recoveryPhrase)
if errors.Is(err, ssss.ErrIncorrectSSSSKey) {
return nil, fmt.Errorf("Incorrect passphrase")
}
} else {
key, err = keyData.VerifyRecoveryKey(recoveryPhrase)
if errors.Is(err, ssss.ErrInvalidRecoveryKey) {
return nil, fmt.Errorf("Malformed recovery key")
} else if errors.Is(err, ssss.ErrIncorrectSSSSKey) {
return nil, fmt.Errorf("Incorrect recovery key")
}
}
// All the errors should already be handled above, this is just for backup
if err != nil {
return nil, fmt.Errorf("Failed to get SSSS key: %v", err)