Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[server][gen-random-key] Remove redundant dependency on libsodium

Neeraj Gupta0d7bba56935c
diff --git a/server/tools/gen-random-keys/main.go b/server/tools/gen-random-keys/main.go
index 1679789744..8a9baa61c0 100644
--- a/server/tools/gen-random-keys/main.go
+++ b/server/tools/gen-random-keys/main.go
@@ -3,31 +3,26 @@ package main
import (
"encoding/base64"
"fmt"
- "log"
-
"github.com/ente-io/museum/pkg/utils/auth"
-
- generichash "github.com/GoKillers/libsodium-go/cryptogenerichash"
- secretbox "github.com/GoKillers/libsodium-go/cryptosecretbox"
- "github.com/GoKillers/libsodium-go/sodium"
+ "log"
)
func main() {
- sodium.Init()
-
- keyBytes, err := auth.GenerateRandomBytes(secretbox.CryptoSecretBoxKeyBytes())
+ keyLen := 32
+ hashByteLen := 64
+ keyBytes, err := auth.GenerateRandomBytes(keyLen)
if err != nil {
log.Fatal(err)
}
key := base64.StdEncoding.EncodeToString(keyBytes)
- hashBytes, err := auth.GenerateRandomBytes(generichash.CryptoGenericHashBytesMax())
+ hashBytes, err := auth.GenerateRandomBytes(hashByteLen)
if err != nil {
log.Fatal(err)
}
hash := base64.StdEncoding.EncodeToString(hashBytes)
- jwtBytes, err := auth.GenerateRandomBytes(secretbox.CryptoSecretBoxKeyBytes())
+ jwtBytes, err := auth.GenerateRandomBytes(keyLen)
if err != nil {
log.Fatal(err)
}