Skip to content
API Documentation
BastionGuard™
EncryptedVolumeSupport Class Reference

#include <encrypted_volume_support.hpp>

Static Public Member Functions

static std::vector< ScanResult > probe (DiskReader &reader, const std::vector< ScanResult > &seed_results, std::vector< std::string > &logs)
static bool collect_detected_containers (const ScanReport &report, std::vector< EncryptedContainerInfo > &out)

Detailed Description

Definition at line 17 of file encrypted_volume_support.hpp.

Member Function Documentation

◆ collect_detected_containers()

bool EncryptedVolumeSupport::collect_detected_containers ( const ScanReport & report,
std::vector< EncryptedContainerInfo > & out )
static

Definition at line 133 of file encrypted_volume_support.cpp.

134 {
135 out.clear();
136 for (const auto& r : report.results) {
137 EncryptedContainerInfo info;
138 if (r.type == "LUKS1 container") info.scheme = "LUKS1";
139 else if (r.type == "LUKS2 container") info.scheme = "LUKS2";
140 else if (r.type == "BitLocker volume") info.scheme = "BitLocker";
141 else continue;
142 info.offset_bytes = r.offset_bytes;
143 info.size_bytes = r.size_bytes;
144 info.detail = r.detail;
145 // Best-effort payload offset extraction from detail string.
146 const std::string needle = "payload offset: ";
147 const auto pos = r.detail.find(needle);
148 if (pos != std::string::npos) {
149 const auto start = pos + needle.size();
150 const auto end = r.detail.find(' ', start);
151 try {
152 info.payload_offset_bytes = std::stoull(r.detail.substr(start, end - start));
153 } catch (...) {
154 info.payload_offset_bytes = 0;
155 }
156 }
157 out.push_back(info);
158 }
159 return !out.empty();
160}
std::vector< ScanResult > results
Definition models.hpp:40

References EncryptedContainerInfo::detail, EncryptedContainerInfo::offset_bytes, EncryptedContainerInfo::payload_offset_bytes, ScanReport::results, EncryptedContainerInfo::scheme, and EncryptedContainerInfo::size_bytes.

◆ probe()

std::vector< ScanResult > EncryptedVolumeSupport::probe ( DiskReader & reader,
const std::vector< ScanResult > & seed_results,
std::vector< std::string > & logs )
static

Definition at line 102 of file encrypted_volume_support.cpp.

104 {
105 std::vector<ScanResult> out;
106 std::set<uint64_t> seen_offsets;
107 logs.push_back(trs("Encrypted volume probes: analysis started."));
108
109 for (const auto& seed : seed_results) {
110 const bool interesting_seed =
111 seed.kind == ResultKind::Partition ||
113 seed.kind == ResultKind::FilesystemCandidate ||
114 seed.kind == ResultKind::FilesystemVolume ||
115 seed.kind == ResultKind::NtfsVolume;
116 if (!interesting_seed || seen_offsets.count(seed.offset_bytes) != 0) continue;
117 seen_offsets.insert(seed.offset_bytes);
118
119 if (auto r = luks_probe(reader, seed.offset_bytes); !r.type.empty()) out.push_back(r);
120 if (auto r = bitlocker_probe(reader, seed.offset_bytes); !r.type.empty()) out.push_back(r);
121 }
122
123 // Also probe the whole source offset 0 for raw encrypted-device headers.
124 if (seen_offsets.insert(0).second) {
125 if (auto r = luks_probe(reader, 0); !r.type.empty()) out.push_back(r);
126 if (auto r = bitlocker_probe(reader, 0); !r.type.empty()) out.push_back(r);
127 }
128
129 logs.push_back(trs("Encrypted volume probes: analysis completed."));
130 return out;
131}
std::string trs(const char *msgid)
Definition i18n.cpp:22
@ Partition
Definition models.hpp:8
@ LostPartitionCandidate
Definition models.hpp:9
@ FilesystemCandidate
Definition models.hpp:10
@ FilesystemVolume
Definition models.hpp:11
ScanResult bitlocker_probe(DiskReader &reader, uint64_t offset)
ScanResult luks_probe(DiskReader &reader, uint64_t offset)

References FilesystemCandidate, FilesystemVolume, LostPartitionCandidate, NtfsVolume, Partition, and trs().


The documentation for this class was generated from the following files: