|
|
|
@ -482,19 +482,28 @@ namespace stream
@@ -482,19 +482,28 @@ namespace stream
|
|
|
|
|
uint16_t flags = PACKET_FLAG_SYNCHRONIZE | PACKET_FLAG_FROM_INCLUDED | |
|
|
|
|
PACKET_FLAG_SIGNATURE_INCLUDED | PACKET_FLAG_MAX_PACKET_SIZE_INCLUDED; |
|
|
|
|
if (isNoAck) flags |= PACKET_FLAG_NO_ACK; |
|
|
|
|
bool isOfflineSignature = m_LocalDestination.GetOwner ()->GetPrivateKeys ().IsOfflineSignature (); |
|
|
|
|
if (isOfflineSignature) flags |= PACKET_FLAG_OFFLINE_SIGNATURE; |
|
|
|
|
htobe16buf (packet + size, flags); |
|
|
|
|
size += 2; // flags
|
|
|
|
|
size_t identityLen = m_LocalDestination.GetOwner ()->GetIdentity ()->GetFullLen (); |
|
|
|
|
size_t signatureLen = m_LocalDestination.GetOwner ()->GetIdentity ()->GetSignatureLen (); |
|
|
|
|
htobe16buf (packet + size, identityLen + signatureLen + 2); // identity + signature + packet size
|
|
|
|
|
size_t signatureLen = m_LocalDestination.GetOwner ()->GetPrivateKeys ().GetSignatureLen (); |
|
|
|
|
uint8_t * optionsSize = packet + size; // set options size later
|
|
|
|
|
size += 2; // options size
|
|
|
|
|
m_LocalDestination.GetOwner ()->GetIdentity ()->ToBuffer (packet + size, identityLen); |
|
|
|
|
size += identityLen; // from
|
|
|
|
|
htobe16buf (packet + size, STREAMING_MTU); |
|
|
|
|
size += 2; // max packet size
|
|
|
|
|
if (isOfflineSignature) |
|
|
|
|
{ |
|
|
|
|
const auto& offlineSignature = m_LocalDestination.GetOwner ()->GetPrivateKeys ().GetOfflineSignature (); |
|
|
|
|
memcpy (packet + size, offlineSignature.data (), offlineSignature.size ()); |
|
|
|
|
size += offlineSignature.size (); // offline signature
|
|
|
|
|
} |
|
|
|
|
uint8_t * signature = packet + size; // set it later
|
|
|
|
|
memset (signature, 0, signatureLen); // zeroes for now
|
|
|
|
|
size += signatureLen; // signature
|
|
|
|
|
htobe16buf (optionsSize, packet + size - optionsSize); // actual options size
|
|
|
|
|
size += m_SendBuffer.Get (packet + size, STREAMING_MTU - size); // payload
|
|
|
|
|
m_LocalDestination.GetOwner ()->Sign (packet, size, signature); |
|
|
|
|
} |
|
|
|
|