diff options
author | kavsrf <kavsrf@gmail.com> | 2017-01-23 15:30:22 +0300 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2017-06-05 17:36:52 +0200 |
commit | f648e29d050cab362cc660c1a5c5109182028768 (patch) | |
tree | da3a3ce3f3b03edee797c4606a1cd1227cd6eb95 /Library/VeraCryptLib | |
parent | d37d6d681061fdefc2a909b5975b40b604a27c62 (diff) | |
download | VeraCrypt-DCS-f648e29d050cab362cc660c1a5c5109182028768.tar.gz VeraCrypt-DCS-f648e29d050cab362cc660c1a5c5109182028768.zip |
DcsInfo added
DcsBoot is driver now (to support DriverOrder list)
Diffstat (limited to 'Library/VeraCryptLib')
-rw-r--r-- | Library/VeraCryptLib/DcsConfig.c | 72 | ||||
-rw-r--r-- | Library/VeraCryptLib/DcsConfig.h | 29 | ||||
-rw-r--r-- | Library/VeraCryptLib/DcsVeraCrypt.c | 53 | ||||
-rw-r--r-- | Library/VeraCryptLib/DcsVeraCrypt.h | 3 | ||||
-rw-r--r-- | Library/VeraCryptLib/VeraCryptLib.inf | 2 |
5 files changed, 104 insertions, 55 deletions
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
|