gencertbuf.pl 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. #!/usr/bin/perl
  2. # gencertbuf.pl
  3. # version 1.1
  4. # Updated 07/01/2014
  5. #
  6. # Copyright (C) 2006-2015 wolfSSL Inc.
  7. #
  8. use strict;
  9. use warnings;
  10. # ---- SCRIPT SETTINGS -------------------------------------------------------
  11. # output C header file to write cert/key buffers to
  12. my $outputFile = "./wolfssl/certs_test.h";
  13. # ecc keys and certs to be converted
  14. # Used with HAVE_ECC && USE_CERT_BUFFERS_256
  15. my @fileList_ecc = (
  16. [ "./certs/ecc-client-key.der", "ecc_clikey_der_256" ],
  17. [ "./certs/ecc-client-keyPub.der", "ecc_clikeypub_der_256" ],
  18. [ "./certs/client-ecc-cert.der", "cliecc_cert_der_256" ],
  19. [ "./certs/ecc-key.der", "ecc_key_der_256" ],
  20. [ "./certs/ecc-keyPub.der", "ecc_key_pub_der_256" ],
  21. [ "./certs/statickeys/ecc-secp256r1.der", "ecc_secp_r1_statickey_der_256" ],
  22. [ "./certs/server-ecc-comp.der", "serv_ecc_comp_der_256" ],
  23. [ "./certs/server-ecc-rsa.der", "serv_ecc_rsa_der_256" ],
  24. [ "./certs/server-ecc.der", "serv_ecc_der_256" ],
  25. [ "./certs/ca-ecc-key.der", "ca_ecc_key_der_256" ],
  26. [ "./certs/ca-ecc-cert.der", "ca_ecc_cert_der_256" ],
  27. [ "./certs/ca-ecc384-key.der", "ca_ecc_key_der_384" ],
  28. [ "./certs/ca-ecc384-cert.der", "ca_ecc_cert_der_384" ]
  29. );
  30. # ed25519 keys and certs
  31. # Used with HAVE_ED25519 define.
  32. my @fileList_ed = (
  33. [ "./certs/ed25519/server-ed25519.der", "server_ed25519_cert" ],
  34. [ "./certs/ed25519/server-ed25519-key.der", "server_ed25519_key" ],
  35. [ "./certs/ed25519/ca-ed25519.der", "ca_ed25519_cert" ],
  36. [ "./certs/ed25519/client-ed25519.der", "client_ed25519_cert" ],
  37. [ "./certs/ed25519/client-ed25519-key.der", "client_ed25519_key" ]
  38. );
  39. # x25519 keys and certs
  40. # Used with USE_CERT_BUFFERS_25519 define.
  41. my @fileList_x = (
  42. [ "./certs/statickeys/x25519.der", "x25519_statickey_der" ],
  43. [ "./certs/statickeys/x25519-pub.der", "x25519_pub_statickey_der" ]
  44. );
  45. # 1024-bit certs/keys to be converted
  46. # Used with USE_CERT_BUFFERS_1024 define.
  47. my @fileList_1024 = (
  48. [ "./certs/1024/client-key.der", "client_key_der_1024" ],
  49. [ "./certs/1024/client-keyPub.der", "client_keypub_der_1024" ],
  50. [ "./certs/1024/client-cert.der", "client_cert_der_1024" ],
  51. [ "./certs/1024/dh1024.der", "dh_key_der_1024" ],
  52. [ "./certs/1024/dsa1024.der", "dsa_key_der_1024" ],
  53. [ "./certs/1024/rsa1024.der", "rsa_key_der_1024" ],
  54. [ "./certs/1024/ca-key.der", "ca_key_der_1024"],
  55. [ "./certs/1024/ca-cert.der", "ca_cert_der_1024" ],
  56. [ "./certs/1024/server-key.der", "server_key_der_1024" ],
  57. [ "./certs/1024/server-cert.der", "server_cert_der_1024" ]
  58. );
  59. # 2048-bit certs/keys to be converted
  60. # Used with USE_CERT_BUFFERS_2048 define.
  61. my @fileList_2048 = (
  62. [ "./certs/client-key.der", "client_key_der_2048" ],
  63. [ "./certs/client-keyPub.der", "client_keypub_der_2048" ],
  64. [ "./certs/client-cert.der", "client_cert_der_2048" ],
  65. [ "./certs/dh2048.der", "dh_key_der_2048" ],
  66. [ "./certs/dh-pubkey-2048.der", "dh_pub_key_der_2048" ],
  67. [ "./certs/statickeys/dh-ffdhe2048.der", "dh_ffdhe_statickey_der_2048" ],
  68. [ "./certs/statickeys/dh-ffdhe2048-pub.der", "dh_ffdhe_pub_statickey_der_2048" ],
  69. [ "./certs/dsa-pubkey-2048.der", "dsa_pub_key_der_2048" ],
  70. [ "./certs/dsa2048.der", "dsa_key_der_2048" ],
  71. [ "./certs/rsa2048.der", "rsa_key_der_2048" ],
  72. [ "./certs/ca-key.der", "ca_key_der_2048" ],
  73. [ "./certs/ca-cert.der", "ca_cert_der_2048" ],
  74. [ "./certs/ca-cert-chain.der", "ca_cert_chain_der" ],
  75. [ "./certs/server-key.der", "server_key_der_2048" ],
  76. [ "./certs/server-cert.der", "server_cert_der_2048" ]
  77. );
  78. # 3072-bit certs/keys to be converted
  79. # Used with USE_CERT_BUFFERS_3072 define.
  80. my @fileList_3072 = (
  81. [ "./certs/dh3072.der", "dh_key_der_3072" ],
  82. [ "./certs/dsa3072.der", "dsa_key_der_3072" ],
  83. [ "./certs/rsa3072.der", "rsa_key_der_3072" ],
  84. [ "./certs/3072/client-key.der", "client_key_der_3072" ],
  85. [ "./certs/3072/client-keyPub.der", "client_keypub_der_3072" ],
  86. [ "./certs/3072/client-cert.der", "client_cert_der_3072" ],
  87. );
  88. # 4096-bit certs/keys to be converted
  89. # Used with USE_CERT_BUFFERS_4096 define.
  90. my @fileList_4096 = (
  91. [ "./certs/4096/client-key.der", "client_key_der_4096" ],
  92. [ "./certs/4096/client-keyPub.der", "client_keypub_der_4096" ],
  93. [ "./certs/4096/client-cert.der", "client_cert_der_4096" ],
  94. [ "./certs/dh4096.der", "dh_key_der_4096" ],
  95. );
  96. #Falcon Post-Quantum Keys
  97. #Used with HAVE_PQC
  98. my @fileList_falcon = (
  99. ["certs/falcon/bench_falcon_level1_key.der", "bench_falcon_level1_key" ],
  100. ["certs/falcon/bench_falcon_level5_key.der", "bench_falcon_level5_key" ],
  101. );
  102. #Dilithium Post-Quantum Keys
  103. #Used with HAVE_PQC
  104. my @fileList_dilithium = (
  105. ["certs/dilithium/bench_dilithium_level2_key.der", "bench_dilithium_level2_key" ],
  106. ["certs/dilithium/bench_dilithium_level3_key.der", "bench_dilithium_level3_key" ],
  107. ["certs/dilithium/bench_dilithium_level5_key.der", "bench_dilithium_level5_key" ],
  108. );
  109. #Sphincs+ Post-Quantum Keys
  110. #Used with HAVE_PQC
  111. my @fileList_sphincs = (
  112. ["certs/sphincs/bench_sphincs_fast_level1_key.der", "bench_sphincs_fast_level1_key" ],
  113. ["certs/sphincs/bench_sphincs_fast_level3_key.der", "bench_sphincs_fast_level3_key" ],
  114. ["certs/sphincs/bench_sphincs_fast_level5_key.der", "bench_sphincs_fast_level5_key" ],
  115. ["certs/sphincs/bench_sphincs_small_level1_key.der", "bench_sphincs_small_level1_key" ],
  116. ["certs/sphincs/bench_sphincs_small_level3_key.der", "bench_sphincs_small_level3_key" ],
  117. ["certs/sphincs/bench_sphincs_small_level5_key.der", "bench_sphincs_small_level5_key" ],
  118. );
  119. # ----------------------------------------------------------------------------
  120. my $num_ecc = @fileList_ecc;
  121. my $num_ed = @fileList_ed;
  122. my $num_x = @fileList_x;
  123. my $num_1024 = @fileList_1024;
  124. my $num_2048 = @fileList_2048;
  125. my $num_3072 = @fileList_3072;
  126. my $num_4096 = @fileList_4096;
  127. my $num_falcon = @fileList_falcon;
  128. my $num_dilithium = @fileList_dilithium;
  129. my $num_sphincs = @fileList_sphincs;
  130. # open our output file, "+>" creates and/or truncates
  131. open OUT_FILE, "+>", $outputFile or die $!;
  132. print OUT_FILE "/* certs_test.h */\n";
  133. print OUT_FILE "/* This file was generated using: ./gencertbuf.pl */\n\n";
  134. print OUT_FILE "#ifndef WOLFSSL_CERTS_TEST_H\n";
  135. print OUT_FILE "#define WOLFSSL_CERTS_TEST_H\n\n";
  136. # convert and print 1024-bit cert/keys
  137. print OUT_FILE "#ifdef USE_CERT_BUFFERS_1024\n\n";
  138. for (my $i = 0; $i < $num_1024; $i++) {
  139. my $fname = $fileList_1024[$i][0];
  140. my $sname = $fileList_1024[$i][1];
  141. print OUT_FILE "/* $fname, 1024-bit */\n";
  142. print OUT_FILE "static const unsigned char $sname\[] =\n";
  143. print OUT_FILE "{\n";
  144. file_to_hex($fname);
  145. print OUT_FILE "};\n";
  146. print OUT_FILE "static const int sizeof_$sname = sizeof($sname);\n\n";
  147. }
  148. print OUT_FILE "#endif /* USE_CERT_BUFFERS_1024 */\n\n";
  149. # convert and print 2048-bit certs/keys
  150. print OUT_FILE "#ifdef USE_CERT_BUFFERS_2048\n\n";
  151. for (my $i = 0; $i < $num_2048; $i++) {
  152. my $fname = $fileList_2048[$i][0];
  153. my $sname = $fileList_2048[$i][1];
  154. print OUT_FILE "/* $fname, 2048-bit */\n";
  155. print OUT_FILE "static const unsigned char $sname\[] =\n";
  156. print OUT_FILE "{\n";
  157. file_to_hex($fname);
  158. print OUT_FILE "};\n";
  159. print OUT_FILE "static const int sizeof_$sname = sizeof($sname);\n\n";
  160. }
  161. print OUT_FILE "#endif /* USE_CERT_BUFFERS_2048 */\n\n";
  162. # convert and print 3072-bit certs/keys
  163. print OUT_FILE "#ifdef USE_CERT_BUFFERS_3072\n\n";
  164. for (my $i = 0; $i < $num_3072; $i++) {
  165. my $fname = $fileList_3072[$i][0];
  166. my $sname = $fileList_3072[$i][1];
  167. print OUT_FILE "/* $fname, 3072-bit */\n";
  168. print OUT_FILE "static const unsigned char $sname\[] =\n";
  169. print OUT_FILE "{\n";
  170. file_to_hex($fname);
  171. print OUT_FILE "};\n";
  172. print OUT_FILE "static const int sizeof_$sname = sizeof($sname);\n\n";
  173. }
  174. print OUT_FILE "#endif /* USE_CERT_BUFFERS_3072 */\n\n";
  175. # convert and print 4096-bit certs/keys
  176. print OUT_FILE "#ifdef USE_CERT_BUFFERS_4096\n\n";
  177. for (my $i = 0; $i < $num_4096; $i++) {
  178. my $fname = $fileList_4096[$i][0];
  179. my $sname = $fileList_4096[$i][1];
  180. print OUT_FILE "/* $fname, 4096-bit */\n";
  181. print OUT_FILE "static const unsigned char $sname\[] =\n";
  182. print OUT_FILE "{\n";
  183. file_to_hex($fname);
  184. print OUT_FILE "};\n";
  185. print OUT_FILE "static const int sizeof_$sname = sizeof($sname);\n\n";
  186. }
  187. print OUT_FILE "#endif /* USE_CERT_BUFFERS_4096 */\n\n";
  188. # convert and print falcon keys
  189. print OUT_FILE "#if defined(HAVE_PQC) && defined(HAVE_FALCON)\n\n";
  190. for (my $i = 0; $i < $num_falcon; $i++) {
  191. my $fname = $fileList_falcon[$i][0];
  192. my $sname = $fileList_falcon[$i][1];
  193. print OUT_FILE "/* $fname */\n";
  194. print OUT_FILE "static const unsigned char $sname\[] =\n";
  195. print OUT_FILE "{\n";
  196. file_to_hex($fname);
  197. print OUT_FILE "};\n";
  198. print OUT_FILE "static const int sizeof_$sname = sizeof($sname);\n\n";
  199. }
  200. print OUT_FILE "#endif /* HAVE_PQC && HAVE_FALCON */\n\n";
  201. # convert and print dilithium keys
  202. print OUT_FILE "#if defined (HAVE_PQC) && defined(HAVE_DILITHIUM)\n\n";
  203. for (my $i = 0; $i < $num_dilithium; $i++) {
  204. my $fname = $fileList_dilithium[$i][0];
  205. my $sname = $fileList_dilithium[$i][1];
  206. print OUT_FILE "/* $fname */\n";
  207. print OUT_FILE "static const unsigned char $sname\[] =\n";
  208. print OUT_FILE "{\n";
  209. file_to_hex($fname);
  210. print OUT_FILE "};\n";
  211. print OUT_FILE "static const int sizeof_$sname = sizeof($sname);\n\n";
  212. }
  213. print OUT_FILE "#endif /* HAVE_PQC && HAVE_DILITHIUM */\n\n";
  214. # convert and print sphincs keys
  215. print OUT_FILE "#if defined(HAVE_PQC) && defined(HAVE_SPHINCS)\n\n";
  216. for (my $i = 0; $i < $num_sphincs; $i++) {
  217. my $fname = $fileList_sphincs[$i][0];
  218. my $sname = $fileList_sphincs[$i][1];
  219. print OUT_FILE "/* $fname */\n";
  220. print OUT_FILE "static const unsigned char $sname\[] =\n";
  221. print OUT_FILE "{\n";
  222. file_to_hex($fname);
  223. print OUT_FILE "};\n";
  224. print OUT_FILE "static const int sizeof_$sname = sizeof($sname);\n\n";
  225. }
  226. print OUT_FILE "#endif /* HAVE_PQC && HAVE_SPHINCS */\n\n";
  227. # convert and print 256-bit cert/keys
  228. print OUT_FILE "#if defined(HAVE_ECC) && defined(USE_CERT_BUFFERS_256)\n\n";
  229. for (my $i = 0; $i < $num_ecc; $i++) {
  230. my $fname = $fileList_ecc[$i][0];
  231. my $sname = $fileList_ecc[$i][1];
  232. print OUT_FILE "/* $fname, ECC */\n";
  233. print OUT_FILE "static const unsigned char $sname\[] =\n";
  234. print OUT_FILE "{\n";
  235. file_to_hex($fname);
  236. print OUT_FILE "};\n";
  237. print OUT_FILE "static const int sizeof_$sname = sizeof($sname);\n\n";
  238. }
  239. print OUT_FILE "#endif /* HAVE_ECC && USE_CERT_BUFFERS_256 */\n\n";
  240. print OUT_FILE "/* dh1024 p */
  241. static const unsigned char dh_p[] =
  242. {
  243. 0xE6, 0x96, 0x9D, 0x3D, 0x49, 0x5B, 0xE3, 0x2C, 0x7C, 0xF1, 0x80, 0xC3,
  244. 0xBD, 0xD4, 0x79, 0x8E, 0x91, 0xB7, 0x81, 0x82, 0x51, 0xBB, 0x05, 0x5E,
  245. 0x2A, 0x20, 0x64, 0x90, 0x4A, 0x79, 0xA7, 0x70, 0xFA, 0x15, 0xA2, 0x59,
  246. 0xCB, 0xD5, 0x23, 0xA6, 0xA6, 0xEF, 0x09, 0xC4, 0x30, 0x48, 0xD5, 0xA2,
  247. 0x2F, 0x97, 0x1F, 0x3C, 0x20, 0x12, 0x9B, 0x48, 0x00, 0x0E, 0x6E, 0xDD,
  248. 0x06, 0x1C, 0xBC, 0x05, 0x3E, 0x37, 0x1D, 0x79, 0x4E, 0x53, 0x27, 0xDF,
  249. 0x61, 0x1E, 0xBB, 0xBE, 0x1B, 0xAC, 0x9B, 0x5C, 0x60, 0x44, 0xCF, 0x02,
  250. 0x3D, 0x76, 0xE0, 0x5E, 0xEA, 0x9B, 0xAD, 0x99, 0x1B, 0x13, 0xA6, 0x3C,
  251. 0x97, 0x4E, 0x9E, 0xF1, 0x83, 0x9E, 0xB5, 0xDB, 0x12, 0x51, 0x36, 0xF7,
  252. 0x26, 0x2E, 0x56, 0xA8, 0x87, 0x15, 0x38, 0xDF, 0xD8, 0x23, 0xC6, 0x50,
  253. 0x50, 0x85, 0xE2, 0x1F, 0x0D, 0xD5, 0xC8, 0x6B,
  254. };
  255. /* dh1024 g */
  256. static const unsigned char dh_g[] =
  257. {
  258. 0x02,
  259. };\n\n";
  260. print OUT_FILE "#if defined(NO_ASN) && defined(WOLFSSL_SP_MATH)\n";
  261. print OUT_FILE "/* dh2048 p */
  262. static const unsigned char dh2048_p[] =
  263. {
  264. 0xb0, 0xa1, 0x08, 0x06, 0x9c, 0x08, 0x13, 0xba, 0x59, 0x06, 0x3c, 0xbc,
  265. 0x30, 0xd5, 0xf5, 0x00, 0xc1, 0x4f, 0x44, 0xa7, 0xd6, 0xef, 0x4a, 0xc6,
  266. 0x25, 0x27, 0x1c, 0xe8, 0xd2, 0x96, 0x53, 0x0a, 0x5c, 0x91, 0xdd, 0xa2,
  267. 0xc2, 0x94, 0x84, 0xbf, 0x7d, 0xb2, 0x44, 0x9f, 0x9b, 0xd2, 0xc1, 0x8a,
  268. 0xc5, 0xbe, 0x72, 0x5c, 0xa7, 0xe7, 0x91, 0xe6, 0xd4, 0x9f, 0x73, 0x07,
  269. 0x85, 0x5b, 0x66, 0x48, 0xc7, 0x70, 0xfa, 0xb4, 0xee, 0x02, 0xc9, 0x3d,
  270. 0x9a, 0x4a, 0xda, 0x3d, 0xc1, 0x46, 0x3e, 0x19, 0x69, 0xd1, 0x17, 0x46,
  271. 0x07, 0xa3, 0x4d, 0x9f, 0x2b, 0x96, 0x17, 0x39, 0x6d, 0x30, 0x8d, 0x2a,
  272. 0xf3, 0x94, 0xd3, 0x75, 0xcf, 0xa0, 0x75, 0xe6, 0xf2, 0x92, 0x1f, 0x1a,
  273. 0x70, 0x05, 0xaa, 0x04, 0x83, 0x57, 0x30, 0xfb, 0xda, 0x76, 0x93, 0x38,
  274. 0x50, 0xe8, 0x27, 0xfd, 0x63, 0xee, 0x3c, 0xe5, 0xb7, 0xc8, 0x09, 0xae,
  275. 0x6f, 0x50, 0x35, 0x8e, 0x84, 0xce, 0x4a, 0x00, 0xe9, 0x12, 0x7e, 0x5a,
  276. 0x31, 0xd7, 0x33, 0xfc, 0x21, 0x13, 0x76, 0xcc, 0x16, 0x30, 0xdb, 0x0c,
  277. 0xfc, 0xc5, 0x62, 0xa7, 0x35, 0xb8, 0xef, 0xb7, 0xb0, 0xac, 0xc0, 0x36,
  278. 0xf6, 0xd9, 0xc9, 0x46, 0x48, 0xf9, 0x40, 0x90, 0x00, 0x2b, 0x1b, 0xaa,
  279. 0x6c, 0xe3, 0x1a, 0xc3, 0x0b, 0x03, 0x9e, 0x1b, 0xc2, 0x46, 0xe4, 0x48,
  280. 0x4e, 0x22, 0x73, 0x6f, 0xc3, 0x5f, 0xd4, 0x9a, 0xd6, 0x30, 0x07, 0x48,
  281. 0xd6, 0x8c, 0x90, 0xab, 0xd4, 0xf6, 0xf1, 0xe3, 0x48, 0xd3, 0x58, 0x4b,
  282. 0xa6, 0xb9, 0xcd, 0x29, 0xbf, 0x68, 0x1f, 0x08, 0x4b, 0x63, 0x86, 0x2f,
  283. 0x5c, 0x6b, 0xd6, 0xb6, 0x06, 0x65, 0xf7, 0xa6, 0xdc, 0x00, 0x67, 0x6b,
  284. 0xbb, 0xc3, 0xa9, 0x41, 0x83, 0xfb, 0xc7, 0xfa, 0xc8, 0xe2, 0x1e, 0x7e,
  285. 0xaf, 0x00, 0x3f, 0x93
  286. };
  287. /* dh2048 g */
  288. static const unsigned char dh2048_g[] =
  289. {
  290. 0x02,
  291. };\n";
  292. print OUT_FILE "#endif\n\n";
  293. # convert and print ed25519 cert/keys
  294. print OUT_FILE "#if defined(HAVE_ED25519)\n\n";
  295. for (my $i = 0; $i < $num_ed; $i++) {
  296. my $fname = $fileList_ed[$i][0];
  297. my $sname = $fileList_ed[$i][1];
  298. print OUT_FILE "/* $fname, ED25519 */\n";
  299. print OUT_FILE "static const unsigned char $sname\[] =\n";
  300. print OUT_FILE "{\n";
  301. file_to_hex($fname);
  302. print OUT_FILE "};\n";
  303. print OUT_FILE "static const int sizeof_$sname = sizeof($sname);\n\n";
  304. }
  305. print OUT_FILE "#endif /* HAVE_ED25519 */\n\n";
  306. # convert and print CURVE25519 cert/keys
  307. print OUT_FILE "#if defined(USE_CERT_BUFFERS_25519)\n\n";
  308. for (my $i = 0; $i < $num_x; $i++) {
  309. my $fname = $fileList_x[$i][0];
  310. my $sname = $fileList_x[$i][1];
  311. print OUT_FILE "/* $fname, CURVE25519 */\n";
  312. print OUT_FILE "static const unsigned char $sname\[] =\n";
  313. print OUT_FILE "{\n";
  314. file_to_hex($fname);
  315. print OUT_FILE "};\n";
  316. print OUT_FILE "static const int sizeof_$sname = sizeof($sname);\n\n";
  317. }
  318. print OUT_FILE "#endif /* USE_CERT_BUFFERS_25519 */\n\n";
  319. print OUT_FILE "#endif /* WOLFSSL_CERTS_TEST_H */\n\n";
  320. # close certs_test.h file
  321. close OUT_FILE or die $!;
  322. # print file as hex, comma-separated, as needed by C buffer
  323. sub file_to_hex {
  324. my $fileName = $_[0];
  325. open my $fp, "<", $fileName or die $!;
  326. binmode($fp);
  327. my $fileLen = -s $fileName;
  328. my $byte;
  329. for (my $i = 0, my $j = 1; $i < $fileLen; $i++, $j++)
  330. {
  331. if ($j == 1) {
  332. print OUT_FILE " ";
  333. }
  334. if ($j != 1) {
  335. print OUT_FILE " ";
  336. }
  337. read($fp, $byte, 1) or die "Error reading $fileName";
  338. my $output = sprintf("0x%02X", ord($byte));
  339. print OUT_FILE $output;
  340. if ($i != ($fileLen - 1)) {
  341. print OUT_FILE ",";
  342. }
  343. if ($j == 10) {
  344. $j = 0;
  345. print OUT_FILE "\n";
  346. }
  347. }
  348. print OUT_FILE "\n";
  349. close($fp);
  350. }