aboutsummaryrefslogtreecommitdiff
path: root/zenserver/config.cpp
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2022-02-07 15:46:51 +0100
committerPer Larsson <[email protected]>2022-02-07 15:46:51 +0100
commit4b3d9873def5e974fd47a5360a3eff4095aab88b (patch)
tree23196dba05475cbec6bb6141e08390fcd44d6961 /zenserver/config.cpp
parentReplaced crypto transform abstraction with a concrete API. (diff)
downloadzen-4b3d9873def5e974fd47a5360a3eff4095aab88b.tar.xz
zen-4b3d9873def5e974fd47a5360a3eff4095aab88b.zip
Refactored auth manager to use simplified encryption API.
Diffstat (limited to 'zenserver/config.cpp')
-rw-r--r--zenserver/config.cpp27
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)
{