summaryrefslogtreecommitdiffstats
path: root/src/librbd/crypto/luks/Magic.h
blob: ad06e67f500de434f68eaa3bd09dfc55075d326b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#ifndef CEPH_LIBRBD_CRYPTO_LUKS_MAGIC_H
#define CEPH_LIBRBD_CRYPTO_LUKS_MAGIC_H

#include "common/ceph_context.h"
#include "include/buffer.h"

namespace librbd {
namespace crypto {
namespace luks {

class Magic {
public:
  static int is_luks(ceph::bufferlist& bl);
  static int is_rbd_clone(ceph::bufferlist& bl);

  static int replace_magic(CephContext* cct, ceph::bufferlist& bl);
private:
  static int read(ceph::bufferlist& bl, uint32_t bl_off,
                  uint32_t read_size, char* result);
  static int cmp(ceph::bufferlist& bl, uint32_t bl_off,
                 const std::string& cmp_str);
  static void transform_secondary_header_magic(char* magic);
};

} // namespace luks
} // namespace crypto
} // namespace librbd

#endif // CEPH_LIBRBD_CRYPTO_LUKS_MAGIC_H