mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-07 04:53:44 +02:00
ARM64 build fixes
This commit is contained in:
parent
c7f3f3add9
commit
37d4e83fad
2 changed files with 64 additions and 62 deletions
112
node/Buf.hpp
112
node/Buf.hpp
|
@ -250,8 +250,8 @@ public:
|
||||||
ii += 2;
|
ii += 2;
|
||||||
#ifdef ZT_NO_UNALIGNED_ACCESS
|
#ifdef ZT_NO_UNALIGNED_ACCESS
|
||||||
return (
|
return (
|
||||||
((uint16_t)data.bytes[s] << 8U) |
|
((uint16_t)unsafeData[s] << 8U) |
|
||||||
(uint16_t)data.bytes[s + 1]);
|
(uint16_t)unsafeData[s + 1]);
|
||||||
#else
|
#else
|
||||||
return Utils::ntoh(*reinterpret_cast<const uint16_t *>(unsafeData + s));
|
return Utils::ntoh(*reinterpret_cast<const uint16_t *>(unsafeData + s));
|
||||||
#endif
|
#endif
|
||||||
|
@ -269,10 +269,10 @@ public:
|
||||||
ii += 4;
|
ii += 4;
|
||||||
#ifdef ZT_NO_UNALIGNED_ACCESS
|
#ifdef ZT_NO_UNALIGNED_ACCESS
|
||||||
return (
|
return (
|
||||||
((uint32_t)data.bytes[s] << 24U) |
|
((uint32_t)unsafeData[s] << 24U) |
|
||||||
((uint32_t)data.bytes[s + 1] << 16U) |
|
((uint32_t)unsafeData[s + 1] << 16U) |
|
||||||
((uint32_t)data.bytes[s + 2] << 8U) |
|
((uint32_t)unsafeData[s + 2] << 8U) |
|
||||||
(uint32_t)data.bytes[s + 3]);
|
(uint32_t)unsafeData[s + 3]);
|
||||||
#else
|
#else
|
||||||
return Utils::ntoh(*reinterpret_cast<const uint32_t *>(unsafeData + s));
|
return Utils::ntoh(*reinterpret_cast<const uint32_t *>(unsafeData + s));
|
||||||
#endif
|
#endif
|
||||||
|
@ -290,14 +290,14 @@ public:
|
||||||
ii += 8;
|
ii += 8;
|
||||||
#ifdef ZT_NO_UNALIGNED_ACCESS
|
#ifdef ZT_NO_UNALIGNED_ACCESS
|
||||||
return (
|
return (
|
||||||
((uint64_t)data.bytes[s] << 56U) |
|
((uint64_t)unsafeData[s] << 56U) |
|
||||||
((uint64_t)data.bytes[s + 1] << 48U) |
|
((uint64_t)unsafeData[s + 1] << 48U) |
|
||||||
((uint64_t)data.bytes[s + 2] << 40U) |
|
((uint64_t)unsafeData[s + 2] << 40U) |
|
||||||
((uint64_t)data.bytes[s + 3] << 32U) |
|
((uint64_t)unsafeData[s + 3] << 32U) |
|
||||||
((uint64_t)data.bytes[s + 4] << 24U) |
|
((uint64_t)unsafeData[s + 4] << 24U) |
|
||||||
((uint64_t)data.bytes[s + 5] << 16U) |
|
((uint64_t)unsafeData[s + 5] << 16U) |
|
||||||
((uint64_t)data.bytes[s + 6] << 8U) |
|
((uint64_t)unsafeData[s + 6] << 8U) |
|
||||||
(uint64_t)data.bytes[s + 7]);
|
(uint64_t)unsafeData[s + 7]);
|
||||||
#else
|
#else
|
||||||
return Utils::ntoh(*reinterpret_cast<const uint64_t *>(unsafeData + s));
|
return Utils::ntoh(*reinterpret_cast<const uint64_t *>(unsafeData + s));
|
||||||
#endif
|
#endif
|
||||||
|
@ -440,8 +440,8 @@ public:
|
||||||
const unsigned int s = (unsigned int)ii & ZT_BUF_MEM_MASK;
|
const unsigned int s = (unsigned int)ii & ZT_BUF_MEM_MASK;
|
||||||
#ifdef ZT_NO_UNALIGNED_ACCESS
|
#ifdef ZT_NO_UNALIGNED_ACCESS
|
||||||
return (
|
return (
|
||||||
((uint16_t)data.bytes[s] << 8U) |
|
((uint16_t)unsafeData[s] << 8U) |
|
||||||
(uint16_t)data.bytes[s + 1]);
|
(uint16_t)unsafeData[s + 1]);
|
||||||
#else
|
#else
|
||||||
return Utils::ntoh(*reinterpret_cast<const uint16_t *>(unsafeData + s));
|
return Utils::ntoh(*reinterpret_cast<const uint16_t *>(unsafeData + s));
|
||||||
#endif
|
#endif
|
||||||
|
@ -459,10 +459,10 @@ public:
|
||||||
const unsigned int s = (unsigned int)ii & ZT_BUF_MEM_MASK;
|
const unsigned int s = (unsigned int)ii & ZT_BUF_MEM_MASK;
|
||||||
#ifdef ZT_NO_UNALIGNED_ACCESS
|
#ifdef ZT_NO_UNALIGNED_ACCESS
|
||||||
return (
|
return (
|
||||||
((uint32_t)data.bytes[s] << 24U) |
|
((uint32_t)unsafeData[s] << 24U) |
|
||||||
((uint32_t)data.bytes[s + 1] << 16U) |
|
((uint32_t)unsafeData[s + 1] << 16U) |
|
||||||
((uint32_t)data.bytes[s + 2] << 8U) |
|
((uint32_t)unsafeData[s + 2] << 8U) |
|
||||||
(uint32_t)data.bytes[s + 3]);
|
(uint32_t)unsafeData[s + 3]);
|
||||||
#else
|
#else
|
||||||
return Utils::ntoh(*reinterpret_cast<const uint32_t *>(unsafeData + s));
|
return Utils::ntoh(*reinterpret_cast<const uint32_t *>(unsafeData + s));
|
||||||
#endif
|
#endif
|
||||||
|
@ -480,14 +480,14 @@ public:
|
||||||
const unsigned int s = (unsigned int)ii & ZT_BUF_MEM_MASK;
|
const unsigned int s = (unsigned int)ii & ZT_BUF_MEM_MASK;
|
||||||
#ifdef ZT_NO_UNALIGNED_ACCESS
|
#ifdef ZT_NO_UNALIGNED_ACCESS
|
||||||
return (
|
return (
|
||||||
((uint64_t)data.bytes[s] << 56U) |
|
((uint64_t)unsafeData[s] << 56U) |
|
||||||
((uint64_t)data.bytes[s + 1] << 48U) |
|
((uint64_t)unsafeData[s + 1] << 48U) |
|
||||||
((uint64_t)data.bytes[s + 2] << 40U) |
|
((uint64_t)unsafeData[s + 2] << 40U) |
|
||||||
((uint64_t)data.bytes[s + 3] << 32U) |
|
((uint64_t)unsafeData[s + 3] << 32U) |
|
||||||
((uint64_t)data.bytes[s + 4] << 24U) |
|
((uint64_t)unsafeData[s + 4] << 24U) |
|
||||||
((uint64_t)data.bytes[s + 5] << 16U) |
|
((uint64_t)unsafeData[s + 5] << 16U) |
|
||||||
((uint64_t)data.bytes[s + 6] << 8U) |
|
((uint64_t)unsafeData[s + 6] << 8U) |
|
||||||
(uint64_t)data.bytes[s + 7]);
|
(uint64_t)unsafeData[s + 7]);
|
||||||
#else
|
#else
|
||||||
return Utils::ntoh(*reinterpret_cast<const uint64_t *>(unsafeData + s));
|
return Utils::ntoh(*reinterpret_cast<const uint64_t *>(unsafeData + s));
|
||||||
#endif
|
#endif
|
||||||
|
@ -516,8 +516,8 @@ public:
|
||||||
const unsigned int s = ((unsigned int)ii) & ZT_BUF_MEM_MASK;
|
const unsigned int s = ((unsigned int)ii) & ZT_BUF_MEM_MASK;
|
||||||
ii += 2;
|
ii += 2;
|
||||||
#ifdef ZT_NO_UNALIGNED_ACCESS
|
#ifdef ZT_NO_UNALIGNED_ACCESS
|
||||||
b[s] = (uint8_t)(n >> 8U);
|
unsafeData[s] = (uint8_t)(n >> 8U);
|
||||||
b[s + 1] = (uint8_t)n;
|
unsafeData[s + 1] = (uint8_t)n;
|
||||||
#else
|
#else
|
||||||
*reinterpret_cast<uint16_t *>(unsafeData + s) = Utils::hton(n);
|
*reinterpret_cast<uint16_t *>(unsafeData + s) = Utils::hton(n);
|
||||||
#endif
|
#endif
|
||||||
|
@ -534,10 +534,10 @@ public:
|
||||||
const unsigned int s = ((unsigned int)ii) & ZT_BUF_MEM_MASK;
|
const unsigned int s = ((unsigned int)ii) & ZT_BUF_MEM_MASK;
|
||||||
ii += 4;
|
ii += 4;
|
||||||
#ifdef ZT_NO_UNALIGNED_ACCESS
|
#ifdef ZT_NO_UNALIGNED_ACCESS
|
||||||
b[s] = (uint8_t)(n >> 24U);
|
unsafeData[s] = (uint8_t)(n >> 24U);
|
||||||
b[s + 1] = (uint8_t)(n >> 16U);
|
unsafeData[s + 1] = (uint8_t)(n >> 16U);
|
||||||
b[s + 2] = (uint8_t)(n >> 8U);
|
unsafeData[s + 2] = (uint8_t)(n >> 8U);
|
||||||
b[s + 3] = (uint8_t)n;
|
unsafeData[s + 3] = (uint8_t)n;
|
||||||
#else
|
#else
|
||||||
*reinterpret_cast<uint32_t *>(unsafeData + s) = Utils::hton(n);
|
*reinterpret_cast<uint32_t *>(unsafeData + s) = Utils::hton(n);
|
||||||
#endif
|
#endif
|
||||||
|
@ -554,14 +554,14 @@ public:
|
||||||
const unsigned int s = ((unsigned int)ii) & ZT_BUF_MEM_MASK;
|
const unsigned int s = ((unsigned int)ii) & ZT_BUF_MEM_MASK;
|
||||||
ii += 8;
|
ii += 8;
|
||||||
#ifdef ZT_NO_UNALIGNED_ACCESS
|
#ifdef ZT_NO_UNALIGNED_ACCESS
|
||||||
b[s] = (uint8_t)(n >> 56U);
|
unsafeData[s] = (uint8_t)(n >> 56U);
|
||||||
b[s + 1] = (uint8_t)(n >> 48U);
|
unsafeData[s + 1] = (uint8_t)(n >> 48U);
|
||||||
b[s + 2] = (uint8_t)(n >> 40U);
|
unsafeData[s + 2] = (uint8_t)(n >> 40U);
|
||||||
b[s + 3] = (uint8_t)(n >> 32U);
|
unsafeData[s + 3] = (uint8_t)(n >> 32U);
|
||||||
b[s + 4] = (uint8_t)(n >> 24U);
|
unsafeData[s + 4] = (uint8_t)(n >> 24U);
|
||||||
b[s + 5] = (uint8_t)(n >> 16U);
|
unsafeData[s + 5] = (uint8_t)(n >> 16U);
|
||||||
b[s + 6] = (uint8_t)(n >> 8U);
|
unsafeData[s + 6] = (uint8_t)(n >> 8U);
|
||||||
b[s + 7] = (uint8_t)n;
|
unsafeData[s + 7] = (uint8_t)n;
|
||||||
#else
|
#else
|
||||||
*reinterpret_cast<uint64_t *>(unsafeData + s) = Utils::hton(n);
|
*reinterpret_cast<uint64_t *>(unsafeData + s) = Utils::hton(n);
|
||||||
#endif
|
#endif
|
||||||
|
@ -635,8 +635,8 @@ public:
|
||||||
{
|
{
|
||||||
const unsigned int s = ((unsigned int)ii) & ZT_BUF_MEM_MASK;
|
const unsigned int s = ((unsigned int)ii) & ZT_BUF_MEM_MASK;
|
||||||
#ifdef ZT_NO_UNALIGNED_ACCESS
|
#ifdef ZT_NO_UNALIGNED_ACCESS
|
||||||
b[s] = (uint8_t)(n >> 8U);
|
unsafeData[s] = (uint8_t)(n >> 8U);
|
||||||
b[s + 1] = (uint8_t)n;
|
unsafeData[s + 1] = (uint8_t)n;
|
||||||
#else
|
#else
|
||||||
*reinterpret_cast<uint16_t *>(unsafeData + s) = Utils::hton(n);
|
*reinterpret_cast<uint16_t *>(unsafeData + s) = Utils::hton(n);
|
||||||
#endif
|
#endif
|
||||||
|
@ -649,10 +649,10 @@ public:
|
||||||
{
|
{
|
||||||
const unsigned int s = ((unsigned int)ii) & ZT_BUF_MEM_MASK;
|
const unsigned int s = ((unsigned int)ii) & ZT_BUF_MEM_MASK;
|
||||||
#ifdef ZT_NO_UNALIGNED_ACCESS
|
#ifdef ZT_NO_UNALIGNED_ACCESS
|
||||||
b[s] = (uint8_t)(n >> 24U);
|
unsafeData[s] = (uint8_t)(n >> 24U);
|
||||||
b[s + 1] = (uint8_t)(n >> 16U);
|
unsafeData[s + 1] = (uint8_t)(n >> 16U);
|
||||||
b[s + 2] = (uint8_t)(n >> 8U);
|
unsafeData[s + 2] = (uint8_t)(n >> 8U);
|
||||||
b[s + 3] = (uint8_t)n;
|
unsafeData[s + 3] = (uint8_t)n;
|
||||||
#else
|
#else
|
||||||
*reinterpret_cast<uint32_t *>(unsafeData + s) = Utils::hton(n);
|
*reinterpret_cast<uint32_t *>(unsafeData + s) = Utils::hton(n);
|
||||||
#endif
|
#endif
|
||||||
|
@ -665,14 +665,14 @@ public:
|
||||||
{
|
{
|
||||||
const unsigned int s = ((unsigned int)ii) & ZT_BUF_MEM_MASK;
|
const unsigned int s = ((unsigned int)ii) & ZT_BUF_MEM_MASK;
|
||||||
#ifdef ZT_NO_UNALIGNED_ACCESS
|
#ifdef ZT_NO_UNALIGNED_ACCESS
|
||||||
b[s] = (uint8_t)(n >> 56U);
|
unsafeData[s] = (uint8_t)(n >> 56U);
|
||||||
b[s + 1] = (uint8_t)(n >> 48U);
|
unsafeData[s + 1] = (uint8_t)(n >> 48U);
|
||||||
b[s + 2] = (uint8_t)(n >> 40U);
|
unsafeData[s + 2] = (uint8_t)(n >> 40U);
|
||||||
b[s + 3] = (uint8_t)(n >> 32U);
|
unsafeData[s + 3] = (uint8_t)(n >> 32U);
|
||||||
b[s + 4] = (uint8_t)(n >> 24U);
|
unsafeData[s + 4] = (uint8_t)(n >> 24U);
|
||||||
b[s + 5] = (uint8_t)(n >> 16U);
|
unsafeData[s + 5] = (uint8_t)(n >> 16U);
|
||||||
b[s + 6] = (uint8_t)(n >> 8U);
|
unsafeData[s + 6] = (uint8_t)(n >> 8U);
|
||||||
b[s + 7] = (uint8_t)n;
|
unsafeData[s + 7] = (uint8_t)n;
|
||||||
#else
|
#else
|
||||||
*reinterpret_cast<uint64_t *>(unsafeData + s) = Utils::hton(n);
|
*reinterpret_cast<uint64_t *>(unsafeData + s) = Utils::hton(n);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -95,7 +95,6 @@ bool identityV1ProofOfWorkCriteria(const void *in,const unsigned int len)
|
||||||
polykey[2] = b[2];
|
polykey[2] = b[2];
|
||||||
polykey[3] = b[3];
|
polykey[3] = b[3];
|
||||||
|
|
||||||
// Put bits in hash in LE byte order on BE machines.
|
|
||||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||||
b[0] = Utils::swapBytes(b[0]);
|
b[0] = Utils::swapBytes(b[0]);
|
||||||
b[1] = Utils::swapBytes(b[1]);
|
b[1] = Utils::swapBytes(b[1]);
|
||||||
|
@ -140,7 +139,6 @@ bool identityV1ProofOfWorkCriteria(const void *in,const unsigned int len)
|
||||||
}
|
}
|
||||||
std::sort(b,b + 98304);
|
std::sort(b,b + 98304);
|
||||||
|
|
||||||
// Put bits in little-endian byte order if this is a BE machine.
|
|
||||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||||
for(unsigned int i=0;i<98304;i+=8) {
|
for(unsigned int i=0;i<98304;i+=8) {
|
||||||
b[i] = Utils::swapBytes(b[i]);
|
b[i] = Utils::swapBytes(b[i]);
|
||||||
|
@ -195,17 +193,21 @@ bool Identity::generate(const Type t)
|
||||||
|
|
||||||
case P384: {
|
case P384: {
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
// Loop until we pass the PoW criteria. The nonce is only 8 bits, so generate
|
||||||
|
// some new key material every time it wraps. The ECC384 generator is slightly
|
||||||
|
// faster so use that one.
|
||||||
_pub.nonce = 0;
|
_pub.nonce = 0;
|
||||||
v1_pow_new_keys:
|
|
||||||
C25519::generate(_pub.c25519,_priv.c25519);
|
C25519::generate(_pub.c25519,_priv.c25519);
|
||||||
ECC384GenerateKey(_pub.p384,_priv.p384);
|
ECC384GenerateKey(_pub.p384,_priv.p384);
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if (identityV1ProofOfWorkCriteria(&_pub,sizeof(_pub)))
|
if (identityV1ProofOfWorkCriteria(&_pub,sizeof(_pub)))
|
||||||
break;
|
break;
|
||||||
if (++_pub.nonce == 0) // endian-ness doesn't matter, just change the nonce each time
|
if (++_pub.nonce == 0)
|
||||||
goto v1_pow_new_keys;
|
ECC384GenerateKey(_pub.p384,_priv.p384);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we passed PoW then check that the address is valid, otherwise loop
|
||||||
|
// back around and run the whole process again.
|
||||||
_computeHash();
|
_computeHash();
|
||||||
_address.setTo(_fp.hash());
|
_address.setTo(_fp.hash());
|
||||||
if (!_address.isReserved())
|
if (!_address.isReserved())
|
||||||
|
|
Loading…
Add table
Reference in a new issue