From 050db499d18c61d90a68096027ac0d5aaa842f57 Mon Sep 17 00:00:00 2001 From: ishaan Date: Sun, 12 Jul 2026 16:41:00 +0530 Subject: add init/new/edit subcommands, config, mlock/cleared sensitive info --- internal/crypt/rawDecrypt.go | 2 ++ internal/crypt/rawEncrypt.go | 2 ++ 2 files changed, 4 insertions(+) (limited to 'internal/crypt') diff --git a/internal/crypt/rawDecrypt.go b/internal/crypt/rawDecrypt.go index b82f0fb..fe190a5 100644 --- a/internal/crypt/rawDecrypt.go +++ b/internal/crypt/rawDecrypt.go @@ -37,6 +37,8 @@ func DecryptRawBytes(inputBytes []byte, password []byte) ([]byte, error) { } key := argon2.IDKey(password, headers.Salt[:], 1, 2*1024*1024, 2, 32) + utils.TryMlock(key) + defer clear(key) aead, err := chacha20poly1305.New(key) if err != nil { return nil, fmt.Errorf("decrypt: failed to create cipher: %w", err) diff --git a/internal/crypt/rawEncrypt.go b/internal/crypt/rawEncrypt.go index 77803e0..f197650 100644 --- a/internal/crypt/rawEncrypt.go +++ b/internal/crypt/rawEncrypt.go @@ -23,6 +23,8 @@ func EncryptRawBytes(inputBytes []byte, password []byte) ([]byte, error) { headers := utils.FileHeaders{Salt: salt, Nonce: nonce} key := argon2.IDKey(password, headers.Salt[:], 1, 2*1024*1024, 2, 32) + utils.TryMlock(key) + defer clear(key) aead, err := chacha20poly1305.New(key) if err != nil { return nil, fmt.Errorf("encrypt: failed to create cipher: %w", err) -- cgit v1.3