Custom encryption

As an optional feature, the TeamSpeak 3 SDK allows users to implement custom encryption and decryption for all network traffic. Custom encryption replaces the default AES encryption implemented by the TeamSpeak 3 SDK. A possible reason to apply own encryption might be to make ones TeamSpeak 3 client/server incompatible to other SDK implementations.

Custom encryption must be implemented the same way in both the client and server.

[Note]Note

If you do not want to use this feature, just don't implement the two encryption callbacks.

To encrypt outgoing data, implement the callback:

void onCustomPacketEncryptEvent(dataToSend,  
 sizeOfData); 
char** dataToSend;
unsigned int* sizeOfData;
 


To decrypt incoming data, implement the callback:

void onCustomPacketDecryptEvent(dataReceived,  
 dataReceivedSize); 
char** dataReceived;
unsigned int* dataReceivedSize;
 

Example code implementing a very simple XOR custom encryption and decryption (also see the SDK examples):

void onCustomPacketEncryptEvent(char** dataToSend, unsigned int* sizeOfData) {
    unsigned int i;
    for(i = 0; i < *sizeOfData; i++) {
        (*dataToSend)[i] ^= CUSTOM_CRYPT_KEY;
    }
}

void onCustomPacketDecryptEvent(char** dataReceived, unsigned int* dataReceivedSize) {
    unsigned int i;
    for(i = 0; i < *dataReceivedSize; i++) {
        (*dataReceived)[i] ^= CUSTOM_CRYPT_KEY;
    }
}