|
|
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 "Common/Tcdefs.h"
10: #include "VolumeInfo.h"
11: #include "Platform/SerializerFactory.h"
12:
13: namespace TrueCrypt
14: {
15: void VolumeInfo::Deserialize (shared_ptr <Stream> stream)
16: {
17: Serializer sr (stream);
18:
19: sr.Deserialize ("ProgramVersion", ProgramVersion);
20: AuxMountPoint = sr.DeserializeWString ("AuxMountPoint");
21: sr.Deserialize ("EncryptionAlgorithmBlockSize", EncryptionAlgorithmBlockSize);
22: sr.Deserialize ("EncryptionAlgorithmKeySize", EncryptionAlgorithmKeySize);
23: sr.Deserialize ("EncryptionAlgorithmMinBlockSize", EncryptionAlgorithmMinBlockSize);
24: EncryptionAlgorithmName = sr.DeserializeWString ("EncryptionAlgorithmName");
25: EncryptionModeName = sr.DeserializeWString ("EncryptionModeName");
26: sr.Deserialize ("HeaderCreationTime", HeaderCreationTime);
27: sr.Deserialize ("HiddenVolumeProtectionTriggered", HiddenVolumeProtectionTriggered);
28: LoopDevice = sr.DeserializeWString ("LoopDevice");
29: MountPoint = sr.DeserializeWString ("MountPoint");
30: Path = sr.DeserializeWString ("Path");
31: sr.Deserialize ("Pkcs5IterationCount", Pkcs5IterationCount);
32: Pkcs5PrfName = sr.DeserializeWString ("Pkcs5PrfName");
33: Protection = static_cast <VolumeProtection::Enum> (sr.DeserializeInt32 ("Protection"));
34: sr.Deserialize ("SerialInstanceNumber", SerialInstanceNumber);
35: sr.Deserialize ("Size", Size);
36: sr.Deserialize ("SlotNumber", SlotNumber);
37: sr.Deserialize ("TotalDataRead", TotalDataRead);
38: sr.Deserialize ("TotalDataWritten", TotalDataWritten);
39: Type = static_cast <VolumeType::Enum> (sr.DeserializeInt32 ("Type"));
40: VirtualDevice = sr.DeserializeWString ("VirtualDevice");
41: sr.Deserialize ("VolumeCreationTime", VolumeCreationTime);
42: }
43:
44: void VolumeInfo::Serialize (shared_ptr <Stream> stream) const
45: {
46: Serializable::Serialize (stream);
47: Serializer sr (stream);
48:
49: const uint32 version = VERSION_NUM;
50: sr.Serialize ("ProgramVersion", version);
51: sr.Serialize ("AuxMountPoint", wstring (AuxMountPoint));
52: sr.Serialize ("EncryptionAlgorithmBlockSize", EncryptionAlgorithmBlockSize);
53: sr.Serialize ("EncryptionAlgorithmKeySize", EncryptionAlgorithmKeySize);
54: sr.Serialize ("EncryptionAlgorithmMinBlockSize", EncryptionAlgorithmMinBlockSize);
55: sr.Serialize ("EncryptionAlgorithmName", EncryptionAlgorithmName);
56: sr.Serialize ("EncryptionModeName", EncryptionModeName);
57: sr.Serialize ("HeaderCreationTime", HeaderCreationTime);
58: sr.Serialize ("HiddenVolumeProtectionTriggered", HiddenVolumeProtectionTriggered);
59: sr.Serialize ("LoopDevice", wstring (LoopDevice));
60: sr.Serialize ("MountPoint", wstring (MountPoint));
61: sr.Serialize ("Path", wstring (Path));
62: sr.Serialize ("Pkcs5IterationCount", Pkcs5IterationCount);
63: sr.Serialize ("Pkcs5PrfName", Pkcs5PrfName);
64: sr.Serialize ("Protection", static_cast <uint32> (Protection));
65: sr.Serialize ("SerialInstanceNumber", SerialInstanceNumber);
66: sr.Serialize ("Size", Size);
67: sr.Serialize ("SlotNumber", SlotNumber);
68: sr.Serialize ("TotalDataRead", TotalDataRead);
69: sr.Serialize ("TotalDataWritten", TotalDataWritten);
70: sr.Serialize ("Type", static_cast <uint32> (Type));
71: sr.Serialize ("VirtualDevice", wstring (VirtualDevice));
72: sr.Serialize ("VolumeCreationTime", VolumeCreationTime);
73: }
74:
75: void VolumeInfo::Set (const Volume &volume)
76: {
77: EncryptionAlgorithmBlockSize = static_cast <uint32> (volume.GetEncryptionAlgorithm()->GetMaxBlockSize());
78: EncryptionAlgorithmKeySize = static_cast <uint32> (volume.GetEncryptionAlgorithm()->GetKeySize());
79: EncryptionAlgorithmMinBlockSize = static_cast <uint32> (volume.GetEncryptionAlgorithm()->GetMinBlockSize());
80: EncryptionAlgorithmName = volume.GetEncryptionAlgorithm()->GetName();
81: EncryptionModeName = volume.GetEncryptionMode()->GetName();
82: HeaderCreationTime = volume.GetHeaderCreationTime();
83: VolumeCreationTime = volume.GetVolumeCreationTime();
84: HiddenVolumeProtectionTriggered = volume.IsHiddenVolumeProtectionTriggered();
85: Path = volume.GetPath();
86: Pkcs5IterationCount = volume.GetPkcs5Kdf()->GetIterationCount();
87: Pkcs5PrfName = volume.GetPkcs5Kdf()->GetName();
88: Protection = volume.GetProtectionType();
89: Size = volume.GetSize();
90: Type = volume.GetType();
91: TotalDataRead = volume.GetTotalDataRead();
92: TotalDataWritten = volume.GetTotalDataWritten();
93: }
94:
95: TC_SERIALIZER_FACTORY_ADD_CLASS (VolumeInfo);
96: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.