diff options
author | kavsrf <kavsrf@gmail.com> | 2017-02-05 17:31:28 +0300 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2017-06-05 17:36:54 +0200 |
commit | abf3adcd2f37f4e278fc9ef7634ca0c8f5171893 (patch) | |
tree | c7fe7706e8648c7a989bcfd30dbc66a1faa108f3 /Library | |
parent | d200f27ac3b8a4f58e52a5ee798e11e3fdf74924 (diff) | |
download | VeraCrypt-DCS-abf3adcd2f37f4e278fc9ef7634ca0c8f5171893.tar.gz VeraCrypt-DCS-abf3adcd2f37f4e278fc9ef7634ca0c8f5171893.zip |
picture password bmp and DcsProp can be in secregion on separate flash
Tables overlay configuration commands
Diffstat (limited to 'Library')
-rw-r--r-- | Library/CommonLib/GptRead.c | 157 | ||||
-rw-r--r-- | Library/DcsCfgLib/GptEdit.c | 133 | ||||
-rw-r--r-- | Library/PasswordLib/PicturePassword.c | 10 | ||||
-rw-r--r-- | Library/PasswordLib/PlatformID.c | 86 | ||||
-rw-r--r-- | Library/VeraCryptLib/DcsConfig.c | 4 | ||||
-rw-r--r-- | Library/VeraCryptLib/DcsConfig.h | 2 | ||||
-rw-r--r-- | Library/VeraCryptLib/DcsVeraCrypt.c | 30 |
7 files changed, 399 insertions, 23 deletions
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, 0xA7, 0xC8, 0x65, 0x7E, 0xFC, 0xA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 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, 0x74, 0x00,
+ 0x66, 0x00, 0x6F, 0x00, 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F, 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));
}
|