Diff

Differences From Artifact [74a40bc096]:

To Artifact [990f9a7e47]:


283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
		}
		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;
	}







|




|







283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
		}
		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;
	}
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
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;"







|







510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
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;"