summaryrefslogtreecommitdiffstats
path: root/utils/hwstub/tools/hwstub_shell.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/hwstub/tools/hwstub_shell.cpp')
-rw-r--r--utils/hwstub/tools/hwstub_shell.cpp86
1 files changed, 32 insertions, 54 deletions
diff --git a/utils/hwstub/tools/hwstub_shell.cpp b/utils/hwstub/tools/hwstub_shell.cpp
index 58147319e0..69e580f88e 100644
--- a/utils/hwstub/tools/hwstub_shell.cpp
+++ b/utils/hwstub/tools/hwstub_shell.cpp
@@ -41,6 +41,7 @@ struct hwstub_device_t g_hwdev;
struct usb_resp_info_version_t g_hwdev_ver;
struct usb_resp_info_layout_t g_hwdev_layout;
struct usb_resp_info_features_t g_hwdev_features;
+struct usb_resp_info_target_t g_hwdev_target;
struct usb_resp_info_stmp_t g_hwdev_stmp;
lua_State *g_lua;
@@ -253,12 +254,22 @@ bool my_lua_import_hwstub()
lua_setfield(g_lua, -2, "ocram");
lua_setfield(g_lua, -2, "layout");
- lua_newtable(g_lua); // stmp
- lua_pushinteger(g_lua, g_hwdev_stmp.chipid);
- lua_setfield(g_lua, -2, "chipid");
- lua_pushinteger(g_lua, g_hwdev_stmp.rev);
- lua_setfield(g_lua, -2, "rev");
- lua_setfield(g_lua, -2, "stmp");
+ lua_newtable(g_lua); // target
+ lua_pushstring(g_lua, g_hwdev_target.name);
+ lua_setfield(g_lua, -2, "name");
+ lua_pushinteger(g_lua, g_hwdev_target.id);
+ lua_setfield(g_lua, -2, "id");
+ lua_setfield(g_lua, -2, "target");
+
+ if(g_hwdev_target.id == HWSTUB_TARGET_STMP)
+ {
+ lua_newtable(g_lua); // stmp
+ lua_pushinteger(g_lua, g_hwdev_stmp.chipid);
+ lua_setfield(g_lua, -2, "chipid");
+ lua_pushinteger(g_lua, g_hwdev_stmp.rev);
+ lua_setfield(g_lua, -2, "rev");
+ lua_setfield(g_lua, -2, "stmp");
+ }
lua_newtable(g_lua); // features
lua_pushboolean(g_lua, !!(g_hwdev_features.feature_mask & HWSTUB_FEATURE_LOG));
@@ -269,8 +280,6 @@ bool my_lua_import_hwstub()
lua_setfield(g_lua, -2, "call");
lua_pushboolean(g_lua, !!(g_hwdev_features.feature_mask & HWSTUB_FEATURE_JUMP));
lua_setfield(g_lua, -2, "jump");
- lua_pushboolean(g_lua, !!(g_hwdev_features.feature_mask & HWSTUB_FEATURE_AES_OTP));
- lua_setfield(g_lua, -2, "aes_otp");
lua_setfield(g_lua, -2, "features");
lua_pushlightuserdata(g_lua, (void *)&hw_read8);
@@ -751,14 +760,25 @@ int main(int argc, char **argv)
goto Lerr;
}
- // get STMP specific information
- ret = hwstub_get_info(&g_hwdev, HWSTUB_INFO_STMP, &g_hwdev_stmp, sizeof(g_hwdev_stmp));
- if(ret != sizeof(g_hwdev_stmp))
+ // get target
+ ret = hwstub_get_info(&g_hwdev, HWSTUB_INFO_TARGET, &g_hwdev_target, sizeof(g_hwdev_target));
+ if(ret != sizeof(g_hwdev_target))
{
- printf("Cannot get stmp: %d\n", ret);
+ printf("Cannot get target: %d\n", ret);
goto Lerr;
}
+ // get STMP specific information
+ if(g_hwdev_target.id == HWSTUB_TARGET_STMP)
+ {
+ ret = hwstub_get_info(&g_hwdev, HWSTUB_INFO_STMP, &g_hwdev_stmp, sizeof(g_hwdev_stmp));
+ if(ret != sizeof(g_hwdev_stmp))
+ {
+ printf("Cannot get stmp: %d\n", ret);
+ goto Lerr;
+ }
+ }
+
// dump ROM
if(!g_quiet)
{
@@ -776,48 +796,6 @@ int main(int argc, char **argv)
fclose(f);
}
- // test DCP
-#if 0
- if(!g_quiet)
- {
- struct
- {
- uint8_t iv[16];
- uint8_t data[16];
- } __attribute__((packed)) dcp_test;
-
- for(int i = 0; i < 16; i++)
- dcp_test.iv[i] = rand();
- for(int i = 0; i < 16; i++)
- dcp_test.data[i] = rand();
- printf("DCP\n");
- printf(" IN\n");
- printf(" IV:");
- for(int i = 0; i < 16; i++)
- printf(" %02x", dcp_test.iv[i]);
- printf("\n");
- printf(" IV:");
- for(int i = 0; i < 16; i++)
- printf(" %02x", dcp_test.data[i]);
- printf("\n");
-
- if(!hwstub_aes_otp(&g_hwdev, &dcp_test, sizeof(dcp_test), HWSTUB_AES_OTP_ENCRYPT))
- {
- printf(" OUT\n");
- printf(" IV:");
- for(int i = 0; i < 16; i++)
- printf(" %02x", dcp_test.iv[i]);
- printf("\n");
- printf(" IV:");
- for(int i = 0; i < 16; i++)
- printf(" %02x", dcp_test.data[i]);
- printf("\n");
- }
- else
- printf("DCP error!\n");
- }
-#endif
-
/** Init lua */
// create lua state