Merge branch 'fix/sym-password-incorrect' into 'master'
Don't loop forever when passed an incorrect password See merge request ProtonMail/go-pm-crypto!19
This commit is contained in:
commit
e03fe86077
1 changed files with 6 additions and 1 deletions
|
|
@ -230,9 +230,14 @@ func (pm *PmCrypto) DecryptMessageWithPassword(encrypted string, password string
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
firstTimeCalled := true
|
||||||
var prompt = func(keys []openpgp.Key, symmetric bool) ([]byte, error) {
|
var prompt = func(keys []openpgp.Key, symmetric bool) ([]byte, error) {
|
||||||
|
if firstTimeCalled {
|
||||||
|
firstTimeCalled = false
|
||||||
return []byte(password), nil
|
return []byte(password), nil
|
||||||
}
|
}
|
||||||
|
return nil, errors.New("password incorrect")
|
||||||
|
}
|
||||||
|
|
||||||
config := &packet.Config{Time: pm.getTimeGenerator()}
|
config := &packet.Config{Time: pm.getTimeGenerator()}
|
||||||
md, err := openpgp.ReadMessage(encryptedio.Body, nil, prompt, config)
|
md, err := openpgp.ReadMessage(encryptedio.Body, nil, prompt, config)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue