VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--DcsCfg/DcsCfgCrypt.c13
-rw-r--r--DcsCfg/DcsCfgMain.c44
-rw-r--r--DcsInt/DcsInt.c50
-rw-r--r--Include/Library/CommonLib.h30
-rw-r--r--Include/Library/DcsCfgLib.h27
-rw-r--r--Include/Library/PasswordLib.h7
-rw-r--r--Library/CommonLib/GptRead.c157
-rw-r--r--Library/DcsCfgLib/GptEdit.c133
-rw-r--r--Library/PasswordLib/PicturePassword.c10
-rw-r--r--Library/PasswordLib/PlatformID.c86
-rw-r--r--Library/VeraCryptLib/DcsConfig.c4
-rw-r--r--Library/VeraCryptLib/DcsConfig.h2
-rw-r--r--Library/VeraCryptLib/DcsVeraCrypt.c30
13 files changed, 566 insertions, 27 deletions
diff --git a/DcsCfg/DcsCfgCrypt.c b/DcsCfg/DcsCfgCrypt.c
index 45523dd..94f8768 100644
--- a/DcsCfg/DcsCfgCrypt.c
+++ b/DcsCfg/DcsCfgCrypt.c
@@ -1380,6 +1380,8 @@ SecRigionAdd(
EFI_BLOCK_IO_PROTOCOL* bio;
UINT8* regionData;
UINTN regionSize;
+ UINT8* padding = NULL;
+ UINTN paddingSize = 0;
INTN deListHdrIdOk;
res = FileLoad(NULL, (CHAR16*)DcsDiskEntrysFileName, &regionData, &regionSize);
if (EFI_ERROR(res)) {
@@ -1400,9 +1402,18 @@ SecRigionAdd(
res = EFI_ACCESS_DENIED;
goto error;
}
-
+ paddingSize = regionSize & 0x01FF;
+ regionSize -= paddingSize;
res = bio->WriteBlocks(bio, bio->Media->MediaId, 62 + regIdx * (128 * 1024 / 512), regionSize, regionData);
+ if (!EFI_ERROR(res) &&
+ paddingSize != 0) {
+ padding = MEM_ALLOC(512);
+ CopyMem(padding, regionData + regionSize, paddingSize);
+ res = bio->WriteBlocks(bio, bio->Media->MediaId, 62 + regIdx * ((128 * 1024 ) / 512) + regionSize / 512, 512, padding);
+ MEM_FREE(padding);
+ }
+
if (EFI_ERROR(res)) {
ERR_PRINT(L"Write: %r\n", res);
goto error;
diff --git a/DcsCfg/DcsCfgMain.c b/DcsCfg/DcsCfgMain.c
index 6e4c863..ec92b25 100644
--- a/DcsCfg/DcsCfgMain.c
+++ b/DcsCfg/DcsCfgMain.c
@@ -81,8 +81,22 @@ https://opensource.org/licenses/LGPL-3.0
#define OPT_TPM_PCRS L"-tpmpcrs"
#define OPT_TPM_NVLIST L"-tpmnvlist"
#define OPT_TPM_CFG L"-tpmcfg"
+
+#define OPT_TBL_FILE L"-tbf"
+#define OPT_TBL_ZERO L"-tbz"
+#define OPT_TBL_LIST L"-tbl"
+#define OPT_TBL_NAME L"-tbn"
+#define OPT_TBL_DELETE L"-tbd"
+#define OPT_TBL_APPEND L"-tba"
+
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- { OPT_DISK_LIST, TypeValue },
+ { OPT_TBL_FILE, TypeValue },
+ { OPT_TBL_ZERO, TypeFlag },
+ { OPT_TBL_LIST, TypeFlag },
+ { OPT_TBL_DELETE, TypeFlag },
+ { OPT_TBL_NAME, TypeValue },
+ { OPT_TBL_APPEND, TypeValue },
+ { OPT_DISK_LIST, TypeValue },
{ OPT_DISK_CHECK, TypeFlag },
{ OPT_DISK_START, TypeValue },
{ OPT_DISK_END, TypeValue },
@@ -228,6 +242,34 @@ DcsCfgMain(
DcsDiskEntrysFileName = ShellCommandLineGetValue(Package, OPT_PARTITION_FILE);
}
+ if (ShellCommandLineGetFlag(Package, OPT_TBL_FILE)) {
+ DcsTablesFileName = ShellCommandLineGetValue(Package, OPT_TBL_FILE);
+ }
+
+ if (ShellCommandLineGetFlag(Package, OPT_TBL_DELETE) &&
+ ShellCommandLineGetFlag(Package, OPT_TBL_NAME)
+ ) {
+ CONST CHAR16* opt1 = NULL;
+ opt1 = ShellCommandLineGetValue(Package, OPT_TBL_NAME);
+ res = TablesDel(opt1);
+ }
+
+ if (ShellCommandLineGetFlag(Package, OPT_TBL_APPEND) &&
+ ShellCommandLineGetFlag(Package, OPT_TBL_NAME)
+ ) {
+ CONST CHAR16* opt1 = NULL;
+ CONST CHAR16* opt2 = NULL;
+ opt1 = ShellCommandLineGetValue(Package, OPT_TBL_NAME);
+ opt2 = ShellCommandLineGetValue(Package, OPT_TBL_APPEND);
+ res = TablesNew(opt1, opt2);
+ }
+
+ if (ShellCommandLineGetFlag(Package, OPT_TBL_LIST)) {
+ if (gDcsTables == NULL) TablesLoad();
+ OUT_PRINT(L"Size = %d, Zones=%d\n", gDcsTablesSize, (gDcsTablesSize + 128 * 1024 - 1) / (128 * 1024));
+ TablesList(gDcsTablesSize, gDcsTables);
+ }
+
if (ShellCommandLineGetFlag(Package, OPT_AUTH_ASK)) {
TestAuthAsk();
}
diff --git a/DcsInt/DcsInt.c b/DcsInt/DcsInt.c
index e792993..06f8841 100644
--- a/DcsInt/DcsInt.c
+++ b/DcsInt/DcsInt.c
@@ -24,6 +24,7 @@ https://opensource.org/licenses/LGPL-3.0
#include <Library/BaseLib.h>
#include <Library/DcsCfgLib.h>
#include <Library/DcsTpmLib.h>
+#include <Library/PasswordLib.h>
#include "common/Tcdefs.h"
#include "common/Crypto.h"
@@ -67,7 +68,7 @@ typedef struct _BOOT_PARAMS {
UINT32 gHeaderSaltCrc32 = 0;
PBOOT_PARAMS bootParams = NULL;
-//#define EFI_BOOTARGS_REGIONS_TEST ,0x9000000, 0xA000000
+// #define EFI_BOOTARGS_REGIONS_TEST ,0x9000000, 0xA000000
#define EFI_BOOTARGS_REGIONS_TEST
UINTN BootArgsRegions[] = { EFI_BOOTARGS_REGIONS_HIGH, EFI_BOOTARGS_REGIONS_LOW EFI_BOOTARGS_REGIONS_TEST };
@@ -640,6 +641,15 @@ SecRegionTryDecrypt()
}
OUT_PRINT(L"%a", gAuthStartMsg);
do {
+ // EFI tables?
+ if (TablesVerify(SecRegionSize - SecRegionOffset, SecRegionData + SecRegionOffset)) {
+ EFI_TABLE_HEADER *mhdr = (EFI_TABLE_HEADER *)(SecRegionData + SecRegionOffset);
+ UINTN tblZones = (mhdr->HeaderSize + 1024 * 128 - 1) / (1024 * 128);
+ SecRegionOffset += tblZones * 1024 * 128;
+ vcres = 1;
+ continue;
+ }
+ // Try authorize zone
CopyMem(Header, SecRegionData + SecRegionOffset, 512);
vcres = ReadVolumeHeader(gAuthBoot, Header, &gAuthPassword, gAuthHash, gAuthPim, gAuthTc, &SecRegionCryptInfo, NULL);
SecRegionOffset += (vcres != 0) ? 1024 * 128 : 0;
@@ -943,6 +953,40 @@ VirtualNotifyEvent(
}
//////////////////////////////////////////////////////////////////////////
+// Open tables
+//////////////////////////////////////////////////////////////////////////
+UINT8* gOpenTables = NULL;
+
+BOOLEAN
+SecRegionTablesFind(UINT8* secRegion, UINTN secRegionSize, VOID** tables) {
+ UINTN pos = 0;
+ while (pos < SecRegionSize) {
+ if (TablesVerify(secRegionSize - pos, secRegion + pos)) {
+ *tables = secRegion + pos;
+ return TRUE;
+ }
+ pos += 128 * 1024;
+ }
+ return FALSE;
+}
+
+#define DCSPROP_HEADER_SIGN SIGNATURE_64('D','C','S','P','R','O','P','_')
+#define PICTPWD_HEADER_SIGN SIGNATURE_64('P','I','C','T','P','W','D','_')
+
+VOID
+VCAuthLoadConfigUpdated(UINT8* secRegion, UINTN secRegionSize) {
+ if (SecRegionTablesFind(secRegion, secRegionSize, &gOpenTables)) {
+ if (TablesGetData(gOpenTables, DCSPROP_HEADER_SIGN, &gConfigBufferUpdated, &gConfigBufferUpdatedSize)) {
+ // Reload config parameters
+ MEM_FREE(gAuthPasswordMsg);
+ gAuthPasswordMsg = NULL;
+ VCAuthLoadConfig();
+ }
+ TablesGetData(gOpenTables, PICTPWD_HEADER_SIGN, &gPictPwdBmp, &gPictPwdBmpSize);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////
// Driver Entry Point
//////////////////////////////////////////////////////////////////////////
EFI_STATUS
@@ -966,6 +1010,7 @@ UefiMain(
EFI_INPUT_KEY key;
EfiPrintDevicePath(SecRegionHandle);
OUT_PRINT(L"\n");
+ VCAuthLoadConfigUpdated(SecRegionData, SecRegionSize);
key = KeyWait(L"%2d \r", 2, 0, 0);
if (key.UnicodeChar != 0) {
GetKey();
@@ -1015,7 +1060,8 @@ UefiMain(
if (EFI_ERROR(res)) {
return OnExit(gOnExitNotFound, OnExitAuthNotFound, res);
}
- // force password type and message
+ // force password type and message to simulate "press ESC to continue"
+ MEM_FREE(gAuthPasswordMsg);
gAuthPasswordType = gForcePasswordType;
gAuthPasswordMsg = gForcePasswordMsg;
gPasswordProgress = gForcePasswordProgress;
diff --git a/Include/Library/CommonLib.h b/Include/Library/CommonLib.h
index 98e93db..2c698d0 100644
--- a/Include/Library/CommonLib.h
+++ b/Include/Library/CommonLib.h
@@ -174,6 +174,36 @@ GptReadHeader(
);
//////////////////////////////////////////////////////////////////////////
+// General EFI tables
+//////////////////////////////////////////////////////////////////////////
+#define EFITABLE_HEADER_SIGN SIGNATURE_64('E','F','I','T','A','B','L','E')
+
+BOOLEAN
+TablesVerify(
+ IN UINTN maxSize,
+ IN VOID* tables);
+
+BOOLEAN
+TablesGetData(
+ IN VOID* tables,
+ IN UINT64 sign,
+ OUT VOID** data,
+ OUT UINTN* size);
+
+BOOLEAN
+TablesDelete(
+ IN VOID* tables,
+ IN UINT64 sign
+ );
+
+BOOLEAN
+TablesAppend(
+ IN OUT VOID** tables,
+ IN UINT64 sign,
+ IN VOID* data,
+ IN UINTN size);
+
+//////////////////////////////////////////////////////////////////////////
// Bluetooth
//////////////////////////////////////////////////////////////////////////
extern EFI_HANDLE* gBluetoothIoHandles;
diff --git a/Include/Library/DcsCfgLib.h b/Include/Library/DcsCfgLib.h
index 322aaa1..259004e 100644
--- a/Include/Library/DcsCfgLib.h
+++ b/Include/Library/DcsCfgLib.h
@@ -112,6 +112,33 @@ BOOLEAN
IsRegionOverlap(UINT64 start1, UINT64 end1, UINT64 start2, UINT64 end2);
//////////////////////////////////////////////////////////////////////////
+// Tables
+//////////////////////////////////////////////////////////////////////////
+extern CONST CHAR16* DcsTablesFileName;
+extern UINT8* gDcsTables;
+extern UINTN gDcsTablesSize;
+
+EFI_STATUS
+TablesDel(
+ IN CONST CHAR16* sign
+ );
+
+EFI_STATUS
+TablesNew(
+ IN CONST CHAR16* sign,
+ IN CONST CHAR16* dataFileName
+ );
+
+EFI_STATUS
+TablesLoad();
+
+BOOLEAN
+TablesList(
+ IN UINTN maxSize,
+ IN VOID* tables
+ );
+
+//////////////////////////////////////////////////////////////////////////
// Random
//////////////////////////////////////////////////////////////////////////
enum RndGeneratorTypes {
diff --git a/Include/Library/PasswordLib.h b/Include/Library/PasswordLib.h
index 7ed31c5..a827b16 100644
--- a/Include/Library/PasswordLib.h
+++ b/Include/Library/PasswordLib.h
@@ -25,6 +25,8 @@ extern UINTN gPasswordPictureCharsLen;
extern UINT8 gPasswordVisible;
extern UINT8 gPasswordProgress;
extern int gPasswordShowMark;
+extern VOID* gPictPwdBmp;
+extern UINTN gPictPwdBmpSize;
extern int gPlatformLocked;
extern int gTPMLocked;
@@ -114,4 +116,9 @@ PlatformGetAuthData(
OUT EFI_HANDLE *secRegionHandle
);
+//////////////////////////////////////////////////////////////////////////
+// Certificates
+//////////////////////////////////////////////////////////////////////////
+extern CHAR8* gDCS_platform_crt_der;
+
#endif \ No newline at end of file
diff --git a/Library/CommonLib/GptRead.c b/Library/CommonLib/GptRead.c
index 0eab963..9267531 100644
--- a/Library/CommonLib/GptRead.c
+++ b/Library/CommonLib/GptRead.c
@@ -60,14 +60,11 @@ GptHeaderCheckCrcAltSize(
Hdr->CRC32 = 0;
Status = gBS->CalculateCrc32((UINT8 *)Hdr, Size, &Crc);
+ Hdr->CRC32 = OrgCrc;
if (EFI_ERROR(Status)) {
return FALSE;
}
- //
// set results
- //
- Hdr->CRC32 = OrgCrc;
-
return (BOOLEAN)(OrgCrc == Crc);
}
@@ -213,3 +210,155 @@ GptReadHeader(
*PartHeader = PartHdr;
return EFI_SUCCESS;
}
+
+//////////////////////////////////////////////////////////////////////////
+// General EFI tables
+//////////////////////////////////////////////////////////////////////////
+
+BOOLEAN
+TablesVerify(
+ IN UINTN maxSize,
+ IN VOID* tables)
+{
+ EFI_TABLE_HEADER *mhdr = (EFI_TABLE_HEADER *)tables;
+ if (tables != NULL &&
+ mhdr->Signature == EFITABLE_HEADER_SIGN &&
+ GptHeaderCheckCrc(maxSize, mhdr)) {
+ UINT8* raw = (UINT8*)tables;
+ UINTN rawSize = mhdr->HeaderSize;
+ UINTN tpos = sizeof(EFI_TABLE_HEADER);
+ while (tpos < rawSize) {
+ EFI_TABLE_HEADER *hdr = (EFI_TABLE_HEADER *)(raw + tpos);
+ if (!GptHeaderCheckCrc(rawSize - tpos, hdr)) {
+ return FALSE; // wrong crc
+ }
+ tpos += hdr->HeaderSize;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+BOOLEAN
+TablesGetData(
+ IN VOID* tables,
+ IN UINT64 sign,
+ OUT VOID** data,
+ OUT UINTN* size)
+{
+ EFI_TABLE_HEADER *mhdr = (EFI_TABLE_HEADER *)tables;
+ if (tables != NULL &&
+ mhdr->Signature == EFITABLE_HEADER_SIGN &&
+ GptHeaderCheckCrc(0, mhdr)) {
+ UINT8* raw = (UINT8*)tables;
+ UINTN rawSize = mhdr->HeaderSize;
+ UINTN tpos = sizeof(EFI_TABLE_HEADER);
+ while (tpos < rawSize) {
+ EFI_TABLE_HEADER *hdr = (EFI_TABLE_HEADER *)(raw + tpos);
+ if (GptHeaderCheckCrc(rawSize - tpos, hdr)) {
+ if (hdr->Signature == sign) {
+ *data = raw + tpos + sizeof(EFI_TABLE_HEADER);
+ *size = hdr->HeaderSize - sizeof(EFI_TABLE_HEADER);
+ return TRUE;
+ }
+ tpos += hdr->HeaderSize;
+ }
+ else {
+ return FALSE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+BOOLEAN
+TablesDelete(
+ IN VOID* tables,
+ IN UINT64 sign
+ )
+{
+ EFI_TABLE_HEADER *mhdr = (EFI_TABLE_HEADER *)tables;
+ EFI_TABLE_HEADER *thdr = NULL;
+ UINT8* raw = (UINT8*)tables;
+ UINTN rawSize = mhdr->HeaderSize;
+ UINTN tpos = sizeof(EFI_TABLE_HEADER);
+ if (tables != NULL &&
+ mhdr->Signature == EFITABLE_HEADER_SIGN &&
+ GptHeaderCheckCrc(0, mhdr)) {
+ while (tpos < rawSize) {
+ EFI_TABLE_HEADER *hdr = (EFI_TABLE_HEADER *)(raw + tpos);
+ if (GptHeaderCheckCrc(rawSize - tpos, hdr)) {
+ if (hdr->Signature == sign) {
+ thdr = hdr;
+ break;
+ }
+ tpos += hdr->HeaderSize;
+ } else {
+ return FALSE;
+ }
+ }
+ if (thdr != NULL) {
+ UINT32 Crc;
+ UINTN pos;
+ mhdr->HeaderSize -= thdr->HeaderSize;
+ pos = tpos + thdr->HeaderSize;
+ while (pos < rawSize) {
+ raw[tpos] = raw[pos];
+ ++tpos;
+ ++pos;
+ }
+ mhdr->CRC32 = 0;
+ if (EFI_ERROR(gBS->CalculateCrc32((UINT8 *)raw, mhdr->HeaderSize, &Crc))) {
+ return FALSE;
+ }
+ mhdr->CRC32 = Crc;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+BOOLEAN
+TablesAppend(
+ IN OUT VOID** tables,
+ IN UINT64 sign,
+ IN VOID* data,
+ IN UINTN size)
+{
+ EFI_TABLE_HEADER *mhdr = NULL;
+ EFI_TABLE_HEADER *thdr = NULL;
+ UINTN rawSize = 0;
+ UINT8* raw = (UINT8*)tables;
+ if (tables != NULL &&
+ (mhdr = (EFI_TABLE_HEADER *)*tables) != NULL &&
+ mhdr->Signature == EFITABLE_HEADER_SIGN &&
+ GptHeaderCheckCrc(0, mhdr)) {
+ UINT32 Crc;
+ rawSize = mhdr->HeaderSize;
+ raw = MEM_REALLOC(rawSize, rawSize + sizeof(EFI_TABLE_HEADER) + size, mhdr);
+ if (raw == NULL) {
+ return FALSE;
+ }
+ mhdr = (EFI_TABLE_HEADER *)raw;
+ thdr = (EFI_TABLE_HEADER *)(raw + rawSize);
+ thdr->HeaderSize = (UINT32)(sizeof(EFI_TABLE_HEADER) + size);
+ thdr->Signature = sign;
+ CopyMem(((UINT8 *)thdr) + sizeof(EFI_TABLE_HEADER), data, size);
+
+ thdr->CRC32 = 0;
+ if (EFI_ERROR(gBS->CalculateCrc32((UINT8 *)thdr, thdr->HeaderSize, &Crc))) {
+ return FALSE;
+ }
+ thdr->CRC32 = Crc;
+
+ mhdr->HeaderSize += (UINT32)(size + sizeof(EFI_TABLE_HEADER));
+ mhdr->CRC32 = 0;
+ if (EFI_ERROR(gBS->CalculateCrc32((UINT8 *)raw, mhdr->HeaderSize, &Crc))) {
+ return FALSE;
+ }
+ mhdr->CRC32 = Crc;
+ *tables = raw;
+ return TRUE;
+ }
+ return FALSE;
+}
diff --git a/Library/DcsCfgLib/GptEdit.c b/Library/DcsCfgLib/GptEdit.c
index e1d6d2a..d486909 100644
--- a/Library/DcsCfgLib/GptEdit.c
+++ b/Library/DcsCfgLib/GptEdit.c
@@ -745,3 +745,136 @@ DeListRndLoad()
}
return res;
}
+
+//////////////////////////////////////////////////////////////////////////
+// Tables
+//////////////////////////////////////////////////////////////////////////
+
+CONST CHAR16* DcsTablesFileName = L"DcsTables";
+UINT8* gDcsTables = NULL;
+UINTN gDcsTablesSize = 0;
+
+BOOLEAN
+TablesList(
+ IN UINTN maxSize,
+ IN VOID* tables
+ ) {
+ EFI_TABLE_HEADER *mhdr = (EFI_TABLE_HEADER *)tables;
+ if (tables != NULL &&
+ mhdr->Signature == EFITABLE_HEADER_SIGN &&
+ GptHeaderCheckCrc(maxSize, mhdr)) {
+ UINT8* raw = (UINT8*)tables;
+ UINTN rawSize = mhdr->HeaderSize;
+ UINTN tpos = sizeof(EFI_TABLE_HEADER);
+ while (tpos < rawSize) {
+ EFI_TABLE_HEADER *hdr = (EFI_TABLE_HEADER *)(raw + tpos);
+ CHAR8 asc_sign[sizeof(hdr->Signature) + 1] = { 0 };
+ CopyMem(asc_sign, &hdr->Signature, sizeof(hdr->Signature));
+ asc_sign[sizeof(hdr->Signature)] = 0;
+ OUT_PRINT(L"%a, SZ=%d", asc_sign, hdr->HeaderSize);
+ if (!GptHeaderCheckCrc(rawSize - tpos, hdr)) {
+ ERR_PRINT(L" - wrong crc\n");
+ return FALSE; // wrong crc
+ }
+ OUT_PRINT(L" - OK\n");
+ tpos += hdr->HeaderSize;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+EFI_STATUS
+TablesLoad() {
+ EFI_STATUS res = EFI_SUCCESS;
+ if (EFI_ERROR(FileExist(NULL, (CHAR16*)DcsTablesFileName))) {
+ EFI_TABLE_HEADER* mhdr = NULL;
+ UINT32 Crc;
+ gDcsTables = MEM_ALLOC(sizeof(EFI_TABLE_HEADER));
+ gDcsTablesSize = sizeof(EFI_TABLE_HEADER);
+ mhdr = (EFI_TABLE_HEADER*)gDcsTables;
+ mhdr->HeaderSize = sizeof(EFI_TABLE_HEADER);
+ mhdr->Signature = EFITABLE_HEADER_SIGN;
+ mhdr->CRC32 = 0;
+ if (EFI_ERROR(res = gBS->CalculateCrc32((UINT8 *)gDcsTables, mhdr->HeaderSize, &Crc))) {
+ goto err;
+ }
+ mhdr->CRC32 = Crc;
+ OUT_PRINT(L"New tables created %s\n", DcsTablesFileName);
+ } else {
+ res = FileLoad(NULL, (CHAR16*)DcsTablesFileName, &gDcsTables, &gDcsTablesSize);
+ if (!EFI_ERROR(res)) {
+ res = TablesVerify(gDcsTablesSize, gDcsTables) ? EFI_SUCCESS : EFI_CRC_ERROR;
+ }
+ }
+err:
+ if (EFI_ERROR(res)) {
+ ERR_PRINT(L"Tables load error %r\n", res);
+ }
+ return res;
+}
+
+EFI_STATUS
+TablesNew(
+ IN CONST CHAR16* signStr,
+ IN CONST CHAR16* dataFileName
+ ) {
+ EFI_STATUS res = EFI_SUCCESS;
+ VOID* data;
+ UINTN dataSize;
+ UINT64 sign;
+ EFI_TABLE_HEADER* mhdr;
+
+ if (StrLen(signStr) != 8) {
+ res = EFI_INVALID_PARAMETER;
+ goto err;
+ }
+ sign = SIGNATURE_64(signStr[0], signStr[1], signStr[2], signStr[3], signStr[4], signStr[5], signStr[6], signStr[7]);
+
+ CE(TablesLoad());
+ TablesDelete(gDcsTables, sign);
+ CE(FileLoad(NULL, (CHAR16*)dataFileName, &data, &dataSize));
+ if (!TablesAppend(&gDcsTables, sign, data, dataSize)) {
+ res = EFI_INVALID_PARAMETER;
+ goto err;
+ }
+ mhdr = (EFI_TABLE_HEADER*)gDcsTables;
+ gDcsTablesSize = mhdr->HeaderSize;
+ res = FileSave(NULL, (CHAR16*)DcsTablesFileName, mhdr, mhdr->HeaderSize);
+
+err:
+ if (EFI_ERROR(res)) {
+ ERR_PRINT(L"Tables append error %r\n", res);
+ }
+ return res;
+}
+
+EFI_STATUS
+TablesDel(
+ IN CONST CHAR16* signStr
+ ) {
+ EFI_STATUS res = EFI_SUCCESS;
+ UINT64 sign;
+ EFI_TABLE_HEADER* mhdr;
+
+ if (StrLen(signStr) != 8) {
+ res = EFI_INVALID_PARAMETER;
+ goto err;
+ }
+ sign = SIGNATURE_64(signStr[0], signStr[1], signStr[2], signStr[3], signStr[4], signStr[5], signStr[6], signStr[7]);
+
+ CE(TablesLoad());
+ if (!TablesDelete(gDcsTables, sign)) {
+ res = EFI_INVALID_PARAMETER;
+ goto err;
+ }
+ mhdr = (EFI_TABLE_HEADER*)gDcsTables;
+ gDcsTablesSize = mhdr->HeaderSize;
+ res = FileSave(NULL, (CHAR16*)DcsTablesFileName, gDcsTables, gDcsTablesSize);
+
+err:
+ if (EFI_ERROR(res)) {
+ ERR_PRINT(L"Tables delete error %r\n", res);
+ }
+ return res;
+}
diff --git a/Library/PasswordLib/PicturePassword.c b/Library/PasswordLib/PicturePassword.c
index f40b095..c3831ad 100644
--- a/Library/PasswordLib/PicturePassword.c
+++ b/Library/PasswordLib/PicturePassword.c
@@ -41,8 +41,8 @@ int gSCLocked = 0;
// Picture password
//////////////////////////////////////////////////////////////////////////
CONST CHAR16* BmpName = L"Test.bmp";
-VOID* Bmp = NULL;
-UINTN BmpSize = 0;
+VOID* gPictPwdBmp = NULL;
+UINTN gPictPwdBmpSize = 0;
BLT_HEADER* bltPwd = NULL;
UINTN posPictX, posPictY;
BLT_HEADER* bltScrn = NULL;
@@ -196,7 +196,7 @@ DrawPwdPicture()
if (bltPwd != NULL) MEM_FREE(bltPwd);
- res = BmpToBlt(Bmp, BmpSize, &bltPwd);
+ res = BmpToBlt(gPictPwdBmp, gPictPwdBmpSize, &bltPwd);
if (EFI_ERROR(res)) {
return res;
}
@@ -287,9 +287,9 @@ AskPictPwdInt(
InitSpeaker();
}
- if (Bmp == NULL) {
+ if (gPictPwdBmp == NULL) {
if (gPasswordPictureFileName != NULL) {
- res = FileLoad(NULL, (CHAR16*)gPasswordPictureFileName, &Bmp, &BmpSize);
+ res = FileLoad(NULL, (CHAR16*)gPasswordPictureFileName, &gPictPwdBmp, &gPictPwdBmpSize);
if (EFI_ERROR(res)) {
ERR_PRINT(L"File load - %r\n", res);
return;
diff --git a/Library/PasswordLib/PlatformID.c b/Library/PasswordLib/PlatformID.c
index 100b0c0..ca8188b 100644
--- a/Library/PasswordLib/PlatformID.c
+++ b/Library/PasswordLib/PlatformID.c
@@ -283,3 +283,89 @@ PlatformGetAuthData(
return res;
}
+CHAR8 gDCS_platform_crt_der[1341] = {
+ 0x30, 0x82, 0x05, 0x39, 0x30, 0x82, 0x03, 0x21, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x32,
+ 0xDC, 0x46, 0x30, 0x87, 0xE5, 0x4F, 0xB1, 0x43, 0x0F, 0x58, 0x9E, 0xC0, 0xDA, 0x58, 0xF8, 0x30,
+ 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05, 0x00, 0x30, 0x23,
+ 0x31, 0x21, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x04, 0x03, 0x1E, 0x18, 0x00, 0x44, 0x00, 0x43, 0x00,
+ 0x53, 0x00, 0x5F, 0x00, 0x70, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x74, 0x00, 0x66, 0x00, 0x6F, 0x00,
+ 0x72, 0x00, 0x6D, 0x30, 0x1E, 0x17, 0x0D, 0x31, 0x36, 0x30, 0x38, 0x30, 0x39, 0x30, 0x38, 0x33,
+ 0x38, 0x31, 0x31, 0x5A, 0x17, 0x0D, 0x33, 0x31, 0x30, 0x38, 0x30, 0x39, 0x30, 0x38, 0x33, 0x38,
+ 0x31, 0x30, 0x5A, 0x30, 0x23, 0x31, 0x21, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x04, 0x03, 0x1E, 0x18,
+ 0x00, 0x44, 0x00, 0x43, 0x00, 0x53, 0x00, 0x5F, 0x00, 0x70, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x74,
+ 0x00, 0x66, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6D, 0x30, 0x82, 0x02, 0x22, 0x30, 0x0D, 0x06, 0x09,
+ 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x02, 0x0F, 0x00,
+ 0x30, 0x82, 0x02, 0x0A, 0x02, 0x82, 0x02, 0x01, 0x00, 0xAF, 0x5B, 0x97, 0x06, 0x70, 0x4F, 0x3B,
+ 0x2E, 0x50, 0x6A, 0xD1, 0x47, 0xCB, 0x70, 0x20, 0xF4, 0x77, 0x79, 0x06, 0xCA, 0xA9, 0xA2, 0x13,
+ 0x75, 0xAD, 0x07, 0x66, 0x94, 0xC2, 0xBB, 0xCA, 0x7E, 0xFC, 0x6C, 0x19, 0x16, 0x5D, 0x60, 0x77,
+ 0x6E, 0xCB, 0xF3, 0x8A, 0xC2, 0xF6, 0x53, 0xC7, 0xC2, 0xB1, 0x87, 0x5F, 0x8E, 0xFA, 0x20, 0xDF,
+ 0xBA, 0x00, 0xCE, 0xBA, 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0x35, 0x28, 0xE5, 0x15, 0xBC, 0xAF, 0x33, 0xBA, 0x67, 0xF2,
+ 0x06, 0x79, 0xEE, 0x50, 0x0F, 0x14, 0x98, 0xFC, 0x95, 0xEC, 0x65, 0x40, 0x88, 0xA8, 0x1A, 0x0C,
+ 0x10, 0x74, 0x79, 0x42, 0x3B, 0xCD, 0xE1, 0xD1, 0xAD, 0x7E, 0x29, 0x41, 0xC4, 0x39, 0x75, 0xC5,
+ 0xCB, 0x0F, 0xB1, 0x6F, 0x30, 0xD3, 0xAE, 0x53, 0x59, 0xD6, 0x86, 0x34, 0x31, 0x8B, 0x96, 0x82,
+ 0xDF, 0xA4, 0x01, 0x32, 0xB4, 0x29, 0xDC, 0x9C, 0x28, 0x53, 0x72, 0xAE, 0x96, 0x37, 0xE3, 0x65,
+ 0x59, 0x91, 0x84, 0x95, 0xB3, 0x2D, 0x3F, 0x84, 0x12, 0xD2, 0x52, 0x85, 0x8D, 0x85, 0xD5, 0x2E,
+ 0x2A, 0x3E, 0xEB, 0x0C, 0x11, 0xA4, 0x4F, 0xED, 0x29, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x69,
+ 0x30, 0x67, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x01, 0x01, 0xFF, 0x04, 0x05, 0x30, 0x03,
+ 0x01, 0x01, 0xFF, 0x30, 0x54, 0x06, 0x03, 0x55, 0x1D, 0x01, 0x04, 0x4D, 0x30, 0x4B, 0x80, 0x10,
+ 0x8F, 0x11, 0x13, 0x21, 0xAA, 0xC0, 0xFA, 0xB1, 0x63, 0xD5, 0xE6, 0x00, 0x9B, 0x78, 0x67, 0x40,
+ 0xA1, 0x25, 0x30, 0x23, 0x31, 0x21, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x04, 0x03, 0x1E, 0x18, 0x00,
+ 0x44, 0x00, 0x43, 0x00, 0x53, 0x00, 0x5F, 0x00, 0x70, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x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11, 0xF8, 0x04, 0x79, 0x94, 0x88, 0x3F, 0x0D, 0x6C, 0x1F, 0x07,
+ 0x61, 0xF6, 0x51, 0xB2, 0xBC, 0xB8, 0xD3, 0x87, 0xA7, 0x15, 0x12, 0x60, 0x7B
+}; \ No newline at end of file
diff --git a/Library/VeraCryptLib/DcsConfig.c b/Library/VeraCryptLib/DcsConfig.c
index 00aa5f8..e29e767 100644
--- a/Library/VeraCryptLib/DcsConfig.c
+++ b/Library/VeraCryptLib/DcsConfig.c
@@ -23,6 +23,8 @@ https://opensource.org/licenses/Apache-2.0
//////////////////////////////////////////////////////////////////////////
char *gConfigBuffer = NULL;
UINTN gConfigBufferSize = 0;
+char *gConfigBufferUpdated = NULL;
+UINTN gConfigBufferUpdatedSize = 0;
BOOLEAN
ConfigRead(char *configKey, char *configValue, int maxValueSize)
@@ -35,7 +37,7 @@ ConfigRead(char *configKey, char *configValue, int maxValueSize)
}
}
- xml = gConfigBuffer;
+ xml = gConfigBufferUpdated != NULL? gConfigBufferUpdated : gConfigBuffer;
if (xml != NULL)
{
xml = XmlFindElementByAttributeValue(xml, "config", "key", configKey);
diff --git a/Library/VeraCryptLib/DcsConfig.h b/Library/VeraCryptLib/DcsConfig.h
index 04719d9..cc803ce 100644
--- a/Library/VeraCryptLib/DcsConfig.h
+++ b/Library/VeraCryptLib/DcsConfig.h
@@ -22,6 +22,8 @@ https://opensource.org/licenses/Apache-2.0
//////////////////////////////////////////////////////////////////////////
extern char *gConfigBuffer;
extern UINTN gConfigBufferSize;
+extern char *gConfigBufferUpdated;
+extern UINTN gConfigBufferUpdatedSize;
BOOLEAN ConfigRead(char *configKey, char *configValue, int maxValueSize);
int ConfigReadInt(char *configKey, int defaultValue);
diff --git a/Library/VeraCryptLib/DcsVeraCrypt.c b/Library/VeraCryptLib/DcsVeraCrypt.c
index cc85f4e..f4a1e27 100644
--- a/Library/VeraCryptLib/DcsVeraCrypt.c
+++ b/Library/VeraCryptLib/DcsVeraCrypt.c
@@ -85,6 +85,10 @@ CHAR8* gOnExitNotFound = NULL;
// Authorize
/////////////////////////////////////////////////////////////////////////
+#define VCCONFIG_ALLOC(data, size) \
+ if(data == NULL) MEM_FREE(data); \
+ data = MEM_ALLOC(size);
+
VOID
VCAuthLoadConfig()
{
@@ -96,30 +100,30 @@ VCAuthLoadConfig()
SetMem(&gAuthPassword, sizeof(gAuthPassword), 0);
strTemp = MEM_ALLOC(MAX_MSG);
- gPasswordPictureFileName = MEM_ALLOC(MAX_MSG * 2);
+ VCCONFIG_ALLOC(gPasswordPictureFileName, MAX_MSG * 2);
ConfigReadString("PasswordPicture", "\\EFI\\VeraCrypt\\login.bmp", strTemp, MAX_MSG);
AsciiStrToUnicodeStr(strTemp, gPasswordPictureFileName);
MEM_FREE(strTemp);
- gPasswordPictureChars = MEM_ALLOC(MAX_MSG);
+ VCCONFIG_ALLOC(gPasswordPictureChars, MAX_MSG);
ConfigReadString("PictureChars", gPasswordPictureCharsDefault, gPasswordPictureChars, MAX_MSG);
gPasswordPictureCharsLen = strlen(gPasswordPictureChars);
gAuthPasswordType = ConfigReadInt("PasswordType", 0);
- gAuthPasswordMsg = MEM_ALLOC(MAX_MSG);
+ VCCONFIG_ALLOC(gAuthPasswordMsg, MAX_MSG);
ConfigReadString("PasswordMsg", "Password:", gAuthPasswordMsg, MAX_MSG);
gAutoLogin = (UINT8)ConfigReadInt("AutoLogin", 0);
- gAutoPassword = MEM_ALLOC(MAX_PASSWORD);
+ VCCONFIG_ALLOC(gAutoPassword, MAX_PASSWORD);
ConfigReadString("AutoPassword", "", gAutoPassword, MAX_PASSWORD);
- gAuthPimMsg = MEM_ALLOC(MAX_MSG);
+ VCCONFIG_ALLOC(gAuthPimMsg, MAX_MSG);
gAuthPimRqt = ConfigReadInt("PimRqt", 1);
gAuthPim = ConfigReadInt("Pim", 0);
ConfigReadString("PimMsg", "Pim:", gAuthPimMsg, MAX_MSG);
- gAuthHashMsg = MEM_ALLOC(MAX_MSG);
+ VCCONFIG_ALLOC(gAuthHashMsg, MAX_MSG);
gAuthHashRqt = ConfigReadInt("HashRqt", 1);
gAuthHash = ConfigReadInt("Hash", 0);
@@ -145,15 +149,15 @@ VCAuthLoadConfig()
gDcsBootForce = ConfigReadInt("DcsBootForce", 1); // Ask password even if no USB marked found.
- gForcePasswordMsg = MEM_ALLOC(MAX_MSG);
+ VCCONFIG_ALLOC(gForcePasswordMsg, MAX_MSG);
ConfigReadString("ForcePasswordMsg", gAuthPasswordMsg, gForcePasswordMsg, MAX_MSG);
gForcePasswordType = ConfigReadInt("ForcePasswordType", gAuthPasswordType);
gForcePasswordProgress = (UINT8)ConfigReadInt("ForcePasswordProgress", gPasswordProgress);
gAuthRetry = ConfigReadInt("AuthorizeRetry", 10);
- gAuthStartMsg = MEM_ALLOC(MAX_MSG);
+ VCCONFIG_ALLOC(gAuthStartMsg, MAX_MSG);
ConfigReadString("AuthStartMsg", "Authorizing...\n\r", gAuthStartMsg, MAX_MSG);
- gAuthErrorMsg = MEM_ALLOC(MAX_MSG);
+ VCCONFIG_ALLOC(gAuthErrorMsg, MAX_MSG);
ConfigReadString("AuthErrorMsg", "Authorization failed. Wrong password, PIM or hash.\n\r", gAuthErrorMsg, MAX_MSG);
gRUD = ConfigReadInt("RUD", 0);
@@ -166,11 +170,11 @@ VCAuthLoadConfig()
gSCLocked = ConfigReadInt("SCLocked", 0);
// Actions for DcsInt
- gOnExitSuccess = MEM_ALLOC(MAX_MSG);
+ VCCONFIG_ALLOC(gOnExitSuccess, MAX_MSG);
ConfigReadString("ActionSuccess", "Exit", gOnExitSuccess, MAX_MSG);
- gOnExitNotFound = MEM_ALLOC(MAX_MSG);
+ VCCONFIG_ALLOC(gOnExitNotFound, MAX_MSG);
ConfigReadString("ActionNotFound", "Exit", gOnExitNotFound, MAX_MSG);
- gOnExitFailed = MEM_ALLOC(MAX_MSG);
+ VCCONFIG_ALLOC(gOnExitFailed, MAX_MSG);
ConfigReadString("ActionFailed", "Exit", gOnExitFailed, MAX_MSG);
strTemp = MEM_ALLOC(MAX_MSG);
@@ -178,7 +182,7 @@ VCAuthLoadConfig()
if (strTemp[0] != 0) {
EFI_GUID g;
if (AsciiStrToGuid(&g, strTemp)) {
- gPartitionGuidOS = MEM_ALLOC(sizeof(EFI_GUID));
+ VCCONFIG_ALLOC(gPartitionGuidOS, sizeof(EFI_GUID));
if (gPartitionGuidOS != NULL) {
memcpy(gPartitionGuidOS, &g, sizeof(g));
}