John Wedig | 2098dab | 2021-09-14 13:56:28 -0700 | [diff] [blame^] | 1 | #pragma once |
| 2 | |
| 3 | #include <sdbusplus/bus.hpp> |
| 4 | #include <sdbusplus/exception.hpp> |
| 5 | #include <sdbusplus/server/object.hpp> |
| 6 | #include <xyz/openbmc_project/eStoraged/server.hpp> |
| 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | namespace estoraged |
| 12 | { |
| 13 | using eStoragedInherit = sdbusplus::server::object_t< |
| 14 | sdbusplus::xyz::openbmc_project::server::eStoraged>; |
| 15 | |
| 16 | /** @class eStoraged |
| 17 | * @brief eStoraged object to manage a LUKS encrypted storage device. |
| 18 | */ |
| 19 | class eStoraged : eStoragedInherit |
| 20 | { |
| 21 | public: |
| 22 | eStoraged(sdbusplus::bus::bus& bus, const char* path, |
| 23 | const std::string& devPath, const std::string& containerName) : |
| 24 | eStoragedInherit(bus, path), |
| 25 | devPath(devPath), containerName(containerName) |
| 26 | {} |
| 27 | |
| 28 | /** @brief Format the LUKS encrypted device and create empty filesystem. |
| 29 | * |
| 30 | * @param[in] password - password to set for the LUKS device. |
| 31 | */ |
| 32 | void format(std::vector<uint8_t> password) override; |
| 33 | |
| 34 | /** @brief Erase the contents of the storage device. |
| 35 | * |
| 36 | * @param[in] password - password for the LUKS device. |
| 37 | * @param[in] eraseType - type of erase operation. |
| 38 | */ |
| 39 | void erase(std::vector<uint8_t> password, EraseMethod eraseType) override; |
| 40 | |
| 41 | /** @brief Unmount filesystem and lock the LUKS device. |
| 42 | * |
| 43 | * @param[in] password - password for the LUKS device. |
| 44 | */ |
| 45 | void lock(std::vector<uint8_t> password) override; |
| 46 | |
| 47 | /** @brief Unlock device and mount the filesystem. |
| 48 | * |
| 49 | * @param[in] password - password for the LUKS device. |
| 50 | */ |
| 51 | void unlock(std::vector<uint8_t> password) override; |
| 52 | |
| 53 | /** @brief Change the password for the LUKS device. |
| 54 | * |
| 55 | * @param[in] oldPassword - old password for the LUKS device. |
| 56 | * @param[in] newPassword - new password for the LUKS device. |
| 57 | */ |
| 58 | void changePassword(std::vector<uint8_t> oldPassword, |
| 59 | std::vector<uint8_t> newPassword) override; |
| 60 | |
| 61 | private: |
| 62 | /* Full path of the device file, e.g. /dev/mmcblk0 */ |
| 63 | std::string devPath; |
| 64 | |
| 65 | /* Name of the LUKS container. */ |
| 66 | std::string containerName; |
| 67 | }; |
| 68 | |
| 69 | } // namespace estoraged |