cryptsetupInterface.hpp (6218dc5dc915b91019e9e0ff404c683c822d7920) | cryptsetupInterface.hpp (59dffa63af63ac1021f372e4505fb8c1b9084906) |
---|---|
1#pragma once 2 3#include <libcryptsetup.h> 4 5#include <stdplus/handle/managed.hpp> 6 7namespace estoraged 8{ --- 82 unchanged lines hidden (view full) --- 91 * @details Used for mocking purposes. 92 * 93 * @param[in] cd - crypt device handle, can be NULL. 94 * @param[in] name - name of device to deactivate. 95 * 96 * @returns 0 on success or negative errno value otherwise. 97 */ 98 virtual int cryptDeactivate(struct crypt_device* cd, const char* name) = 0; | 1#pragma once 2 3#include <libcryptsetup.h> 4 5#include <stdplus/handle/managed.hpp> 6 7namespace estoraged 8{ --- 82 unchanged lines hidden (view full) --- 91 * @details Used for mocking purposes. 92 * 93 * @param[in] cd - crypt device handle, can be NULL. 94 * @param[in] name - name of device to deactivate. 95 * 96 * @returns 0 on success or negative errno value otherwise. 97 */ 98 virtual int cryptDeactivate(struct crypt_device* cd, const char* name) = 0; |
99 100 /** @brief Wrapper around crypt_keyslot_destory. 101 * @details Used for mocking purposes. 102 * 103 * @param[in] cd - crypt device handle, can not be NULL. 104 * @param[in] keyslot requested key slot to destroy 105 * 106 * @returns 0 on success or negative errno value otherwise. 107 */ 108 virtual int cryptKeyslotDestroy(struct crypt_device* cd, 109 const int keyslot) = 0; 110 111 /** @breif Wapper around crypt_keyslot_max 112 * @details Used for mocking purposes. 113 * 114 * @param type crypt device type 115 * 116 * @return slot count or negative errno otherwise if device 117 * does not support keyslots. 118 */ 119 virtual int cryptKeySlotMax(const char* type) = 0; 120 121 /** @breif Wapper around crypt_keyslot_status 122 * @details Used for mocking purposes. 123 * Get information about particular key slot. 124 * 125 * @param cd crypt device handle 126 * @param keyslot requested keyslot to check or CRYPT_ANY_SLOT 127 * 128 * @return value defined by crypt_keyslot_info 129 * 130 */ 131 virtual crypt_keyslot_info cryptKeySlotStatus(struct crypt_device* cd, 132 int keyslot) = 0; |
|
99}; 100 101/** @class Cryptsetup 102 * @brief Implements CryptsetupInterface. 103 */ 104class Cryptsetup : public CryptsetupInterface 105{ 106 public: --- 31 unchanged lines hidden (view full) --- 138 return crypt_activate_by_passphrase(cd, name, keyslot, passphrase, 139 passphraseSize, flags); 140 } 141 142 int cryptDeactivate(struct crypt_device* cd, const char* name) override 143 { 144 return crypt_deactivate(cd, name); 145 } | 133}; 134 135/** @class Cryptsetup 136 * @brief Implements CryptsetupInterface. 137 */ 138class Cryptsetup : public CryptsetupInterface 139{ 140 public: --- 31 unchanged lines hidden (view full) --- 172 return crypt_activate_by_passphrase(cd, name, keyslot, passphrase, 173 passphraseSize, flags); 174 } 175 176 int cryptDeactivate(struct crypt_device* cd, const char* name) override 177 { 178 return crypt_deactivate(cd, name); 179 } |
180 181 int cryptKeyslotDestroy(struct crypt_device* cd, const int keyslot) override 182 { 183 return crypt_keyslot_destroy(cd, keyslot); 184 } 185 186 int cryptKeySlotMax(const char* type) override 187 { 188 return crypt_keyslot_max(type); 189 } 190 191 crypt_keyslot_info cryptKeySlotStatus(struct crypt_device* cd, 192 int keyslot) override 193 { 194 return crypt_keyslot_status(cd, keyslot); 195 } |
|
146}; 147 148/** @class CryptHandle 149 * @brief This manages a crypt_device struct and automatically frees it when 150 * this handle exits the current scope. 151 */ 152class CryptHandle 153{ --- 45 unchanged lines hidden --- | 196}; 197 198/** @class CryptHandle 199 * @brief This manages a crypt_device struct and automatically frees it when 200 * this handle exits the current scope. 201 */ 202class CryptHandle 203{ --- 45 unchanged lines hidden --- |