diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2008-08-28 13:37:37 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2008-08-28 13:37:37 +0000 |
commit | 26e0a9766da3cf375483d40f988813276bda3741 (patch) | |
tree | 897a5d1088d7ca7df06b0d70770af6df7b0ea1c0 | |
parent | a3a54503994bb6b29180b1edcac166f2bc6ea54a (diff) | |
download | rockbox-26e0a9766da3cf375483d40f988813276bda3741.tar.gz rockbox-26e0a9766da3cf375483d40f988813276bda3741.zip |
mkzenboot:
* Make it compile using MingW on Windows
* Add other devices
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18359 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | tools/Makefile | 3 | ||||
-rw-r--r-- | tools/mkzenboot.c | 104 |
2 files changed, 96 insertions, 11 deletions
diff --git a/tools/Makefile b/tools/Makefile index 2e3f1e0fc1..0bd0209b86 100644 --- a/tools/Makefile +++ b/tools/Makefile | |||
@@ -57,6 +57,9 @@ mkzenboot.o: mkzenboot.c | |||
57 | mkzenboot: mkzenboot.o hmac-sha1.o | 57 | mkzenboot: mkzenboot.o hmac-sha1.o |
58 | $(SILENT)$(CC) $(LDFLAGS) -lz $+ -o $@ | 58 | $(SILENT)$(CC) $(LDFLAGS) -lz $+ -o $@ |
59 | 59 | ||
60 | mkzenboot.exe: mkzenboot.o hmac-sha1.o | ||
61 | $(SILENT)$(CC) $(LDFLAGS) -lz $+ C:\MingW\lib\libz.a -o $@ | ||
62 | |||
60 | lngdump: lngdump.c | 63 | lngdump: lngdump.c |
61 | $(SILENT)$(CC) $(CFLAGS) $+ -o $@ | 64 | $(SILENT)$(CC) $(CFLAGS) $+ -o $@ |
62 | 65 | ||
diff --git a/tools/mkzenboot.c b/tools/mkzenboot.c index 2ed9284583..494838833a 100644 --- a/tools/mkzenboot.c +++ b/tools/mkzenboot.c | |||
@@ -777,11 +777,75 @@ static inline uint32_t swap(uint32_t val) | |||
777 | | ((val & 0xFF000000) >> 24); | 777 | | ((val & 0xFF000000) >> 24); |
778 | } | 778 | } |
779 | 779 | ||
780 | const char *tl_key = "1sN0TM3D az u~may th1nk*" | 780 | static const char null_key_v1[] = "CTL:N0MAD|PDE0.SIGN."; |
781 | "Creative Zen Vision:M"; | 781 | static const char null_key_v2[] = "CTL:N0MAD|PDE0.DPMP."; |
782 | const char *null_key = "CTL:N0MAD|PDE0.DPMP."; | 782 | static const char null_key_v3[] = "CTL:N0MAD|PDE0.DPFP."; |
783 | static const char null_key_v4[] = "CTL:Z3N07|PDE0.DPMP."; | ||
784 | |||
785 | static const char fresc_key_v1[] = "Copyright (C) CTL. -" | ||
786 | " zN0MAD iz v~p0wderful!"; | ||
787 | static const char fresc_key_v2[] = ""; /* Unknown atm */ | ||
788 | |||
789 | static const char tl_zvm_key[] = "1sN0TM3D az u~may th1nk*" | ||
790 | "Creative Zen Vision:M"; | ||
791 | static const char tl_zvm60_key[] = "1sN0TM3D az u~may th1nk*" | ||
792 | "Creative Zen Vision:M (D" | ||
793 | "VP-HD0004)"; | ||
794 | static const char tl_zen_key[] = "1sN0TM3D az u~may th1nk*" | ||
795 | "Creative ZEN"; | ||
796 | static const char tl_zenxf_key[] = "1sN0TM3D az u~may th1nk*" | ||
797 | "Creative ZEN X-Fi"; | ||
798 | static const char tl_zv_key[] = "1sN0TM3D az u~may th1nk*" | ||
799 | "Creative Zen Vision"; | ||
800 | static const char tl_zvw_key[] = "1sN0TM3D az u~may th1nk*" | ||
801 | "Creative ZEN Vision W"; | ||
802 | static const char tl_zm_key[] = "1sN0TM3D az u~may th1nk*" | ||
803 | "Creative Zen Micro"; | ||
804 | static const char tl_zmp_key[] = "1sN0TM3D az u~may th1nk*" | ||
805 | "Creative Zen MicroPhoto"; | ||
806 | static const char tl_zs_key[] = "1sN0TM3D az u~may th1nk*" | ||
807 | "Creative Zen Sleek"; | ||
808 | static const char tl_zsp_key[] = "1sN0TM3D az u~may th1nk*" | ||
809 | "Creative Zen Sleek Photo"; | ||
810 | static const char tl_zt_key[] = "1sN0TM3D az u~may th1nk*" | ||
811 | "Creative Zen Touch"; | ||
812 | static const char tl_zx_key[] = "1sN0TM3D az u~may th1nk*" | ||
813 | "NOMAD Jukebox Zen Xtra"; | ||
814 | static const char tl_zenv_key[] = "1sN0TM3D az u~may th1nk*" | ||
815 | "Creative ZEN V"; | ||
816 | static const char tl_zenvp_key[] = "1sN0TM3D az u~may th1nk*" | ||
817 | "Creative ZEN V Plus"; | ||
818 | static const char tl_zenvv_key[] = "1sN0TM3D az u~may th1nk*" | ||
819 | "Creative ZEN V (Video)"; | ||
820 | struct player_info_t | ||
821 | { | ||
822 | const char* name; | ||
823 | const char* null_key; /* HMAC-SHA1 key */ | ||
824 | const char* fresc_key; /* BlowFish key */ | ||
825 | const char* tl_key; /* BlowFish key */ | ||
826 | bool big_endian; | ||
827 | }; | ||
828 | |||
829 | static struct player_info_t players[] = { | ||
830 | {"Zen Vision:M", null_key_v2, fresc_key_v1, tl_zvm_key, false}, | ||
831 | {"Zen Vision:M 60GB", null_key_v2, fresc_key_v1, tl_zvm60_key, false}, | ||
832 | {"ZEN", null_key_v4, fresc_key_v2, tl_zen_key, false}, | ||
833 | {"ZEN X-Fi", null_key_v4, fresc_key_v2, tl_zenxf_key, false}, | ||
834 | {"Zen Vision", null_key_v2, fresc_key_v1, tl_zv_key, false}, | ||
835 | {"Zen Vision W", null_key_v2, fresc_key_v1, tl_zvw_key, false}, | ||
836 | {"Zen Micro", null_key_v1, fresc_key_v1, tl_zm_key, true}, | ||
837 | {"Zen MicroPhoto", null_key_v1, fresc_key_v1, tl_zmp_key, true}, | ||
838 | {"Zen Sleek", null_key_v1, fresc_key_v1, tl_zs_key, true}, | ||
839 | {"Zen SleekPhoto", null_key_v1, fresc_key_v1, tl_zsp_key, true}, | ||
840 | {"Zen Touch", null_key_v1, fresc_key_v1, tl_zt_key, true}, | ||
841 | {"Zen Xtra", null_key_v1, fresc_key_v1, tl_zx_key, true}, | ||
842 | {"Zen V", null_key_v3, fresc_key_v1, tl_zenv_key, false}, | ||
843 | {"Zen V Plus", null_key_v3, fresc_key_v1, tl_zenvp_key, false}, | ||
844 | {"Zen V Video", null_key_v3, fresc_key_v1, tl_zenvv_key, false}, | ||
845 | {NULL, NULL, NULL, NULL, false} | ||
846 | }; | ||
783 | 847 | ||
784 | int mkboot(const char* infile, const char* bootfile, const char* outfile) | 848 | int mkboot(const char* infile, const char* bootfile, const char* outfile, struct player_info_t *player) |
785 | { | 849 | { |
786 | FILE *infd, *bootfd, *outfd; | 850 | FILE *infd, *bootfd, *outfd; |
787 | unsigned char *buffer, *out_buffer, enc_data[40], hash_key[20]; | 851 | unsigned char *buffer, *out_buffer, enc_data[40], hash_key[20]; |
@@ -976,7 +1040,7 @@ int mkboot(const char* infile, const char* bootfile, const char* outfile) | |||
976 | 1040 | ||
977 | iv[0] = 0; | 1041 | iv[0] = 0; |
978 | iv[1] = swap(le2int(&out_buffer[i+4])); | 1042 | iv[1] = swap(le2int(&out_buffer[i+4])); |
979 | if(bf_cbc_decrypt((unsigned char*)tl_key, strlen(tl_key)+1, &out_buffer[i+8], | 1043 | if(bf_cbc_decrypt((unsigned char*)player->tl_key, strlen(player->tl_key)+1, &out_buffer[i+8], |
980 | le2int(&out_buffer[i+4]), (const unsigned char*)&iv) | 1044 | le2int(&out_buffer[i+4]), (const unsigned char*)&iv) |
981 | == false) | 1045 | == false) |
982 | { | 1046 | { |
@@ -1139,7 +1203,7 @@ int mkboot(const char* infile, const char* bootfile, const char* outfile) | |||
1139 | return -31; | 1203 | return -31; |
1140 | } | 1204 | } |
1141 | 1205 | ||
1142 | hmac_sha1((unsigned char*)null_key, strlen(null_key), &buffer[0], filesize(outfd)-28, &hash_key); | 1206 | hmac_sha1((unsigned char*)player->null_key, strlen(player->null_key), &buffer[0], filesize(outfd)-28, &hash_key); |
1143 | 1207 | ||
1144 | fseek(outfd, filesize(outfd)-20, SEEK_SET); | 1208 | fseek(outfd, filesize(outfd)-20, SEEK_SET); |
1145 | if(fwrite(hash_key, 20, 1, outfd) != 1) | 1209 | if(fwrite(hash_key, 20, 1, outfd) != 1) |
@@ -1159,23 +1223,41 @@ int mkboot(const char* infile, const char* bootfile, const char* outfile) | |||
1159 | #ifdef STANDALONE | 1223 | #ifdef STANDALONE |
1160 | static void usage(void) | 1224 | static void usage(void) |
1161 | { | 1225 | { |
1162 | printf("Usage: mkzenboot <firmware file> <boot file> <output file>\n"); | 1226 | int i; |
1227 | |||
1228 | printf("Usage: mkzenboot <firmware file> <boot file> <output file> <player>\n"); | ||
1229 | printf("Players:\n"); | ||
1230 | for (i = 0; players[i].name != NULL; i++) | ||
1231 | printf(" * \"%s\"\n", players[i].name); | ||
1232 | |||
1163 | exit(1); | 1233 | exit(1); |
1164 | } | 1234 | } |
1165 | 1235 | ||
1166 | int main(int argc, char *argv[]) | 1236 | int main(int argc, char *argv[]) |
1167 | { | 1237 | { |
1168 | char *infile, *bootfile, *outfile; | 1238 | char *infile, *bootfile, *outfile; |
1239 | int i; | ||
1240 | struct player_info_t *player = NULL; | ||
1169 | 1241 | ||
1170 | if(argc < 3) | 1242 | if(argc < 5) |
1171 | { | ||
1172 | usage(); | 1243 | usage(); |
1173 | } | ||
1174 | 1244 | ||
1175 | infile = argv[1]; | 1245 | infile = argv[1]; |
1176 | bootfile = argv[2]; | 1246 | bootfile = argv[2]; |
1177 | outfile = argv[3]; | 1247 | outfile = argv[3]; |
1178 | 1248 | ||
1179 | return mkboot(infile, bootfile, outfile); | 1249 | for (i = 0; players[i].name != NULL; i++) |
1250 | { | ||
1251 | if(!strcasecmp(players[i].name, argv[4])) | ||
1252 | player = &players[i]; | ||
1253 | } | ||
1254 | |||
1255 | if(player == NULL) | ||
1256 | { | ||
1257 | fprintf(stderr, "[ERR] %s isn't listed as a player!\n", argv[4]); | ||
1258 | exit(1); | ||
1259 | } | ||
1260 | |||
1261 | return mkboot(infile, bootfile, outfile, player); | ||
1180 | } | 1262 | } |
1181 | #endif | 1263 | #endif |