cryptsetupInterface.hpp (2443a0217d6ffe4cec3226992a49b45d37bbb53d) | cryptsetupInterface.hpp (15b63e12bdc3f3116fb841349dd4f1cd17a8398b) |
---|---|
1#pragma once 2 3#include <libcryptsetup.h> 4 5#include <phosphor-logging/lg2.hpp> 6#include <stdplus/handle/managed.hpp> 7#include <xyz/openbmc_project/Common/error.hpp> 8 --- 49 unchanged lines hidden (view full) --- 58 * @param[in] keyslotNew - new keyslot or CRYPT_ANY_SLOT. 59 * @param[in] passphrase - passphrase for new keyslot. 60 * @param[in] passphraseSize - size of passphrase. 61 * @param[in] newPassphrase - new passphrase for the specified keyslot 62 * @param[in] newPassphraseSize - size of newPassphrase (in bytes). 63 * 64 * @returns allocated key slot number or negative errno otherwise. 65 */ | 1#pragma once 2 3#include <libcryptsetup.h> 4 5#include <phosphor-logging/lg2.hpp> 6#include <stdplus/handle/managed.hpp> 7#include <xyz/openbmc_project/Common/error.hpp> 8 --- 49 unchanged lines hidden (view full) --- 58 * @param[in] keyslotNew - new keyslot or CRYPT_ANY_SLOT. 59 * @param[in] passphrase - passphrase for new keyslot. 60 * @param[in] passphraseSize - size of passphrase. 61 * @param[in] newPassphrase - new passphrase for the specified keyslot 62 * @param[in] newPassphraseSize - size of newPassphrase (in bytes). 63 * 64 * @returns allocated key slot number or negative errno otherwise. 65 */ |
66 virtual int cryptKeyslotChangeByPassphrase(struct crypt_device* cd, 67 int keyslotOld, int keyslotNew, 68 const char* passphrase, 69 size_t passphraseSize, 70 const char* newPassphrase, 71 size_t newPassphraseSize) = 0; | 66 virtual int cryptKeyslotChangeByPassphrase( 67 struct crypt_device* cd, int keyslotOld, int keyslotNew, 68 const char* passphrase, size_t passphraseSize, 69 const char* newPassphrase, size_t newPassphraseSize) = 0; |
72 73 /** @brief Wrapper around crypt_keyslot_add_by_volume_key. 74 * @details Used for mocking purposes. 75 * 76 * @param[in] cd - crypt device handle. 77 * @param[in] keyslot - requested keyslot or CRYPT_ANY_SLOT. 78 * @param[in] volume_key - provided volume key or NULL if used after 79 * crypt_format. 80 * @param[in] volume_key_size - size of volume_key. 81 * @param[in] passphrase - passphrase for new keyslot. 82 * @param[in] passphrase_size - size of passphrase. 83 * 84 * @returns allocated key slot number or negative errno otherwise. 85 */ | 70 71 /** @brief Wrapper around crypt_keyslot_add_by_volume_key. 72 * @details Used for mocking purposes. 73 * 74 * @param[in] cd - crypt device handle. 75 * @param[in] keyslot - requested keyslot or CRYPT_ANY_SLOT. 76 * @param[in] volume_key - provided volume key or NULL if used after 77 * crypt_format. 78 * @param[in] volume_key_size - size of volume_key. 79 * @param[in] passphrase - passphrase for new keyslot. 80 * @param[in] passphrase_size - size of passphrase. 81 * 82 * @returns allocated key slot number or negative errno otherwise. 83 */ |
86 virtual int cryptKeyslotAddByVolumeKey(struct crypt_device* cd, int keyslot, 87 const char* volumeKey, 88 size_t volumeKeySize, 89 const char* passphrase, 90 size_t passphraseSize) = 0; | 84 virtual int cryptKeyslotAddByVolumeKey( 85 struct crypt_device* cd, int keyslot, const char* volumeKey, 86 size_t volumeKeySize, const char* passphrase, 87 size_t passphraseSize) = 0; |
91 92 /** @brief Wrapper around crypt_load. 93 * @details Used for mocking purposes. 94 * 95 * @param[in] cd - crypt device handle. 96 * @param[in] requested_type - crypt-type or NULL for all known. 97 * @param[in] params - crypt type specific parameters (see crypt-type). 98 * --- 10 unchanged lines hidden (view full) --- 109 * passphrase. 110 * @param[in] keyslot - requested keyslot to check or CRYPT_ANY_SLOT. 111 * @param[in] passphrase - passphrase used to unlock volume key. 112 * @param[in] passphrase_size - size of passphrase. 113 * @param[in] flags - activation flags. 114 * 115 * @returns unlocked key slot number or negative errno otherwise. 116 */ | 88 89 /** @brief Wrapper around crypt_load. 90 * @details Used for mocking purposes. 91 * 92 * @param[in] cd - crypt device handle. 93 * @param[in] requested_type - crypt-type or NULL for all known. 94 * @param[in] params - crypt type specific parameters (see crypt-type). 95 * --- 10 unchanged lines hidden (view full) --- 106 * passphrase. 107 * @param[in] keyslot - requested keyslot to check or CRYPT_ANY_SLOT. 108 * @param[in] passphrase - passphrase used to unlock volume key. 109 * @param[in] passphrase_size - size of passphrase. 110 * @param[in] flags - activation flags. 111 * 112 * @returns unlocked key slot number or negative errno otherwise. 113 */ |
117 virtual int cryptActivateByPassphrase(struct crypt_device* cd, 118 const char* name, int keyslot, 119 const char* passphrase, 120 size_t passphraseSize, 121 uint32_t flags) = 0; | 114 virtual int cryptActivateByPassphrase( 115 struct crypt_device* cd, const char* name, int keyslot, 116 const char* passphrase, size_t passphraseSize, uint32_t flags) = 0; |
122 123 /** @brief Wrapper around crypt_deactivate. 124 * @details Used for mocking purposes. 125 * 126 * @param[in] cd - crypt device handle, can be NULL. 127 * @param[in] name - name of device to deactivate. 128 * 129 * @returns 0 on success or negative errno value otherwise. --- 24 unchanged lines hidden (view full) --- 154 * @details Used for mocking purposes. 155 * Get information about particular key slot. 156 * 157 * @param cd crypt device handle 158 * @param keyslot requested keyslot to check or CRYPT_ANY_SLOT 159 * 160 * @return value defined by crypt_keyslot_info 161 */ | 117 118 /** @brief Wrapper around crypt_deactivate. 119 * @details Used for mocking purposes. 120 * 121 * @param[in] cd - crypt device handle, can be NULL. 122 * @param[in] name - name of device to deactivate. 123 * 124 * @returns 0 on success or negative errno value otherwise. --- 24 unchanged lines hidden (view full) --- 149 * @details Used for mocking purposes. 150 * Get information about particular key slot. 151 * 152 * @param cd crypt device handle 153 * @param keyslot requested keyslot to check or CRYPT_ANY_SLOT 154 * 155 * @return value defined by crypt_keyslot_info 156 */ |
162 virtual crypt_keyslot_info cryptKeySlotStatus(struct crypt_device* cd, 163 int keyslot) = 0; | 157 virtual crypt_keyslot_info 158 cryptKeySlotStatus(struct crypt_device* cd, int keyslot) = 0; |
164 165 /** @brief Wrapper around crypt_get_dir. 166 * @details Used for mocking purposes. 167 * 168 * @returns the directory where mapped crypt devices are created. 169 */ 170 virtual std::string cryptGetDir() = 0; 171}; --- 16 unchanged lines hidden (view full) --- 188 const char* cipher, const char* cipherMode, 189 const char* uuid, const char* volumeKey, 190 size_t volumeKeySize, void* params) override 191 { 192 return crypt_format(cd, type, cipher, cipherMode, uuid, volumeKey, 193 volumeKeySize, params); 194 } 195 | 159 160 /** @brief Wrapper around crypt_get_dir. 161 * @details Used for mocking purposes. 162 * 163 * @returns the directory where mapped crypt devices are created. 164 */ 165 virtual std::string cryptGetDir() = 0; 166}; --- 16 unchanged lines hidden (view full) --- 183 const char* cipher, const char* cipherMode, 184 const char* uuid, const char* volumeKey, 185 size_t volumeKeySize, void* params) override 186 { 187 return crypt_format(cd, type, cipher, cipherMode, uuid, volumeKey, 188 volumeKeySize, params); 189 } 190 |
196 int cryptKeyslotChangeByPassphrase(struct crypt_device* cd, int keyslotOld, 197 int keyslotNew, const char* passphrase, 198 size_t passphraseSize, 199 const char* newPassphrase, 200 size_t newPassphraseSize) override | 191 int cryptKeyslotChangeByPassphrase( 192 struct crypt_device* cd, int keyslotOld, int keyslotNew, 193 const char* passphrase, size_t passphraseSize, 194 const char* newPassphrase, size_t newPassphraseSize) override |
201 { 202 return crypt_keyslot_change_by_passphrase( 203 cd, keyslotOld, keyslotNew, passphrase, passphraseSize, 204 newPassphrase, newPassphraseSize); 205 } 206 207 int cryptKeyslotAddByVolumeKey(struct crypt_device* cd, int keyslot, 208 const char* volumeKey, size_t volumeKeySize, --- 5 unchanged lines hidden (view full) --- 214 } 215 216 int cryptLoad(struct crypt_device* cd, const char* requestedType, 217 void* params) override 218 { 219 return crypt_load(cd, requestedType, params); 220 } 221 | 195 { 196 return crypt_keyslot_change_by_passphrase( 197 cd, keyslotOld, keyslotNew, passphrase, passphraseSize, 198 newPassphrase, newPassphraseSize); 199 } 200 201 int cryptKeyslotAddByVolumeKey(struct crypt_device* cd, int keyslot, 202 const char* volumeKey, size_t volumeKeySize, --- 5 unchanged lines hidden (view full) --- 208 } 209 210 int cryptLoad(struct crypt_device* cd, const char* requestedType, 211 void* params) override 212 { 213 return crypt_load(cd, requestedType, params); 214 } 215 |
222 int cryptActivateByPassphrase(struct crypt_device* cd, const char* name, 223 int keyslot, const char* passphrase, 224 size_t passphraseSize, 225 uint32_t flags) override | 216 int cryptActivateByPassphrase( 217 struct crypt_device* cd, const char* name, int keyslot, 218 const char* passphrase, size_t passphraseSize, uint32_t flags) override |
226 { 227 return crypt_activate_by_passphrase(cd, name, keyslot, passphrase, 228 passphraseSize, flags); 229 } 230 231 int cryptDeactivate(struct crypt_device* cd, const char* name) override 232 { 233 return crypt_deactivate(cd, name); --- 85 unchanged lines hidden --- | 219 { 220 return crypt_activate_by_passphrase(cd, name, keyslot, passphrase, 221 passphraseSize, flags); 222 } 223 224 int cryptDeactivate(struct crypt_device* cd, const char* name) override 225 { 226 return crypt_deactivate(cd, name); --- 85 unchanged lines hidden --- |