diff options
| author | Per Larsson <[email protected]> | 2022-01-31 14:11:19 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2022-01-31 14:11:19 +0100 |
| commit | 275185d7e3157aa55739ae985b80dc99a32588f8 (patch) | |
| tree | 3af731490fc13a480ad94045f2df170515f3db06 /zencore/include | |
| parent | Merge branch 'main' of https://github.com/EpicGames/zen (diff) | |
| download | zen-275185d7e3157aa55739ae985b80dc99a32588f8.tar.xz zen-275185d7e3157aa55739ae985b80dc99a32588f8.zip | |
Initial support for symmetric encryption/decryption using OpenSSL.
Diffstat (limited to 'zencore/include')
| -rw-r--r-- | zencore/include/zencore/crypto.h | 50 |
1 files changed, 50 insertions, 0 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 |