Commit 184cba42 authored by aligungr's avatar aligungr

EEA3 refactor

parent c1c06785
......@@ -9,6 +9,9 @@
#include "eea3.hpp"
#include "zuc.hpp"
#include <endian.h>
#include <vector>
namespace crypto::eea3
{
......@@ -61,17 +64,14 @@ uint32_t EIA3(const uint8_t *pKey, uint32_t count, uint32_t direction, uint32_t
z = new uint32_t[L];
ZUC(pKey, IV, z, L);
uint32_t data_htobe32[length/32+1];
for (int i=0; i<(length+31)/32; i++)
data_htobe32[i] = htobe32(*(pData+i));
uint32_t *pData_htobe32 = data_htobe32;
std::vector<uint32_t> data_htobe32(length / 32 + 1);
for (uint32_t j = 0; j < (length + 31) / 32; j++)
data_htobe32[j] = htobe32(*(pData + j));
T = 0;
for (i = 0; i < length; i++)
{
if (GetBit(pData_htobe32, i))
if (GetBit(data_htobe32.data(), i))
T ^= GetWord(z, i);
}
......@@ -112,8 +112,8 @@ void EEA3(const uint8_t *pKey, uint32_t count, uint32_t bearer, uint32_t directi
ZUC(pKey, iv, z, L);
for (i = 0; i < L; i++)
pData[i] = be32toh(htobe32(*(pData+i)) ^ z[i]);
pData[i] = be32toh(htobe32(*(pData + i)) ^ z[i]);
delete[] z;
}
} // namespace crypt::eea3
} // namespace crypto::eea3
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment