|
|
@ -285,7 +285,7 @@ namespace data |
|
|
|
uint16_t expires = bufbe16toh (buf + offset); offset += 2; // expires (seconds)
|
|
|
|
uint16_t expires = bufbe16toh (buf + offset); offset += 2; // expires (seconds)
|
|
|
|
SetExpirationTime ((timestamp + expires)*1000LL); // in milliseconds
|
|
|
|
SetExpirationTime ((timestamp + expires)*1000LL); // in milliseconds
|
|
|
|
uint16_t flags = bufbe16toh (buf + offset); offset += 2; // flags
|
|
|
|
uint16_t flags = bufbe16toh (buf + offset); offset += 2; // flags
|
|
|
|
if (flags & 0x0001) |
|
|
|
if (flags & LEASESET2_FLAG_OFFLINE_KEYS) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// transient key
|
|
|
|
// transient key
|
|
|
|
m_TransientVerifier = ProcessOfflineSignature (identity, buf, len, offset); |
|
|
|
m_TransientVerifier = ProcessOfflineSignature (identity, buf, len, offset); |
|
|
@ -431,7 +431,7 @@ namespace data |
|
|
|
uint16_t expires = bufbe16toh (buf + offset); offset += 2; // expires (seconds)
|
|
|
|
uint16_t expires = bufbe16toh (buf + offset); offset += 2; // expires (seconds)
|
|
|
|
SetExpirationTime ((timestamp + expires)*1000LL); // in milliseconds
|
|
|
|
SetExpirationTime ((timestamp + expires)*1000LL); // in milliseconds
|
|
|
|
uint16_t flags = bufbe16toh (buf + offset); offset += 2; // flags
|
|
|
|
uint16_t flags = bufbe16toh (buf + offset); offset += 2; // flags
|
|
|
|
if (flags & 0x0001) |
|
|
|
if (flags & LEASESET2_FLAG_OFFLINE_KEYS) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// transient key
|
|
|
|
// transient key
|
|
|
|
m_TransientVerifier = ProcessOfflineSignature (blindedVerifier, buf, len, offset); |
|
|
|
m_TransientVerifier = ProcessOfflineSignature (blindedVerifier, buf, len, offset); |
|
|
@ -579,16 +579,24 @@ namespace data |
|
|
|
return ident.Verify(ptr, leases - ptr, leases); |
|
|
|
return ident.Verify(ptr, leases - ptr, leases); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LocalLeaseSet2::LocalLeaseSet2 (uint8_t storeType, std::shared_ptr<const IdentityEx> identity, |
|
|
|
LocalLeaseSet2::LocalLeaseSet2 (uint8_t storeType, const i2p::data::PrivateKeys& keys, |
|
|
|
uint16_t keyType, uint16_t keyLen, const uint8_t * encryptionPublicKey, |
|
|
|
uint16_t keyType, uint16_t keyLen, const uint8_t * encryptionPublicKey, |
|
|
|
std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> > tunnels): |
|
|
|
std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> > tunnels): |
|
|
|
LocalLeaseSet (identity, nullptr, 0) |
|
|
|
LocalLeaseSet (keys.GetPublic (), nullptr, 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
auto identity = keys.GetPublic (); |
|
|
|
// assume standard LS2
|
|
|
|
// assume standard LS2
|
|
|
|
int num = tunnels.size (); |
|
|
|
int num = tunnels.size (); |
|
|
|
if (num > MAX_NUM_LEASES) num = MAX_NUM_LEASES; |
|
|
|
if (num > MAX_NUM_LEASES) num = MAX_NUM_LEASES; |
|
|
|
m_BufferLen = identity->GetFullLen () + 4/*published*/ + 2/*expires*/ + 2/*flag*/ + 2/*properties len*/ + |
|
|
|
m_BufferLen = identity->GetFullLen () + 4/*published*/ + 2/*expires*/ + 2/*flag*/ + 2/*properties len*/ + |
|
|
|
1/*num keys*/ + 2/*key type*/ + 2/*key len*/ + keyLen/*key*/ + 1/*num leases*/ + num*LEASE2_SIZE + identity->GetSignatureLen (); |
|
|
|
1/*num keys*/ + 2/*key type*/ + 2/*key len*/ + keyLen/*key*/ + 1/*num leases*/ + num*LEASE2_SIZE + identity->GetSignatureLen (); |
|
|
|
|
|
|
|
uint16_t flags = 0; |
|
|
|
|
|
|
|
if (keys.IsOfflineSignature ()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
flags |= LEASESET2_FLAG_OFFLINE_KEYS; |
|
|
|
|
|
|
|
m_BufferLen += keys.GetOfflineSignature ().size (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_Buffer = new uint8_t[m_BufferLen + 1]; |
|
|
|
m_Buffer = new uint8_t[m_BufferLen + 1]; |
|
|
|
m_Buffer[0] = storeType; |
|
|
|
m_Buffer[0] = storeType; |
|
|
|
// LS2 header
|
|
|
|
// LS2 header
|
|
|
@ -597,6 +605,13 @@ namespace data |
|
|
|
htobe32buf (m_Buffer + offset, timestamp); offset += 4; // published timestamp (seconds)
|
|
|
|
htobe32buf (m_Buffer + offset, timestamp); offset += 4; // published timestamp (seconds)
|
|
|
|
uint8_t * expiresBuf = m_Buffer + offset; offset += 2; // expires, fill later
|
|
|
|
uint8_t * expiresBuf = m_Buffer + offset; offset += 2; // expires, fill later
|
|
|
|
htobe16buf (m_Buffer + offset, 0); offset += 2; // flags
|
|
|
|
htobe16buf (m_Buffer + offset, 0); offset += 2; // flags
|
|
|
|
|
|
|
|
if (keys.IsOfflineSignature ()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// offline signature
|
|
|
|
|
|
|
|
const auto& offlineSignature = keys.GetOfflineSignature (); |
|
|
|
|
|
|
|
memcpy (m_Buffer + offset, offlineSignature.data (), offlineSignature.size ()); |
|
|
|
|
|
|
|
offset += offlineSignature.size (); |
|
|
|
|
|
|
|
} |
|
|
|
htobe16buf (m_Buffer + offset, 0); offset += 2; // properties len
|
|
|
|
htobe16buf (m_Buffer + offset, 0); offset += 2; // properties len
|
|
|
|
// keys
|
|
|
|
// keys
|
|
|
|
m_Buffer[offset] = 1; offset++; // 1 key
|
|
|
|
m_Buffer[offset] = 1; offset++; // 1 key
|
|
|
@ -621,7 +636,8 @@ namespace data |
|
|
|
SetExpirationTime (expirationTime*1000LL); |
|
|
|
SetExpirationTime (expirationTime*1000LL); |
|
|
|
auto expires = expirationTime - timestamp; |
|
|
|
auto expires = expirationTime - timestamp; |
|
|
|
htobe16buf (expiresBuf, expires > 0 ? expires : 0); |
|
|
|
htobe16buf (expiresBuf, expires > 0 ? expires : 0); |
|
|
|
// we don't sign it yet. must be signed later on
|
|
|
|
// sign
|
|
|
|
|
|
|
|
keys.Sign (m_Buffer, offset, m_Buffer + offset); // LS + leading store type
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LocalLeaseSet2::LocalLeaseSet2 (uint8_t storeType, std::shared_ptr<const IdentityEx> identity, const uint8_t * buf, size_t len): |
|
|
|
LocalLeaseSet2::LocalLeaseSet2 (uint8_t storeType, std::shared_ptr<const IdentityEx> identity, const uint8_t * buf, size_t len): |
|
|
|