Unverified Commit c1c06785 authored by Ali Güngör's avatar Ali Güngör Committed by GitHub

Merge pull request #429 from haotingC/master

fix EIA3 reading data byte-order
parents 0765eba2 8bd60af7
...@@ -61,10 +61,17 @@ uint32_t EIA3(const uint8_t *pKey, uint32_t count, uint32_t direction, uint32_t ...@@ -61,10 +61,17 @@ uint32_t EIA3(const uint8_t *pKey, uint32_t count, uint32_t direction, uint32_t
z = new uint32_t[L]; z = new uint32_t[L];
ZUC(pKey, IV, z, 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;
T = 0; T = 0;
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
if (GetBit(pData, i)) if (GetBit(pData_htobe32, i))
T ^= GetWord(z, i); T ^= GetWord(z, i);
} }
...@@ -105,7 +112,7 @@ void EEA3(const uint8_t *pKey, uint32_t count, uint32_t bearer, uint32_t directi ...@@ -105,7 +112,7 @@ void EEA3(const uint8_t *pKey, uint32_t count, uint32_t bearer, uint32_t directi
ZUC(pKey, iv, z, L); ZUC(pKey, iv, z, L);
for (i = 0; i < L; i++) for (i = 0; i < L; i++)
pData[i] ^= z[i]; pData[i] = be32toh(htobe32(*(pData+i)) ^ z[i]);
delete[] z; delete[] z;
} }
......
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