|
|
1.1.1.9 root 1: /* 1.1.1.11! root 2: Legal Notice: Some portions of the source code contained in this file were ! 3: derived from the source code of Encryption for the Masses 2.02a, which is ! 4: Copyright (c) 1998-2000 Paul Le Roux and which is governed by the 'License ! 5: Agreement for Encryption for the Masses'. Modifications and additions to ! 6: the original source code (contained in this file) and all other portions of ! 7: this file are Copyright (c) 2003-2008 TrueCrypt Foundation and are governed ! 8: by the TrueCrypt License 2.4 the full text of which is contained in the ! 9: file License.txt included in TrueCrypt binary and source code distribution 1.1.1.9 root 10: packages. */ 1.1 root 11: 1.1.1.6 root 12: #include "Tcdefs.h" 1.1 root 13: 14: #ifndef NT4_DRIVER 15: #pragma VxD_LOCKED_CODE_SEG 16: #pragma VxD_LOCKED_DATA_SEG 17: #endif 18: 1.1.1.6 root 19: #include "Crypto.h" 20: #include "Fat.h" 21: #include "Volumes.h" 22: #include "Apidrvr.h" 23: #include "Common.h" 24: #include "Cache.h" 25: 26: Password CachedPasswords[CACHE_SIZE]; 1.1 root 27: int cacheEmpty = 1; 1.1.1.6 root 28: static int nPasswordIdx = 0; 1.1 root 29: 30: int 1.1.1.6 root 31: VolumeReadHeaderCache (BOOL bCache, char *header, Password *password, PCRYPTO_INFO *retInfo) 1.1 root 32: { 33: int nReturnCode = ERR_PASSWORD_WRONG; 34: int i; 35: 36: /* Attempt to recognize volume using mount password */ 1.1.1.6 root 37: if (password->Length > 0) 1.1 root 38: { 1.1.1.11! root 39: nReturnCode = VolumeReadHeader (FALSE, header, password, retInfo, NULL); 1.1 root 40: 41: /* Save mount passwords back into cache if asked to do so */ 1.1.1.6 root 42: if (bCache && (nReturnCode == 0 || nReturnCode == ERR_CIPHER_INIT_WEAK_KEY)) 1.1 root 43: { 44: for (i = 0; i < CACHE_SIZE; i++) 45: { 1.1.1.6 root 46: if (memcmp (&CachedPasswords[i], password, sizeof (Password)) == 0) 1.1 root 47: break; 48: } 49: 50: if (i == CACHE_SIZE) 51: { 52: /* Store the password */ 1.1.1.6 root 53: CachedPasswords[nPasswordIdx] = *password; 1.1 root 54: 55: /* Try another slot */ 56: nPasswordIdx = (nPasswordIdx + 1) % CACHE_SIZE; 57: 58: cacheEmpty = 0; 59: } 60: } 61: } 62: else if (!cacheEmpty) 63: { 64: /* Attempt to recognize volume using cached passwords */ 65: for (i = 0; i < CACHE_SIZE; i++) 66: { 1.1.1.6 root 67: if (CachedPasswords[i].Length > 0) 1.1 root 68: { 1.1.1.11! root 69: nReturnCode = VolumeReadHeader (FALSE, header, &CachedPasswords[i], retInfo, NULL); 1.1 root 70: 71: if (nReturnCode != ERR_PASSWORD_WRONG) 72: break; 73: } 74: } 75: } 76: 77: return nReturnCode; 78: } 79: 80: void 81: WipeCache () 82: { 1.1.1.6 root 83: burn (CachedPasswords, sizeof (CachedPasswords)); 1.1 root 84: nPasswordIdx = 0; 85: cacheEmpty = 1; 86: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.