]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/crypto/luks/Header.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / librbd / crypto / luks / Header.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef CEPH_LIBRBD_CRYPTO_LUKS_HEADER_H
5 #define CEPH_LIBRBD_CRYPTO_LUKS_HEADER_H
6
7 #include <libcryptsetup.h>
8 #include "common/ceph_context.h"
9 #include "include/buffer.h"
10
11 namespace librbd {
12 namespace crypto {
13 namespace luks {
14
15 class Header {
16 public:
17 Header(CephContext* cct);
18 ~Header();
19 int init();
20
21 int write(const ceph::bufferlist& bl);
22 ssize_t read(ceph::bufferlist* bl);
23
24 int format(const char* type, const char* alg, const char* key,
25 size_t key_size, const char* cipher_mode, uint32_t sector_size,
26 uint32_t data_alignment, bool insecure_fast_mode);
27 int add_keyslot(const char* passphrase, size_t passphrase_size);
28 int load(const char* type);
29 int read_volume_key(const char* passphrase, size_t passphrase_size,
30 char* volume_key, size_t* volume_key_size);
31
32 int get_sector_size();
33 uint64_t get_data_offset();
34 const char* get_cipher();
35 const char* get_cipher_mode();
36 const char* get_format_name();
37
38 private:
39 void libcryptsetup_log(int level, const char* msg);
40 static void libcryptsetup_log_wrapper(int level, const char* msg,
41 void* header);
42
43 CephContext* m_cct;
44 int m_fd;
45 struct crypt_device *m_cd;
46 };
47
48 } // namespace luks
49 } // namespace crypto
50 } // namespace librbd
51
52 #endif // CEPH_LIBRBD_CRYPTO_LUKS_HEADER_H