diff --git a/node/Identity.cpp b/node/Identity.cpp index 4a892979d..c514b0455 100644 --- a/node/Identity.cpp +++ b/node/Identity.cpp @@ -93,13 +93,13 @@ bool _v1_identity_generate_cond(const void *in,const unsigned int len) #if __BYTE_ORDER == __BIG_ENDIAN b[0] = Utils::swapBytes(b[0]); - b[1] = Utils::swapBytes(b[0]); - b[2] = Utils::swapBytes(b[0]); - b[3] = Utils::swapBytes(b[0]); - b[4] = Utils::swapBytes(b[0]); - b[5] = Utils::swapBytes(b[0]); - b[6] = Utils::swapBytes(b[0]); - b[7] = Utils::swapBytes(b[0]); + b[1] = Utils::swapBytes(b[1]); + b[2] = Utils::swapBytes(b[2]); + b[3] = Utils::swapBytes(b[3]); + b[4] = Utils::swapBytes(b[4]); + b[5] = Utils::swapBytes(b[5]); + b[6] = Utils::swapBytes(b[6]); + b[7] = Utils::swapBytes(b[7]); #endif Speck128<24> s16; @@ -113,12 +113,12 @@ bool _v1_identity_generate_cond(const void *in,const unsigned int len) uint64_t y2 = b[i + 5]; uint64_t x3 = b[i + 6]; uint64_t y3 = b[i + 7]; - x0 += x1; - x1 += x2; i += 8; + x0 += x1; // mix parallel 128-bit blocks + x1 += x2; x2 += x3; x3 += y0; - s16.encrypt512(x0,y0,x1,y1,x2,y2,x3,y3); + s16.encryptXYXYXYXY(x0,y0,x1,y1,x2,y2,x3,y3); b[i] = x0; b[i + 1] = y0; b[i + 2] = x1; @@ -147,7 +147,7 @@ bool _v1_identity_generate_cond(const void *in,const unsigned int len) #if __BYTE_ORDER == __BIG_ENDIAN return ((Utils::swapBytes(b[0]) + Utils::swapBytes(b[1])) >> 56U) == 0; #else - return ((b[0] + b[1]) >> 56U) == 0; + return ((b[0] + b[1]) & 0xffU) == 0; #endif } diff --git a/node/Speck128.hpp b/node/Speck128.hpp index e38cc66c2..b34ac6d8f 100644 --- a/node/Speck128.hpp +++ b/node/Speck128.hpp @@ -98,7 +98,7 @@ public: /** * Encrypt 512 bits in parallel with the same key */ - ZT_INLINE void encrypt512(uint64_t &x0,uint64_t &y0,uint64_t &x1,uint64_t &y1,uint64_t &x2,uint64_t &y2,uint64_t &x3,uint64_t &y3) const noexcept + ZT_INLINE void encryptXYXYXYXY(uint64_t &x0,uint64_t &y0,uint64_t &x1,uint64_t &y1,uint64_t &x2,uint64_t &y2,uint64_t &x3,uint64_t &y3) const noexcept { for (int i=0;i