MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / ExtractPublishedTimestamp

Method ExtractPublishedTimestamp

libi2pd/LeaseSet.cpp:721–750  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

719 }
720
721 uint64_t LeaseSet2::ExtractPublishedTimestamp (const uint8_t * buf, size_t len, uint64_t& expiration) const
722 {
723 if (len < 8) return 0;
724 if (m_StoreType == NETDB_STORE_TYPE_ENCRYPTED_LEASESET2)
725 {
726 // encrypted LS2
727 size_t offset = 0;
728 uint16_t blindedKeyType = bufbe16toh (buf + offset); offset += 2;
729 std::unique_ptr<i2p::crypto::Verifier> blindedVerifier (i2p::data::IdentityEx::CreateVerifier (blindedKeyType));
730 if (!blindedVerifier) return 0 ;
731 auto blindedKeyLen = blindedVerifier->GetPublicKeyLen ();
732 if (offset + blindedKeyLen + 6 >= len) return 0;
733 offset += blindedKeyLen;
734 uint32_t timestamp = bufbe32toh (buf + offset); offset += 4;
735 uint16_t expires = bufbe16toh (buf + offset); offset += 2;
736 expiration = (timestamp + expires)* 1000LL;
737 return timestamp;
738 }
739 else
740 {
741 auto identity = GetIdentity ();
742 if (!identity) return 0;
743 size_t offset = identity->GetFullLen ();
744 if (offset + 6 >= len) return 0;
745 uint32_t timestamp = bufbe32toh (buf + offset); offset += 4;
746 uint16_t expires = bufbe16toh (buf + offset); offset += 2;
747 expiration = (timestamp + expires)* 1000LL;
748 return timestamp;
749 }
750 }
751
752 LocalLeaseSet::LocalLeaseSet (std::shared_ptr<const IdentityEx> identity, const uint8_t * encryptionPublicKey, std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> > tunnels):
753 m_ExpirationTime (0), m_Identity (identity)

Callers

nothing calls this directly

Calls 4

bufbe16tohFunction · 0.85
bufbe32tohFunction · 0.85
GetPublicKeyLenMethod · 0.45
GetFullLenMethod · 0.45

Tested by

no test coverage detected