diff options
Diffstat (limited to 'zenserver/config.cpp')
| -rw-r--r-- | zenserver/config.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/zenserver/config.cpp b/zenserver/config.cpp index 14908b615..cb6d5ea6d 100644 --- a/zenserver/config.cpp +++ b/zenserver/config.cpp @@ -4,6 +4,7 @@ #include "diag/logging.h" +#include <zencore/crypto.h> #include <zencore/fmtutils.h> #include <zencore/iobuffer.h> #include <zencore/string.h> @@ -59,6 +60,30 @@ PickDefaultStateDirectory() #endif +void +ValidateOptions(ZenServerOptions& ServerOptions) +{ + if (ServerOptions.EncryptionKey.empty() == false) + { + const auto Key = zen::AesKey256Bit::FromString(ServerOptions.EncryptionKey); + + if (Key.IsValid() == false) + { + throw cxxopts::OptionParseException("Invalid AES encryption key"); + } + } + + if (ServerOptions.EncryptionIV.empty() == false) + { + const auto IV = zen::AesIV128Bit::FromString(ServerOptions.EncryptionIV); + + if (IV.IsValid() == false) + { + throw cxxopts::OptionParseException("Invalid AES initialization vector"); + } + } +} + UpstreamCachePolicy ParseUpstreamCachePolicy(std::string_view Options) { @@ -365,6 +390,8 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) { ParseConfigFile(ServerOptions.DataDir / "zen_cfg.lua", ServerOptions); } + + ValidateOptions(ServerOptions); } catch (cxxopts::OptionParseException& e) { |