From 1b71b6d01a5e3bc5a746fff59d7433633931df8f Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 25 Feb 2020 16:15:14 -0800 Subject: [PATCH] hash() -> fingerprint() --- controller/EmbeddedNetworkController.cpp | 2 +- node/Identity.cpp | 2 +- node/Identity.hpp | 2 +- node/Network.cpp | 2 +- node/Node.cpp | 2 +- node/Peer.cpp | 2 +- node/Protocol.cpp | 4 ++-- node/Topology.cpp | 10 +++++----- node/Trace.cpp | 6 +++--- node/VL1.cpp | 6 +++--- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/controller/EmbeddedNetworkController.cpp b/controller/EmbeddedNetworkController.cpp index d1a6a6761..cf4a375cd 100644 --- a/controller/EmbeddedNetworkController.cpp +++ b/controller/EmbeddedNetworkController.cpp @@ -1295,7 +1295,7 @@ void EmbeddedNetworkController::_request( nc->credentialTimeMaxDelta = credentialtmd; nc->revision = OSUtils::jsonInt(network["revision"],0ULL); nc->issuedTo = identity.address(); - memcpy(nc->issuedToIdentityHash,identity.hash(),sizeof(nc->issuedToIdentityHash)); + memcpy(nc->issuedToIdentityHash,identity.fingerprint(),sizeof(nc->issuedToIdentityHash)); if (OSUtils::jsonBool(network["enableBroadcast"],true)) nc->flags |= ZT_NETWORKCONFIG_FLAG_ENABLE_BROADCAST; Utils::scopy(nc->name,sizeof(nc->name),OSUtils::jsonString(network["name"],"").c_str()); nc->mtu = std::max(std::min((unsigned int)OSUtils::jsonInt(network["mtu"],ZT_DEFAULT_MTU),(unsigned int)ZT_MAX_MTU),(unsigned int)ZT_MIN_MTU); diff --git a/node/Identity.cpp b/node/Identity.cpp index fb8a012bf..e8b211a0c 100644 --- a/node/Identity.cpp +++ b/node/Identity.cpp @@ -615,7 +615,7 @@ void ZT_Identity_hash(const ZT_Identity *id,uint8_t h[48],int includePrivate) { if (includePrivate) reinterpret_cast(id)->hashWithPrivate(h); - else memcpy(h,reinterpret_cast(id)->hash().data(),ZT_IDENTITY_HASH_SIZE); + else memcpy(h,reinterpret_cast(id)->fingerprint().data(),ZT_IDENTITY_HASH_SIZE); } ZT_SDK_API void ZT_Identity_delete(ZT_Identity *id) diff --git a/node/Identity.hpp b/node/Identity.hpp index 3c5f2c5ee..1a3ced62b 100644 --- a/node/Identity.hpp +++ b/node/Identity.hpp @@ -128,7 +128,7 @@ public: * * @return 384-bit/48-byte hash */ - ZT_ALWAYS_INLINE const Hash<384> &hash() const noexcept { return _hash; } + ZT_ALWAYS_INLINE const Hash<384> &fingerprint() const noexcept { return _hash; } /** * Compute a hash of this identity's public and private keys. diff --git a/node/Network.cpp b/node/Network.cpp index 8a55ac918..afd0832a8 100644 --- a/node/Network.cpp +++ b/node/Network.cpp @@ -1010,7 +1010,7 @@ int Network::setConfiguration(void *tPtr,const NetworkConfig &nconf,bool saveToD try { if ((nconf.issuedTo != RR->identity.address())||(nconf.networkId != _id)) return 0; // invalid config that is not for us or not for this network - if ((!Utils::allZero(nconf.issuedToIdentityHash,ZT_IDENTITY_HASH_SIZE))&&(memcmp(nconf.issuedToIdentityHash,RR->identity.hash().data(),ZT_IDENTITY_HASH_SIZE) != 0)) + if ((!Utils::allZero(nconf.issuedToIdentityHash,ZT_IDENTITY_HASH_SIZE))&&(memcmp(nconf.issuedToIdentityHash,RR->identity.fingerprint().data(),ZT_IDENTITY_HASH_SIZE) != 0)) return 0; // full identity hash is present and does not match if (_config == nconf) diff --git a/node/Node.cpp b/node/Node.cpp index 7493c1788..f40824650 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -482,7 +482,7 @@ ZT_PeerList *Node::peers() const p->address = (*pi)->address().toInt(); identities[pl->peerCount] = (*pi)->identity(); // need to make a copy in case peer gets deleted p->identity = &identities[pl->peerCount]; - memcpy(p->identityHash,(*pi)->identity().hash().data(),ZT_IDENTITY_HASH_SIZE); + memcpy(p->identityHash,(*pi)->identity().fingerprint().data(),ZT_IDENTITY_HASH_SIZE); if ((*pi)->remoteVersionKnown()) { p->versionMajor = (int)(*pi)->remoteVersionMajor(); p->versionMinor = (int)(*pi)->remoteVersionMinor(); diff --git a/node/Peer.cpp b/node/Peer.cpp index cf4d14d3c..dc1615060 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -123,7 +123,7 @@ void Peer::received( RR->t->learnedNewPath(tPtr,0x582fabdd,packetId,_id,path->address(),old); } else { if (RR->node->shouldUsePathForZeroTierTraffic(tPtr,_id,path->localSocket(),path->address())) { - RR->t->tryingNewPath(tPtr,0xb7747ddd,_id,path->address(),path->address(),packetId,(uint8_t)verb,_id.address(),_id.hash().data(),ZT_TRACE_TRYING_NEW_PATH_REASON_PACKET_RECEIVED_FROM_UNKNOWN_PATH); + RR->t->tryingNewPath(tPtr,0xb7747ddd,_id,path->address(),path->address(),packetId,(uint8_t)verb,_id.address(),_id.fingerprint().data(),ZT_TRACE_TRYING_NEW_PATH_REASON_PACKET_RECEIVED_FROM_UNKNOWN_PATH); path->sent(now,sendHELLO(tPtr,path->localSocket(),path->address(),now)); } } diff --git a/node/Protocol.cpp b/node/Protocol.cpp index 8d6a33988..e1ddba92e 100644 --- a/node/Protocol.cpp +++ b/node/Protocol.cpp @@ -30,8 +30,8 @@ namespace Protocol { uint64_t createProbe(const Identity &sender,const Identity &recipient,const uint8_t key[ZT_PEER_SECRET_KEY_LENGTH]) noexcept { uint8_t tmp[ZT_IDENTITY_HASH_SIZE + ZT_IDENTITY_HASH_SIZE]; - memcpy(tmp,sender.hash().data(),ZT_IDENTITY_HASH_SIZE); - memcpy(tmp + ZT_IDENTITY_HASH_SIZE,recipient.hash().data(),ZT_IDENTITY_HASH_SIZE); + memcpy(tmp,sender.fingerprint().data(),ZT_IDENTITY_HASH_SIZE); + memcpy(tmp + ZT_IDENTITY_HASH_SIZE,recipient.fingerprint().data(),ZT_IDENTITY_HASH_SIZE); uint64_t hash[6]; SHA384(hash,tmp,sizeof(tmp),key,ZT_PEER_SECRET_KEY_LENGTH); return hash[0]; diff --git a/node/Topology.cpp b/node/Topology.cpp index 9d8502f8f..e27619e85 100644 --- a/node/Topology.cpp +++ b/node/Topology.cpp @@ -68,7 +68,7 @@ Topology::Topology(const RuntimeEnvironment *renv,void *tPtr) : _rootPeers.push_back(p); _peers[p->address()] = p; _peersByIncomingProbe[p->incomingProbe()] = p; - _peersByIdentityHash[p->identity().hash()] = p; + _peersByIdentityHash[p->identity().fingerprint()] = p; } } @@ -87,13 +87,13 @@ SharedPtr Topology::add(void *tPtr,const SharedPtr &peer) _loadCached(tPtr,peer->address(),hp); if (hp) { _peersByIncomingProbe[peer->incomingProbe()] = hp; - _peersByIdentityHash[peer->identity().hash()] = hp; + _peersByIdentityHash[peer->identity().fingerprint()] = hp; return hp; } hp = peer; _peersByIncomingProbe[peer->incomingProbe()] = peer; - _peersByIdentityHash[peer->identity().hash()] = peer; + _peersByIdentityHash[peer->identity().fingerprint()] = peer; return peer; } @@ -157,7 +157,7 @@ void Topology::addRoot(void *tPtr,const Identity &id,const InetAddress &bootstra if (bootstrap) p->setBootstrap(Endpoint(bootstrap)); _peersByIncomingProbe[p->incomingProbe()] = p; - _peersByIdentityHash[p->identity().hash()] = p; + _peersByIdentityHash[p->identity().fingerprint()] = p; } _rootPeers.push_back(p); @@ -212,7 +212,7 @@ void Topology::doPeriodicTasks(void *tPtr,const int64_t now) if ( (!(*p)->alive(now)) && (_roots.count((*p)->identity()) == 0) ) { (*p)->save(tPtr); _peersByIncomingProbe.erase((*p)->incomingProbe()); - _peersByIdentityHash.erase((*p)->identity().hash()); + _peersByIdentityHash.erase((*p)->identity().fingerprint()); _peers.erase(*a); } } diff --git a/node/Trace.cpp b/node/Trace.cpp index bdd0a6c01..a92ddac49 100644 --- a/node/Trace.cpp +++ b/node/Trace.cpp @@ -118,7 +118,7 @@ void Trace::_tryingNewPath( ev.evType = ZT_CONST_TO_BE_UINT16(ZT_TRACE_VL1_TRYING_NEW_PATH); ev.codeLocation = Utils::hton(codeLocation); ev.address = Utils::hton(trying.address().toInt()); - memcpy(ev.identityHash,trying.hash().data(),48); + memcpy(ev.identityHash,trying.fingerprint().data(),48); physicalAddress.forTrace(ev.physicalAddress); triggerAddress.forTrace(ev.triggerAddress); ev.triggeringPacketId = triggeringPacketId; @@ -145,7 +145,7 @@ void Trace::_learnedNewPath( ev.codeLocation = Utils::hton(codeLocation); ev.packetId = packetId; // packet IDs are kept in big-endian ev.address = Utils::hton(peerIdentity.address().toInt()); - memcpy(ev.identityHash,peerIdentity.hash().data(),ZT_IDENTITY_HASH_SIZE); + memcpy(ev.identityHash,peerIdentity.fingerprint().data(),ZT_IDENTITY_HASH_SIZE); physicalAddress.forTrace(ev.physicalAddress); replaced.forTrace(ev.replaced); @@ -171,7 +171,7 @@ void Trace::_incomingPacketDropped( ev.networkId = Utils::hton(networkId); if (peerIdentity) { ev.address = Utils::hton(peerIdentity.address().toInt()); - memcpy(ev.identityHash,peerIdentity.hash().data(),ZT_IDENTITY_HASH_SIZE); + memcpy(ev.identityHash,peerIdentity.fingerprint().data(),ZT_IDENTITY_HASH_SIZE); } else { ev.address = 0; memset(ev.identityHash,0,ZT_IDENTITY_HASH_SIZE); diff --git a/node/VL1.cpp b/node/VL1.cpp index d5b68da03..176aa2ff5 100644 --- a/node/VL1.cpp +++ b/node/VL1.cpp @@ -823,7 +823,7 @@ bool VL1::_RENDEZVOUS(void *tPtr,const SharedPtr &path,const SharedPtrcontact(tPtr,Endpoint(atAddr),now,false); - RR->t->tryingNewPath(tPtr,0x55a19aaa,with->identity(),atAddr,path->address(),Protocol::packetId(pkt,packetSize),Protocol::VERB_RENDEZVOUS,peer->address(),peer->identity().hash().data(),ZT_TRACE_TRYING_NEW_PATH_REASON_RENDEZVOUS); + RR->t->tryingNewPath(tPtr,0x55a19aaa,with->identity(),atAddr,path->address(),Protocol::packetId(pkt,packetSize),Protocol::VERB_RENDEZVOUS,peer->address(),peer->identity().fingerprint().data(),ZT_TRACE_TRYING_NEW_PATH_REASON_RENDEZVOUS); } break; case 255: { @@ -835,7 +835,7 @@ bool VL1::_RENDEZVOUS(void *tPtr,const SharedPtr &path,const SharedPtrcontact(tPtr,ep,now,false); - RR->t->tryingNewPath(tPtr,0x55a19aab,with->identity(),ep.inetAddr(),path->address(),Protocol::packetId(pkt,packetSize),Protocol::VERB_RENDEZVOUS,peer->address(),peer->identity().hash().data(),ZT_TRACE_TRYING_NEW_PATH_REASON_RENDEZVOUS); + RR->t->tryingNewPath(tPtr,0x55a19aab,with->identity(),ep.inetAddr(),path->address(),Protocol::packetId(pkt,packetSize),Protocol::VERB_RENDEZVOUS,peer->address(),peer->identity().fingerprint().data(),ZT_TRACE_TRYING_NEW_PATH_REASON_RENDEZVOUS); break; default: break; @@ -969,7 +969,7 @@ bool VL1::_PUSH_DIRECT_PATHS(void *tPtr,const SharedPtr &path,const Shared } if (a) { - RR->t->tryingNewPath(tPtr,0xa5ab1a43,peer->identity(),a,path->address(),Protocol::packetId(pkt,packetSize),Protocol::VERB_RENDEZVOUS,peer->address(),peer->identity().hash().data(),ZT_TRACE_TRYING_NEW_PATH_REASON_RECEIVED_PUSH_DIRECT_PATHS); + RR->t->tryingNewPath(tPtr,0xa5ab1a43,peer->identity(),a,path->address(),Protocol::packetId(pkt,packetSize),Protocol::VERB_RENDEZVOUS,peer->address(),peer->identity().fingerprint().data(),ZT_TRACE_TRYING_NEW_PATH_REASON_RECEIVED_PUSH_DIRECT_PATHS); } ptr += (int)addrRecordLen;