Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Common/Volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ int ReadVolumeHeader (BOOL bBoot, unsigned char *encryptedHeader, Password *pass
{
unsigned char header[TC_VOLUME_HEADER_EFFECTIVE_SIZE];
unsigned char* keyInfoBuffer = NULL;
int keyInfoBufferSize = sizeof (KEY_INFO) + 16;
int keyInfoBufferSize = sizeof (KEY_INFO) + TC_KEY_INFO_BUFFER_ALIGNMENT;
size_t keyInfoBufferOffset;
PKEY_INFO keyInfo;
PCRYPTO_INFO cryptoInfo;
CRYPTOPP_ALIGN_DATA(16) unsigned char dk[MASTER_KEYDATA_SIZE];
CRYPTOPP_ALIGN_DATA(TC_DERIVED_KEY_BUFFER_ALIGNMENT) unsigned char dk[MASTER_KEYDATA_SIZE];
int enqPkcs5Prf, pkcs5_prf;
uint16 headerVersion;
int status = ERR_PARAMETER_INCORRECT;
Expand All @@ -199,7 +199,7 @@ int ReadVolumeHeader (BOOL bBoot, unsigned char *encryptedHeader, Password *pass
keyInfoBuffer = TCalloc(keyInfoBufferSize);
if (!keyInfoBuffer)
return ERR_OUTOFMEMORY;
keyInfoBufferOffset = 16 - (((uint64) keyInfoBuffer) % 16);
keyInfoBufferOffset = TC_KEY_INFO_BUFFER_ALIGNMENT - (((uint64) keyInfoBuffer) % TC_KEY_INFO_BUFFER_ALIGNMENT);
keyInfo = (PKEY_INFO) (keyInfoBuffer + keyInfoBufferOffset);

#if !defined(DEVICE_DRIVER) && !defined(_UEFI)
Expand Down Expand Up @@ -884,7 +884,7 @@ int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, unsigned char *header,
#endif // !defined(_UEFI)
{
unsigned char *p = header;
static CRYPTOPP_ALIGN_DATA(16) KEY_INFO keyInfo;
static CRYPTOPP_ALIGN_DATA(TC_KEY_INFO_BUFFER_ALIGNMENT) KEY_INFO keyInfo;

int nUserKeyLen = password? password->Length : 0;
PCRYPTO_INFO cryptoInfo = crypto_open ();
Expand Down
6 changes: 6 additions & 0 deletions src/Common/Volumes.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ extern "C" {
// specifies the minimum program version required to decrypt the system partition/drive
#define TC_SYSENC_KEYSCOPE_MIN_REQ_PROG_VERSION 0x010b

// Required 16-byte alignment for derived key buffers to ensure optimal performance and compatibility with SIMD instructions.
#define TC_DERIVED_KEY_BUFFER_ALIGNMENT 16

// Required 16-byte alignment for KEY_INFO buffer to ensure optimal performance and compatibility with SIMD instructions.
#define TC_KEY_INFO_BUFFER_ALIGNMENT 16

// Current volume format version (created by TrueCrypt 6.0+)
#define TC_VOLUME_FORMAT_VERSION 2

Expand Down