]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/crypto/openssl/DataCryptor.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / librbd / crypto / openssl / DataCryptor.h
CommitLineData
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_OPENSSL_DATA_CRYPTOR_H
5#define CEPH_LIBRBD_CRYPTO_OPENSSL_DATA_CRYPTOR_H
6
7#include "librbd/crypto/DataCryptor.h"
8#include "include/Context.h"
9#include <openssl/evp.h>
10
11namespace librbd {
12namespace crypto {
13namespace openssl {
14
15class DataCryptor : public crypto::DataCryptor<EVP_CIPHER_CTX> {
16
17public:
18 DataCryptor(CephContext* cct) : m_cct(cct) {};
19 ~DataCryptor();
20
21 int init(const char* cipher_name, const unsigned char* key,
22 uint16_t key_length);
23 uint32_t get_block_size() const override;
24 uint32_t get_iv_size() const override;
25 const unsigned char* get_key() const override;
26 int get_key_length() const override;
27
28 EVP_CIPHER_CTX* get_context(CipherMode mode) override;
29 void return_context(EVP_CIPHER_CTX* ctx, CipherMode mode) override;
30 int init_context(EVP_CIPHER_CTX* ctx, const unsigned char* iv,
31 uint32_t iv_length) const override;
32 int update_context(EVP_CIPHER_CTX* ctx, const unsigned char* in,
33 unsigned char* out, uint32_t len) const override;
34
35private:
36 CephContext* m_cct;
37 unsigned char* m_key = nullptr;
20effc67 38 uint16_t m_key_size = 0;
f67539c2
TL
39 const EVP_CIPHER* m_cipher;
40 uint32_t m_iv_size;
41
42 void log_errors() const;
43};
44
45} // namespace openssl
46} // namespace crypto
47} // namespace librbd
48
49#endif // CEPH_LIBRBD_CRYPTO_OPENSSL_DATA_CRYPTOR_H