diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-30 16:42:58 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-30 16:42:58 +0200 |
commit | f0d14229706eca615198c888bd8d3b95b663cfb4 (patch) | |
tree | dfcb7fb092091b69a80b3b362adf862f80ba1ba0 /src/mbedTLS++/AesCfb128Encryptor.cpp | |
parent | Initial zombies (diff) | |
parent | Merge pull request #3969 from peterbell10/cuboid (diff) | |
download | cuberite-f0d14229706eca615198c888bd8d3b95b663cfb4.tar cuberite-f0d14229706eca615198c888bd8d3b95b663cfb4.tar.gz cuberite-f0d14229706eca615198c888bd8d3b95b663cfb4.tar.bz2 cuberite-f0d14229706eca615198c888bd8d3b95b663cfb4.tar.lz cuberite-f0d14229706eca615198c888bd8d3b95b663cfb4.tar.xz cuberite-f0d14229706eca615198c888bd8d3b95b663cfb4.tar.zst cuberite-f0d14229706eca615198c888bd8d3b95b663cfb4.zip |
Diffstat (limited to 'src/mbedTLS++/AesCfb128Encryptor.cpp')
-rw-r--r-- | src/mbedTLS++/AesCfb128Encryptor.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/mbedTLS++/AesCfb128Encryptor.cpp b/src/mbedTLS++/AesCfb128Encryptor.cpp new file mode 100644 index 000000000..11582fc19 --- /dev/null +++ b/src/mbedTLS++/AesCfb128Encryptor.cpp @@ -0,0 +1,55 @@ + +// AesCfb128Encryptor.cpp + +// Implements the cAesCfb128Encryptor class encrypting data using AES CFB-128 + +#include "Globals.h" +#include "AesCfb128Encryptor.h" + + + + + +cAesCfb128Encryptor::cAesCfb128Encryptor(void): + m_IsValid(false) +{ + mbedtls_aes_init(&m_Aes); +} + + + + + +cAesCfb128Encryptor::~cAesCfb128Encryptor() +{ + // Clear the leftover in-memory data, so that they can't be accessed by a backdoor + mbedtls_aes_free(&m_Aes); +} + + + + + +void cAesCfb128Encryptor::Init(const Byte a_Key[16], const Byte a_IV[16]) +{ + ASSERT(!IsValid()); // Cannot Init twice + + memcpy(m_IV, a_IV, 16); + mbedtls_aes_setkey_enc(&m_Aes, a_Key, 128); + m_IsValid = true; +} + + + + + +void cAesCfb128Encryptor::ProcessData(Byte * a_EncryptedOut, const Byte * a_PlainIn, size_t a_Length) +{ + ASSERT(IsValid()); // Must Init() first + mbedtls_aes_crypt_cfb8(&m_Aes, MBEDTLS_AES_ENCRYPT, a_Length, m_IV, a_PlainIn, a_EncryptedOut); +} + + + + + |