|
20 | 20 | #include "keystore.h"
|
21 | 21 | #include "kelf.h"
|
22 | 22 |
|
| 23 | +uint8_t GSystemtype = SYSTEM_TYPE_PS2; |
| 24 | +uint8_t GMGZones = REGION_ALL_ALLOWED; |
| 25 | +uint16_t GFlags = HDR_PREDEF_KELF; |
| 26 | +uint8_t GApplicationType = KELFTYPE_XOSDMAIN; |
| 27 | + |
23 | 28 | // TODO: implement load/save kelf header configuration for byte-perfect encryption, decryption
|
24 | 29 |
|
25 | 30 | std::string getKeyStorePath()
|
@@ -89,6 +94,41 @@ int encrypt(int argc, char **argv)
|
89 | 94 | if (!strncmp("--keys=", argv[x], strlen("--keys="))) {
|
90 | 95 | printf("- Custom keyset %s\n", &argv[x][7]);
|
91 | 96 | KeyStoreEntry = &argv[x][7];
|
| 97 | + } else if (!strncmp("--systemtype=", argv[x], strlen("--systemtype="))) { |
| 98 | + const char* a = &argv[x][13]; |
| 99 | + long t; |
| 100 | + if (!strcmp(a, "PS2")) { |
| 101 | + GSystemtype = SYSTEM_TYPE_PS2; |
| 102 | + } else if (!strcmp(a, "PSX")) { |
| 103 | + GSystemtype = SYSTEM_TYPE_PSX; |
| 104 | + } else if ((t = strtoul(a, NULL, 10)) <= std::numeric_limits<std::uint8_t>::max()) { |
| 105 | + GSystemtype = (uint8_t)t; |
| 106 | + } |
| 107 | + } else if (!strncmp("--kflags=", argv[x], strlen("--kflags="))) { |
| 108 | + const char* a = &argv[x][9]; |
| 109 | + unsigned long t; |
| 110 | + if (!strcmp(a, "KELF")) { |
| 111 | + GFlags = HDR_PREDEF_KELF; |
| 112 | + } else if (!strcmp(a, "KIRX")) { |
| 113 | + GFlags = HDR_PREDEF_KIRX; |
| 114 | + } else if ((t = strtoul(a, NULL, 16)) <= std::numeric_limits<std::uint16_t>::max()) { |
| 115 | + GFlags = (uint16_t)t; |
| 116 | + if ((GFlags & HDR_FLAG4_1DES) && (GFlags & HDR_FLAG4_3DES)) { |
| 117 | + printf("WARNING: 0x%x specifies both Single and Triple DES. only one should be defined\n", GFlags); |
| 118 | + } |
| 119 | + } |
| 120 | + } else if (!strncmp("--mgzone=", argv[x], strlen("--mgzone="))) { |
| 121 | + const char* a = &argv[x][9]; |
| 122 | + long t; |
| 123 | + if ((t = strtoul(a, NULL, 16))<std::numeric_limits<std::uint8_t>::max()) { |
| 124 | + GMGZones = (uint8_t)t; |
| 125 | + } |
| 126 | + } else if (!strncmp("--apptype=", argv[x], strlen("--apptype="))) { |
| 127 | + const char* a = &argv[x][10]; |
| 128 | + long t; |
| 129 | + if ((t = strtoul(a, NULL, 16)) <= std::numeric_limits<std::uint8_t>::max()) { |
| 130 | + GApplicationType = (uint8_t)t; |
| 131 | + } |
92 | 132 | }
|
93 | 133 | }
|
94 | 134 |
|
|
0 commit comments