summaryrefslogtreecommitdiffstats
path: root/src/mbedTLS++/AesCfb128Decryptor.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/mbedTLS++/AesCfb128Decryptor.cpp (renamed from src/PolarSSL++/AesCfb128Decryptor.cpp)24
1 files changed, 6 insertions, 18 deletions
diff --git a/src/PolarSSL++/AesCfb128Decryptor.cpp b/src/mbedTLS++/AesCfb128Decryptor.cpp
index 0aba1c42c..78a7ab9c5 100644
--- a/src/PolarSSL++/AesCfb128Decryptor.cpp
+++ b/src/mbedTLS++/AesCfb128Decryptor.cpp
@@ -1,4 +1,4 @@
-
+
// AesCfb128Decryptor.cpp
// Implements the cAesCfb128Decryptor class decrypting data using AES CFB-128
@@ -10,10 +10,10 @@
-cAesCfb128Decryptor::cAesCfb128Decryptor(void) :
- m_IVOffset(0),
+cAesCfb128Decryptor::cAesCfb128Decryptor(void):
m_IsValid(false)
{
+ mbedtls_aes_init(&m_Aes);
}
@@ -23,7 +23,7 @@ cAesCfb128Decryptor::cAesCfb128Decryptor(void) :
cAesCfb128Decryptor::~cAesCfb128Decryptor()
{
// Clear the leftover in-memory data, so that they can't be accessed by a backdoor
- memset(&m_Aes, 0, sizeof(m_Aes));
+ mbedtls_aes_free(&m_Aes);
}
@@ -35,7 +35,7 @@ void cAesCfb128Decryptor::Init(const Byte a_Key[16], const Byte a_IV[16])
ASSERT(!IsValid()); // Cannot Init twice
memcpy(m_IV, a_IV, 16);
- aes_setkey_enc(&m_Aes, a_Key, 128);
+ mbedtls_aes_setkey_enc(&m_Aes, a_Key, 128);
m_IsValid = true;
}
@@ -46,19 +46,7 @@ void cAesCfb128Decryptor::Init(const Byte a_Key[16], const Byte a_IV[16])
void cAesCfb128Decryptor::ProcessData(Byte * a_DecryptedOut, const Byte * a_EncryptedIn, size_t a_Length)
{
ASSERT(IsValid()); // Must Init() first
-
- // PolarSSL doesn't support AES-CFB8, need to implement it manually:
- for (size_t i = 0; i < a_Length; i++)
- {
- Byte Buffer[sizeof(m_IV)];
- aes_crypt_ecb(&m_Aes, AES_ENCRYPT, m_IV, Buffer);
- for (size_t idx = 0; idx < sizeof(m_IV) - 1; idx++)
- {
- m_IV[idx] = m_IV[idx + 1];
- }
- m_IV[sizeof(m_IV) - 1] = a_EncryptedIn[i];
- a_DecryptedOut[i] = a_EncryptedIn[i] ^ Buffer[0];
- }
+ mbedtls_aes_crypt_cfb8(&m_Aes, MBEDTLS_AES_DECRYPT, a_Length, m_IV, a_EncryptedIn, a_DecryptedOut);
}