aboutsummaryrefslogtreecommitdiff
path: root/zencore/include
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2022-02-02 19:08:10 +0100
committerPer Larsson <[email protected]>2022-02-02 19:08:10 +0100
commit10ab6d8c768b54dfcd085ec94aa959dc9d1103ce (patch)
treec48a96d8a1ea8d4267906af76e72e1e95f70fc78 /zencore/include
parentChanged OIDC token endpoint. (diff)
parentMerge branch 'main' of https://github.com/EpicGames/zen (diff)
downloadzen-10ab6d8c768b54dfcd085ec94aa959dc9d1103ce.tar.xz
zen-10ab6d8c768b54dfcd085ec94aa959dc9d1103ce.zip
Merged main.
Diffstat (limited to 'zencore/include')
-rw-r--r--zencore/include/zencore/crypto.h50
-rw-r--r--zencore/include/zencore/refcount.h7
-rw-r--r--zencore/include/zencore/trace.h1
-rw-r--r--zencore/include/zencore/zencore.h15
4 files changed, 62 insertions, 11 deletions
diff --git a/zencore/include/zencore/crypto.h b/zencore/include/zencore/crypto.h
new file mode 100644
index 000000000..4d6ddba47
--- /dev/null
+++ b/zencore/include/zencore/crypto.h
@@ -0,0 +1,50 @@
+
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#pragma once
+
+#include <zencore/memory.h>
+#include <zencore/zencore.h>
+
+#include <memory>
+
+namespace zen {
+
+/**
+ * Experimental interface for a symmetric encryption/decryption algorithm.
+ * Currenlty only AES 256 bit CBC is supported using OpenSSL.
+ */
+class SymmetricCipher
+{
+public:
+ virtual ~SymmetricCipher() = default;
+
+ virtual bool Initialize(MemoryView Key, MemoryView InitVector) = 0;
+
+ struct CipherSettings
+ {
+ size_t KeySize = 0;
+ size_t InitVectorSize = 0;
+ size_t BlockSize = 0;
+ };
+
+ virtual CipherSettings Settings() = 0;
+
+ virtual MemoryView Encrypt(MemoryView Data, MutableMemoryView EncryptionBuffer) = 0;
+
+ virtual MemoryView Decrypt(MemoryView Data, MutableMemoryView DecryptionBuffer) = 0;
+};
+
+std::unique_ptr<SymmetricCipher> MakeNullCipher();
+
+#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
+
+void crypto_forcelink();
+
+} // namespace zen
diff --git a/zencore/include/zencore/refcount.h b/zencore/include/zencore/refcount.h
index 254a22db5..7befbb338 100644
--- a/zencore/include/zencore/refcount.h
+++ b/zencore/include/zencore/refcount.h
@@ -114,7 +114,7 @@ public:
private:
T* m_Ref = nullptr;
- template <typename U>
+ template<typename U>
friend class RefPtr;
};
@@ -135,8 +135,9 @@ public:
inline ~Ref() { m_Ref && m_Ref->Release(); }
template<typename DerivedType>
- requires DerivedFrom<DerivedType, T>
- inline Ref(const Ref<DerivedType>& Rhs) : Ref(Rhs.m_Ref) {}
+ requires DerivedFrom<DerivedType, T> inline Ref(const Ref<DerivedType>& Rhs) : Ref(Rhs.m_Ref)
+ {
+ }
[[nodiscard]] inline bool IsNull() const { return m_Ref == nullptr; }
inline explicit operator bool() const { return m_Ref != nullptr; }
diff --git a/zencore/include/zencore/trace.h b/zencore/include/zencore/trace.h
index f28fdeeaf..0af490f23 100644
--- a/zencore/include/zencore/trace.h
+++ b/zencore/include/zencore/trace.h
@@ -22,6 +22,7 @@ enum class TraceType
{
File,
Network,
+ None
};
void TraceInit(const char* HostOrPath, TraceType Type);
diff --git a/zencore/include/zencore/zencore.h b/zencore/include/zencore/zencore.h
index 023b237cd..bd5e5a531 100644
--- a/zencore/include/zencore/zencore.h
+++ b/zencore/include/zencore/zencore.h
@@ -153,7 +153,7 @@ concept DerivedFrom = std::derived_from<D, B>;
template<class T>
concept Integral = std::is_integral_v<T>;
template<class T>
-concept SignedIntegral = Integral<T> && std::is_signed_v<T>;
+concept SignedIntegral = Integral<T>&& std::is_signed_v<T>;
template<class T>
concept UnsignedIntegral = Integral<T> && !std::is_signed_v<T>;
template<class F, class... A>
@@ -162,7 +162,7 @@ concept Invocable = requires(F&& f, A&&... a)
std::invoke(std::forward<F>(f), std::forward<A>(a)...);
};
template<class D, class B>
-concept DerivedFrom = std::is_base_of_v<B, D> && std::is_convertible_v<const volatile D*, const volatile B*>;
+concept DerivedFrom = std::is_base_of_v<B, D>&& std::is_convertible_v<const volatile D*, const volatile B*>;
#endif
#if defined(__cpp_lib_ranges)
@@ -239,13 +239,12 @@ static_assert(sizeof(wchar_t) == 2, "wchar_t is expected to be two bytes in size
# define ZEN_DEBUG_SECTION ZEN_CODE_SECTION(".zcold")
#endif
-namespace zen
+namespace zen {
+class AssertException : public std::logic_error
{
- class AssertException : public std::logic_error
- {
- public:
- AssertException(const char* Msg) : std::logic_error(Msg) {}
- };
+public:
+ AssertException(const char* Msg) : std::logic_error(Msg) {}
+};
} // namespace zen