Rename all occurrences of "passphrase" to "password"

This commit is contained in:
2025-10-26 12:28:07 -04:00
parent 235f6b5ed4
commit b9175d7ff3
6 changed files with 41 additions and 41 deletions
+7 -7
View File
@@ -14,8 +14,8 @@ import (
)
// LibmuttonInit creates the libmutton config structure based on user input.
// rcwPassphrase and clientSpecificIniData can be left blank if not needed.
func LibmuttonInit(inputCB func(prompt string) string, clientSpecificIniData [][3]string, rcwPassphrase []byte, preserveOldConfigDir bool) error {
// rcwPassword and clientSpecificIniData can be left blank if not needed.
func LibmuttonInit(inputCB func(prompt string) string, clientSpecificIniData [][3]string, rcwPassword []byte, preserveOldConfigDir bool) error {
r := strings.ToLower(inputCB("Configure SSH settings (for synchronization)? (Y/n)"))
if len(r) > 0 && r[0] == 'n' {
// initialize libmutton directories
@@ -35,7 +35,7 @@ func LibmuttonInit(inputCB func(prompt string) string, clientSpecificIniData [][
} else {
// ensure ssh key file exists (and is a file)
fallbackSSHKey := back.Home + global.PathSeparator + ".ssh" + global.PathSeparator + "id_ed25519"
sshKeyPath := cmp.Or(back.ExpandPathWithHome(inputCB(back.AnsiBold+"Note:"+back.AnsiReset+" Only key-based authentication is supported (keys may optionally be passphrase-protected).\n The remote server must already be in your ~"+global.PathSeparator+".ssh"+global.PathSeparator+"known_hosts file.\n\nSSH private identity file path (falls back to \""+fallbackSSHKey+"\"):")), fallbackSSHKey)
sshKeyPath := cmp.Or(back.ExpandPathWithHome(inputCB(back.AnsiBold+"Note:"+back.AnsiReset+" Only key-based authentication is supported (keys may optionally be password-protected).\n The remote server must already be in your ~"+global.PathSeparator+".ssh"+global.PathSeparator+"known_hosts file.\n\nSSH private identity file path (falls back to \""+fallbackSSHKey+"\"):")), fallbackSSHKey)
_, err := back.TargetIsFile(sshKeyPath, true)
if err != nil {
return errors.New("unable to find SSH identity file: " + err.Error())
@@ -84,8 +84,8 @@ func LibmuttonInit(inputCB func(prompt string) string, clientSpecificIniData [][
}
}
// generate rcw sanity check file (if requested)
if len(rcwPassphrase) > 0 {
err := RCWSanityCheckGen(rcwPassphrase)
if len(rcwPassword) > 0 {
err := RCWSanityCheckGen(rcwPassword)
if err != nil {
return err
}
@@ -94,8 +94,8 @@ func LibmuttonInit(inputCB func(prompt string) string, clientSpecificIniData [][
}
// RCWSanityCheckGen generates the RCW sanity check file for libmutton.
func RCWSanityCheckGen(passphrase []byte) error {
err := wrappers.GenSanityCheck(global.ConfigDir+global.PathSeparator+"sanity.rcw", passphrase)
func RCWSanityCheckGen(password []byte) error {
err := wrappers.GenSanityCheck(global.ConfigDir+global.PathSeparator+"sanity.rcw", password)
if err != nil {
return errors.New("unable to generate sanity check file: " + err.Error())
}
+7 -7
View File
@@ -21,14 +21,14 @@ func WriteEntry(targetLocation string, decBytes []byte) error {
return nil
}
// EntryRefresh re-encrypts all libmutton entries with a new passphrase
// EntryRefresh re-encrypts all libmutton entries with a new password
// and optimizes each entry to ensure they are as slim as possible.
// This includes stripping trailing whitespace/newlines/carriage returns
// from each field and running each note through ClampTrailingWhitespace
// to ensure each note line is optimized as possible without breaking
// Markdown formatting.
// Be sure to verify passphrases before using as input for this function!!
func EntryRefresh(oldRCWPassphrase, newRCWPassphrase []byte, removeOldDir bool) error {
// Be sure to verify passwords before using as input for this function!!
func EntryRefresh(oldRCWPassword, newRCWPassword []byte, removeOldDir bool) error {
// ensure global.EntryRoot+"-new" and global.EntryRoot-"old" do not exist
dirEnds := []string{"-new", "-old"}
for i, dirEnd := range dirEnds {
@@ -63,7 +63,7 @@ func EntryRefresh(oldRCWPassphrase, newRCWPassphrase []byte, removeOldDir bool)
if err != nil {
return errors.New("unable to open \"" + targetLocation + "\" for decryption: " + err.Error())
}
decBytes, err := wrappers.Decrypt(encBytes, oldRCWPassphrase)
decBytes, err := wrappers.Decrypt(encBytes, oldRCWPassword)
decryptedEntry := strings.Split(string(decBytes), "\n")
if err != nil {
return err
@@ -91,8 +91,8 @@ func EntryRefresh(oldRCWPassphrase, newRCWPassphrase []byte, removeOldDir bool)
decryptedEntry = append(fieldsMain, fieldsNote...)
}
// re-encrypt the entry with the new passphrase
encBytes = wrappers.Encrypt([]byte(strings.Join(decryptedEntry, "\n")), newRCWPassphrase)
// re-encrypt the entry with the new password
encBytes = wrappers.Encrypt([]byte(strings.Join(decryptedEntry, "\n")), newRCWPassword)
// write the entry to the new directory
err = os.WriteFile(global.EntryRoot+"-new"+strings.ReplaceAll(entryName, "/", global.PathSeparator), encBytes, 0600)
@@ -101,7 +101,7 @@ func EntryRefresh(oldRCWPassphrase, newRCWPassphrase []byte, removeOldDir bool)
}
// generate new sanity check file
err = RCWSanityCheckGen(newRCWPassphrase)
err = RCWSanityCheckGen(newRCWPassword)
if err != nil {
return err
}