diff options
Diffstat (limited to 'DcsCfg')
-rw-r--r-- | DcsCfg/DcsCfg.h | 5 | ||||
-rw-r--r-- | DcsCfg/DcsCfgCrypt.c | 22 | ||||
-rw-r--r-- | DcsCfg/DcsCfgMain.c | 16 |
3 files changed, 41 insertions, 2 deletions
diff --git a/DcsCfg/DcsCfg.h b/DcsCfg/DcsCfg.h index 412e4c4..37fdbca 100644 --- a/DcsCfg/DcsCfg.h +++ b/DcsCfg/DcsCfg.h @@ -135,8 +135,9 @@ extern UINTN UsbIndex; VOID
PrintUsbList();
-VOID
-UsbSelect();
+EFI_STATUS
+UsbScApdu(
+ IN CHAR16* hexString);
//////////////////////////////////////////////////////////////////////////
// Beep
diff --git a/DcsCfg/DcsCfgCrypt.c b/DcsCfg/DcsCfgCrypt.c index 08c2ee6..e4e0e2e 100644 --- a/DcsCfg/DcsCfgCrypt.c +++ b/DcsCfg/DcsCfgCrypt.c @@ -1552,6 +1552,28 @@ PrintUsbList() { UsbIoPrintDevicePaths(L"%HUSB IO handles%N\n");
}
+EFI_STATUS
+UsbScApdu(
+ IN CHAR16* hexString)
+{
+ UINT8 cmd[256];
+ UINTN cmdLen = sizeof(cmd) - sizeof(CCID_HEADER_OUT);
+ UINT8 resp[256];
+ UINTN respLen = sizeof(resp);
+ UINT16 statusSc = 0;
+ EFI_USB_IO_PROTOCOL *UsbIo =NULL;
+ EFI_STATUS res;
+ CE(InitUsb());
+ CE(UsbGetIO(gUSBHandles[UsbIndex], &UsbIo));
+ StrHexToBytes(cmd + sizeof(CCID_HEADER_OUT), &cmdLen, hexString);
+ CE(UsbScTransmit(UsbIo, cmd, cmdLen + sizeof(CCID_HEADER_OUT), resp, &respLen, &statusSc));
+ PrintBytes(resp, respLen);
+ return res;
+err:
+ ERR_PRINT(L"Error(%d) %r\n", gCELine, res);
+ return res;
+}
+
//////////////////////////////////////////////////////////////////////////
// Set DcsInt parameters
diff --git a/DcsCfg/DcsCfgMain.c b/DcsCfg/DcsCfgMain.c index c289bf8..3abd759 100644 --- a/DcsCfg/DcsCfgMain.c +++ b/DcsCfg/DcsCfgMain.c @@ -40,6 +40,8 @@ https://opensource.org/licenses/LGPL-3.0 #define OPT_DISK_END L"-de"
#define OPT_DISK_BOOT L"-db"
#define OPT_USB_LIST L"-ul"
+#define OPT_USB_SELECT L"-us"
+#define OPT_SC_APDU L"-scapdu"
#define OPT_TOUCH_LIST L"-tl"
#define OPT_TOUCH_TEST L"-tt"
#define OPT_GRAPH_LIST L"-gl"
@@ -123,6 +125,8 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = { { OPT_VOLUME_DECRYPT,TypeValue },
{ OPT_VOLUME_CHANGEPWD,TypeValue },
{ OPT_USB_LIST, TypeFlag },
+ { OPT_USB_SELECT, TypeValue },
+ { OPT_SC_APDU, TypeValue },
{ OPT_TOUCH_LIST, TypeFlag },
{ OPT_TOUCH_TEST, TypeValue },
{ OPT_GRAPH_LIST, TypeFlag },
@@ -409,6 +413,18 @@ DcsCfgMain( PrintUsbList();
}
+ if (ShellCommandLineGetFlag(Package, OPT_USB_SELECT)) {
+ CHAR16 * opt;
+ opt = (CHAR16*)ShellCommandLineGetValue(Package, OPT_USB_SELECT);
+ UsbIndex = StrDecimalToUintn(opt);
+ }
+
+ if (ShellCommandLineGetFlag(Package, OPT_SC_APDU)) {
+ CHAR16 * opt;
+ opt = (CHAR16*)ShellCommandLineGetValue(Package, OPT_SC_APDU);
+ UsbScApdu(opt);
+ }
+
// Randoms
if (ShellCommandLineGetFlag(Package, OPT_RND_LOAD)) {
CONST CHAR16* opt = NULL;
|