Files
TS_WIFILED/docs/client_html/ar01s25.html
2020-04-04 17:21:07 +02:00

25 lines
6.2 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Custom encryption</title><link rel="stylesheet" href="ts3doc.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.74.0"><link rel="home" href="index.html" title="TeamSpeak 3 Client SDK Developer Manual"><link rel="up" href="index.html" title="TeamSpeak 3 Client SDK Developer Manual"><link rel="prev" href="ar01s24.html" title="Muting clients locally"><link rel="next" href="ar01s26.html" title="Custom passwords"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><img id="logo" src="images/logo.png"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Custom encryption</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ar01s24.html"><img src="images/prev.png" alt="Prev"></a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ar01s26.html"><img src="images/next.png" alt="Next"></a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="encrypt"></a>Custom encryption</h2></div></div></div><p>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.</p><p>Custom encryption must be implemented the same way in both the client and server.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>If you do not want to use this feature, just don't implement the two encryption callbacks.</p></td></tr></table></div><p>
To encrypt outgoing data, implement the callback:
</p><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">onCustomPacketEncryptEvent</b>(</code></td><td><var class="pdparam">dataToSend</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">sizeOfData</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>char** <var class="pdparam">dataToSend</var></code>;<br><code>unsigned int* <var class="pdparam">sizeOfData</var></code>;</div><div class="funcprototype-spacer"> </div></div><p>
<a class="indexterm" name="idm44835433154080"></a>
</p><div class="itemizedlist"><ul type="disc"><li><p><em class="parameter"><code>dataToSend</code></em></p><p>Pointer to an array with the outgoing data to be encrypted.</p><p>Apply your custom encryption to the data array. If the encrypted data is smaller than sizeOfData, write your encrypted data into the existing memory of dataToSend. If your encrypted data is larger, you need to allocate memory and redirect the pointer dataToSend. You need to take care of freeing your own allocated memory yourself. The memory allocated by the SDK, to which dataToSend is originally pointing to, must not be freed.</p></li><li><p><em class="parameter"><code>sizeOfData</code></em></p><p>Pointer to an integer value containing the size of the data array.</p></li></ul></div><p>
</p><div class="literallayout"><p><br>
</p></div><p>
To decrypt incoming data, implement the callback:
</p><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">onCustomPacketDecryptEvent</b>(</code></td><td><var class="pdparam">dataReceived</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">dataReceivedSize</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>char** <var class="pdparam">dataReceived</var></code>;<br><code>unsigned int* <var class="pdparam">dataReceivedSize</var></code>;</div><div class="funcprototype-spacer"> </div></div><p>
<a class="indexterm" name="idm44835433144960"></a>
</p><div class="itemizedlist"><ul type="disc"><li><p><em class="parameter"><code>dataReceived</code></em></p><p>Pointer to an array with the received data to be decrypted.</p><p>Apply your custom decryption to the data array. If the decrypted data is smaller than dataReceivedSize, write your decrypted data into the existing memory of dataReceived. If your decrypted data is larger, you need to allocate memory and redirect the pointer dataReceived. You need to take care of freeing your own allocated memory yourself. The memory allocated by the SDK, to which dataReceived is originally pointing to, must not be freed.</p></li><li><p><em class="parameter"><code>dataReceivedSize</code></em></p><p>Pointer to an integer value containing the size of the data array.</p></li></ul></div><p>
</p><p>Example code implementing a very simple XOR custom encryption and decryption (also see the SDK examples):</p><pre class="programlisting">void onCustomPacketEncryptEvent(char** dataToSend, unsigned int* sizeOfData) {
unsigned int i;
for(i = 0; i &lt; *sizeOfData; i++) {
(*dataToSend)[i] ^= CUSTOM_CRYPT_KEY;
}
}
void onCustomPacketDecryptEvent(char** dataReceived, unsigned int* dataReceivedSize) {
unsigned int i;
for(i = 0; i &lt; *dataReceivedSize; i++) {
(*dataReceived)[i] ^= CUSTOM_CRYPT_KEY;
}
}</pre></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ar01s24.html"><img src="images/prev.png" alt="Prev"></a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="ar01s26.html"><img src="images/next.png" alt="Next"></a></td></tr><tr><td width="40%" align="left" valign="top">Muting clients locally </td><td width="20%" align="center"><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a></td><td width="40%" align="right" valign="top"> Custom passwords</td></tr></table></div></body></html>