From eacd16bc30dd7265fc2b8b1ab46b78820a2f383f Mon Sep 17 00:00:00 2001 From: Jemma Poffinbarger Date: Fri, 29 May 2026 17:43:27 -0500 Subject: [PATCH] feat(config): add checks for Mii decryption key config --- init.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/init.go b/init.go index d8b7497..9d85e48 100644 --- a/init.go +++ b/init.go @@ -1,6 +1,7 @@ package main import ( + "crypto/md5" "crypto/rand" "encoding/hex" "fmt" @@ -71,5 +72,21 @@ func init() { "X-API-Key", globals.Config.AccountGRPCAPIKey, ) + if strings.TrimSpace(globals.Config.MiiDecryptKey) == "" { + globals.Logger.Warning("PN_FRIENDS_CONFIG_MII_DECRYPT_KEY environment variable not set. 3DS Mii data cannot be decrypted") + } + + miiKeyBytes, err := hex.DecodeString(globals.Config.MiiDecryptKey) + if err != nil { + globals.Logger.Criticalf("Failed to decode PN_FRIENDS_CONFIG_MII_DECRYPT_KEY %v", err) + os.Exit(0) + } + + miiMD5Hash := md5.Sum(miiKeyBytes) + if hex.EncodeToString(miiMD5Hash[:]) != "aeb707b225ec0fcd8a503e26e3dcd596" { + globals.Logger.Criticalf("PN_FRIENDS_CONFIG_MII_DECRYPT_KEY is incorrect! md5: %s", hex.EncodeToString(miiMD5Hash[:])) + os.Exit(0) + } + database.ConnectPostgres() }