Check-in [a400fc4409]
Overview
SHA1:a400fc44090cc4efa252a45dda88f6b3e0b8f43d
Date: 2016-12-09 04:18:12
User: rkeene
Comment:Updated to support partial decryption of data
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2016-12-09
15:00
[05b1c2cb3a] Updated to latest version of tcc4tcl (user: rkeene, tags: trunk)
04:18
[a400fc4409] Updated to support partial decryption of data (user: rkeene, tags: trunk)
2016-11-10
21:14
[0fb3b3b582] Updated to use Tcl allocation routines for memory allocating/releasing (user: rkeene, tags: trunk)
Changes

Modified kitsh/buildsrc/kitsh-0.0/dir2c.tcl from [74a40bc096] to [990f9a7e47].

283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
...
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
		}
		h &= ((~g) & 0xffffffffLU);
	}
        
        return(h);
}

static int cvfs_decrypt(unsigned char *out, const unsigned char *in, unsigned long in_out_length, struct cvfs_key *key) {
	unsigned long i;
	unsigned char in_ch, out_ch;
	int ch_idx;

	for (i = 0; i < in_out_length; i++) {
		in_ch = in[i];

		ch_idx = (in_ch + (i / key->typedata.rotate_subst.rotate_length)) % 256;

		out_ch = key->typedata.rotate_subst.subst[ch_idx];
		out[i] = out_ch;
	}
................................................................................
if {$obsfucate} {
	puts "static void ${code_tag}_decryptFile(const char *path, struct cvfs_data *finfo) {"
	puts "\tstatic struct cvfs_key key = { [string map [list "\n" " "] [encrypt_key_export $obsfucation_key "c"]] };"
	puts "\tunsigned char *new_data, *old_data;"
	puts "\tint decrypt_ret, free_old_data;"
	puts ""
	puts "\tnew_data = (void *) Tcl_Alloc(finfo->size);"
	puts "\tdecrypt_ret = cvfs_decrypt(new_data, finfo->data, finfo->size, &key);"
	puts "\tif (decrypt_ret != 0) {"
	puts "\t\tTcl_Free((void *) new_data);"
	puts ""
	puts "\t\treturn;"
	puts "\t}"
	puts ""
	puts "\tfree_old_data = finfo->free;"







|




|







 







|







283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
...
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
		}
		h &= ((~g) & 0xffffffffLU);
	}
        
        return(h);
}

static int cvfs_decrypt(unsigned char *out, const unsigned char *in, unsigned long offset, unsigned long in_out_length, struct cvfs_key *key) {
	unsigned long i;
	unsigned char in_ch, out_ch;
	int ch_idx;

	for (i = offset; i < in_out_length; i++) {
		in_ch = in[i];

		ch_idx = (in_ch + (i / key->typedata.rotate_subst.rotate_length)) % 256;

		out_ch = key->typedata.rotate_subst.subst[ch_idx];
		out[i] = out_ch;
	}
................................................................................
if {$obsfucate} {
	puts "static void ${code_tag}_decryptFile(const char *path, struct cvfs_data *finfo) {"
	puts "\tstatic struct cvfs_key key = { [string map [list "\n" " "] [encrypt_key_export $obsfucation_key "c"]] };"
	puts "\tunsigned char *new_data, *old_data;"
	puts "\tint decrypt_ret, free_old_data;"
	puts ""
	puts "\tnew_data = (void *) Tcl_Alloc(finfo->size);"
	puts "\tdecrypt_ret = cvfs_decrypt(new_data, finfo->data, 0, finfo->size, &key);"
	puts "\tif (decrypt_ret != 0) {"
	puts "\t\tTcl_Free((void *) new_data);"
	puts ""
	puts "\t\treturn;"
	puts "\t}"
	puts ""
	puts "\tfree_old_data = finfo->free;"