summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-08-12 23:51:04 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-08-12 23:51:04 +0000
commitbc628fe5ce01c8e6e34eeb940949059ad8ff9a5a (patch)
tree842fd24f0ed3243d773e5fab4e3a99a796898b16
parent1e3ed744798aea993d884b449d99f2c4e4387747 (diff)
downloadrockbox-bc628fe5ce01c8e6e34eeb940949059ad8ff9a5a.tar.gz
rockbox-bc628fe5ce01c8e6e34eeb940949059ad8ff9a5a.zip
Zenutils:
* Make update_extract work again * Add other players to zen_crypt * Change stricmp() calls to strcasecmp() in zen_crypt git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18264 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--utils/zenutils/source/shared/updater.cpp19
-rw-r--r--utils/zenutils/source/zen_crypt/main.cpp59
2 files changed, 61 insertions, 17 deletions
diff --git a/utils/zenutils/source/shared/updater.cpp b/utils/zenutils/source/shared/updater.cpp
index 25d8452992..3944863533 100644
--- a/utils/zenutils/source/shared/updater.cpp
+++ b/utils/zenutils/source/shared/updater.cpp
@@ -99,6 +99,24 @@ bool zen::find_firmware_archive(const std::string& filename, dword& va, dword& p
99 99
100bool zen::crypt_firmware(const char* key, byte* buffer, size_t len) 100bool zen::crypt_firmware(const char* key, byte* buffer, size_t len)
101{ 101{
102#if 1
103 char key_cpy[255];
104 unsigned int i;
105 unsigned int tmp = 0;
106 int key_length = strlen(key);
107
108 strcpy(key_cpy, key);
109 for(i=0; i < strlen(key); i++)
110 key_cpy[i] = key[i] - 1;
111
112 for(i=0; i < len; i++)
113 {
114 buffer[i] ^= key_cpy[tmp] | 0x80;
115 tmp = (tmp + 1) % key_length;
116 }
117
118 return true;
119#else
102 // Determine if the key length is dword aligned. 120 // Determine if the key length is dword aligned.
103 int keylen = strlen(key); 121 int keylen = strlen(key);
104 int keylen_rem = keylen % sizeof(dword); 122 int keylen_rem = keylen % sizeof(dword);
@@ -148,4 +166,5 @@ bool zen::crypt_firmware(const char* key, byte* buffer, size_t len)
148 } 166 }
149 167
150 return true; 168 return true;
169#endif
151} 170}
diff --git a/utils/zenutils/source/zen_crypt/main.cpp b/utils/zenutils/source/zen_crypt/main.cpp
index 9944ba97f8..84fee89bd2 100644
--- a/utils/zenutils/source/zen_crypt/main.cpp
+++ b/utils/zenutils/source/zen_crypt/main.cpp
@@ -47,23 +47,35 @@ 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_v1; // 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
57static const char VERSION[] = "0.1"; 57static const char VERSION[] = "0.2";
58 58
59static const char null_key_v1[] = "CTL:N0MAD|PDE0.SIGN."; 59static const char null_key_v1[] = "CTL:N0MAD|PDE0.SIGN.";
60static const char null_key_v2[] = "CTL:N0MAD|PDE0.DPMP."; 60static const char null_key_v2[] = "CTL:N0MAD|PDE0.DPMP.";
61static const char null_key_v3[] = "CTL:N0MAD|PDE0.DPFP.";
62static const char null_key_v4[] = "CTL:Z3N07|PDE0.DPMP.";
61 63
62static const char fresc_key[] = "Copyright (C) CTL. -" 64static const char fresc_key_v1[] = "Copyright (C) CTL. -"
63 " zN0MAD iz v~p0wderful!"; 65 " zN0MAD iz v~p0wderful!";
66static const char fresc_key_v2[] = ""; /* Unknown atm */
64 67
65static const char tl_zvm_key[] = "1sN0TM3D az u~may th1nk*" 68static const char tl_zvm_key[] = "1sN0TM3D az u~may th1nk*"
66 "Creative Zen Vision:M"; 69 "Creative Zen Vision:M";
70static const char tl_zvm60_key[] = "1sN0TM3D az u~may th1nk*"
71 "Creative Zen Vision:M (D"
72 "VP-HD0004)";
73static const char tl_zen_key[] = "1sN0TM3D az u~may th1nk*"
74 "Creative ZEN";
75static const char tl_zenxf_key[] = "1sN0TM3D az u~may th1nk*"
76 "Creative ZEN X-Fi";
77static const char tl_zv_key[] = "1sN0TM3D az u~may th1nk*"
78 "Creative Zen Vision";
67static const char tl_zvw_key[] = "1sN0TM3D az u~may th1nk*" 79static const char tl_zvw_key[] = "1sN0TM3D az u~may th1nk*"
68 "Creative ZEN Vision W"; 80 "Creative ZEN Vision W";
69static const char tl_zm_key[] = "1sN0TM3D az u~may th1nk*" 81static const char tl_zm_key[] = "1sN0TM3D az u~may th1nk*"
@@ -78,16 +90,29 @@ static const char tl_zt_key[] = "1sN0TM3D az u~may th1nk*"
78 "Creative Zen Touch"; 90 "Creative Zen Touch";
79static const char tl_zx_key[] = "1sN0TM3D az u~may th1nk*" 91static const char tl_zx_key[] = "1sN0TM3D az u~may th1nk*"
80 "NOMAD Jukebox Zen Xtra"; 92 "NOMAD Jukebox Zen Xtra";
93static const char tl_zenv_key[] = "1sN0TM3D az u~may th1nk*"
94 "Creative ZEN V";
95static const char tl_zenvp_key[] = "1sN0TM3D az u~may th1nk*"
96 "Creative ZEN V Plus";
97static const char tl_zenvv_key[] = "1sN0TM3D az u~may th1nk*"
98 "Creative ZEN V (Video)";
81 99
82player_info_t players[] = { 100player_info_t players[] = {
83 {"Vision:M", null_key_v2, fresc_key, tl_zvm_key, false}, 101 {"Zen Vision:M", null_key_v2, fresc_key_v1, tl_zvm_key, false},
84 {"Vision W", null_key_v2, fresc_key, tl_zvw_key, false}, 102 {"Zen Vision:M 60GB", null_key_v2, fresc_key_v1, tl_zvm60_key, false},
85 {"Micro", null_key_v1, fresc_key, tl_zm_key, true}, 103 {"ZEN", null_key_v4, fresc_key_v2, tl_zen_key, false},
86 {"MicroPhoto", null_key_v1, fresc_key, tl_zmp_key, true}, 104 {"ZEN X-Fi", null_key_v4, fresc_key_v2, tl_zenxf_key, false},
87 {"Sleek", null_key_v1, fresc_key, tl_zs_key, true}, 105 {"Zen Vision", null_key_v2, fresc_key_v1, tl_zv_key, false},
88 {"SleekPhoto", null_key_v1, fresc_key, tl_zsp_key, true}, 106 {"Zen Vision W", null_key_v2, fresc_key_v1, tl_zvw_key, false},
89 {"Touch", null_key_v1, fresc_key, tl_zt_key, true}, 107 {"Zen Micro", null_key_v1, fresc_key_v1, tl_zm_key, true},
90 {"Xtra", null_key_v1, fresc_key, tl_zx_key, true}, 108 {"Zen MicroPhoto", null_key_v1, fresc_key_v1, tl_zmp_key, true},
109 {"Zen Sleek", null_key_v1, fresc_key_v1, tl_zs_key, true},
110 {"Zen SleekPhoto", null_key_v1, fresc_key_v1, tl_zsp_key, true},
111 {"Zen Touch", null_key_v1, fresc_key_v1, tl_zt_key, true},
112 {"Zen Xtra", null_key_v1, fresc_key_v1, tl_zx_key, true},
113 {"Zen V", null_key_v3, fresc_key_v1, tl_zenv_key, false},
114 {"Zen V Plus", null_key_v3, fresc_key_v1, tl_zenvp_key, false},
115 {"Zen V Video", null_key_v3, fresc_key_v1, tl_zenvv_key, false},
91 {NULL, NULL, NULL, NULL, false} 116 {NULL, NULL, NULL, NULL, false}
92}; 117};
93 118
@@ -96,7 +121,7 @@ player_info_t* find_player_info(std::string player)
96{ 121{
97 for (int i = 0; players[i].name != NULL; i++) 122 for (int i = 0; players[i].name != NULL; i++)
98 { 123 {
99 if (!stricmp(players[i].name, player.c_str())) 124 if (!strcasecmp(players[i].name, player.c_str()))
100 { 125 {
101 return &players[i]; 126 return &players[i];
102 } 127 }
@@ -444,8 +469,8 @@ bool decrypt(shared::bytes& data, int mode, player_info_t* pi,
444 std::cout << "[*] Decrypting input file..." << std::endl; 469 std::cout << "[*] Decrypting input file..." << std::endl;
445 470
446 dword iv[2] = {shared::swap(data.size()), 0}; 471 dword iv[2] = {shared::swap(data.size()), 0};
447 if (!zen::bf_cbc_decrypt((const byte*)pi->fresc_key, 472 if (!zen::bf_cbc_decrypt((const byte*)pi->fresc_key_v1,
448 strlen(pi->fresc_key)+1, &data[0], 473 strlen(pi->fresc_key_v1)+1, &data[0],
449 data.size(), (const byte*)iv)) 474 data.size(), (const byte*)iv))
450 { 475 {
451 std::cerr << "Failed to decrypt the input file." << std::endl; 476 std::cerr << "Failed to decrypt the input file." << std::endl;
@@ -555,11 +580,11 @@ int process_arguments(int argc, char*argv[])
555 std::string name = cl.next(""); 580 std::string name = cl.next("");
556 if (!name.empty()) 581 if (!name.empty())
557 { 582 {
558 if (!stricmp(name.c_str(), "CENC")) 583 if (!strcasecmp(name.c_str(), "CENC"))
559 mode = mode_cenc; 584 mode = mode_cenc;
560 else if (!stricmp(name.c_str(), "FRESC")) 585 else if (!strcasecmp(name.c_str(), "FRESC"))
561 mode = mode_fresc; 586 mode = mode_fresc;
562 else if (!stricmp(name.c_str(), "TL")) 587 else if (!strcasecmp(name.c_str(), "TL"))
563 mode = mode_tl; 588 mode = mode_tl;
564 } 589 }
565 if (mode == mode_none) 590 if (mode == mode_none)