From 5ccc91a7c3c0c41a2b4e5e7d4ccc279b71ab8641 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 17 Sep 2013 16:49:16 -0400 Subject: Prescient endian-ness fix in deriveAddress. --- node/Identity.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/node/Identity.cpp b/node/Identity.cpp index 161ec659..93d5024b 100644 --- a/node/Identity.cpp +++ b/node/Identity.cpp @@ -30,6 +30,7 @@ #include #include +#include "Constants.hpp" #include "Identity.hpp" #include "SHA512.hpp" #include "Salsa20.hpp" @@ -160,7 +161,31 @@ Address Identity::deriveAddress(const void *keyBytes,unsigned int keyLen) uint64_t nonce = 0; for(unsigned int r=0;r> 8) | + ((nonce & 0x0000FF0000000000ULL) >> 24) | + ((nonce & 0x00FF000000000000ULL) >> 40) | + ((nonce & 0xFF00000000000000ULL) >> 56) + ); +#endif Salsa20 s20(salsaKey,256,&nonce); +#if __BYTE_ORDER == __BIG_ENDIAN + nonce = ( // swap back to big endian + ((nonce & 0x00000000000000FFULL) << 56) | + ((nonce & 0x000000000000FF00ULL) << 40) | + ((nonce & 0x0000000000FF0000ULL) << 24) | + ((nonce & 0x00000000FF000000ULL) << 8) | + ((nonce & 0x000000FF00000000ULL) >> 8) | + ((nonce & 0x0000FF0000000000ULL) >> 24) | + ((nonce & 0x00FF000000000000ULL) >> 40) | + ((nonce & 0xFF00000000000000ULL) >> 56) + ); +#endif s20.encrypt(ram,ram,ZT_IDENTITY_DERIVEADDRESS_MEMORY); } -- cgit v1.2.3