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:
parent
b8a41425bd
commit
507aa3c61c
1 changed files with 13 additions and 5 deletions
|
@ -147,11 +147,19 @@ func getSSSS(mach *crypto.OlmMachine, recoveryPhrase string) (*ssss.Key, error)
|
|||
}
|
||||
}
|
||||
|
||||
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")
|
||||
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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue