|
|
1.1 ! root 1: /* ! 2: Copyright (c) 2008 TrueCrypt Foundation. All rights reserved. ! 3: ! 4: Governed by the TrueCrypt License 2.4 the full text of which is contained ! 5: in the file License.txt included in TrueCrypt binary and source code ! 6: distribution packages. ! 7: */ ! 8: ! 9: #include "VolumePasswordCache.h" ! 10: ! 11: namespace TrueCrypt ! 12: { ! 13: CachedPasswordList VolumePasswordCache::GetPasswords () ! 14: { ! 15: CachedPasswordList passwords; ! 16: ! 17: foreach_ref (const VolumePassword &password, CachedPasswords) ! 18: passwords.push_back (make_shared <VolumePassword> (VolumePassword (password))); ! 19: ! 20: return passwords; ! 21: } ! 22: ! 23: void VolumePasswordCache::Store (const VolumePassword &newPassword) ! 24: { ! 25: CachedPasswordList::iterator iter = CachedPasswords.begin(); ! 26: foreach_ref (const VolumePassword &password, CachedPasswords) ! 27: { ! 28: if (newPassword == password) ! 29: { ! 30: CachedPasswords.erase (iter); ! 31: break; ! 32: } ! 33: iter++; ! 34: } ! 35: ! 36: CachedPasswords.push_front (make_shared <VolumePassword> (VolumePassword (newPassword))); ! 37: ! 38: if (CachedPasswords.size() > Capacity) ! 39: CachedPasswords.pop_back(); ! 40: } ! 41: ! 42: CachedPasswordList VolumePasswordCache::CachedPasswords; ! 43: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.