Main password encrypted in memory

This commit is contained in:
ycc
2026-02-02 18:15:57 +01:00
parent bb56b8dd9c
commit 7cf212fc76
13 changed files with 145 additions and 110 deletions

View File

@@ -216,7 +216,10 @@ func (id *Identity) FinalizeInvitation(ReceivedContact *meowlib.ContactCard) err
// LoadIdentity loads an identity from an encrypted file
func LoadIdentity(filename string, password string) (*Identity, error) {
var id Identity
GetConfig().memoryPassword = password
err := GetConfig().SetMemPass(password)
if err != nil {
return nil, err
}
GetConfig().IdentityFile = filename
indata, err := os.ReadFile(filename)
if err != nil {
@@ -242,7 +245,11 @@ func (id *Identity) Save() error {
return errors.New("identity filename empty")
}
b, _ := json.Marshal(id)
armor, err := helper.EncryptMessageWithPassword([]byte(GetConfig().memoryPassword), string(b))
password, err := GetConfig().GetMemPass()
if err != nil {
return err
}
armor, err := helper.EncryptMessageWithPassword([]byte(password), string(b))
if err != nil {
return err
}