Skip to content

Commit

Permalink
Standardize around "Recovery Code" language
Browse files Browse the repository at this point in the history
  • Loading branch information
FIGBERT committed Aug 17, 2023
1 parent 8a1e095 commit 634a335
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions headless/headless.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
)

type Config struct {
OutputDir, MxPassword, Homeserver, KeyPath, KeyPassword, RecoveryPhrase string
MxID id.UserID
OutputDir, MxPassword, Homeserver, KeyPath, KeyPassword, RecoveryCode string
MxID id.UserID
}

func Init(conf Config, updates chan fmt.Stringer) error {
Expand Down Expand Up @@ -93,7 +93,7 @@ func Init(conf Config, updates chan fmt.Stringer) error {
updates <- syncFinished{}

// verify (fetch)
key, err := getSSSS(mach, conf.RecoveryPhrase)
key, err := getSSSS(mach, conf.RecoveryCode)
if err != nil {
return err
}
Expand Down Expand Up @@ -142,7 +142,7 @@ func initDirs() (string, string, string, string, error) {
return config, data, cache, download, nil
}

func getSSSS(mach *crypto.OlmMachine, recoveryPhrase string) (*ssss.Key, error) {
func getSSSS(mach *crypto.OlmMachine, recoveryCode string) (*ssss.Key, error) {
_, keyData, err := mach.SSSS.GetDefaultKeyData()
if err != nil {
if errors.Is(err, mautrix.MNotFound) {
Expand All @@ -154,12 +154,12 @@ func getSSSS(mach *crypto.OlmMachine, recoveryPhrase string) (*ssss.Key, error)

var key *ssss.Key
if keyData.Passphrase != nil && keyData.Passphrase.Algorithm == ssss.PassphraseAlgorithmPBKDF2 {
key, err = keyData.VerifyPassphrase(recoveryPhrase)
key, err = keyData.VerifyPassphrase(recoveryCode)
if errors.Is(err, ssss.ErrIncorrectSSSSKey) {
return nil, fmt.Errorf("Incorrect passphrase")
}
} else {
key, err = keyData.VerifyRecoveryKey(recoveryPhrase)
key, err = keyData.VerifyRecoveryKey(recoveryCode)
if errors.Is(err, ssss.ErrInvalidRecoveryKey) {
return nil, fmt.Errorf("Malformed recovery key")
} else if errors.Is(err, ssss.ErrIncorrectSSSSKey) {
Expand Down

0 comments on commit 634a335

Please sign in to comment.