From d433b1af731ff901b9c14a647678471b27fdfe8a Mon Sep 17 00:00:00 2001 From: ishaan Date: Mon, 13 Jul 2026 11:09:34 +0530 Subject: better --- internal/crypt/rawEncrypt.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'internal/crypt/rawEncrypt.go') diff --git a/internal/crypt/rawEncrypt.go b/internal/crypt/rawEncrypt.go index f197650..135efdf 100644 --- a/internal/crypt/rawEncrypt.go +++ b/internal/crypt/rawEncrypt.go @@ -4,12 +4,11 @@ import ( "fmt" "strconv" - "gitlab.com/whiteboardguy/eno/internal/utils" "golang.org/x/crypto/argon2" "golang.org/x/crypto/chacha20poly1305" ) -func EncryptRawBytes(inputBytes []byte, password []byte) ([]byte, error) { +func EncryptRawBytes(inputBytes []byte, password []byte, authMode AuthMode) ([]byte, error) { salt, err := NewSalt() if err != nil { return nil, fmt.Errorf("encrypt: %w", err) @@ -20,10 +19,10 @@ func EncryptRawBytes(inputBytes []byte, password []byte) ([]byte, error) { return nil, fmt.Errorf("encrypt: %w", err) } - headers := utils.FileHeaders{Salt: salt, Nonce: nonce} + headers := FileHeaders{Salt: salt, Nonce: nonce, Type: File, Parts: 1, Auth: authMode} key := argon2.IDKey(password, headers.Salt[:], 1, 2*1024*1024, 2, 32) - utils.TryMlock(key) + TryMlock(key) defer clear(key) aead, err := chacha20poly1305.New(key) if err != nil { @@ -32,7 +31,7 @@ func EncryptRawBytes(inputBytes []byte, password []byte) ([]byte, error) { encrypted := aead.Seal(nil, headers.Nonce[:], inputBytes, nil) - headerBytes, err := utils.FileHeadersBytes(headers) + headerBytes, err := FileHeadersBytes(headers) if err != nil { return nil, fmt.Errorf("encrypt: %w", err) } -- cgit v1.3