MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / EncipherBlock

Function EncipherBlock

src/_PlatformBase.h:275–287  ·  view source on GitHub ↗

Encrypts data using XTEA block cipher, with OS specific method to get machine-specific key */

Source from the content-addressed store, hash-verified

273
274/* Encrypts data using XTEA block cipher, with OS specific method to get machine-specific key */
275static void EncipherBlock(cc_uint32* v, const cc_uint32* key, cc_string* dst) {
276 cc_uint32 v0 = v[0], v1 = v[1], sum = 0, delta = 0x9E3779B9;
277 int i;
278
279 for (i = 0; i < 12; i++)
280 {
281 v0 += (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + key[sum & 3]);
282 sum += delta;
283 v1 += (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + key[(sum>>11) & 3]);
284 }
285 v[0] = v0; v[1] = v1;
286 String_AppendAll(dst, v, 8);
287}
288
289static void DecipherBlock(cc_uint32* v, const cc_uint32* key) {
290 cc_uint32 v0 = v[0], v1 = v[1], delta = 0x9E3779B9, sum = delta * 12;

Callers 1

Platform_EncryptFunction · 0.85

Calls 1

String_AppendAllFunction · 0.85

Tested by

no test coverage detected