diff --git a/src/crypto/groestl.c b/src/crypto/groestl.c index 00bf987..8884a74 100644 --- a/src/crypto/groestl.c +++ b/src/crypto/groestl.c @@ -8,6 +8,8 @@ * */ +#include + #include "groestl.h" #include "groestl_tables.h" @@ -204,7 +206,7 @@ static void OutputTransformation(hashState *ctx) { /* initialise context */ static void Init(hashState* ctx) { - int i = 0; + size_t i = 0; /* allocate memory for state and data buffer */ for(;i<(SIZE512/sizeof(uint32_t));i++) @@ -357,4 +359,4 @@ static int crypto_hash(unsigned char *out, return 0; } -*/ \ No newline at end of file +*/ diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c index 8fd3e13..6034458 100644 --- a/src/crypto/slow-hash.c +++ b/src/crypto/slow-hash.c @@ -565,7 +565,7 @@ union cn_slow_hash_state { }; #pragma pack(pop) -void cn_slow_hash(const void *data, size_t length, char *hash) { +void cn_slow_hash(const void *data, size_t length, char *hash, int light) { uint8_t long_state[MEMORY]; union cn_slow_hash_state state; uint8_t text[INIT_SIZE_BYTE]; @@ -583,7 +583,7 @@ void cn_slow_hash(const void *data, size_t length, char *hash) { aes_ctx = (oaes_ctx *) oaes_alloc(); oaes_key_import_data(aes_ctx, aes_key, AES_KEY_SIZE); - for (i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) { + for (i = 0; i < MEMORY / (light?2:1) / INIT_SIZE_BYTE; i++) { for (j = 0; j < INIT_SIZE_BLK; j++) { aesb_pseudo_round(&text[AES_BLOCK_SIZE * j], &text[AES_BLOCK_SIZE * j], aes_ctx->key->exp_data); } @@ -595,35 +595,35 @@ void cn_slow_hash(const void *data, size_t length, char *hash) { b[i] = state.k[16 + i] ^ state.k[48 + i]; } - for (i = 0; i < ITER / 2; i++) { + for (i = 0; i < ITER / (light?2:1) / 2; i++) { /* Dependency chain: address -> read value ------+ * written value <-+ hard function (AES or MUL) <+ * next address <-+ */ /* Iteration 1 */ - j = e2i(a, MEMORY / AES_BLOCK_SIZE); + j = e2i(a, MEMORY / (light?2:1) / AES_BLOCK_SIZE); copy_block(c, &long_state[j * AES_BLOCK_SIZE]); - aesb_single_round(c, c, a); + aesb_single_round(c, c, a); xor_blocks(b, c); swap_blocks(b, c); copy_block(&long_state[j * AES_BLOCK_SIZE], c); - assert(j == e2i(a, MEMORY / AES_BLOCK_SIZE)); + assert(j == e2i(a, MEMORY / (light?2:1) / AES_BLOCK_SIZE)); swap_blocks(a, b); /* Iteration 2 */ - j = e2i(a, MEMORY / AES_BLOCK_SIZE); + j = e2i(a, MEMORY / (light?2:1) / AES_BLOCK_SIZE); copy_block(c, &long_state[j * AES_BLOCK_SIZE]); mul(a, c, d); sum_half_blocks(b, d); swap_blocks(b, c); xor_blocks(b, c); copy_block(&long_state[j * AES_BLOCK_SIZE], c); - assert(j == e2i(a, MEMORY / AES_BLOCK_SIZE)); + assert(j == e2i(a, MEMORY / (light?2:1) / AES_BLOCK_SIZE)); swap_blocks(a, b); } memcpy(text, state.init, INIT_SIZE_BYTE); oaes_key_import_data(aes_ctx, &state.hs.b[32], AES_KEY_SIZE); - for (i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) { + for (i = 0; i < MEMORY / (light?2:1) / INIT_SIZE_BYTE; i++) { for (j = 0; j < INIT_SIZE_BLK; j++) { xor_blocks(&text[j * AES_BLOCK_SIZE], &long_state[i * INIT_SIZE_BYTE + j * AES_BLOCK_SIZE]); aesb_pseudo_round(&text[AES_BLOCK_SIZE * j], &text[AES_BLOCK_SIZE * j], aes_ctx->key->exp_data); diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index e5d5627..4086480 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -586,7 +586,9 @@ namespace nodetool peerlist_entry pe_local = AUTO_VAL_INIT(pe_local); pe_local.adr = na; pe_local.id = pi; - time(&pe_local.last_seen); + time_t last_seen; + time(&last_seen); + pe_local.last_seen = static_cast(last_seen); m_peerlist.append_with_peer_white(pe_local); //update last seen and push it to peerlist manager @@ -1064,7 +1066,9 @@ namespace nodetool peerlist_entry pe; pe.adr.ip = context.m_remote_ip; pe.adr.port = port_l; - time(&pe.last_seen); + time_t last_seen; + time(&last_seen); + pe.last_seen = static_cast(last_seen); pe.id = peer_id_l; this->m_peerlist.append_with_peer_white(pe); LOG_PRINT_CCONTEXT_L2("PING SUCCESS " << epee::string_tools::get_ip_string_from_int32(context.m_remote_ip) << ":" << port_l); diff --git a/src/p2p/net_peerlist.h b/src/p2p/net_peerlist.h index 6e17459..3964b56 100644 --- a/src/p2p/net_peerlist.h +++ b/src/p2p/net_peerlist.h @@ -128,7 +128,7 @@ namespace nodetool // access by peerlist_entry::net_adress boost::multi_index::ordered_unique, boost::multi_index::member >, // sort by peerlist_entry::last_seen< - boost::multi_index::ordered_non_unique, boost::multi_index::member > + boost::multi_index::ordered_non_unique, boost::multi_index::member > > > peers_indexed; @@ -140,7 +140,7 @@ namespace nodetool // access by peerlist_entry::net_adress boost::multi_index::ordered_unique, boost::multi_index::member >, // sort by peerlist_entry::last_seen< - boost::multi_index::ordered_non_unique, boost::multi_index::member > + boost::multi_index::ordered_non_unique, boost::multi_index::member > > > peers_indexed_old; public: diff --git a/src/p2p/p2p_protocol_defs.h b/src/p2p/p2p_protocol_defs.h index 1f230b2..d5a046b 100644 --- a/src/p2p/p2p_protocol_defs.h +++ b/src/p2p/p2p_protocol_defs.h @@ -53,7 +53,7 @@ namespace nodetool { net_address adr; peerid_type id; - time_t last_seen; + int64_t last_seen; }; struct connection_entry