| 176 | } |
| 177 | |
| 178 | uint64_t LeaseSet::ExtractExpirationTimestamp (const uint8_t * buf, size_t len) const |
| 179 | { |
| 180 | if (!m_Identity) return 0; |
| 181 | size_t size = m_Identity->GetFullLen (); |
| 182 | if (size > len) return 0; |
| 183 | size += 256; // encryption key |
| 184 | size += m_Identity->GetSigningPublicKeyLen (); // unused signing key |
| 185 | if (size > len) return 0; |
| 186 | uint8_t num = buf[size]; |
| 187 | size++; // num |
| 188 | if (size + num*LEASE_SIZE > len) return 0; |
| 189 | uint64_t timestamp= 0 ; |
| 190 | for (int i = 0; i < num; i++) |
| 191 | { |
| 192 | size += 36; // gateway (32) + tunnelId(4) |
| 193 | auto endDate = bufbe64toh (buf + size); |
| 194 | size += 8; // end date |
| 195 | if (!timestamp || endDate < timestamp) |
| 196 | timestamp = endDate; |
| 197 | } |
| 198 | return timestamp; |
| 199 | } |
| 200 | |
| 201 | bool LeaseSet::IsNewer (const uint8_t * buf, size_t len) const |
| 202 | { |
nothing calls this directly
no test coverage detected