func (o *onetimeSavedPassword) GenerateKey(params config.EncryptionParameters) ([]byte, []byte, bool) { if o.savedPassword != "" { ourPwd := o.savedPassword o.savedPassword = "" l, r := config.GenerateKeys(ourPwd, params) return l, r, true } return o.realF.GenerateKey(params) }
func (c *cliUI) getMasterPassword(params config.EncryptionParameters, previousFailed bool) ([]byte, []byte, bool) { password, err := c.term.ReadPassword("Master password for configuration file: ") if err != nil { c.alert(err.Error()) return nil, nil, false } l, r := config.GenerateKeys(password, params) return l, r, true }
func (u *gtkUI) getMasterPassword(params config.EncryptionParameters, lastAttemptFailed bool) ([]byte, []byte, bool) { dialogID := "MasterPassword" pwdResultChan := make(chan string) var cleanup func() doInUIThread(func() { builder := newBuilder(dialogID) dialogOb := builder.getObj(dialogID) dialog := dialogOb.(gtki.Dialog) cleanup = dialog.Destroy passObj := builder.getObj("password") password := passObj.(gtki.Entry) msgObj := builder.getObj("passMessage") messageObj := msgObj.(gtki.Label) messageObj.SetSelectable(true) if lastAttemptFailed { messageObj.SetLabel(i18n.Local("Incorrect password entered, please try again.")) } builder.ConnectSignals(map[string]interface{}{ "on_save_signal": func() { passText, _ := password.GetText() if len(passText) > 0 { messageObj.SetLabel(i18n.Local("Checking password...")) pwdResultChan <- passText close(pwdResultChan) } }, "on_cancel_signal": func() { close(pwdResultChan) u.quit() }, }) dialog.SetTransientFor(u.window) dialog.ShowAll() }) pwd, ok := <-pwdResultChan if !ok { doInUIThread(cleanup) return nil, nil, false } l, r := config.GenerateKeys(pwd, params) doInUIThread(cleanup) return l, r, true }