]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
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_FORMAT_REQUEST_H | |
5 | #define CEPH_LIBRBD_CRYPTO_LUKS_FORMAT_REQUEST_H | |
6 | ||
1e59de90 | 7 | #include <string_view> |
f67539c2 TL |
8 | #include "include/rbd/librbd.hpp" |
9 | #include "librbd/ImageCtx.h" | |
10 | #include "librbd/crypto/CryptoInterface.h" | |
11 | #include "librbd/crypto/luks/Header.h" | |
12 | ||
13 | namespace librbd { | |
14 | ||
15 | class ImageCtx; | |
16 | ||
17 | namespace crypto { | |
18 | namespace luks { | |
19 | ||
20 | template <typename I> | |
21 | class FormatRequest { | |
22 | public: | |
23 | static FormatRequest* create( | |
24 | I* image_ctx, encryption_format_t format, | |
1e59de90 TL |
25 | encryption_algorithm_t alg, std::string_view passphrase, |
26 | std::unique_ptr<CryptoInterface>* result_crypto, Context* on_finish, | |
f67539c2 | 27 | bool insecure_fast_mode) { |
1e59de90 | 28 | return new FormatRequest(image_ctx, format, alg, passphrase, |
f67539c2 TL |
29 | result_crypto, on_finish, insecure_fast_mode); |
30 | } | |
31 | ||
32 | FormatRequest(I* image_ctx, encryption_format_t format, | |
1e59de90 TL |
33 | encryption_algorithm_t alg, std::string_view passphrase, |
34 | std::unique_ptr<CryptoInterface>* result_crypto, | |
f67539c2 TL |
35 | Context* on_finish, bool insecure_fast_mode); |
36 | void send(); | |
37 | void finish(int r); | |
38 | ||
39 | private: | |
40 | I* m_image_ctx; | |
41 | ||
42 | encryption_format_t m_format; | |
43 | encryption_algorithm_t m_alg; | |
1e59de90 TL |
44 | std::string_view m_passphrase; |
45 | std::unique_ptr<CryptoInterface>* m_result_crypto; | |
f67539c2 TL |
46 | Context* m_on_finish; |
47 | bool m_insecure_fast_mode; | |
48 | Header m_header; | |
49 | ||
50 | void handle_write_header(int r); | |
51 | }; | |
52 | ||
53 | } // namespace luks | |
54 | } // namespace crypto | |
55 | } // namespace librbd | |
56 | ||
57 | extern template class librbd::crypto::luks::FormatRequest<librbd::ImageCtx>; | |
58 | ||
59 | #endif // CEPH_LIBRBD_CRYPTO_LUKS_FORMAT_REQUEST_H |