VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common')
-rw-r--r--src/Common/Crypto.c2
-rw-r--r--src/Common/Crypto.h11
-rw-r--r--src/Common/Volumes.c4
3 files changed, 14 insertions, 3 deletions
diff --git a/src/Common/Crypto.c b/src/Common/Crypto.c
index e7a40a30..fcc4c3b8 100644
--- a/src/Common/Crypto.c
+++ b/src/Common/Crypto.c
@@ -739,12 +739,14 @@ PCRYPTO_INFO crypto_open ()
#endif // TC_WINDOWS_BOOT
}
+#ifndef TC_WINDOWS_BOOT
void crypto_loadkey (PKEY_INFO keyInfo, char *lpszUserKey, int nUserKeyLen)
{
keyInfo->keyLength = nUserKeyLen;
burn (keyInfo->userKey, sizeof (keyInfo->userKey));
memcpy (keyInfo->userKey, lpszUserKey, nUserKeyLen);
}
+#endif
void crypto_close (PCRYPTO_INFO cryptoInfo)
{
diff --git a/src/Common/Crypto.h b/src/Common/Crypto.h
index 51539765..a28084a1 100644
--- a/src/Common/Crypto.h
+++ b/src/Common/Crypto.h
@@ -191,15 +191,22 @@ typedef struct
#include "GfMul.h"
#include "Password.h"
+#ifndef TC_WINDOWS_BOOT
+
+#include "config.h"
+
typedef struct keyInfo_t
{
int noIterations; /* Number of times to iterate (PKCS-5) */
int keyLength; /* Length of the key */
- __int8 userKey[MAX_PASSWORD]; /* Password (to which keyfiles may have been applied). WITHOUT +1 for the null terminator. */
+ uint64 dummy; /* Dummy field to ensure 16-byte alignment of this structure */
__int8 salt[PKCS5_SALT_SIZE]; /* PKCS-5 salt */
__int8 master_keydata[MASTER_KEYDATA_SIZE]; /* Concatenated master primary and secondary key(s) (XTS mode). For LRW (deprecated/legacy), it contains the tweak key before the master key(s). For CBC (deprecated/legacy), it contains the IV seed before the master key(s). */
+ CRYPTOPP_ALIGN_DATA(16) __int8 userKey[MAX_PASSWORD]; /* Password (to which keyfiles may have been applied). WITHOUT +1 for the null terminator. */
} KEY_INFO, *PKEY_INFO;
+#endif
+
typedef struct CRYPTO_INFO_t
{
int ea; /* Encryption algorithm ID */
@@ -273,7 +280,9 @@ typedef struct BOOT_CRYPTO_HEADER_t
#endif
PCRYPTO_INFO crypto_open (void);
+#ifndef TC_WINDOWS_BOOT
void crypto_loadkey (PKEY_INFO keyInfo, char *lpszUserKey, int nUserKeyLen);
+#endif
void crypto_close (PCRYPTO_INFO cryptoInfo);
int CipherGetBlockSize (int cipher);
diff --git a/src/Common/Volumes.c b/src/Common/Volumes.c
index b19b8114..93b0eacb 100644
--- a/src/Common/Volumes.c
+++ b/src/Common/Volumes.c
@@ -169,7 +169,7 @@ BOOL ReadVolumeHeaderRecoveryMode = FALSE;
int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int selected_pkcs5_prf, int pim, BOOL truecryptMode, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo)
{
char header[TC_VOLUME_HEADER_EFFECTIVE_SIZE];
- KEY_INFO keyInfo;
+ CRYPTOPP_ALIGN_DATA(16) KEY_INFO keyInfo;
PCRYPTO_INFO cryptoInfo;
char dk[MASTER_KEYDATA_SIZE];
int enqPkcs5Prf, pkcs5_prf;
@@ -798,7 +798,7 @@ int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *header, int ea,
unsigned __int64 encryptedAreaStart, unsigned __int64 encryptedAreaLength, uint16 requiredProgramVersion, uint32 headerFlags, uint32 sectorSize, BOOL bWipeMode)
{
unsigned char *p = (unsigned char *) header;
- static KEY_INFO keyInfo;
+ static CRYPTOPP_ALIGN_DATA(16) KEY_INFO keyInfo;
int nUserKeyLen = password->Length;
PCRYPTO_INFO cryptoInfo = crypto_open ();