diff options
| author | David Anderson <dvander@google.com> | 2024-10-01 11:01:08 -0700 |
|---|---|---|
| committer | Julian Veit <claymore1298@gmail.com> | 2025-06-11 18:49:51 +0200 |
| commit | 666f772e38fcb37f8ec1d2b56e486fd715a9cc41 (patch) | |
| tree | b98cbeea1c792d1942df7ab2c78c463f67f36cc6 /fs_mgr/libdm/dm_test.cpp | |
| parent | 98c0a74b1851fe8eb97b38078144849da3d4ec1f (diff) | |
libdm: Redact keys from dm-crypt targets when calling GetTable.s12.1
Ignore-AOSP-First: security fix
Bug: 368069390
Test: libdm_test
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:a48086d28966c20794c3a04af83cdf13af268dcc)
Merged-In: I40b9a0129e58b1a0f116ca29f0ee66f91a27a73d
Change-Id: I40b9a0129e58b1a0f116ca29f0ee66f91a27a73d
Diffstat (limited to 'fs_mgr/libdm/dm_test.cpp')
| -rw-r--r-- | fs_mgr/libdm/dm_test.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/fs_mgr/libdm/dm_test.cpp b/fs_mgr/libdm/dm_test.cpp index 541f254cbc..f4c9784da8 100644 --- a/fs_mgr/libdm/dm_test.cpp +++ b/fs_mgr/libdm/dm_test.cpp @@ -690,3 +690,32 @@ TEST(libdm, CreateEmptyDevice) { // Empty device should be in suspended state. ASSERT_EQ(DmDeviceState::SUSPENDED, dm.GetState("empty-device")); } + +TEST(libdm, RedactDmCrypt) { + static constexpr uint64_t kImageSize = 65536; + static constexpr const char* kTestName = "RedactDmCrypt"; + unique_fd temp_file(CreateTempFile("file_1", kImageSize)); + ASSERT_GE(temp_file, 0); + + LoopDevice loop(temp_file, 10s); + ASSERT_TRUE(loop.valid()); + + static constexpr const char* kAlgorithm = "aes-cbc-essiv:sha256"; + static constexpr const char* kKey = "0e64ef514e6a1315b1f6390cb57c9e6a"; + + auto target = std::make_unique<DmTargetCrypt>(0, kImageSize / 512, kAlgorithm, kKey, 0, + loop.device(), 0); + target->AllowDiscards(); + + DmTable table; + table.AddTarget(std::move(target)); + + auto& dm = DeviceMapper::Instance(); + std::string crypt_path; + ASSERT_TRUE(dm.CreateDevice(kTestName, table, &crypt_path, 10s)); + + std::vector<DeviceMapper::TargetInfo> targets; + ASSERT_TRUE(dm.GetTableInfo(kTestName, &targets)); + ASSERT_EQ(targets.size(), 1); + EXPECT_EQ(targets[0].data.find(kKey), std::string::npos); +} |
