Skip to content

Commit

Permalink
TrueCrypt Source Version 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Truecrypt Foundation authored and FreeApophis committed May 29, 2014
1 parent c277781 commit f3e7058
Show file tree
Hide file tree
Showing 80 changed files with 3,467 additions and 450 deletions.
2 changes: 1 addition & 1 deletion Common/APIDRVR.H
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

/* DeviceIoControl values.
Expand Down
2 changes: 1 addition & 1 deletion Common/CACHE.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

#include "tcdefs.h"
Expand Down
2 changes: 1 addition & 1 deletion Common/CACHE.H
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

extern char szDriverPassword[4][MAX_PASSWORD + 1];
Expand Down
2 changes: 1 addition & 1 deletion Common/CMDLINE.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

#include "TCdefs.h"
Expand Down
2 changes: 1 addition & 1 deletion Common/CMDLINE.H
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

#define HAS_ARGUMENT 1
Expand Down
2 changes: 1 addition & 1 deletion Common/COMBO.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

#include "TCdefs.h"
Expand Down
2 changes: 1 addition & 1 deletion Common/COMBO.H
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */


Expand Down
2 changes: 1 addition & 1 deletion Common/CRC.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

#include "TCdefs.h"
Expand Down
2 changes: 1 addition & 1 deletion Common/CRC.H
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

extern unsigned long crc_32_tab[];
Expand Down
19 changes: 16 additions & 3 deletions Common/CRYPTO.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

