Use symbolic data header length

This commit is contained in:
Davide De Rosa 2018-09-18 23:12:49 +02:00
parent aa39414a77
commit f6ee187db7
2 changed files with 4 additions and 4 deletions

View File

@ -244,7 +244,7 @@ const NSInteger CryptoAEADTagLength = 16;
peerId &= 0xffffff;
if (peerId == PacketPeerIdDisabled) {
self.headerLength = 1;
self.headerLength = PacketOpcodeLength;
self.crypto.extraLength = PacketIdLength;
self.crypto.extraPacketIdOffset = 0;
self.setDataHeader = ^(uint8_t *to, uint8_t key) {
@ -253,7 +253,7 @@ const NSInteger CryptoAEADTagLength = 16;
self.checkPeerId = NULL;
}
else {
self.headerLength = 4;
self.headerLength = PacketOpcodeLength + PacketPeerIdLength;
self.crypto.extraLength = self.headerLength + PacketIdLength;
self.crypto.extraPacketIdOffset = self.headerLength;
self.setDataHeader = ^(uint8_t *to, uint8_t key) {

View File

@ -286,14 +286,14 @@ const NSInteger CryptoCBCMaxHMACLength = 100;
peerId &= 0xffffff;
if (peerId == PacketPeerIdDisabled) {
self.headerLength = 1;
self.headerLength = PacketOpcodeLength;
self.setDataHeader = ^(uint8_t *to, uint8_t key) {
PacketHeaderSet(to, PacketCodeDataV1, key, nil);
};
self.checkPeerId = NULL;
}
else {
self.headerLength = 4;
self.headerLength = PacketOpcodeLength + PacketPeerIdLength;
self.setDataHeader = ^(uint8_t *to, uint8_t key) {
PacketHeaderSetDataV2(to, key, peerId);
};