diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2014-07-20 05:11:10 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2014-11-08 23:21:32 +0100 |
commit | 75f780871949e5bacca4718507e66c8d28d72e69 (patch) | |
tree | b5e57e50960de3d508098e01b3d80397edb9b474 /src/Common/Crypto.c | |
parent | 0594532cf1d6bb5fc8886d1c99db4e3861185112 (diff) | |
download | VeraCrypt-75f780871949e5bacca4718507e66c8d28d72e69.tar.gz VeraCrypt-75f780871949e5bacca4718507e66c8d28d72e69.zip |
Remove deprecated/legacy cryptographic algorithms and encryption modes that are never used by VeraCrypt. This will speed up volumes opening in many cases.
Diffstat (limited to 'src/Common/Crypto.c')
-rw-r--r-- | src/Common/Crypto.c | 874 |
1 files changed, 10 insertions, 864 deletions
diff --git a/src/Common/Crypto.c b/src/Common/Crypto.c index dd30e488..d8f8ae3a 100644 --- a/src/Common/Crypto.c +++ b/src/Common/Crypto.c @@ -45,38 +45,27 @@ static Cipher Ciphers[] = { AES, "AES", 16, 32, AES_KS },
{ SERPENT, "Serpent", 16, 32, 140*4 },
{ TWOFISH, "Twofish", 16, 32, TWOFISH_KS },
-#ifndef TC_WINDOWS_BOOT
- { BLOWFISH, "Blowfish", 8, 56, sizeof (BF_KEY) }, // Deprecated/legacy
- { CAST, "CAST5", 8, 16, sizeof (CAST_KEY) }, // Deprecated/legacy
- { TRIPLEDES,"Triple DES", 8, 8*3, sizeof (TDES_KEY) }, // Deprecated/legacy
-#endif
{ 0, 0, 0, 0, 0 }
};
// Encryption algorithm configuration
-// The following modes have been deprecated (legacy): LRW, CBC, INNER_CBC, OUTER_CBC
static EncryptionAlgorithm EncryptionAlgorithms[] =
{
// Cipher(s) Modes FormatEnabled
#ifndef TC_WINDOWS_BOOT
- { { 0, 0 }, { 0, 0, 0, 0 }, 0 }, // Must be all-zero
- { { AES, 0 }, { XTS, LRW, CBC, 0 }, 1 },
- { { SERPENT, 0 }, { XTS, LRW, CBC, 0 }, 1 },
- { { TWOFISH, 0 }, { XTS, LRW, CBC, 0 }, 1 },
- { { TWOFISH, AES, 0 }, { XTS, LRW, OUTER_CBC, 0 }, 1 },
- { { SERPENT, TWOFISH, AES, 0 }, { XTS, LRW, OUTER_CBC, 0 }, 1 },
- { { AES, SERPENT, 0 }, { XTS, LRW, OUTER_CBC, 0 }, 1 },
- { { AES, TWOFISH, SERPENT, 0 }, { XTS, LRW, OUTER_CBC, 0 }, 1 },
- { { SERPENT, TWOFISH, 0 }, { XTS, LRW, OUTER_CBC, 0 }, 1 },
- { { BLOWFISH, 0 }, { LRW, CBC, 0, 0 }, 0 }, // Deprecated/legacy
- { { CAST, 0 }, { LRW, CBC, 0, 0 }, 0 }, // Deprecated/legacy
- { { TRIPLEDES, 0 }, { LRW, CBC, 0, 0 }, 0 }, // Deprecated/legacy
- { { BLOWFISH, AES, 0 }, { INNER_CBC, 0, 0, 0 }, 0 }, // Deprecated/legacy
- { { SERPENT, BLOWFISH, AES, 0 }, { INNER_CBC, 0, 0, 0 }, 0 }, // Deprecated/legacy
- { { 0, 0 }, { 0, 0, 0, 0 }, 0 } // Must be all-zero
+ { { 0, 0 }, { 0, 0}, 0 }, // Must be all-zero
+ { { AES, 0 }, { XTS, 0 }, 1 },
+ { { SERPENT, 0 }, { XTS, 0 }, 1 },
+ { { TWOFISH, 0 }, { XTS, 0 }, 1 },
+ { { TWOFISH, AES, 0 }, { XTS, 0 }, 1 },
+ { { SERPENT, TWOFISH, AES, 0 }, { XTS, 0 }, 1 },
+ { { AES, SERPENT, 0 }, { XTS, 0 }, 1 },
+ { { AES, TWOFISH, SERPENT, 0 }, { XTS, 0 }, 1 },
+ { { SERPENT, TWOFISH, 0 }, { XTS, 0 }, 1 },
+ { { 0, 0 }, { 0, 0}, 0 } // Must be all-zero
#else // TC_WINDOWS_BOOT
@@ -105,7 +94,6 @@ static Hash Hashes[] = #ifndef TC_WINDOWS_BOOT
{ SHA512, "SHA-512", FALSE, FALSE },
{ WHIRLPOOL, "Whirlpool", FALSE, FALSE },
- { SHA1, "SHA-1", TRUE, FALSE }, // Deprecated/legacy
#endif
{ 0, 0, 0 }
};
@@ -138,32 +126,6 @@ int CipherInit (int cipher, unsigned char *key, unsigned __int8 *ks) twofish_set_key ((TwofishInstance *)ks, (const u4byte *)key, CipherGetKeySize(TWOFISH) * 8);
break;
-#ifndef TC_WINDOWS_BOOT
-
- case BLOWFISH:
- /* Deprecated/legacy */
- BlowfishSetKey ((BF_KEY *)ks, CipherGetKeySize(BLOWFISH), key);
- break;
-
- case CAST:
- /* Deprecated/legacy */
- Cast5SetKey ((CAST_KEY *) ks, CipherGetKeySize(CAST), key);
- break;
-
- case TRIPLEDES:
- /* Deprecated/legacy */
- TripleDesSetKey (key, CipherGetKeySize (TRIPLEDES), (TDES_KEY *) ks);
-
- // Verify whether all three DES keys are mutually different
- if (((*((__int64 *) key) ^ *((__int64 *) key+1)) & 0xFEFEFEFEFEFEFEFEULL) == 0
- || ((*((__int64 *) key+1) ^ *((__int64 *) key+2)) & 0xFEFEFEFEFEFEFEFEULL) == 0
- || ((*((__int64 *) key) ^ *((__int64 *) key+2)) & 0xFEFEFEFEFEFEFEFEULL) == 0)
- retVal = ERR_CIPHER_INIT_WEAK_KEY; // Non-fatal error
-
- break;
-
-#endif // TC_WINDOWS_BOOT
-
default:
// Unknown/wrong cipher ID
return ERR_CIPHER_INIT_FAILURE;
@@ -188,11 +150,6 @@ void EncipherBlock(int cipher, void *data, void *ks) case TWOFISH: twofish_encrypt (ks, data, data); break;
case SERPENT: serpent_encrypt (data, data, ks); break;
-#ifndef TC_WINDOWS_BOOT
- case BLOWFISH: BlowfishEncryptLE (data, data, ks, 1); break; // Deprecated/legacy
- case CAST: Cast5Encrypt (data, data, ks); break; // Deprecated/legacy
- case TRIPLEDES: TripleDesEncrypt (data, data, ks, 1); break; // Deprecated/legacy
-#endif
default: TC_THROW_FATAL_EXCEPTION; // Unknown/wrong ID
}
}
@@ -256,9 +213,6 @@ void DecipherBlock(int cipher, void *data, void *ks) aes_decrypt (data, data, (void *) ((char *) ks + sizeof(aes_encrypt_ctx)));
break;
- case BLOWFISH: BlowfishEncryptLE (data, data, ks, 0); break; // Deprecated/legacy
- case CAST: Cast5Decrypt (data, data, ks); break; // Deprecated/legacy
- case TRIPLEDES: TripleDesEncrypt (data, data, ks, 0); break; // Deprecated/legacy
#else
case AES: aes_decrypt (data, data, ks); break;
#endif
@@ -427,28 +381,6 @@ BOOL EAInitMode (PCRYPTO_INFO ci) that the size of each of the volumes is 1024 terabytes). */
break;
- case LRW:
- switch (CipherGetBlockSize (EAGetFirstCipher (ci->ea)))
- {
- case 8:
- /* Deprecated/legacy */
- return Gf64TabInit (ci->k2, &ci->gf_ctx);
-
- case 16:
- return Gf128Tab64Init (ci->k2, &ci->gf_ctx);
-
- default:
- TC_THROW_FATAL_EXCEPTION;
- }
-
- break;
-
- case CBC:
- case INNER_CBC:
- case OUTER_CBC:
- // The mode does not need to be initialized or is initialized elsewhere
- return TRUE;
-
default:
// Unknown/wrong ID
TC_THROW_FATAL_EXCEPTION;
@@ -537,37 +469,6 @@ char *EAGetModeName (int ea, int mode, BOOL capitalLetters) return "XTS";
- case LRW:
-
- /* Deprecated/legacy */
-
- return "LRW";
-
- case CBC:
- {
- /* Deprecated/legacy */
-
- char eaName[100];
- EAGetName (eaName, ea);
-
- if (strcmp (eaName, "Triple DES") == 0)
- return capitalLetters ? "Outer-CBC" : "outer-CBC";
-
- return "CBC";
- }
-
- case OUTER_CBC:
-
- /* Deprecated/legacy */
-
- return capitalLetters ? "Outer-CBC" : "outer-CBC";
-
- case INNER_CBC:
-
- /* Deprecated/legacy */
-
- return capitalLetters ? "Inner-CBC" : "inner-CBC";
-
}
return "[unknown]";
}
@@ -805,441 +706,6 @@ void crypto_close (PCRYPTO_INFO cryptoInfo) #ifndef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE
-#ifndef TC_NO_COMPILER_INT64
-void Xor128 (unsigned __int64 *a, unsigned __int64 *b)
-{
- *a++ ^= *b++;
- *a ^= *b;
-}
-
-
-void Xor64 (unsigned __int64 *a, unsigned __int64 *b)
-{
- *a ^= *b;
-}
-
-
-void EncryptBufferLRW128 (byte *buffer, uint64 length, uint64 blockIndex, PCRYPTO_INFO cryptoInfo)
-{
- /* Deprecated/legacy */
-
- int cipher = EAGetFirstCipher (cryptoInfo->ea);
- int cipherCount = EAGetCipherCount (cryptoInfo->ea);
- unsigned __int8 *p = buffer;
- unsigned __int8 *ks = cryptoInfo->ks;
- unsigned __int8 i[8];
- unsigned __int8 t[16];
- unsigned __int64 b;
-
- *(unsigned __int64 *)i = BE64(blockIndex);
-
- if (length % 16)
- TC_THROW_FATAL_EXCEPTION;
-
- // Note that the maximum supported volume size is 8589934592 GB (i.e., 2^63 bytes).
-
- for (b = 0; b < length >> 4; b++)
- {
- Gf128MulBy64Tab (i, t, &cryptoInfo->gf_ctx);
- Xor128 ((unsigned __int64 *)p, (unsigned __int64 *)t);
-
- if (cipherCount > 1)
- {
- // Cipher cascade
- for (cipher = EAGetFirstCipher (cryptoInfo->ea);
- cipher != 0;
- cipher = EAGetNextCipher (cryptoInfo->ea, cipher))
- {
- EncipherBlock (cipher, p, ks);
- ks += CipherGetKeyScheduleSize (cipher);
- }
- ks = cryptoInfo->ks;
- }
- else
- {
- EncipherBlock (cipher, p, ks);
- }
-
- Xor128 ((unsigned __int64 *)p, (unsigned __int64 *)t);
-
- p += 16;
-
- if (i[7] != 0xff)
- i[7]++;
- else
- *(unsigned __int64 *)i = BE64 ( BE64(*(unsigned __int64 *)i) + 1 );
- }
-
- FAST_ERASE64 (t, sizeof(t));
-}
-
-
-void EncryptBufferLRW64 (byte *buffer, uint64 length, uint64 blockIndex, PCRYPTO_INFO cryptoInfo)
-{
- /* Deprecated/legacy */
-
- int cipher = EAGetFirstCipher (cryptoInfo->ea);
- unsigned __int8 *p = buffer;
- unsigned __int8 *ks = cryptoInfo->ks;
- unsigned __int8 i[8];
- unsigned __int8 t[8];
- unsigned __int64 b;
-
- *(unsigned __int64 *)i = BE64(blockIndex);
-
- if (length % 8)
- TC_THROW_FATAL_EXCEPTION;
-
- for (b = 0; b < length >> 3; b++)
- {
- Gf64MulTab (i, t, &cryptoInfo->gf_ctx);
- Xor64 ((unsigned __int64 *)p, (unsigned __int64 *)t);
-
- EncipherBlock (cipher, p, ks);
-
- Xor64 ((unsigned __int64 *)p, (unsigned __int64 *)t);
-
- p += 8;
-
- if (i[7] != 0xff)
- i[7]++;
- else
- *(unsigned __int64 *)i = BE64 ( BE64(*(unsigned __int64 *)i) + 1 );
- }
-
- FAST_ERASE64 (t, sizeof(t));
-}
-
-
-void DecryptBufferLRW128 (byte *buffer, uint64 length, uint64 blockIndex, PCRYPTO_INFO cryptoInfo)
-{
- /* Deprecated/legacy */
-
- int cipher = EAGetFirstCipher (cryptoInfo->ea);
- int cipherCount = EAGetCipherCount (cryptoInfo->ea);
- unsigned __int8 *p = buffer;
- unsigned __int8 *ks = cryptoInfo->ks;
- unsigned __int8 i[8];
- unsigned __int8 t[16];
- unsigned __int64 b;
-
- *(unsigned __int64 *)i = BE64(blockIndex);
-
- if (length % 16)
- TC_THROW_FATAL_EXCEPTION;
-
- // Note that the maximum supported volume size is 8589934592 GB (i.e., 2^63 bytes).
-
- for (b = 0; b < length >> 4; b++)
- {
- Gf128MulBy64Tab (i, t, &cryptoInfo->gf_ctx);
- Xor128 ((unsigned __int64 *)p, (unsigned __int64 *)t);
-
- if (cipherCount > 1)
- {
- // Cipher cascade
- ks = cryptoInfo->ks + EAGetKeyScheduleSize (cryptoInfo->ea);
-
- for (cipher = EAGetLastCipher (cryptoInfo->ea);
- cipher != 0;
- cipher = EAGetPreviousCipher (cryptoInfo->ea, cipher))
- {
- ks -= CipherGetKeyScheduleSize (cipher);
- DecipherBlock (cipher, p, ks);
- }
- }
- else
- {
- DecipherBlock (cipher, p, ks);
- }
-
- Xor128 ((unsigned __int64 *)p, (unsigned __int64 *)t);
-
- p += 16;
-
- if (i[7] != 0xff)
- i[7]++;
- else
- *(unsigned __int64 *)i = BE64 ( BE64(*(unsigned __int64 *)i) + 1 );
- }
-
- FAST_ERASE64 (t, sizeof(t));
-}
-
-
-
-void DecryptBufferLRW64 (byte *buffer, uint64 length, uint64 blockIndex, PCRYPTO_INFO cryptoInfo)
-{
- /* Deprecated/legacy */
-
- int cipher = EAGetFirstCipher (cryptoInfo->ea);
- unsigned __int8 *p = buffer;
- unsigned __int8 *ks = cryptoInfo->ks;
- unsigned __int8 i[8];
- unsigned __int8 t[8];
- unsigned __int64 b;
-
- *(unsigned __int64 *)i = BE64(blockIndex);
-
- if (length % 8)
- TC_THROW_FATAL_EXCEPTION;
-
- for (b = 0; b < length >> 3; b++)
- {
- Gf64MulTab (i, t, &cryptoInfo->gf_ctx);
- Xor64 ((unsigned __int64 *)p, (unsigned __int64 *)t);
-
- DecipherBlock (cipher, p, ks);
-
- Xor64 ((unsigned __int64 *)p, (unsigned __int64 *)t);
-
- p += 8;
-
- if (i[7] != 0xff)
- i[7]++;
- else
- *(unsigned __int64 *)i = BE64 ( BE64(*(unsigned __int64 *)i) + 1 );
- }
-
- FAST_ERASE64 (t, sizeof(t));
-}
-
-
-// Initializes IV and whitening values for sector encryption/decryption in CBC mode.
-// IMPORTANT: This function has been deprecated (legacy).
-static void
-InitSectorIVAndWhitening (unsigned __int64 unitNo,
- int blockSize,
- unsigned __int32 *iv,
- unsigned __int64 *ivSeed,
- unsigned __int32 *whitening)
-{
-
- /* IMPORTANT: This function has been deprecated (legacy) */
-
- unsigned __int64 iv64[4];
- unsigned __int32 *iv32 = (unsigned __int32 *) iv64;
-
- iv64[0] = ivSeed[0] ^ LE64(unitNo);
- iv64[1] = ivSeed[1] ^ LE64(unitNo);
- iv64[2] = ivSeed[2] ^ LE64(unitNo);
- if (blockSize == 16)
- {
- iv64[3] = ivSeed[3] ^ LE64(unitNo);
- }
-
- iv[0] = iv32[0];
- iv[1] = iv32[1];
-
- switch (blockSize)
- {
- case 16:
-
- // 128-bit block
-
- iv[2] = iv32[2];
- iv[3] = iv32[3];
-
- whitening[0] = LE32( crc32int ( &iv32[4] ) ^ crc32int ( &iv32[7] ) );
- whitening[1] = LE32( crc32int ( &iv32[5] ) ^ crc32int ( &iv32[6] ) );
- break;
-
- case 8:
-
- // 64-bit block
-
- whitening[0] = LE32( crc32int ( &iv32[2] ) ^ crc32int ( &iv32[5] ) );
- whitening[1] = LE32( crc32int ( &iv32[3] ) ^ crc32int ( &iv32[4] ) );
- break;
-
- default:
- TC_THROW_FATAL_EXCEPTION;
- }
-}
-
-
-// EncryptBufferCBC (deprecated/legacy)
-//
-// data: data to be encrypted
-// len: number of bytes to encrypt (must be divisible by the largest cipher block size)
-// ks: scheduled key
-// iv: IV
-// whitening: whitening constants
-// ea: outer-CBC cascade ID (0 = CBC/inner-CBC)
-// cipher: CBC/inner-CBC cipher ID (0 = outer-CBC)
-
-static void
-EncryptBufferCBC (unsigned __int32 *data,
- unsigned int len,
- unsigned __int8 *ks,
- unsigned __int32 *iv,
- unsigned __int32 *whitening,
- int ea,
- int cipher)
-{
- /* IMPORTANT: This function has been deprecated (legacy) */
-
- unsigned __int32 bufIV[4];
- unsigned __int64 i;
- int blockSize = CipherGetBlockSize (ea != 0 ? EAGetFirstCipher (ea) : cipher);
-
- if (len % blockSize)
- TC_THROW_FATAL_EXCEPTION;
-
- // IV
- bufIV[0] = iv[0];
- bufIV[1] = iv[1];
- if (blockSize == 16)
- {
- bufIV[2] = iv[2];
- bufIV[3] = iv[3];
- }
-
- // Encrypt each block
- for (i = 0; i < len/blockSize; i++)
- {
- // CBC
- data[0] ^= bufIV[0];
- data[1] ^= bufIV[1];
- if (blockSize == 16)
- {
- data[2] ^= bufIV[2];
- data[3] ^= bufIV[3];
- }
-
- if (ea != 0)
- {
- // Outer-CBC
- for (cipher = EAGetFirstCipher (ea); cipher != 0; cipher = EAGetNextCipher (ea, cipher))
- {
- EncipherBlock (cipher, data, ks);
- ks += CipherGetKeyScheduleSize (cipher);
- }
- ks -= EAGetKeyScheduleSize (ea);
- }
- else
- {
- // CBC/inner-CBC
- EncipherBlock (cipher, data, ks);
- }
-
- // CBC
- bufIV[0] = data[0];
- bufIV[1] = data[1];
- if (blockSize == 16)
- {
- bufIV[2] = data[2];
- bufIV[3] = data[3];
- }
-
- // Whitening
- data[0] ^= whitening[0];
- data[1] ^= whitening[1];
- if (blockSize == 16)
- {
- data[2] ^= whitening[0];
- data[3] ^= whitening[1];
- }
-
- data += blockSize / sizeof(*data);
- }
-}
-
-
-// DecryptBufferCBC (deprecated/legacy)
-//
-// data: data to be decrypted
-// len: number of bytes to decrypt (must be divisible by the largest cipher block size)
-// ks: scheduled key
-// iv: IV
-// whitening: whitening constants
-// ea: outer-CBC cascade ID (0 = CBC/inner-CBC)
-// cipher: CBC/inner-CBC cipher ID (0 = outer-CBC)
-
-static void
-DecryptBufferCBC (unsigned __int32 *data,
- unsigned int len,
- unsigned __int8 *ks,
- unsigned __int32 *iv,
- unsigned __int32 *whitening,
- int ea,
- int cipher)
-{
-
- /* IMPORTANT: This function has been deprecated (legacy) */
-
- unsigned __int32 bufIV[4];
- unsigned __int64 i;
- unsigned __int32 ct[4];
- int blockSize = CipherGetBlockSize (ea != 0 ? EAGetFirstCipher (ea) : cipher);
-
- if (len % blockSize)
- TC_THROW_FATAL_EXCEPTION;
-
- // IV
- bufIV[0] = iv[0];
- bufIV[1] = iv[1];
- if (blockSize == 16)
- {
- bufIV[2] = iv[2];
- bufIV[3] = iv[3];
- }
-
- // Decrypt each block
- for (i = 0; i < len/blockSize; i++)
- {
- // Dewhitening
- data[0] ^= whitening[0];
- data[1] ^= whitening[1];
- if (blockSize == 16)
- {
- data[2] ^= whitening[0];
- data[3] ^= whitening[1];
- }
-
- // CBC
- ct[0] = data[0];
- ct[1] = data[1];
- if (blockSize == 16)
- {
- ct[2] = data[2];
- ct[3] = data[3];
- }
-
- if (ea != 0)
- {
- // Outer-CBC
- ks += EAGetKeyScheduleSize (ea);
- for (cipher = EAGetLastCipher (ea); cipher != 0; cipher = EAGetPreviousCipher (ea, cipher))
- {
- ks -= CipherGetKeyScheduleSize (cipher);
- DecipherBlock (cipher, data, ks);
- }
- }
- else
- {
- // CBC/inner-CBC
- DecipherBlock (cipher, data, ks);
- }
-
- // CBC
- data[0] ^= bufIV[0];
- data[1] ^= bufIV[1];
- bufIV[0] = ct[0];
- bufIV[1] = ct[1];
- if (blockSize == 16)
- {
- data[2] ^= bufIV[2];
- data[3] ^= bufIV[3];
- bufIV[2] = ct[2];
- bufIV[3] = ct[3];
- }
-
- data += blockSize / sizeof(*data);
- }
-}
-#endif // #ifndef TC_NO_COMPILER_INT64
-
// EncryptBuffer
//
@@ -1275,100 +741,12 @@ void EncryptBuffer (unsigned __int8 *buf, TC_LARGEST_COMPILER_UINT len, PCRYPTO_ }
break;
-#ifndef TC_NO_COMPILER_INT64
- case LRW:
-
- /* Deprecated/legacy */
-
- switch (CipherGetBlockSize (EAGetFirstCipher (cryptoInfo->ea)))
- {
- case 8:
- EncryptBufferLRW64 ((unsigned __int8 *)buf, (unsigned __int64) len, 1, cryptoInfo);
- break;
-
- case 16:
- EncryptBufferLRW128 ((unsigned __int8 *)buf, (unsigned __int64) len, 1, cryptoInfo);
- break;
-
- default:
- TC_THROW_FATAL_EXCEPTION;
- }
- break;
-
- case CBC:
- case INNER_CBC:
- {
- /* Deprecated/legacy */
-
- unsigned __int8 *ks = cryptoInfo->ks;
- int cipher;
-
- for (cipher = EAGetFirstCipher (cryptoInfo->ea);
- cipher != 0;
- cipher = EAGetNextCipher (cryptoInfo->ea, cipher))
- {
- EncryptBufferCBC ((unsigned __int32 *) buf,
- (unsigned int) len,
- ks,
- (unsigned __int32 *) cryptoInfo->k2,
- (unsigned __int32 *) &cryptoInfo->k2[8],
- 0,
- cipher);
-
- ks += CipherGetKeyScheduleSize (cipher);
- }
- }
- break;
-
- case OUTER_CBC:
-
- /* Deprecated/legacy */
-
- EncryptBufferCBC ((unsigned __int32 *) buf,
- (unsigned int) len,
- cryptoInfo->ks,
- (unsigned __int32 *) cryptoInfo->k2,
- (unsigned __int32 *) &cryptoInfo->k2[8],
- cryptoInfo->ea,
- 0);
-
- break;
-#endif // #ifndef TC_NO_COMPILER_INT64
-
default:
// Unknown/wrong ID
TC_THROW_FATAL_EXCEPTION;
}
}
-#ifndef TC_NO_COMPILER_INT64
-// Converts a data unit number to the index of the first LRW block in the data unit.
-// Note that the maximum supported volume size is 8589934592 GB (i.e., 2^63 bytes).
-uint64 DataUnit2LRWIndex (uint64 dataUnit, int blockSize, PCRYPTO_INFO ci)
-{
- /* Deprecated/legacy */
-
- if (ci->hiddenVolume)
- dataUnit -= ci->hiddenVolumeOffset / ENCRYPTION_DATA_UNIT_SIZE;
- else
- dataUnit -= TC_VOLUME_HEADER_SIZE_LEGACY / ENCRYPTION_DATA_UNIT_SIZE; // Compensate for the volume header size
-
- switch (blockSize)
- {
- case 8:
- return (dataUnit << 6) | 1;
-
- case 16:
- return (dataUnit << 5) | 1;
-
- default:
- TC_THROW_FATAL_EXCEPTION;
- }
-
- return 0;
-}
-#endif // #ifndef TC_NO_COMPILER_INT64
-
// buf: data to be encrypted
// unitNo: sequential number of the data unit with which the buffer starts
@@ -1387,14 +765,6 @@ void EncryptDataUnitsCurrentThread (unsigned __int8 *buf, const UINT64_STRUCT *s unsigned __int8 *ks2 = ci->ks2;
int cipher;
-#ifndef TC_NO_COMPILER_INT64
- void *iv = ci->k2; // Deprecated/legacy
- unsigned __int64 unitNo = structUnitNo->Value;
- unsigned __int64 *iv64 = (unsigned __int64 *) iv; // Deprecated/legacy
- unsigned __int32 sectorIV[4]; // Deprecated/legacy
- unsigned __int32 secWhitening[2]; // Deprecated/legacy
-#endif
-
switch (ci->mode)
{
case XTS:
@@ -1413,81 +783,6 @@ void EncryptDataUnitsCurrentThread (unsigned __int8 *buf, const UINT64_STRUCT *s }
break;
-#ifndef TC_NO_COMPILER_INT64
- case LRW:
-
- /* Deprecated/legacy */
-
- switch (CipherGetBlockSize (EAGetFirstCipher (ea)))
- {
- case 8:
- EncryptBufferLRW64 (buf,
- (unsigned __int64) nbrUnits * ENCRYPTION_DATA_UNIT_SIZE,
- DataUnit2LRWIndex (unitNo, 8, ci),
- ci);
- break;
-
- case 16:
- EncryptBufferLRW128 (buf,
- (unsigned __int64) nbrUnits * ENCRYPTION_DATA_UNIT_SIZE,
- DataUnit2LRWIndex (unitNo, 16, ci),
- ci);
- break;
-
- default:
- TC_THROW_FATAL_EXCEPTION;
- }
- break;
-
- case CBC:
- case INNER_CBC:
-
- /* Deprecated/legacy */
-
- while (nbrUnits--)
- {
- for (cipher = EAGetFirstCipher (ea); cipher != 0; cipher = EAGetNextCipher (ea, cipher))
- {
- InitSectorIVAndWhitening (unitNo, CipherGetBlockSize (cipher), sectorIV, iv64, secWhitening);
-
- EncryptBufferCBC ((unsigned __int32 *) buf,
- ENCRYPTION_DATA_UNIT_SIZE,
- ks,
- sectorIV,
- secWhitening,
- 0,
- cipher);
-
- ks += CipherGetKeyScheduleSize (cipher);
- }
- ks -= EAGetKeyScheduleSize (ea);
- buf += ENCRYPTION_DATA_UNIT_SIZE;
- unitNo++;
- }
- break;
-
- case OUTER_CBC:
-
- /* Deprecated/legacy */
-
- while (nbrUnits--)
- {
- InitSectorIVAndWhitening (unitNo, CipherGetBlockSize (EAGetFirstCipher (ea)), sectorIV, iv64, secWhitening);
-
- EncryptBufferCBC ((unsigned __int32 *) buf,
- ENCRYPTION_DATA_UNIT_SIZE,
- ks,
- sectorIV,
- secWhitening,
- ea,
- 0);
-
- buf += ENCRYPTION_DATA_UNIT_SIZE;
- unitNo++;
- }
- break;
-#endif // #ifndef TC_NO_COMPILER_INT64
-
default:
// Unknown/wrong ID
TC_THROW_FATAL_EXCEPTION;
@@ -1528,65 +823,6 @@ void DecryptBuffer (unsigned __int8 *buf, TC_LARGEST_COMPILER_UINT len, PCRYPTO_ }
break;
-#ifndef TC_NO_COMPILER_INT64
- case LRW:
-
- /* Deprecated/legacy */
-
- switch (CipherGetBlockSize (EAGetFirstCipher (cryptoInfo->ea)))
- {
- case 8:
- DecryptBufferLRW64 (buf, (unsigned __int64) len, 1, cryptoInfo);
- break;
-
- case 16:
- DecryptBufferLRW128 (buf, (unsigned __int64) len, 1, cryptoInfo);
- break;
-
- default:
- TC_THROW_FATAL_EXCEPTION;
- }
- break;
-
- case CBC:
- case INNER_CBC:
- {
- /* Deprecated/legacy */
-
- unsigned __int8 *ks = cryptoInfo->ks + EAGetKeyScheduleSize (cryptoInfo->ea);
- int cipher;
- for (cipher = EAGetLastCipher (cryptoInfo->ea);
- cipher != 0;
- cipher = EAGetPreviousCipher (cryptoInfo->ea, cipher))
- {
- ks -= CipherGetKeyScheduleSize (cipher);
-
- DecryptBufferCBC ((unsigned __int32 *) buf,
- (unsigned int) len,
- ks,
- (unsigned __int32 *) cryptoInfo->k2,
- (unsigned __int32 *) &cryptoInfo->k2[8],
- 0,
- cipher);
- }
- }
- break;
-
- case OUTER_CBC:
-
- /* Deprecated/legacy */
-
- DecryptBufferCBC ((unsigned __int32 *) buf,
- (unsigned int) len,
- cryptoInfo->ks,
- (unsigned __int32 *) cryptoInfo->k2,
- (unsigned __int32 *) &cryptoInfo->k2[8],
- cryptoInfo->ea,
- 0);
-
- break;
-#endif // #ifndef TC_NO_COMPILER_INT64
-
default:
// Unknown/wrong ID
TC_THROW_FATAL_EXCEPTION;
@@ -1610,14 +846,6 @@ void DecryptDataUnitsCurrentThread (unsigned __int8 *buf, const UINT64_STRUCT *s unsigned __int8 *ks2 = ci->ks2;
int cipher;
-#ifndef TC_NO_COMPILER_INT64
- void *iv = ci->k2; // Deprecated/legacy
- unsigned __int64 unitNo = structUnitNo->Value;
- unsigned __int64 *iv64 = (unsigned __int64 *) iv; // Deprecated/legacy
- unsigned __int32 sectorIV[4]; // Deprecated/legacy
- unsigned __int32 secWhitening[2]; // Deprecated/legacy
-#endif // #ifndef TC_NO_COMPILER_INT64
-
switch (ci->mode)
{
@@ -1640,81 +868,6 @@ void DecryptDataUnitsCurrentThread (unsigned __int8 *buf, const UINT64_STRUCT *s }
break;
-#ifndef TC_NO_COMPILER_INT64
- case LRW:
-
- /* Deprecated/legacy */
-
- switch (CipherGetBlockSize (EAGetFirstCipher (ea)))
- {
- case 8:
- DecryptBufferLRW64 (buf,
- (unsigned __int64) nbrUnits * ENCRYPTION_DATA_UNIT_SIZE,
- DataUnit2LRWIndex (unitNo, 8, ci),
- ci);
- break;
-
- case 16:
- DecryptBufferLRW128 (buf,
- (unsigned __int64) nbrUnits * ENCRYPTION_DATA_UNIT_SIZE,
- DataUnit2LRWIndex (unitNo, 16, ci),
- ci);
- break;
-
- default:
- TC_THROW_FATAL_EXCEPTION;
- }
- break;
-
- case CBC:
- case INNER_CBC:
-
- /* Deprecated/legacy */
-
- while (nbrUnits--)
- {
- ks += EAGetKeyScheduleSize (ea);
- for (cipher = EAGetLastCipher (ea); cipher != 0; cipher = EAGetPreviousCipher (ea, cipher))
- {
- InitSectorIVAndWhitening (unitNo, CipherGetBlockSize (cipher), sectorIV, iv64, secWhitening);
-
- ks -= CipherGetKeyScheduleSize (cipher);
-
- DecryptBufferCBC ((unsigned __int32 *) buf,
- ENCRYPTION_DATA_UNIT_SIZE,
- ks,
- sectorIV,
- secWhitening,
- 0,
- cipher);
- }
- buf += ENCRYPTION_DATA_UNIT_SIZE;
- unitNo++;
- }
- break;
-
- case OUTER_CBC:
-
- /* Deprecated/legacy */
-
- while (nbrUnits--)
- {
- InitSectorIVAndWhitening (unitNo, CipherGetBlockSize (EAGetFirstCipher (ea)), sectorIV, iv64, secWhitening);
-
- DecryptBufferCBC ((unsigned __int32 *) buf,
- ENCRYPTION_DATA_UNIT_SIZE,
- ks,
- sectorIV,
- secWhitening,
- ea,
- 0);
-
- buf += ENCRYPTION_DATA_UNIT_SIZE;
- unitNo++;
- }
- break;
-#endif // #ifndef TC_NO_COMPILER_INT64
-
default:
// Unknown/wrong ID
TC_THROW_FATAL_EXCEPTION;
@@ -1729,13 +882,6 @@ int GetMaxPkcs5OutSize (void) size = max (size, EAGetLargestKeyForMode (XTS) * 2); // Sizes of primary + secondary keys
-#ifndef TC_WINDOWS_BOOT
- size = max (size, LEGACY_VOL_IV_SIZE + EAGetLargestKeyForMode (LRW)); // Deprecated/legacy
- size = max (size, LEGACY_VOL_IV_SIZE + EAGetLargestKeyForMode (CBC)); // Deprecated/legacy
- size = max (size, LEGACY_VOL_IV_SIZE + EAGetLargestKeyForMode (OUTER_CBC)); // Deprecated/legacy
- size = max (size, LEGACY_VOL_IV_SIZE + EAGetLargestKeyForMode (INNER_CBC)); // Deprecated/legacy
-#endif
-
return size;
}
|