aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2022-02-03 16:05:34 +0100
committerPer Larsson <[email protected]>2022-02-03 16:05:34 +0100
commit18cc57792422a56bddc5797ceaa80dfe57e009b2 (patch)
tree697c01ba75337e251a8e17bb5241fb81f99b85da
parentMinor cleanup of free functions. (diff)
downloadzen-18cc57792422a56bddc5797ceaa80dfe57e009b2.tar.xz
zen-18cc57792422a56bddc5797ceaa80dfe57e009b2.zip
Enable encryption on all platforms.
-rw-r--r--zencore/crypto.cpp16
-rw-r--r--zencore/include/zencore/crypto.h12
-rw-r--r--zenserver/auth/authmgr.cpp4
3 files changed, 12 insertions, 20 deletions
diff --git a/zencore/crypto.cpp b/zencore/crypto.cpp
index 7fc524bf1..91315aa9a 100644
--- a/zencore/crypto.cpp
+++ b/zencore/crypto.cpp
@@ -18,11 +18,12 @@
namespace zen {
-class NullCipher final : public SymmetricCipher
+class NoOpSymmetricCipher final : public SymmetricCipher
{
public:
- NullCipher() = default;
- virtual ~NullCipher() = default;
+ NoOpSymmetricCipher() = default;
+
+ virtual ~NoOpSymmetricCipher() = default;
virtual bool Initialize(MemoryView, MemoryView) override final { return true; }
@@ -34,12 +35,11 @@ public:
};
std::unique_ptr<SymmetricCipher>
-MakeNullCipher()
+SymmetricCipher::CreateNoOp()
{
- return std::make_unique<NullCipher>();
+ return std::make_unique<NoOpSymmetricCipher>();
}
-#if ZEN_PLATFORM_WINDOWS
class Aes final : public SymmetricCipher
{
public:
@@ -184,13 +184,11 @@ private:
};
std::unique_ptr<SymmetricCipher>
-MakeAesCipher()
+SymmetricCipher::CreateAes()
{
return std::make_unique<Aes>();
}
-#endif // ZEN_PLATFORM_WINDOWS
-
#if ZEN_WITH_TESTS
using namespace std::literals;
diff --git a/zencore/include/zencore/crypto.h b/zencore/include/zencore/crypto.h
index 4d6ddba47..44783cdeb 100644
--- a/zencore/include/zencore/crypto.h
+++ b/zencore/include/zencore/crypto.h
@@ -33,17 +33,11 @@ public:
virtual MemoryView Encrypt(MemoryView Data, MutableMemoryView EncryptionBuffer) = 0;
virtual MemoryView Decrypt(MemoryView Data, MutableMemoryView DecryptionBuffer) = 0;
-};
-std::unique_ptr<SymmetricCipher> MakeNullCipher();
+ static std::unique_ptr<SymmetricCipher> CreateNoOp();
-#if ZEN_PLATFORM_WINDOWS
-/**
- * Create a new instance of a 256 bit AES CBC symmetric cipher.
- * NOTE: Currenlty only tested on Windows
- */
-std::unique_ptr<SymmetricCipher> MakeAesCipher();
-#endif
+ static std::unique_ptr<SymmetricCipher> CreateAes();
+};
void crypto_forcelink();
diff --git a/zenserver/auth/authmgr.cpp b/zenserver/auth/authmgr.cpp
index 0b7d7b492..2c54386ee 100644
--- a/zenserver/auth/authmgr.cpp
+++ b/zenserver/auth/authmgr.cpp
@@ -39,7 +39,7 @@ namespace details {
return IoBuffer();
}
- std::unique_ptr<SymmetricCipher> Cipher = MakeAesCipher();
+ std::unique_ptr<SymmetricCipher> Cipher = SymmetricCipher::CreateAes();
if (Cipher->Initialize(EncryptionKey, IV) == false)
{
@@ -59,7 +59,7 @@ namespace details {
return 0;
}
- std::unique_ptr<SymmetricCipher> Cipher = MakeAesCipher();
+ std::unique_ptr<SymmetricCipher> Cipher = SymmetricCipher::CreateAes();
if (Cipher->Initialize(EncryptionKey, IV) == false)
{