aboutsummaryrefslogtreecommitdiff
path: root/internal/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'internal/crypto')
-rw-r--r--internal/crypto/salt.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/internal/crypto/salt.go b/internal/crypto/salt.go
index 0718010..a3dbcc2 100644
--- a/internal/crypto/salt.go
+++ b/internal/crypto/salt.go
@@ -3,12 +3,15 @@ package crypto
import (
"crypto/rand"
"io"
+ "log/slog"
+ "os"
)
func NewSalt() [16]byte {
salt := [16]byte{}
if _, err := io.ReadFull(rand.Reader, salt[:]); err != nil {
- panic("crypto: failed to read salt: " + err.Error())
+ slog.Error("crypto: failed to read salt", "error", err)
+ os.Exit(1)
}
return salt
@@ -17,7 +20,8 @@ func NewSalt() [16]byte {
func NewNonce() [12]byte {
nonce := [12]byte{}
if _, err := io.ReadFull(rand.Reader, nonce[:]); err != nil {
- panic("crypto: failed to read nonce: " + err.Error())
+ slog.Error("crypto: failed to read nonce", "error", err)
+ os.Exit(1)
}
return nonce