diff options
Diffstat (limited to 'utils/zenutils/source/zen_crypt/main.cpp')
-rw-r--r-- | utils/zenutils/source/zen_crypt/main.cpp | 60 |
1 files changed, 42 insertions, 18 deletions
diff --git a/utils/zenutils/source/zen_crypt/main.cpp b/utils/zenutils/source/zen_crypt/main.cpp index 532de25078..3442baf738 100644 --- a/utils/zenutils/source/zen_crypt/main.cpp +++ b/utils/zenutils/source/zen_crypt/main.cpp | |||
@@ -46,12 +46,12 @@ enum mode_t | |||
46 | struct player_info_t | 46 | struct player_info_t |
47 | { | 47 | { |
48 | const char* name; | 48 | const char* name; |
49 | const char* null_key; // HMAC-SHA1 key | 49 | const char* null_key; /* HMAC-SHA1 key */ |
50 | const char* fresc_key; // BlowFish key | 50 | const char* fresc_key; /* BlowFish key */ |
51 | const char* tl_key; // BlowFish key | 51 | const char* tl_key; /* BlowFish key */ |
52 | bool big_endian; | 52 | bool big_endian; |
53 | }; | 53 | }; |
54 | }; //namespace | 54 | }; /* namespace */ |
55 | 55 | ||
56 | 56 | ||
57 | static const char VERSION[] = "0.2"; | 57 | static const char VERSION[] = "0.2"; |
@@ -210,7 +210,7 @@ bool sign(shared::bytes& data, player_info_t* pi, const std::string& file, | |||
210 | if (index) | 210 | if (index) |
211 | { | 211 | { |
212 | if (verbose) | 212 | if (verbose) |
213 | std::cout << "[*] Found NULL signature at: " | 213 | std::cout << "[*] Found NULL signature at: 0x" |
214 | << std::hex << index << std::endl; | 214 | << std::hex << index << std::endl; |
215 | 215 | ||
216 | if (verbose) | 216 | if (verbose) |
@@ -317,7 +317,7 @@ bool verify(shared::bytes& data, player_info_t* pi, bool verbose) | |||
317 | return false; | 317 | return false; |
318 | } | 318 | } |
319 | if (verbose) | 319 | if (verbose) |
320 | std::cout << "[*] Found NULL signature at: " | 320 | std::cout << "[*] Found NULL signature at: 0x" |
321 | << std::hex << index << std::endl; | 321 | << std::hex << index << std::endl; |
322 | 322 | ||
323 | if (verbose) | 323 | if (verbose) |
@@ -382,8 +382,26 @@ bool encrypt(shared::bytes& data, int mode, player_info_t* pi, | |||
382 | } | 382 | } |
383 | else if (mode == mode_fresc) | 383 | else if (mode == mode_fresc) |
384 | { | 384 | { |
385 | std::cerr << "FRESC mode is not supported." << std::endl; | 385 | if (verbose) |
386 | return false; | 386 | std::cout << "[*] Encrypting input file..." << std::endl; |
387 | |||
388 | dword iv[2] = {shared::swap(data.size()), 0}; | ||
389 | if (!zen::bf_cbc_encrypt((const byte*)pi->fresc_key, | ||
390 | strlen(pi->fresc_key)+1, &data[0], | ||
391 | data.size(), (const byte*)iv)) | ||
392 | { | ||
393 | std::cerr << "Failed to encrypt the input file." << std::endl; | ||
394 | return false; | ||
395 | } | ||
396 | |||
397 | if (verbose) | ||
398 | std::cout << "[*] Writing file data..." << std::endl; | ||
399 | |||
400 | if (!shared::write_file(file, data, true)) | ||
401 | { | ||
402 | std::cerr << "Failed to save the output file." << std::endl; | ||
403 | return false; | ||
404 | } | ||
387 | } | 405 | } |
388 | else if (mode == mode_tl) | 406 | else if (mode == mode_tl) |
389 | { | 407 | { |
@@ -413,7 +431,7 @@ bool encrypt(shared::bytes& data, int mode, player_info_t* pi, | |||
413 | if (!zen::bf_cbc_encrypt((const byte*)pi->tl_key, strlen(pi->tl_key)+1, | 431 | if (!zen::bf_cbc_encrypt((const byte*)pi->tl_key, strlen(pi->tl_key)+1, |
414 | &outbuf[0], len, (const byte*)iv)) | 432 | &outbuf[0], len, (const byte*)iv)) |
415 | { | 433 | { |
416 | std::cerr << "Failed to decrypt the input file." << std::endl; | 434 | std::cerr << "Failed to encrypt the input file." << std::endl; |
417 | return false; | 435 | return false; |
418 | } | 436 | } |
419 | 437 | ||
@@ -540,9 +558,11 @@ bool decrypt(shared::bytes& data, int mode, player_info_t* pi, | |||
540 | 558 | ||
541 | int process_arguments(int argc, char*argv[]) | 559 | int process_arguments(int argc, char*argv[]) |
542 | { | 560 | { |
543 | //-------------------------------------------------------------------- | 561 | /* |
544 | // Parse input variables. | 562 | -------------------------------------------------------------------- |
545 | //-------------------------------------------------------------------- | 563 | Parse input variables. |
564 | -------------------------------------------------------------------- | ||
565 | */ | ||
546 | 566 | ||
547 | GetPot cl(argc, argv); | 567 | GetPot cl(argc, argv); |
548 | if (cl.size() == 1 || cl.search(2, "-h", "--help")) | 568 | if (cl.size() == 1 || cl.search(2, "-h", "--help")) |
@@ -636,9 +656,11 @@ int process_arguments(int argc, char*argv[]) | |||
636 | pi->big_endian = big_endian; | 656 | pi->big_endian = big_endian; |
637 | 657 | ||
638 | 658 | ||
639 | //-------------------------------------------------------------------- | 659 | /* |
640 | // Read the input file. | 660 | -------------------------------------------------------------------- |
641 | //-------------------------------------------------------------------- | 661 | Read the input file. |
662 | -------------------------------------------------------------------- | ||
663 | */ | ||
642 | 664 | ||
643 | if (verbose) | 665 | if (verbose) |
644 | std::cout << "[*] Reading input file..." << std::endl; | 666 | std::cout << "[*] Reading input file..." << std::endl; |
@@ -651,9 +673,11 @@ int process_arguments(int argc, char*argv[]) | |||
651 | } | 673 | } |
652 | 674 | ||
653 | 675 | ||
654 | //-------------------------------------------------------------------- | 676 | /* |
655 | // Process the input file. | 677 | -------------------------------------------------------------------- |
656 | //-------------------------------------------------------------------- | 678 | Process the input file. |
679 | -------------------------------------------------------------------- | ||
680 | */ | ||
657 | 681 | ||
658 | switch (command) | 682 | switch (command) |
659 | { | 683 | { |