| 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) |
nothing calls this directly
no test coverage detected