|
|
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 "Volume/EncryptionMode.h" ! 10: #include "Volume/EncryptionModeCBC.h" ! 11: #include "Volume/EncryptionModeLRW.h" ! 12: #include "Volume/EncryptionModeXTS.h" ! 13: #include "VolumeLayout.h" ! 14: ! 15: namespace TrueCrypt ! 16: { ! 17: VolumeLayout::VolumeLayout () ! 18: { ! 19: } ! 20: ! 21: VolumeLayout::~VolumeLayout () ! 22: { ! 23: } ! 24: ! 25: VolumeLayoutList VolumeLayout::GetAvailableLayouts (VolumeType::Enum type) ! 26: { ! 27: VolumeLayoutList layouts; ! 28: ! 29: layouts.push_back (shared_ptr <VolumeLayout> (new VolumeLayoutV1Normal ())); ! 30: layouts.push_back (shared_ptr <VolumeLayout> (new VolumeLayoutV1Hidden ())); ! 31: ! 32: if (type != VolumeType::Unknown) ! 33: { ! 34: VolumeLayoutList l; ! 35: ! 36: foreach (shared_ptr <VolumeLayout> vl, layouts) ! 37: { ! 38: if (vl->GetType() == type) ! 39: l.push_back (vl); ! 40: } ! 41: ! 42: layouts = l; ! 43: } ! 44: ! 45: return layouts; ! 46: } ! 47: ! 48: shared_ptr <VolumeHeader> VolumeLayout::GetHeader () ! 49: { ! 50: if (Header.get() == nullptr) ! 51: Header.reset (new VolumeHeader (GetHeaderSize())); ! 52: ! 53: return Header; ! 54: } ! 55: ! 56: VolumeLayoutV1Normal::VolumeLayoutV1Normal () ! 57: { ! 58: Type = VolumeType::Normal; ! 59: HeaderOffset = 0; ! 60: HeaderSize = 512; ! 61: ! 62: SupportedEncryptionAlgorithms = EncryptionAlgorithm::GetAvailableAlgorithms(); ! 63: ! 64: SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); ! 65: SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ())); ! 66: SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ())); ! 67: } ! 68: ! 69: uint64 VolumeLayoutV1Normal::GetDataOffset (uint64 volumeHostSize) const ! 70: { ! 71: return HeaderSize; ! 72: } ! 73: ! 74: uint64 VolumeLayoutV1Normal::GetDataSize (uint64 volumeHostSize) const ! 75: { ! 76: return volumeHostSize - GetHeaderSize(); ! 77: } ! 78: ! 79: VolumeLayoutV1Hidden::VolumeLayoutV1Hidden () ! 80: { ! 81: Type = VolumeType::Hidden; ! 82: HeaderOffset = -512 * 3; ! 83: HeaderSize = 512; ! 84: ! 85: SupportedEncryptionAlgorithms = EncryptionAlgorithm::GetAvailableAlgorithms(); ! 86: ! 87: SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); ! 88: SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ())); ! 89: SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ())); ! 90: } ! 91: ! 92: uint64 VolumeLayoutV1Hidden::GetDataOffset (uint64 volumeHostSize) const ! 93: { ! 94: return volumeHostSize - GetDataSize (volumeHostSize) + HeaderOffset; ! 95: } ! 96: ! 97: uint64 VolumeLayoutV1Hidden::GetDataSize (uint64 volumeHostSize) const ! 98: { ! 99: return Header->GetHiddenVolumeDataSize (); ! 100: } ! 101: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.