From 3c5c3280ff9712ca25b243d8c84a4f849fe164d8 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Sun, 20 Oct 2013 11:04:58 -0400 Subject: [PATCH] Fix an endian-non-neutrality bug in new hashcash identity algo. --- node/Identity.cpp | 13 +++++++------ selftest-crypto-vectors.hpp | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/node/Identity.cpp b/node/Identity.cpp index d50c56fe1..0c7c13df0 100644 --- a/node/Identity.cpp +++ b/node/Identity.cpp @@ -66,12 +66,13 @@ static inline void _computeMemoryHardHash(const void *publicKey,unsigned int pub // Do something to genmem[] that iteratively makes every value // possibly dependent on every other value with a nontrivial - // probability. + // probability. Continue to use already-initialized Salsa20 as + // a random source. for(unsigned int i=0;i>=8) ++((unsigned char *)genmem)[(uintptr_t)x % ZT_IDENTITY_GEN_MEMORY]; } else { @@ -135,7 +136,7 @@ bool Identity::locallyValidate() const unsigned char addrb[5]; _address.copyTo(addrb,5); - + return ( (digest[0] < ZT_IDENTITY_GEN_HASHCASH_FIRST_BYTE_LESS_THAN)&& (digest[59] == addrb[0])&& diff --git a/selftest-crypto-vectors.hpp b/selftest-crypto-vectors.hpp index 8e07e36aa..d828d2241 100644 --- a/selftest-crypto-vectors.hpp +++ b/selftest-crypto-vectors.hpp @@ -3,8 +3,8 @@ #ifndef _ZT_SELFTEST_CRYPTO_VECTORS_H #define _ZT_SELFTEST_CRYPTO_VECTORS_H -#define KNOWN_GOOD_IDENTITY "d83ac37b39:0:2641645e99286cba657f46c6c1556e266110177c159741bc0c45a5ed419d9d759e254c928e09275630a4c655d2e42e98394550cb14538bed3f4fdee20f1c6263:3b534f4707c160ac03432f7d5419b9a73abbe76b2f6f68e41918024c4be0cbc407db232eae79c432ee3ac2bce93d77303ac8ffcf07d5c7e9f27a8876ff84d438" -#define KNOWN_BAD_IDENTITY "d83ac37b3a:0:2641645e99286cba657f46c6c1556e266110177c159741bc0c45a5ed419d9d759e254c928e09275630a4c655d2e42e98394550cb14538bed3f4fdee20f1c6263:3b534f4707c160ac03432f7d5419b9a73abbe76b2f6f68e41918024c4be0cbc407db232eae79c432ee3ac2bce93d77303ac8ffcf07d5c7e9f27a8876ff84d438" +#define KNOWN_GOOD_IDENTITY "70c4e2c0df:0:65317c885f0ee89e5442f6d7b8a1e46d5abc0b0384c5d5a8e39a24b26900df302f8843063bbadd030ac77637aae908bad24a7b1bd78d9e71c6a11eadfc5b3ac7:241d41bf21916813b5048eb948561c15fcda055af8927810af32aa96288505e9ce78aa2737d99dc30e413d067315122703ff315c18c71561e9d3dfd62221d3d3" +#define KNOWN_BAD_IDENTITY "71c4e2c0df:0:65317c885f0ee89e5442f6d7b8a1e46d5abc0b0384c5d5a8e39a24b26900df302f8843063bbadd030ac77637aae908bad24a7b1bd78d9e71c6a11eadfc5b3ac7:241d41bf21916813b5048eb948561c15fcda055af8927810af32aa96288505e9ce78aa2737d99dc30e413d067315122703ff315c18c71561e9d3dfd62221d3d3" static const unsigned char s20TV0Key[32] = { 0x0f,0x62,0xb5,0x08,0x5b,0xae,0x01,0x54,0xa7,0xfa,0x4d,0xa0,0xf3,0x46,0x99,0xec,0x3f,0x92,0xe5,0x38,0x8b,0xde,0x31,0x84,0xd7,0x2a,0x7d,0xd0,0x23,0x76,0xc9,0x1c }; static const unsigned char s20TV0Iv[8] = { 0x28,0x8f,0xf6,0x5d,0xc4,0x2b,0x92,0xf9 };