VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkavsrf <kavsrf@gmail.com>2017-01-23 12:30:22 (GMT)
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2017-06-05 15:36:52 (GMT)
commitf648e29d050cab362cc660c1a5c5109182028768 (patch)
treeda3a3ce3f3b03edee797c4606a1cd1227cd6eb95
parentd37d6d681061fdefc2a909b5975b40b604a27c62 (diff)
downloadVeraCrypt-DCS-f648e29d050cab362cc660c1a5c5109182028768.zip
VeraCrypt-DCS-f648e29d050cab362cc660c1a5c5109182028768.tar.gz
DcsInfo added
DcsBoot is driver now (to support DriverOrder list)
-rw-r--r--DcsBoot/DcsBoot.c8
-rw-r--r--DcsBoot/DcsBoot.inf5
-rw-r--r--DcsCfg/DcsCfgCrypt.c102
-rw-r--r--DcsInfo/DcsInfo.c290
-rw-r--r--DcsInfo/DcsInfo.inf77
-rw-r--r--DcsInt/DcsInt.c1
-rw-r--r--DcsPkg.dsc1
-rw-r--r--Dcs_bld.bat1
-rw-r--r--Include/Library/CommonLib.h34
-rw-r--r--Include/Library/PasswordLib.h8
-rw-r--r--Library/CommonLib/CommonLib.inf7
-rw-r--r--Library/CommonLib/EfiBluetooth.c50
-rw-r--r--Library/CommonLib/EfiFile.c19
-rw-r--r--Library/CommonLib/EfiTpm.c34
-rw-r--r--Library/PasswordLib/PlatformID.c19
-rw-r--r--Library/VeraCryptLib/DcsConfig.c72
-rw-r--r--Library/VeraCryptLib/DcsConfig.h29
-rw-r--r--Library/VeraCryptLib/DcsVeraCrypt.c53
-rw-r--r--Library/VeraCryptLib/DcsVeraCrypt.h3
-rw-r--r--Library/VeraCryptLib/VeraCryptLib.inf2
20 files changed, 712 insertions, 103 deletions
diff --git a/DcsBoot/DcsBoot.c b/DcsBoot/DcsBoot.c
index bccf216..60c8eed 100644
--- a/DcsBoot/DcsBoot.c
+++ b/DcsBoot/DcsBoot.c
@@ -16,6 +16,7 @@ https://opensource.org/licenses/LGPL-3.0
#include <Library/CommonLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DevicePathLib.h>
+#include "DcsConfig.h"
EFI_GUID ImagePartGuid;
EFI_GUID *gEfiExecPartGuid = &ImagePartGuid;
@@ -41,12 +42,19 @@ DcsBootMain(
EFI_STATUS res;
UINTN len;
UINT32 attr;
+ int drvInst;
InitBio();
res = InitFS();
if (EFI_ERROR(res)) {
ERR_PRINT(L"InitFS %r\n", res);
}
+ drvInst = ConfigReadInt("DcsDriver", 0);
+
+ if (!FileExist(NULL, L"\\EFI\\VeraCrypt\\PlatformInfo") &&
+ !FileExist(NULL, L"\\EFI\\VeraCrypt\\DcsInfo.dcs")) {
+ res = EfiExec(NULL, L"\\EFI\\VeraCrypt\\DcsInfo.dcs");
+ }
// Load all drivers
res = EfiExec(NULL, L"\\EFI\\VeraCrypt\\LegacySpeaker.dcs");
diff --git a/DcsBoot/DcsBoot.inf b/DcsBoot/DcsBoot.inf
index 9459e92..14d8d0d 100644
--- a/DcsBoot/DcsBoot.inf
+++ b/DcsBoot/DcsBoot.inf
@@ -16,7 +16,7 @@
INF_VERSION = 0x00010006
BASE_NAME = DcsBoot
FILE_GUID = DE8AB4B2-EB47-44E1-A4D7-1001E5E9F0A5
- MODULE_TYPE = UEFI_APPLICATION
+ MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = DcsBootMain
@@ -36,11 +36,12 @@
DcsPkg/DcsPkg.dec
[LibraryClasses]
- UefiApplicationEntryPoint
+ UefiDriverEntryPoint
UefiLib
BaseLib
MemoryAllocationLib
CommonLib
+ VeraCryptLib
[Guids]
gEfiGlobalVariableGuid
diff --git a/DcsCfg/DcsCfgCrypt.c b/DcsCfg/DcsCfgCrypt.c
index 7259e78..0e892dd 100644
--- a/DcsCfg/DcsCfgCrypt.c
+++ b/DcsCfg/DcsCfgCrypt.c
@@ -143,6 +143,7 @@ ChangePassword(
EFI_STATUS res;
PCRYPTO_INFO cryptoInfo, ci;
int vcres;
+ BOOL modified = FALSE;
res = RndPreapare();
if (EFI_ERROR(res)) {
@@ -157,57 +158,66 @@ ChangePassword(
res = TryHeaderDecrypt(header, &cryptoInfo, NULL);
if (EFI_ERROR(res)) return res;
- if (AskConfirm("Change pwd[N]?", 1)) {
- return EFI_INVALID_PARAMETER;
- }
+ if (AskConfirm("Change password[N]?", 1)) {
+ modified = TRUE;
+ do {
+ ZeroMem(&newPassword, sizeof(newPassword));
+ ZeroMem(&confirmPassword, sizeof(newPassword));
+ VCAskPwd(AskPwdNew, &newPassword);
+ if (gAuthPwdCode == AskPwdRetCancel) {
+ return EFI_NOT_READY;
+ }
+ VCAskPwd(AskPwdConfirm, &confirmPassword);
+ if (gAuthPwdCode == AskPwdRetCancel) {
+ MEM_BURN(&newPassword, sizeof(newPassword));
+ return EFI_NOT_READY;
+ }
+ if (newPassword.Length == confirmPassword.Length) {
+ if (CompareMem(newPassword.Text, confirmPassword.Text, confirmPassword.Length) == 0) {
+ gAuthPassword = newPassword;
+ break;
+ }
+ }
- do {
- ZeroMem(&newPassword, sizeof(newPassword));
- ZeroMem(&confirmPassword, sizeof(newPassword));
- VCAskPwd(AskPwdNew, &newPassword);
- if (gAuthPwdCode == AskPwdRetCancel) {
- return EFI_NOT_READY;
- }
- VCAskPwd(AskPwdConfirm, &confirmPassword);
- if (gAuthPwdCode == AskPwdRetCancel) {
- MEM_BURN(&newPassword, sizeof(newPassword));
- return EFI_NOT_READY;
- }
- if (newPassword.Length == confirmPassword.Length) {
- if (CompareMem(newPassword.Text, confirmPassword.Text, confirmPassword.Length) == 0) {
+ if (AskConfirm("Password mismatch, retry[N]?", 1)) {
break;
}
- }
- if (AskConfirm("Password mismatch, retry?", 1)) {
+ } while (TRUE);
+ }
+
+ if (AskConfirm("Change range of encrypted sectors[N]?", 1)) {
+ modified = TRUE;
+ cryptoInfo->VolumeSize.Value = AskUINT64("Volume size", cryptoInfo->VolumeSize.Value >> 9) << 9;
+ cryptoInfo->EncryptedAreaStart.Value = AskUINT64("Encrypted area start", cryptoInfo->EncryptedAreaStart.Value >> 9) << 9;
+ cryptoInfo->EncryptedAreaLength.Value = AskUINT64("Encrypted area length", cryptoInfo->EncryptedAreaLength.Value >> 9) << 9;
+ }
+
+ if (modified) {
+ vcres = CreateVolumeHeaderInMemory(
+ gAuthBoot, header,
+ cryptoInfo->ea,
+ cryptoInfo->mode,
+ &gAuthPassword,
+ cryptoInfo->pkcs5,
+ gAuthPim,
+ cryptoInfo->master_keydata,
+ &ci,
+ cryptoInfo->VolumeSize.Value,
+ cryptoInfo->hiddenVolumeSize,
+ cryptoInfo->EncryptedAreaStart.Value,
+ cryptoInfo->EncryptedAreaLength.Value,
+ gAuthTc ? 0 : cryptoInfo->RequiredProgramVersion,
+ cryptoInfo->HeaderFlags,
+ cryptoInfo->SectorSize,
+ FALSE);
+
+ MEM_BURN(&newPassword, sizeof(newPassword));
+ MEM_BURN(&confirmPassword, sizeof(confirmPassword));
+
+ if (vcres != 0) {
+ ERR_PRINT(L"header create error(%x)\n", vcres);
return EFI_INVALID_PARAMETER;
}
- } while (TRUE);
-
- vcres = CreateVolumeHeaderInMemory(
- gAuthBoot, header,
- cryptoInfo->ea,
- cryptoInfo->mode,
- &newPassword,
- cryptoInfo->pkcs5,
- gAuthPim,
- cryptoInfo->master_keydata,
- &ci,
- cryptoInfo->VolumeSize.Value,
- cryptoInfo->hiddenVolumeSize,
- cryptoInfo->EncryptedAreaStart.Value,
- cryptoInfo->EncryptedAreaLength.Value,
- gAuthTc ? 0 : cryptoInfo->RequiredProgramVersion,
- cryptoInfo->HeaderFlags,
- cryptoInfo->SectorSize,
- FALSE);
-
-
- MEM_BURN(&newPassword, sizeof(newPassword));
- MEM_BURN(&confirmPassword, sizeof(confirmPassword));
-
- if (vcres != 0) {
- ERR_PRINT(L"header create error(%x)\n", vcres);
- return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
diff --git a/DcsInfo/DcsInfo.c b/DcsInfo/DcsInfo.c
new file mode 100644
index 0000000..bec72d9
--- /dev/null
+++ b/DcsInfo/DcsInfo.c
@@ -0,0 +1,290 @@
+/** @file
+ This is DCS platform information application
+
+Copyright (c) 2016. Disk Cryptography Services for EFI (DCS), Alex Kolotnikov
+Copyright (c) 2016. VeraCrypt, Mounir IDRASSI
+
+This program and the accompanying materials
+are licensed and made available under the terms and conditions
+of the GNU Lesser General Public License, version 3.0 (LGPL-3.0).
+
+The full text of the license may be found at
+https://opensource.org/licenses/LGPL-3.0
+**/
+
+#include <Uefi.h>
+#include <Library/CommonLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PrintLib.h>
+#include <Guid/GlobalVariable.h>
+#include <Library/PasswordLib.h>
+#include <Library/GraphLib.h>
+
+#ifdef _M_X64
+#define ARCH_NAME L"x64"
+#else
+#define ARCH_NAME L"IA32"
+#endif
+CHAR8 Temp[1024];
+CHAR8 StrBuffer[1024];
+UINTN gXmlTabs = 0;
+
+UINTN
+XmlOutTab() {
+ UINTN len;
+ UINTN i = gXmlTabs;
+ CHAR8* pos = (CHAR8*)StrBuffer;
+ INTN remains = sizeof(StrBuffer) - 1;
+ while (i > 0 && remains > 0) {
+ *pos = ' ';
+ remains--;
+ i--;
+ pos++;
+ }
+ len = sizeof(StrBuffer) - remains - 1;
+ return len;
+}
+
+UINTN
+XmlTag(
+ IN EFI_FILE *infoFileTxt,
+ IN CONST CHAR8 *tag,
+ IN BOOLEAN closeTag,
+ IN CONST CHAR8 *value,
+ ...
+ ) {
+ VA_LIST args;
+ UINTN len = XmlOutTab();
+ CHAR8* pos = (CHAR8*)StrBuffer + len;
+ CHAR8* attrFormat = NULL;
+ INTN remains = sizeof(StrBuffer) - 1 - len;
+ if (infoFileTxt == NULL) return 0;
+ VA_START(args, value);
+ len = AsciiSPrint(pos, remains, "<%a", tag);
+ remains -= len;
+ pos += len;
+ if ((attrFormat = VA_ARG(args, CHAR8 *)) != NULL) {
+ len = AsciiVSPrint(pos, remains, attrFormat, args);
+ remains -= len;
+ pos += len;
+ }
+ VA_END(args);
+ if (closeTag) {
+ if (value == NULL) {
+ len = AsciiSPrint(pos, remains, "/>\n");
+ remains -= len;
+ pos += len;
+ }
+ else {
+ len = AsciiSPrint(pos, remains, ">%a</%a>\n", value, tag);
+ remains -= len;
+ pos += len;
+ }
+ } else {
+ if (value == NULL) {
+ len = AsciiSPrint(pos, remains, ">");
+ remains -= len;
+ pos += len;
+ }
+ else {
+ len = AsciiSPrint(pos, remains, ">%a", value, tag);
+ remains -= len;
+ pos += len;
+ }
+ }
+ len = sizeof(StrBuffer) - remains - 1;
+ infoFileTxt->Write(infoFileTxt, &len, StrBuffer);
+ return len;
+}
+
+UINTN
+XmlStartTag(
+ IN EFI_FILE *infoFileTxt,
+ IN CONST CHAR8 *tag)
+{
+ UINTN len = XmlOutTab();
+ CHAR8* pos = (CHAR8*)StrBuffer + len;
+ INTN remains = sizeof(StrBuffer) - 1 - len;
+ gXmlTabs += remains > 0 ? 1 : 0;
+ len = AsciiSPrint(pos, remains, "<%a>\n", tag);
+ remains -= len;
+ pos += len;
+ len = sizeof(StrBuffer) - remains - 1;
+ infoFileTxt->Write(infoFileTxt, &len, StrBuffer);
+
+ return len;
+}
+
+UINTN
+XmlEndTag(
+ IN EFI_FILE *infoFileTxt,
+ IN CONST CHAR8 *tag
+ )
+{
+ UINTN len;
+ CHAR8* pos;
+ INTN remains;
+ gXmlTabs -= gXmlTabs > 0 ? 1 : 0;
+ len = XmlOutTab();
+ pos = (CHAR8*)StrBuffer + len;
+ remains = sizeof(StrBuffer) - 1 - len;
+
+ if (infoFileTxt == NULL) return 0;
+ len = AsciiSPrint(pos, remains, "</%a>\n", tag);
+ remains -= len;
+ pos += len;
+ len = sizeof(StrBuffer) - remains - 1;
+ infoFileTxt->Write(infoFileTxt, &len, StrBuffer);
+ return len;
+}
+
+
+UINTN
+XmlEndTagPrint(
+ IN EFI_FILE *infoFileTxt,
+ IN CONST CHAR8 *tag,
+ IN CONST CHAR8 *formatValue,
+ ...
+ )
+{
+ VA_LIST args;
+ UINTN len = 0;
+ CHAR8* pos = (CHAR8*)StrBuffer + len;
+ INTN remains = sizeof(StrBuffer) - 1 - len;
+ if (infoFileTxt == NULL) return 0;
+ VA_START(args, formatValue);
+ if (formatValue != NULL) {
+ len = AsciiVSPrint(pos, remains, formatValue, args);
+ remains -= len;
+ pos += len;
+ }
+ VA_END(args);
+ len = AsciiSPrint(pos, remains, "</%a>\n", tag);
+ remains -= len;
+ pos += len;
+ len = sizeof(StrBuffer) - remains -1;
+ infoFileTxt->Write(infoFileTxt, &len, StrBuffer);
+ return len;
+}
+
+/**
+The actual entry point for the application.
+
+@param[in] ImageHandle The firmware allocated handle for the EFI image.
+@param[in] SystemTable A pointer to the EFI System Table.
+
+@retval EFI_SUCCESS The entry point executed successfully.
+@retval other Some error occur when executing this entry point.
+
+**/
+EFI_STATUS
+EFIAPI
+DcsInfoMain(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS res;
+// EFI_INPUT_KEY key;
+ EFI_FILE *info;
+ UINTN i;
+ UINTN j;
+ InitBio();
+ res = InitFS();
+ if (EFI_ERROR(res)) {
+ ERR_PRINT(L"InitFS %r\n", res);
+ return res;
+ }
+ res = FileOpen(NULL, L"EFI\\VeraCrypt\\PlatformInfo", &info, EFI_FILE_MODE_READ | EFI_FILE_MODE_CREATE | EFI_FILE_MODE_WRITE, 0);
+ if (EFI_ERROR(res)) {
+ ERR_PRINT(L"PlatformInfo create %r\n", res);
+ return res;
+ }
+ FileAsciiPrint(info, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
+ XmlStartTag(info, "PlatformInfo");
+
+ XmlStartTag(info, "EFI");
+ XmlTag(info, "Version", FALSE, NULL, NULL);
+ XmlEndTagPrint(info, "Version", "%d.%d", gST->Hdr.Revision >> 16, gST->Hdr.Revision & 0xFFFF);
+ XmlTag(info, "Vendor", FALSE, NULL, NULL);
+ XmlEndTagPrint(info, "Vendor", "%s", gST->FirmwareVendor);
+ XmlTag(info, "Revision", FALSE, NULL, NULL);
+ XmlEndTagPrint(info, "Revision", "0x0%x", gST->FirmwareRevision);
+ XmlEndTag(info, "EFI");
+
+ res = SMBIOSGetSerials();
+ if (!EFI_ERROR(res)) {
+// XmlTag(info, "System",FALSE, NULL, NULL);
+ XmlStartTag(info, "System");
+ XmlTag(info, "Manufacture", TRUE, gSmbSystemManufacture, NULL);
+ XmlTag(info, "Model", TRUE, gSmbSystemModel, NULL);
+ XmlTag(info, "Version", TRUE, gSmbSystemVersion, NULL);
+ XmlEndTag(info, "System");
+ XmlStartTag(info, "BIOS");
+ XmlTag(info, "Vendor", TRUE, gSmbBiosVendor, NULL);
+ XmlTag(info, "Version", TRUE, gSmbBiosVersion, NULL);
+ XmlTag(info, "Date", TRUE, gSmbBiosDate, NULL);
+ XmlEndTag(info, "BIOS");
+ }
+ // Devices info
+ InitTcg();
+ XmlTag(info, "TPM12", TRUE, NULL, " count=\"%d\"", gTcgCount, NULL);
+ XmlTag(info, "TPM20", TRUE, NULL, " count=\"%d\"", gTcg2Count, NULL);
+ XmlTag(info, "BlockDevices", TRUE, NULL, " count=\"%d\"", gBIOCount, NULL);
+ InitUsb();
+ XmlTag(info, "UsbDevices", TRUE, NULL, " count=\"%d\"", gUSBCount, NULL);
+ InitTouch();
+ XmlTag(info, "TouchDevices", FALSE, NULL, " count=\"%d\"", gTouchCount, NULL);
+ FileAsciiPrint(info, "\n");
+ gXmlTabs++;
+ for (i = 0; i < gTouchCount; ++i) {
+ EFI_ABSOLUTE_POINTER_PROTOCOL *aio;
+ res = TouchGetIO(gTouchHandles[i], &aio);
+ if (!EFI_ERROR(res)) {
+ XmlTag(info, "TouchDevice", TRUE, NULL,
+ " index=\"%d\" minx=\"%d\" miny=\"%d\" minz=\"%d\" maxx=\"%d\" maxy=\"%d\" maxz=\"%d\" attr=\"0x0%x\"", i,
+ aio->Mode->AbsoluteMinX, aio->Mode->AbsoluteMinY, aio->Mode->AbsoluteMinZ,
+ aio->Mode->AbsoluteMaxX, aio->Mode->AbsoluteMaxY, aio->Mode->AbsoluteMaxZ,
+ aio->Mode->Attributes, NULL);
+ }
+ }
+ XmlEndTag(info, "TouchDevices");
+ InitGraph();
+ XmlTag(info, "GraphDevices", FALSE, NULL, " count=\"%d\"", gGraphCount, NULL);
+ FileAsciiPrint(info, "\n");
+ gXmlTabs++;
+ for (i = 0; i < gGraphCount; ++i) {
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *gio;
+ res = GraphGetIO(gGraphHandles[i], &gio);
+ if (!EFI_ERROR(res)) {
+ XmlTag(info, "GraphDevice", FALSE, NULL,
+ " index=\"%d\" modes=\"%d\" H=\"%d\" V=\"%d\"", i,
+ gio->Mode->MaxMode, gio->Mode->Info->HorizontalResolution, gio->Mode->Info->VerticalResolution,
+ NULL);
+ FileAsciiPrint(info, "\n");
+ gXmlTabs++;
+ for (j = 0; j < gio->Mode->MaxMode; ++j) {
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode;
+ UINTN sz = sizeof(mode);
+ res = gio->QueryMode(gio, (UINT32)j, &sz, &mode);
+ if (!EFI_ERROR(res)) {
+ XmlTag(info, "GraphMode", TRUE, NULL,
+ " index=\"%d\" H=\"%d\" V=\"%d\"", j,
+ mode->HorizontalResolution, mode->VerticalResolution,
+ NULL);
+ }
+ }
+ XmlEndTag(info, "GraphDevice");
+ }
+ }
+ XmlEndTag(info, "GraphDevices");
+ InitBluetooth();
+ XmlTag(info, "BluetoothIo", TRUE, NULL, " count=\"%d\"", gBluetoothIoCount, NULL);
+ XmlTag(info, "BluetoothConfig", TRUE, NULL, " count=\"%d\"", gBluetoothConfigCount, NULL);
+ XmlTag(info, "BluetoothHC", TRUE, NULL, " count=\"%d\"", gBluetoothHcCount, NULL);
+ XmlEndTag(info, "PlatformInfo");
+ FileClose(info);
+ return EFI_SUCCESS;
+}
diff --git a/DcsInfo/DcsInfo.inf b/DcsInfo/DcsInfo.inf
new file mode 100644
index 0000000..64eadee
--- /dev/null
+++ b/DcsInfo/DcsInfo.inf
@@ -0,0 +1,77 @@
+## @file
+# This is DCS platform information application
+#
+# Copyright (c) 2016. Disk Cryptography Services for EFI (DCS), Alex Kolotnikov
+# Copyright (c) 2016. VeraCrypt, Mounir IDRASSI
+#
+# This program and the accompanying materials are licensed and made available
+# under the terms and conditions of the GNU Lesser General Public License, version 3.0 (LGPL-3.0).
+#
+# The full text of the license may be found at
+# https://opensource.org/licenses/LGPL-3.0
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = DcsInfo
+ FILE_GUID = 49AD8535-F480-46C9-9E4D-2EC11041F39D
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 1.0
+ ENTRY_POINT = DcsInfoMain
+
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources]
+ DcsInfo.c
+
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ DcsPkg/DcsPkg.dec
+
+[LibraryClasses]
+ UefiApplicationEntryPoint
+ UefiLib
+ BaseLib
+ MemoryAllocationLib
+ PasswordLib
+ GraphLib
+ CommonLib
+
+[Guids]
+ gEfiGlobalVariableGuid
+ gEfiDcsVariableGuid
+ gEfiFileInfoGuid
+
+[Protocols]
+ gEfiBlockIoProtocolGuid
+
+[BuildOptions.IA32]
+RELEASE_VS2010x86_IA32_CC_FLAGS = /FAcs /D_UEFI
+DEBUG_VS2010x86_IA32_CC_FLAGS = /FAcs /D_UEFI
+NOOPT_VS2010x86_IA32_CC_FLAGS = /FAcs /D_UEFI
+
+RELEASE_VS2015x86_IA32_CC_FLAGS = /arch:IA32 /FAcs /D_UEFI
+DEBUG_VS2015x86_IA32_CC_FLAGS = /arch:IA32 /FAcs /D_UEFI
+NOOPT_VS2015x86_IA32_CC_FLAGS = /arch:IA32 /FAcs /D_UEFI
+
+[BuildOptions.X64]
+RELEASE_VS2010x86_X64_CC_FLAGS = /D_UEFI
+DEBUG_VS2010x86_X64_CC_FLAGS = /D_UEFI
+NOOPT_VS2010x86_X64_CC_FLAGS = /D_UEFI
+
+RELEASE_VS2015x86_X64_CC_FLAGS = /D_UEFI
+DEBUG_VS2015x86_X64_CC_FLAGS = /D_UEFI
+NOOPT_VS2015x86_X64_CC_FLAGS = /D_UEFI
+
+[FeaturePcd]
+
+[Pcd]
+
diff --git a/DcsInt/DcsInt.c b/DcsInt/DcsInt.c
index aaeaafc..1499069 100644
--- a/DcsInt/DcsInt.c
+++ b/DcsInt/DcsInt.c
@@ -31,6 +31,7 @@ https://opensource.org/licenses/LGPL-3.0
#include "common/Crc.h"
#include "crypto/cpu.h"
#include "BootCommon.h"
+#include "DcsConfig.h"
#include "DcsVeraCrypt.h"
#include <Guid/EventGroup.h>
diff --git a/DcsPkg.dsc b/DcsPkg.dsc
index 8b1004f..7dc04e5 100644
--- a/DcsPkg.dsc
+++ b/DcsPkg.dsc
@@ -97,5 +97,6 @@
DcsPkg/DcsCfg/DcsCfg.inf
DcsPkg/DcsBoot/DcsBoot.inf
DcsPkg/DcsRe/DcsRe.inf
+ DcsPkg/DcsInfo/DcsInfo.inf
DcsPkg/DcsBml/DcsBml.inf
DcsPkg/LegacySpeaker/LegacySpeaker.inf
diff --git a/Dcs_bld.bat b/Dcs_bld.bat
index ff55c73..a18a4c8 100644
--- a/Dcs_bld.bat
+++ b/Dcs_bld.bat
@@ -33,6 +33,7 @@ call SecureBoot\efi_sign.bat ..\Build\DcsPkg\%dcstype%_%dcsbldtoolset%\%dcsarch%
call SecureBoot\efi_sign.bat ..\Build\DcsPkg\%dcstype%_%dcsbldtoolset%\%dcsarch%\DcsCfg.efi SecureBoot\keys\DCS_sign.pfx SecureBoot\certs\DCS_sign.crt
call SecureBoot\efi_sign.bat ..\Build\DcsPkg\%dcstype%_%dcsbldtoolset%\%dcsarch%\DcsInt.efi SecureBoot\keys\DCS_sign.pfx SecureBoot\certs\DCS_sign.crt
call SecureBoot\efi_sign.bat ..\Build\DcsPkg\%dcstype%_%dcsbldtoolset%\%dcsarch%\DcsRe.efi SecureBoot\keys\DCS_sign.pfx SecureBoot\certs\DCS_sign.crt
+call SecureBoot\efi_sign.bat ..\Build\DcsPkg\%dcstype%_%dcsbldtoolset%\%dcsarch%\DcsInfo.efi SecureBoot\keys\DCS_sign.pfx SecureBoot\certs\DCS_sign.crt
call SecureBoot\efi_sign.bat ..\Build\DcsPkg\%dcstype%_%dcsbldtoolset%\%dcsarch%\LegacySpeaker.efi SecureBoot\keys\DCS_sign.pfx SecureBoot\certs\DCS_sign.crt
:exit
diff --git a/Include/Library/CommonLib.h b/Include/Library/CommonLib.h
index 5f96bba..950406f 100644
--- a/Include/Library/CommonLib.h
+++ b/Include/Library/CommonLib.h
@@ -137,6 +137,33 @@ EfiFindPartByGUID(
);
//////////////////////////////////////////////////////////////////////////
+// Bluetooth
+//////////////////////////////////////////////////////////////////////////
+extern EFI_HANDLE* gBluetoothIoHandles;
+extern UINTN gBluetoothIoCount;
+
+extern EFI_HANDLE* gBluetoothHcHandles;
+extern UINTN gBluetoothHcCount;
+
+extern EFI_HANDLE* gBluetoothConfigHandles;
+extern UINTN gBluetoothConfigCount;
+
+EFI_STATUS
+InitBluetooth();
+
+//////////////////////////////////////////////////////////////////////////
+// TCG
+//////////////////////////////////////////////////////////////////////////
+extern EFI_HANDLE* gTcgHandles;
+extern UINTN gTcgCount;
+
+extern EFI_HANDLE* gTcg2Handles;
+extern UINTN gTcg2Count;
+
+EFI_STATUS
+InitTcg();
+
+//////////////////////////////////////////////////////////////////////////
// USB
//////////////////////////////////////////////////////////////////////////
extern EFI_HANDLE* gUSBHandles;
@@ -510,6 +537,13 @@ FileWrite(
IN OUT UINTN* bytes,
IN OUT UINT64* position);
+UINTN
+FileAsciiPrint(
+ IN EFI_FILE *f,
+ IN CONST CHAR8 *format,
+ ...
+ );
+
EFI_STATUS
FileGetInfo(
IN EFI_FILE* f,
diff --git a/Include/Library/PasswordLib.h b/Include/Library/PasswordLib.h
index 3396164..7ed31c5 100644
--- a/Include/Library/PasswordLib.h
+++ b/Include/Library/PasswordLib.h
@@ -63,9 +63,17 @@ AskConsolePwdInt(
extern EFI_GUID* gSmbSystemUUID; // Universal unique ID
extern CHAR8* gSmbSystemSerial; // System serial
extern CHAR8* gSmbSystemSKU; // SKU number
+extern CHAR8* gSmbSystemManufacture; // computer manufacture
+extern CHAR8* gSmbSystemModel; // computer model
+extern CHAR8* gSmbSystemVersion; // computer version
+
extern CHAR8* gSmbBaseBoardSerial; // Base board serial
extern UINT64* gSmbProcessorID; // Processor ID
+extern CHAR8* gSmbBiosVendor; // BIOS vendor
+extern CHAR8* gSmbBiosVersion; // BIOS version
+extern CHAR8* gSmbBiosDate; // BIOS date
+
EFI_STATUS
SMBIOSGetSerials();
diff --git a/Library/CommonLib/CommonLib.inf b/Library/CommonLib/CommonLib.inf
index 2c379b8..b5758f5 100644
--- a/Library/CommonLib/CommonLib.inf
+++ b/Library/CommonLib/CommonLib.inf
@@ -36,6 +36,8 @@
EfiExec.c
EfiUsb.c
EfiTouch.c
+ EfiBluetooth.c
+ EfiTpm.c
[Sources.IA32]
IA32/EfiCpuHalt.asm
@@ -63,3 +65,8 @@
gEfiAbsolutePointerProtocolGuid
gEfiGraphicsOutputProtocolGuid
gEfiSimpleTextOutProtocolGuid
+ gEfiBluetoothIoProtocolGuid
+ gEfiBluetoothHcProtocolGuid
+ gEfiBluetoothConfigProtocolGuid
+ gEfiTcgProtocolGuid
+ gEfiTcg2ProtocolGuid
diff --git a/Library/CommonLib/EfiBluetooth.c b/Library/CommonLib/EfiBluetooth.c
new file mode 100644
index 0000000..13b03e3
--- /dev/null
+++ b/Library/CommonLib/EfiBluetooth.c
@@ -0,0 +1,50 @@
+/** @file
+EFI BLUETOOTH helpers
+
+Copyright (c) 2016. Disk Cryptography Services for EFI (DCS), Alex Kolotnikov
+Copyright (c) 2016. VeraCrypt, Mounir IDRASSI
+
+This program and the accompanying materials are licensed and made available
+under the terms and conditions of the GNU Lesser General Public License, version 3.0 (LGPL-3.0).
+
+The full text of the license may be found at
+https://opensource.org/licenses/LGPL-3.0
+**/
+
+#include <Library/CommonLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/PrintLib.h>
+#include <Protocol/BluetoothIo.h>
+#include <Protocol/BluetoothConfig.h>
+#include <Protocol/BluetoothHc.h>
+
+EFI_HANDLE* gBluetoothIoHandles = NULL;
+UINTN gBluetoothIoCount = 0;
+
+EFI_HANDLE* gBluetoothHcHandles = NULL;
+UINTN gBluetoothHcCount = 0;
+
+EFI_HANDLE* gBluetoothConfigHandles = NULL;
+UINTN gBluetoothConfigCount = 0;
+
+EFI_STATUS
+InitBluetooth() {
+ EFI_STATUS res;
+ res = EfiGetHandles(ByProtocol, &gEfiBluetoothIoProtocolGuid, 0, &gBluetoothIoHandles, &gBluetoothIoCount);
+ res = EfiGetHandles(ByProtocol, &gEfiBluetoothHcProtocolGuid, 0, &gBluetoothHcHandles, &gBluetoothHcCount);
+ res = EfiGetHandles(ByProtocol, &gEfiBluetoothConfigProtocolGuid, 0, &gBluetoothConfigHandles, &gBluetoothConfigCount);
+ return res;
+}
+
+EFI_STATUS
+BluetoothGetIO(
+ IN EFI_HANDLE Handle,
+ OUT EFI_BLUETOOTH_IO_PROTOCOL** io
+ ) {
+ if (!io) {
+ return EFI_INVALID_PARAMETER;
+ }
+ return gBS->HandleProtocol(Handle, &gEfiBluetoothIoProtocolGuid, (VOID**)io);
+}
+
diff --git a/Library/CommonLib/EfiFile.c b/Library/CommonLib/EfiFile.c
index b1e2076..fdc999c 100644
--- a/Library/CommonLib/EfiFile.c
+++ b/Library/CommonLib/EfiFile.c
@@ -18,6 +18,7 @@ https://opensource.org/licenses/LGPL-3.0
#include <Guid/FileInfo.h>
#include <Guid/FileSystemInfo.h>
#include <Library/BaseMemoryLib.h>
+#include <Library/PrintLib.h>
//////////////////////////////////////////////////////////////////////////
// EFI file
@@ -151,6 +152,24 @@ FileWrite(
return res;
}
+CHAR8 gFileAsciiPrintBuffer[1024];
+
+UINTN
+FileAsciiPrint(
+ IN EFI_FILE *f,
+ IN CONST CHAR8 *format,
+ ...
+ ) {
+ VA_LIST marker;
+ UINTN len;
+ if (f == NULL) return 0;
+ VA_START(marker, format);
+ len = AsciiVSPrint((CHAR8*)gFileAsciiPrintBuffer, sizeof(gFileAsciiPrintBuffer), format, marker);
+ VA_END(marker);
+ f->Write(f, &len, gFileAsciiPrintBuffer);
+ return len;
+}
+
EFI_STATUS
FileGetInfo(
IN EFI_FILE* f,
diff --git a/Library/CommonLib/EfiTpm.c b/Library/CommonLib/EfiTpm.c
new file mode 100644
index 0000000..9b236c5
--- /dev/null
+++ b/Library/CommonLib/EfiTpm.c
@@ -0,0 +1,34 @@
+/** @file
+EFI TCG/TPM helpers
+
+Copyright (c) 2016. Disk Cryptography Services for EFI (DCS), Alex Kolotnikov
+Copyright (c) 2016. VeraCrypt, Mounir IDRASSI
+
+This program and the accompanying materials are licensed and made available
+under the terms and conditions of the GNU Lesser General Public License, version 3.0 (LGPL-3.0).
+
+The full text of the license may be found at
+https://opensource.org/licenses/LGPL-3.0
+**/
+
+#include <Library/CommonLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/PrintLib.h>
+#include <Protocol/TcgService.h>
+#include <Protocol/Tcg2Protocol.h>
+
+EFI_HANDLE* gTcgHandles = NULL;
+UINTN gTcgCount = 0;
+
+EFI_HANDLE* gTcg2Handles = NULL;
+UINTN gTcg2Count = 0;
+
+EFI_STATUS
+InitTcg() {
+ EFI_STATUS res;
+ res = EfiGetHandles(ByProtocol, &gEfiTcgProtocolGuid, 0, &gTcgHandles, &gTcgCount);
+ res = EfiGetHandles(ByProtocol, &gEfiTcg2ProtocolGuid, 0, &gTcg2Handles, &gTcg2Count);
+ return res;
+}
+
diff --git a/Library/PasswordLib/PlatformID.c b/Library/PasswordLib/PlatformID.c
index 63b2e7d..100b0c0 100644
--- a/Library/PasswordLib/PlatformID.c
+++ b/Library/PasswordLib/PlatformID.c
@@ -24,9 +24,19 @@ SMBIOS_TABLE_ENTRY_POINT* gSmbTable = NULL;
EFI_GUID* gSmbSystemUUID = NULL; // Universal unique ID
CHAR8* gSmbSystemSerial = NULL; // System serial
CHAR8* gSmbSystemSKU = NULL; // SKU number
+CHAR8* gSmbSystemManufacture = NULL; // computer manufacture
+CHAR8* gSmbSystemModel = NULL; // computer model
+CHAR8* gSmbSystemVersion = NULL; // computer version
+
CHAR8* gSmbBaseBoardSerial = NULL; // Base board serial
UINT64* gSmbProcessorID = NULL; // Processor ID
+CHAR8* gSmbBiosVendor = NULL; // BIOS vendor
+CHAR8* gSmbBiosVersion = NULL; // BIOS version
+CHAR8* gSmbBiosDate = NULL; // BIOS date
+
+
+
UINTN gBioIndexAuth = 0;
typedef struct _DCS_AUTH_DATA_MARK {
UINT32 HeaderCrc;
@@ -81,9 +91,18 @@ SMBIOSGetSerials()
endOfTable = pSMBIOS.Raw + gSmbTable->TableLength;
do {
SMBIOS_STRUCTURE* smbtbl = (SMBIOS_STRUCTURE*)pos;
+ // BIOS information
+ if (smbtbl->Type == 0) {
+ gSmbBiosVendor = SMBIOSGetString(1, smbtbl, endOfTable);
+ gSmbBiosVersion = SMBIOSGetString(2, smbtbl, endOfTable);
+ gSmbBiosDate = SMBIOSGetString(3, smbtbl, endOfTable);
+ }
// System info
if (smbtbl->Type == 1) {
gSmbSystemUUID = (EFI_GUID*)&pos[8];
+ gSmbSystemManufacture = SMBIOSGetString(1, smbtbl, endOfTable);
+ gSmbSystemModel = SMBIOSGetString(2, smbtbl, endOfTable);
+ gSmbSystemVersion = SMBIOSGetString(3, smbtbl, endOfTable);
gSmbSystemSerial = SMBIOSGetString(4, smbtbl, endOfTable);
gSmbSystemSKU = SMBIOSGetString(5, smbtbl, endOfTable);
}
diff --git a/Library/VeraCryptLib/DcsConfig.c b/Library/VeraCryptLib/DcsConfig.c
new file mode 100644
index 0000000..00aa5f8
--- /dev/null
+++ b/Library/VeraCryptLib/DcsConfig.c
@@ -0,0 +1,72 @@
+/** @file
+Interface for DCS
+
+Copyright (c) 2016. Disk Cryptography Services for EFI (DCS), Alex Kolotnikov
+Copyright (c) 2016. VeraCrypt, Mounir IDRASSI
+
+This program and the accompanying materials
+are licensed and made available under the terms and conditions
+of the Apache License, Version 2.0.
+
+The full text of the license may be found at
+https://opensource.org/licenses/Apache-2.0
+**/
+
+#include <Uefi.h>
+#include <DcsConfig.h>
+
+#include <Library/CommonLib.h>
+#include "common/Xml.h"
+
+//////////////////////////////////////////////////////////////////////////
+// Config
+//////////////////////////////////////////////////////////////////////////
+char *gConfigBuffer = NULL;
+UINTN gConfigBufferSize = 0;
+
+BOOLEAN
+ConfigRead(char *configKey, char *configValue, int maxValueSize)
+{
+ char *xml;
+
+ if (gConfigBuffer == NULL) {
+ if (FileLoad(NULL, L"\\EFI\\VeraCrypt\\DcsProp", &gConfigBuffer, &gConfigBufferSize) != EFI_SUCCESS) {
+ return FALSE;
+ }
+ }
+
+ xml = gConfigBuffer;
+ if (xml != NULL)
+ {
+ xml = XmlFindElementByAttributeValue(xml, "config", "key", configKey);
+ if (xml != NULL)
+ {
+ XmlGetNodeText(xml, configValue, maxValueSize);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+int ConfigReadInt(char *configKey, int defaultValue)
+{
+ char s[32];
+ if (ConfigRead(configKey, s, sizeof(s))) {
+ if (*s == '-') {
+ return (-1) * (int)AsciiStrDecimalToUintn(&s[1]);
+ }
+ return (int)AsciiStrDecimalToUintn(s);
+ }
+ else
+ return defaultValue;
+}
+
+
+char *ConfigReadString(char *configKey, char *defaultValue, char *str, int maxLen)
+{
+ if (!ConfigRead(configKey, str, maxLen)) {
+ AsciiStrCpyS(str, maxLen, defaultValue);
+ }
+ return str;
+}
diff --git a/Library/VeraCryptLib/DcsConfig.h b/Library/VeraCryptLib/DcsConfig.h
new file mode 100644
index 0000000..04719d9
--- /dev/null
+++ b/Library/VeraCryptLib/DcsConfig.h
@@ -0,0 +1,29 @@
+/** @file
+Interface for DCS services
+
+Copyright (c) 2016. Disk Cryptography Services for EFI (DCS), Alex Kolotnikov
+Copyright (c) 2016. VeraCrypt, Mounir IDRASSI
+
+This program and the accompanying materials
+are licensed and made available under the terms and conditions
+of the Apache License, Version 2.0.
+
+The full text of the license may be found at
+https://opensource.org/licenses/Apache-2.0
+**/
+
+#ifndef __DCSCONFIG_H__
+#define __DCSCONFIG_H__
+
+#include <Uefi.h>
+
+//////////////////////////////////////////////////////////////////////////
+// Config
+//////////////////////////////////////////////////////////////////////////
+extern char *gConfigBuffer;
+extern UINTN gConfigBufferSize;
+
+BOOLEAN ConfigRead(char *configKey, char *configValue, int maxValueSize);
+int ConfigReadInt(char *configKey, int defaultValue);
+char *ConfigReadString(char *configKey, char *defaultValue, char *str, int maxLen);
+#endif
diff --git a/Library/VeraCryptLib/DcsVeraCrypt.c b/Library/VeraCryptLib/DcsVeraCrypt.c
index 2979064..d5680ba 100644
--- a/Library/VeraCryptLib/DcsVeraCrypt.c
+++ b/Library/VeraCryptLib/DcsVeraCrypt.c
@@ -23,62 +23,11 @@ https://opensource.org/licenses/Apache-2.0
#include <common/Password.h>
#include "common/Crypto.h"
-#include "common/Xml.h"
#include "common/Crc.h"
#include "BootCommon.h"
#include "Library/DcsTpmLib.h"
+#include <DcsConfig.h>
-//////////////////////////////////////////////////////////////////////////
-// Config
-//////////////////////////////////////////////////////////////////////////
-char *gConfigBuffer = NULL;
-UINTN gConfigBufferSize = 0;
-
-BOOL ConfigRead(char *configKey, char *configValue, int maxValueSize)
-{
- char *xml;
-
- if (gConfigBuffer == NULL) {
- if (FileLoad(NULL, L"\\EFI\\VeraCrypt\\DcsProp", &gConfigBuffer, &gConfigBufferSize) != EFI_SUCCESS) {
- return FALSE;
- }
- }
-
- xml = gConfigBuffer;
- if (xml != NULL)
- {
- xml = XmlFindElementByAttributeValue(xml, "config", "key", configKey);
- if (xml != NULL)
- {
- XmlGetNodeText(xml, configValue, maxValueSize);
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-int ConfigReadInt(char *configKey, int defaultValue)
-{
- char s[32];
- if (ConfigRead(configKey, s, sizeof(s))) {
- if (*s == '-') {
- return (-1) * (int)AsciiStrDecimalToUintn(&s[1]);
- }
- return (int)AsciiStrDecimalToUintn(s);
- }
- else
- return defaultValue;
-}
-
-
-char *ConfigReadString(char *configKey, char *defaultValue, char *str, int maxLen)
-{
- if (!ConfigRead(configKey, str, maxLen)) {
- AsciiStrCpyS(str, maxLen, defaultValue);
- }
- return str;
-}
///////////////////////////////////////////////////////////////////////////
diff --git a/Library/VeraCryptLib/DcsVeraCrypt.h b/Library/VeraCryptLib/DcsVeraCrypt.h
index 23eb4a2..41dc6c2 100644
--- a/Library/VeraCryptLib/DcsVeraCrypt.h
+++ b/Library/VeraCryptLib/DcsVeraCrypt.h
@@ -19,9 +19,6 @@ https://opensource.org/licenses/Apache-2.0
#include <common/Tcdefs.h>
#include <common/Password.h>
-extern char *gConfigBuffer;
-extern UINTN gConfigBufferSize;
-
//////////////////////////////////////////////////////////////////////////
// Auth
//////////////////////////////////////////////////////////////////////////
diff --git a/Library/VeraCryptLib/VeraCryptLib.inf b/Library/VeraCryptLib/VeraCryptLib.inf
index 529043f..a208f9c 100644
--- a/Library/VeraCryptLib/VeraCryptLib.inf
+++ b/Library/VeraCryptLib/VeraCryptLib.inf
@@ -62,6 +62,8 @@ crypto\Camellia.c
crypto\Camellia.h
crypto\cpu.c
crypto\cpu.h
+DcsConfig.c
+DcsConfig.h
DcsVeraCrypt.c
DcsVeraCrypt.h