Overview
Comment: | Updated to free old data (not thread safe, but also not used at the moment) and minor cleanups for CVFS obsfucation |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
284eae926e2a6540726eebd459d4f9d5 |
User & Date: | rkeene on 2014-11-23 20:02:18 |
Other Links: | manifest | tags |
Context
2014-11-24
| ||
03:14 | Added script to make kits for publishing check-in: f6757a3c22 user: rkeene tags: trunk | |
2014-11-23
| ||
20:02 | Updated to free old data (not thread safe, but also not used at the moment) and minor cleanups for CVFS obsfucation check-in: 284eae926e user: rkeene tags: trunk | |
02:55 | Documented obsfucated CVFS support check-in: ae6b7036ca user: rkeene tags: trunk | |
Changes
Modified kitsh/buildsrc/kitsh-0.0/cvfs_data.c from [981ef56829] to [010e908a77].
︙ | ︙ | |||
162 163 164 165 166 167 168 | if (finfo == NULL) { Tcl_SetResult(interp, "No such file or directory", TCL_STATIC); return(TCL_ERROR); } | | | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | if (finfo == NULL) { Tcl_SetResult(interp, "No such file or directory", TCL_STATIC); return(TCL_ERROR); } if (finfo->type == CVFS_FILETYPE_ENCRYPTED_FILE) { cmd_decryptFile = getCmdDecryptFile(hashkey); if (cmd_decryptFile != NULL) { cmd_decryptFile(file, finfo); } } |
︙ | ︙ |
Modified kitsh/buildsrc/kitsh-0.0/dir2c.tcl from [a9768c9e59] to [18ee9a3f9a].
︙ | ︙ | |||
120 121 122 123 124 125 126 | switch -- $key(method) { "rotate_subst" { switch -- $target { "c" { set retval ".type = CVFS_KEYTYPE_ROTATE_SUBST,\n" append retval ".typedata.rotate_subst.rotate_length = $key(rotate_length),\n" | | | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | switch -- $key(method) { "rotate_subst" { switch -- $target { "c" { set retval ".type = CVFS_KEYTYPE_ROTATE_SUBST,\n" append retval ".typedata.rotate_subst.rotate_length = $key(rotate_length),\n" append retval ".typedata.rotate_subst.subst = (unsigned char *) [stringify $key(subst)]\n" return $retval } } } } |
︙ | ︙ | |||
240 241 242 243 244 245 246 | # ifndef LOADED_CVFS_COMMON # define LOADED_CVFS_COMMON 1 typedef enum { CVFS_FILETYPE_FILE = 0, CVFS_FILETYPE_DIR = 1, | < | > > | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | # ifndef LOADED_CVFS_COMMON # define LOADED_CVFS_COMMON 1 typedef enum { CVFS_FILETYPE_FILE = 0, CVFS_FILETYPE_DIR = 1, CVFS_FILETYPE_ENCRYPTED_FILE = 2, CVFS_FILETYPE_COMPRESSED_FILE = 4, } cvfs_filetype_t; struct cvfs_data { const char * name; unsigned long index; unsigned long size; cvfs_filetype_t type; const unsigned char * data; int free; }; typedef enum { CVFS_KEYTYPE_ROTATE_SUBST = 0, } cvfs_keytype_t; struct cvfs_key { |
︙ | ︙ | |||
281 282 283 284 285 286 287 | } h &= ((~g) & 0xffffffffLU); } return(h); } | < | 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | } 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]; |
︙ | ︙ | |||
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | } # endif /* !LOADED_CVFS_COMMON */} puts "" puts "static struct cvfs_data ${code_tag}_data\[\] = {" puts "\t{" puts "\t\t.name = NULL," puts "\t\t.index = 0," puts "\t\t.type = 0," puts "\t\t.size = 0," puts "\t\t.data = NULL," puts "\t}," for {set idx 1} {$idx < [llength $files]} {incr idx} { set file [lindex $files $idx] set shortfile [shorten_file $startdir $file] unset -nocomplain finfo type file stat $file finfo switch -- $finfo(type) { "file" { set size $finfo(size) set fd [open $file] fconfigure $fd -translation binary set data [read $fd] close $fd if {$obsfucate} { | > > | > | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | } # endif /* !LOADED_CVFS_COMMON */} puts "" puts "static struct cvfs_data ${code_tag}_data\[\] = {" puts "\t{" puts "\t\t/* Index 0 cannot be used because we use the value 0 to represent failure */" puts "\t\t.name = NULL," puts "\t\t.index = 0," puts "\t\t.type = 0," puts "\t\t.size = 0," puts "\t\t.data = NULL," puts "\t\t.free = 0," puts "\t}," for {set idx 1} {$idx < [llength $files]} {incr idx} { set file [lindex $files $idx] set shortfile [shorten_file $startdir $file] unset -nocomplain finfo type file stat $file finfo switch -- $finfo(type) { "file" { set size $finfo(size) set fd [open $file] fconfigure $fd -translation binary set data [read $fd] close $fd if {$obsfucate} { set type "CVFS_FILETYPE_ENCRYPTED_FILE" set data "(unsigned char *) [stringify [encrypt $data $obsfucation_key]]" } else { set type "CVFS_FILETYPE_FILE" set data "(unsigned char *) [stringify $data]" } } "directory" { set type "CVFS_FILETYPE_DIR" set data "NULL" set size 0 } } puts "\t{" puts "\t\t.name = \"$shortfile\"," puts "\t\t.index = $idx," puts "\t\t.type = $type," puts "\t\t.size = $size," puts "\t\t.data = $data," puts "\t\t.free = 0," puts "\t}," } puts "};" puts "" puts "static unsigned long ${code_tag}_lookup_index(const char *path) {" puts "\tswitch (cvfs_hash((unsigned char *) path)) {" |
︙ | ︙ | |||
502 503 504 505 506 507 508 | puts "\treturn(num_children);" puts "}" puts "" 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"]] };" | | | > > > > > > > > > | 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 | puts "\treturn(num_children);" puts "}" puts "" 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 = malloc(finfo->size);" puts "\tdecrypt_ret = cvfs_decrypt(new_data, finfo->data, finfo->size, &key);" puts "\tif (decrypt_ret != 0) {" puts "\t\tfree(new_data);" puts "" puts "\t\treturn;" puts "\t}" puts "" puts "\tfree_old_data = finfo->free;" puts "\told_data = (void *) finfo->data;" puts "" puts "\tfinfo->data = new_data;" puts "\tfinfo->free = 1;" puts "\tfinfo->type = CVFS_FILETYPE_FILE;" puts "" puts "\tif (free_old_data) {" puts "\t\tfree(old_data);" puts "\t}" puts "\treturn;" puts "}" puts "" } puts "# ifdef CVFS_MAKE_LOADABLE" |
︙ | ︙ |