#include "TCdefs.h"
Expand All @@ -10,6 +10,10 @@ crypto_open ()
{
/* Do the crt allocation */
PCRYPTO_INFO cryptoInfo = TCalloc (sizeof (CRYPTO_INFO));
#ifndef DEVICE_DRIVER
VirtualLock (cryptoInfo, sizeof (CRYPTO_INFO));
#endif

if (cryptoInfo == NULL)
return NULL;

Expand All @@ -29,14 +33,19 @@ void
crypto_close (PCRYPTO_INFO cryptoInfo)
{
burn (cryptoInfo, sizeof (CRYPTO_INFO));
#ifndef DEVICE_DRIVER
VirtualUnlock (cryptoInfo, sizeof (CRYPTO_INFO));
#endif
TCfree (cryptoInfo);
}

int
get_block_size (int cipher)
{
if (cipher); /* remove warning */
return 8;
if (cipher == AES)
return 16;
else
return 8;
}

int
Expand All @@ -48,6 +57,8 @@ get_key_size (int cipher)
return 16;
else if (cipher == BLOWFISH)
return 56;
else if (cipher == AES)
return 32;
else if (cipher == TRIPLEDES)
return 21;
else if (cipher == CAST)
Expand All @@ -63,6 +74,8 @@ get_cipher_name (int cipher)
{
if (cipher == BLOWFISH)
return "Blowfish";
if (cipher == AES)
return "AES";
else if (cipher == IDEA)
return "IDEA";
else if (cipher == DES56)
Expand Down
23 changes: 11 additions & 12 deletions Common/CRYPTO.H
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */


Expand Down Expand Up @@ -34,12 +34,13 @@
/* The encryption algorithm ID */
#define NONE 0
#define BLOWFISH 1
#define CAST 2
#define IDEA 3
#define TRIPLEDES 4
#define AES 2
#define CAST 3
#define IDEA 4
#define TRIPLEDES 5
#define DES56 100 // Used only for DES test vectors

#define LAST_CIPHER_ID 4 // Last cipher used for volume encryption
#define LAST_CIPHER_ID 5 // Last cipher used for volume encryption

// Length in bytes of the longest key used by encryption algorithms
#define MAX_CIPHER_KEY 56 // Blowfish 448 bits
Expand All @@ -49,12 +50,14 @@
#define DES_KS 128
#define TRIPLEDES_KS (DES_KS*3)
#define BLOWFISH_KS 4168
#define AES_KS 240
#define CAST_KS 128

#define MAX_EXPANDED_KEY 4168

#include "des.h"
#include "blowfish.h"
#include "aes.h"
#include "idea.h"
#include "sha.h"
#include "sha1.h"
Expand Down Expand Up @@ -95,6 +98,7 @@ typedef struct CRYPTO_INFO_t
#define decipher_block(cipher, data, ks) \
{\
if (cipher == BLOWFISH) BF_decrypt ((void *) data, (void *) ks); \
else if (cipher == AES) aes_decrypt ((void *) data, (void *) data, (void *)((char *)(ks)+sizeof(aes_encrypt_ctx))); \
else if (cipher == IDEA) ideaCrypt ((void *) data,(void *) data, (void *) ((char *) ks + IDEA_KS)); \
else if (cipher == DES56) des_encrypt ((void *) data, (void *) ks, 0); \
else if (cipher == CAST) CAST_ecb_encrypt((void *) data,(void *) data,(void*)ks,0); \
Expand All @@ -105,6 +109,7 @@ typedef struct CRYPTO_INFO_t
#define encipher_block(cipher, data, ks) \
{\
if (cipher == BLOWFISH) BF_encrypt ((void *) data, (void *) ks); \
else if (cipher == AES) aes_encrypt ((void *) data, (void *) data, (void *) ks); \
else if (cipher == IDEA) ideaCrypt ((void *) data, (void *) data, (void *) ks); \
else if (cipher == DES56) des_encrypt ((void *) data, (void *) ks, 1); \
else if (cipher == CAST) CAST_ecb_encrypt((void *) data,(void *) data,(void*)ks,1); \
Expand All @@ -115,6 +120,7 @@ typedef struct CRYPTO_INFO_t
#define init_cipher(cipher, key, ks) \
{\
if (cipher == BLOWFISH) BF_set_key ((void*)ks, 56, (void*) (key)); \
else if (cipher == AES) {aes_encrypt_key((void*)(key), 32, (void*)ks); aes_decrypt_key((void*)(key), 32, (void*)((char *)(ks)+sizeof(aes_encrypt_ctx)));} \
else if (cipher == IDEA) ideaExpandKey ((void*) (key), (void*)ks, (void *) ((char *) ks + IDEA_KS)); \
else if (cipher == DES56) des_key_sched ((void*) (key), (void*)ks); \
else if (cipher == CAST) CAST_set_key((void*)ks, 16, (void*)(key)); \
Expand All @@ -125,13 +131,6 @@ typedef struct CRYPTO_INFO_t
} \
}

#define is_valid_tc_cipher(cipher) \
(cipher == BLOWFISH || \
cipher == IDEA || \
cipher == DES56 || \
cipher == CAST || \
cipher == TRIPLEDES)


PCRYPTO_INFO crypto_open (void);
void crypto_loadkey (PKEY_INFO keyInfo, char *lpszUserKey, int nUserKeyLen);
Expand Down
11 changes: 5 additions & 6 deletions Common/Common.rc
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ CLASS "SplashDlg"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",IDOK,121,178,50,14
LTEXT "Copyright � 2004 TrueCrypt Team",IDT_ABOUT_COPYRIGHT,18,
71,154,8
LTEXT "Copyright � 2004 TrueCrypt Foundation",
IDT_ABOUT_COPYRIGHT,18,71,207,8
LTEXT "Based on E4M by Paul Le Roux.",IDC_STATIC,18,114,104,8
LTEXT "Portions of this software are based in part on the works of the following people:",
IDC_STATIC,18,122,256,8
LTEXT "Contact: [email protected]",IDT_ABOUT_MAILTO,185,87,
104,8
LTEXT "Contact: ",IDT_ABOUT_MAILTO,185,87,104,8,NOT WS_VISIBLE
LTEXT "Bruce Schneier, Eric Young, Peter Gutmann, Xuejia Lai, James Massey,",
IDC_STATIC,18,130,226,8
LTEXT "Walt Tuchmann, Whitfield Diffie, Martin Hellman, Don Coppersmith,",
Expand All @@ -54,7 +53,7 @@ BEGIN
WS_EX_STATICEDGE
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,1,169,291,1,
WS_EX_STATICEDGE
LTEXT "www.truecrypt.org",ID_WEBSITE,18,87,79,8,SS_NOTIFY
LTEXT "www.google.com",ID_WEBSITE,18,87,79,8,SS_NOTIFY
END

IDD_COMMANDHELP_DLG DIALOGEX 0, 0, 272, 146
Expand Down Expand Up @@ -239,7 +238,7 @@ STRINGTABLE
BEGIN
IDS_DRIVER_VERSION "This program requires version %s of the TrueCrypt driver. Please reinstall the software."
IDS_NEW_VERSION_REQUIRED
"This volume requires a new version of TrueCrypt.\nNew version is available at http://www.truecrypt.org"
"This volume requires a new version of TrueCrypt."
END

#endif // English (U.S.) resources
Expand Down
2 changes: 1 addition & 1 deletion Common/DISMOUNT.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

/* WARNING: The code for unmounting volumes is ugly for all Windows versions;
Expand Down
2 changes: 1 addition & 1 deletion Common/DISMOUNT.H
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

/* Everything below this line is automatically updated by the -mkproto-tool- */
Expand Down
30 changes: 13 additions & 17 deletions Common/DLGCODE.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

#include "TCdefs.h"
Expand Down Expand Up @@ -283,7 +283,7 @@ AboutDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
if (lw == ID_WEBSITE)
{
ArrowWaitCursor ();
ShellExecute (NULL, "open", "http://www.truecrypt.org", NULL, NULL, SW_SHOWNORMAL);
ShellExecute (NULL, "open", "http://www.google.com/search?q=truecrypt", NULL, NULL, SW_SHOWNORMAL);
Sleep (200);
NormalCursor ();
return 1;
Expand Down Expand Up @@ -1035,23 +1035,19 @@ GetAvailableFixedDisks (HWND hComboBox, char *lpszRootPath)
LvItem.pszText=item2;
SendMessage(hComboBox,LVM_SETITEM,0,(LPARAM)&LvItem);
}
else
{
if(drivePresent)
{
LVITEM LvItem;
memset(&LvItem,0,sizeof(LvItem));
LvItem.mask=LVIF_TEXT;
LvItem.iItem= line++;

LvItem.pszText="";
SendMessage(hComboBox,LVM_INSERTITEM,0,(LPARAM)&LvItem);
}

if (n == 1)
i = 64;
break;
}
}

if(drivePresent)
{
LVITEM LvItem;
memset(&LvItem,0,sizeof(LvItem));
LvItem.mask=LVIF_TEXT;
LvItem.iItem= line++;

LvItem.pszText="";
SendMessage(hComboBox,LVM_INSERTITEM,0,(LPARAM)&LvItem);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Common/DLGCODE.H
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

#define IDC_ABOUT 0x7fff /* ID for AboutBox on system menu in wm_user
Expand Down
2 changes: 1 addition & 1 deletion Common/ENDIAN.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

#include "TCdefs.h"
Expand Down
2 changes: 1 addition & 1 deletion Common/ENDIAN.H
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

#define mputLong(memPtr,data) \
Expand Down
6 changes: 3 additions & 3 deletions Common/FAT.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

#include "TCdefs.h"
Expand Down Expand Up @@ -394,8 +394,8 @@ Format (fatparams * ft, HFILE dev, PCRYPTO_INFO cryptoInfo, int nFrequency, disk

// Generate a random key and IV to randomize data area
// and support a possible hidden volume
RandgetBytes (key, MAX_CIPHER_KEY);
RandgetBytes (cryptoInfo->iv, sizeof cryptoInfo->iv);
RandgetBytes (key, MAX_CIPHER_KEY, FALSE);
RandgetBytes (cryptoInfo->iv, sizeof cryptoInfo->iv, FALSE);
init_cipher (cryptoInfo->cipher, key, cryptoInfo->ks);
ZeroMemory (sector, 512);

Expand Down
2 changes: 1 addition & 1 deletion Common/FAT.H
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

typedef struct fatparams_t
Expand Down
16 changes: 7 additions & 9 deletions Common/FORMAT.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

#include "TCdefs.h"
Expand Down Expand Up @@ -71,19 +71,13 @@ FormatVolume (char *lpszFilename,
ft->num_sectors = (int) (size / SECTOR_SIZE);
memcpy (ft->volume_name, " ", 11);

{
// Avoid random init delay before time counters start
char tmp[1];
RandgetBytes(&tmp, 1);
}

InitProgressBar (ft->num_sectors);

/* Calculate the fats, root dir etc, and update ft */
GetFatParams (ft);

/* Copies any header structures into ft->header, but does not do any
disk io */
VirtualLock (&ft->header, sizeof (ft->header));

nStatus = VolumeWriteHeader (ft->header,
cipher,
lpszPassword,
Expand All @@ -92,11 +86,15 @@ FormatVolume (char *lpszFilename,
0,
&cryptoInfo);

VirtualUnlock (&ft->header, sizeof (ft->header));

if (nStatus != 0)
return nStatus;

KillTimer (hwndDlg, 0xff);

InitProgressBar (ft->num_sectors);

/* This does the disk io, both copying out the header, init the
sectors, and writing the FAT tables etc */
nStatus = Format (ft, (HFILE) dev, cryptoInfo, 1000, write, bDevice==TRUE ? quickFormat:FALSE);
Expand Down
2 changes: 1 addition & 1 deletion Common/FORMAT.H
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

/* Everything below this line is automatically updated by the -mkproto-tool- */
Expand Down
2 changes: 1 addition & 1 deletion Common/PASSWORD.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

#include "TCdefs.h"
Expand Down
2 changes: 1 addition & 1 deletion Common/PASSWORD.H
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */


Expand Down
2 changes: 1 addition & 1 deletion Common/PKCS5.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */

#include "TCdefs.h"
Expand Down
2 changes: 1 addition & 1 deletion Common/PKCS5.H
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
/* Copyright (C) 2004 TrueCrypt Foundation
This product uses components written by Paul Le Roux <[email protected]> */


Expand Down
Loading

0 comments on commit f3e7058

Please sign in to comment.