Compare commits

...

2 Commits

1 changed files with 5 additions and 3 deletions

View File

@ -48,6 +48,7 @@ int encrypt(packet *packet, unsigned char *outBuf, UINT16 *len, unsigned char *k
unsigned char *m = packet->Data;
// additional text
packet->DataType = __bswap_16(packet->DataType);
int adlen = sizeof(packet->DataType);
unsigned char *ad = (unsigned char *)&packet->DataType;
@ -66,8 +67,6 @@ int encrypt(packet *packet, unsigned char *outBuf, UINT16 *len, unsigned char *k
}
// type 0 1
// Swap after adding it as additional data
packet->DataType = __bswap_16(packet->DataType);
int loc = 0;
memcpy(&outBuf[loc], &packet->DataType, sizeof(UINT16));
loc += sizeof(UINT16);
@ -102,6 +101,7 @@ int decrypt(packetEx *packet, unsigned char *inBuf, UINT16 len, unsigned char *k
{
return 1;
}
DEBUG_PRINT("line %d\n", __LINE__);
memcpy(&packet->DataType, &inBuf[loc], sizeof(UINT16));
loc += sizeof(UINT16);
@ -110,7 +110,6 @@ int decrypt(packetEx *packet, unsigned char *inBuf, UINT16 len, unsigned char *k
memcpy(&packet->Size, &inBuf[loc], sizeof(UINT16));
loc += sizeof(UINT16);
packet->DataType = __bswap_16(packet->DataType);
packet->Size = __bswap_16(packet->Size);
packet->Id = __bswap_32(packet->Id);
@ -143,6 +142,9 @@ int decrypt(packetEx *packet, unsigned char *inBuf, UINT16 len, unsigned char *k
DEBUG_PRINT("line %d mlen:%d clen:%d\n", __LINE__, mlen, clen);
int ret = romulus_m_decrypt(m, &mlen, 0, c, clen, ad, adlen, npub, key);
DEBUG_PRINT("line %d packet:%d, mlen %d\n", __LINE__, packet->Size, mlen);
// swap after decrypt, we sign the big endian bytes
packet->DataType = __bswap_16(packet->DataType);
if (ret == 0)
{
DEBUG_PRINT("line %d\n", __LINE__);