aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorishaan <contact@ishaan.cc>2026-07-15 07:23:47 +0530
committerishaan <contact@ishaan.cc>2026-07-15 07:23:47 +0530
commit8ebc072fb0ceae229196e8d3d8ff15bbbc049fdd (patch)
tree922ae6355ec6806dc5366a55582038b7b90cf76d
parent4c64c1f923d2e1b8b5925b0d2d7f7fbd7b38e6a2 (diff)
better encrypted/decrypted file perms
-rw-r--r--cmd/eno/cobra.go8
-rw-r--r--cmd/eno/config.go4
-rw-r--r--internal/crud/cli_new.go8
-rw-r--r--internal/crypt/rawDecrypt.go2
-rw-r--r--internal/crypt/rawEncrypt.go2
5 files changed, 12 insertions, 12 deletions
diff --git a/cmd/eno/cobra.go b/cmd/eno/cobra.go
index 1a58681..4a7443e 100644
--- a/cmd/eno/cobra.go
+++ b/cmd/eno/cobra.go
@@ -74,7 +74,7 @@ var encryptCmd = &cobra.Command{
os.Exit(1)
}
- if err := os.WriteFile(output, encrypted, 0644); err != nil {
+ if err := os.WriteFile(output, encrypted, 0600); err != nil {
return fmt.Errorf("failed to write output file: %v", err)
}
@@ -95,7 +95,7 @@ var encryptCmd = &cobra.Command{
os.Exit(1)
}
- if err := os.WriteFile(output, encrypted, 0644); err != nil {
+ if err := os.WriteFile(output, encrypted, 0600); err != nil {
return fmt.Errorf("failed to write output file: %v", err)
}
@@ -149,7 +149,7 @@ var decryptCmd = &cobra.Command{
crypt.TryMlock(plaintext)
defer clear(plaintext)
- if err := os.WriteFile(output, plaintext, 0644); err != nil {
+ if err := os.WriteFile(output, plaintext, 0600); err != nil {
return fmt.Errorf("failed to write output file: %v", err)
}
@@ -172,7 +172,7 @@ var decryptCmd = &cobra.Command{
crypt.TryMlock(plaintext)
defer clear(plaintext)
- if err := os.WriteFile(output, plaintext, 0644); err != nil {
+ if err := os.WriteFile(output, plaintext, 0600); err != nil {
return fmt.Errorf("failed to write output file: %v", err)
}
diff --git a/cmd/eno/config.go b/cmd/eno/config.go
index 6725e84..90bdf1b 100644
--- a/cmd/eno/config.go
+++ b/cmd/eno/config.go
@@ -109,7 +109,7 @@ func handlerInit() error {
if err := os.MkdirAll(filepath.Dir(Conf.ConfPath), 0755); err != nil {
return fmt.Errorf("creating config dir: %w", err)
}
- f, err := os.Create(Conf.ConfPath)
+ f, err := os.OpenFile(Conf.ConfPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
return fmt.Errorf("creating config file: %w", err)
}
@@ -187,7 +187,7 @@ func updateConfig(key string, val any) error {
lines = append(lines, newLine)
}
- err = os.WriteFile(Conf.ConfPath, []byte(strings.Join(lines, "\n")), 0644)
+ err = os.WriteFile(Conf.ConfPath, []byte(strings.Join(lines, "\n")), 0600)
if err != nil {
return err
}
diff --git a/internal/crud/cli_new.go b/internal/crud/cli_new.go
index dfd32ad..a7408d7 100644
--- a/internal/crud/cli_new.go
+++ b/internal/crud/cli_new.go
@@ -42,7 +42,7 @@ func NewNotePass(output string) error {
}
fmt.Println(output)
- file, err := os.Create(output)
+ file, err := os.OpenFile(output, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
return err
}
@@ -90,7 +90,7 @@ func NewNotePassEdit(output, editorString string) error {
return err
}
- file, err := os.Create(output)
+ file, err := os.OpenFile(output, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
return err
}
@@ -244,7 +244,7 @@ func NewNoteSSH(output string, defaultPubKeyBytes []byte) error {
}
fmt.Println(output)
- file, err := os.Create(output)
+ file, err := os.OpenFile(output, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
return err
}
@@ -282,7 +282,7 @@ func NewNoteSSHEdit(output string, defaultPubKeyBytes []byte, defaultPrivKeyPath
crypt.TryMlock(noteKey)
defer clear(noteKey)
- file, err := os.Create(output)
+ file, err := os.OpenFile(output, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
return err
}
diff --git a/internal/crypt/rawDecrypt.go b/internal/crypt/rawDecrypt.go
index 6cfea1f..d1f0193 100644
--- a/internal/crypt/rawDecrypt.go
+++ b/internal/crypt/rawDecrypt.go
@@ -39,7 +39,7 @@ func DecryptBytesPass(inputBytes []byte, password []byte) ([]byte, error) {
return nil, fmt.Errorf("decrypt: expected password auth, got %s", headers.Auth)
}
- key := argon2.IDKey(password, headers.Salt[:], 1, 64*1024*1024, 2, 32)
+ key := argon2.IDKey(password, headers.Salt[:], 1, 2*1024*1024, 2, 32)
TryMlock(key)
defer clear(key)
aead, err := chacha20poly1305.New(key)
diff --git a/internal/crypt/rawEncrypt.go b/internal/crypt/rawEncrypt.go
index a138753..03f742f 100644
--- a/internal/crypt/rawEncrypt.go
+++ b/internal/crypt/rawEncrypt.go
@@ -22,7 +22,7 @@ func EncryptBytesPass(inputBytes []byte, password []byte) ([]byte, error) {
headers := FileHeaders{Salt: salt, Nonce: nonce, Type: File, Parts: 1, Auth: Pass, Recipients: []WrappedKey{}}
- key := argon2.IDKey(password, headers.Salt[:], 1, 64*1024*1024, 2, 32)
+ key := argon2.IDKey(password, headers.Salt[:], 1, 2*1024*1024, 2, 32)
TryMlock(key)
defer clear(key)
aead, err := chacha20poly1305.New(key)