Add crypto Erase to eStorageD.
The goal is to erase the keys that are used to decrypt the drive. After
the keys are erased it will not be possible to decrypt the drive, even
if the password can be recalled. The data is forever inaccessible.
Testing:
$ systemctl stop emmc.service
$ /eStoraged -b /dev/mmcblk0 &
$ busctl call xyz.openbmc_project.eStoraged.mmcblk0 /xyz/openbmc_project/storage/mmcblk0 xyz.openbmc_project.Inventory.Item.Volume FormatLuks ays 3 1 2 3 xyz.openbmc_project.Inventory.Item.Volume.FilesystemType.ext4
$ busctl call xyz.openbmc_project.eStoraged.mmcblk0 /xyz/openbmc_project/storage/mmcblk0 xyz.openbmc_project.Inventory.Item.Volume Lock
$ busctl call xyz.openbmc_project.eStoraged.mmcblk0 /xyz/openbmc_project/storage/mmcblk0 xyz.openbmc_project.Inventory.Item.Volume Erase s xyz.openbmc_project.Inventory.Item.Volume.EraseMethod.CryptoErase
$ busctl call xyz.openbmc_project.eStoraged.mmcblk0 /xyz/openbmc_project/storage/mmcblk0 xyz.openbmc_project.Inventory.Item.Volume Unlock ay 3 1 2 3
Call failed: The operation failed internally.
Signed-off-by: John Edward Broadbent <jebr@google.com>
Change-Id: I3221e82a92c1b555e2379b19c9e1d5b6e4b02f9b
diff --git a/src/test/estoraged_test.cpp b/src/test/estoraged_test.cpp
index 3b23215..10357fe 100644
--- a/src/test/estoraged_test.cpp
+++ b/src/test/estoraged_test.cpp
@@ -1,13 +1,12 @@
+#include "estoraged_test.hpp"
-#include "cryptsetupInterface.hpp"
#include "estoraged.hpp"
-#include "filesystemInterface.hpp"
#include <unistd.h>
-#include <sdbusplus/bus.hpp>
#include <sdbusplus/test/sdbus_mock.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <xyz/openbmc_project/Inventory/Item/Volume/client.hpp>
#include <exception>
#include <filesystem>
@@ -22,59 +21,6 @@
namespace estoraged_test
{
-class MockFilesystemInterface : public estoraged::FilesystemInterface
-{
- public:
- MOCK_METHOD(int, runMkfs, (const std::string& logicalVolume), (override));
-
- MOCK_METHOD(int, doMount,
- (const char* source, const char* target,
- const char* filesystemtype, unsigned long mountflags,
- const void* data),
- (override));
-
- MOCK_METHOD(int, doUnmount, (const char* target), (override));
-
- MOCK_METHOD(bool, createDirectory, (const std::filesystem::path& p),
- (override));
-
- MOCK_METHOD(bool, removeDirectory, (const std::filesystem::path& p),
- (override));
-
- MOCK_METHOD(bool, directoryExists, (const std::filesystem::path& p),
- (override));
-};
-
-class MockCryptsetupInterface : public estoraged::CryptsetupInterface
-{
- public:
- MOCK_METHOD(int, cryptFormat,
- (struct crypt_device * cd, const char* type, const char* cipher,
- const char* cipher_mode, const char* uuid,
- const char* volume_key, size_t volume_key_size, void* params),
- (override));
-
- MOCK_METHOD(int, cryptKeyslotAddByVolumeKey,
- (struct crypt_device * cd, int keyslot, const char* volume_key,
- size_t volume_key_size, const char* passphrase,
- size_t passphrase_size),
- (override));
-
- MOCK_METHOD(int, cryptLoad,
- (struct crypt_device * cd, const char* requested_type,
- void* params),
- (override));
-
- MOCK_METHOD(int, cryptActivateByPassphrase,
- (struct crypt_device * cd, const char* name, int keyslot,
- const char* passphrase, size_t passphrase_size,
- uint32_t flags),
- (override));
-
- MOCK_METHOD(int, cryptDeactivate,
- (struct crypt_device * cd, const char* name), (override));
-};
-
using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
using sdbusplus::xyz::openbmc_project::Common::Error::ResourceNotFound;
using sdbusplus::xyz::openbmc_project::Inventory::Item::server::Volume;