VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/DcsCfg
diff options
context:
space:
mode:
authorkavsrf <kavsrf@gmail.com>2017-03-27 16:01:33 +0300
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2017-06-18 15:41:15 +0200
commit3cddd24df26085682c819a3c8e9e3ce21a2872da (patch)
treef97065bd54266978df4cae2fe91127c3f58278cd /DcsCfg
parent51088d231d73cbe14516d553e97237e7f5a4f147 (diff)
downloadVeraCrypt-DCS-3cddd24df26085682c819a3c8e9e3ce21a2872da.tar.gz
VeraCrypt-DCS-3cddd24df26085682c819a3c8e9e3ce21a2872da.zip
smart card tests via DcsCfg
Diffstat (limited to 'DcsCfg')
-rw-r--r--DcsCfg/DcsCfg.h5
-rw-r--r--DcsCfg/DcsCfgCrypt.c22
-rw-r--r--DcsCfg/DcsCfgMain.c16
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;