]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rocksdb/env/env_encryption_ctr.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / env / env_encryption_ctr.h
index b22d7e45ff7192a1a0f0f442daef3f2c04880036..cfb440c72ace7c0598122ef1d35b8d7e7a71b290 100644 (file)
 #include "rocksdb/env_encryption.h"
 
 namespace ROCKSDB_NAMESPACE {
-
-// Implements a BlockCipher using ROT13.
-//
-// Note: This is a sample implementation of BlockCipher,
-// it is NOT considered safe and should NOT be used in production.
-class ROT13BlockCipher : public BlockCipher {
- private:
-  size_t blockSize_;
-
- public:
-  ROT13BlockCipher(size_t blockSize) : blockSize_(blockSize) {}
-  virtual ~ROT13BlockCipher(){};
-  const char* Name() const override;
-  // BlockSize returns the size of each block supported by this cipher stream.
-  size_t BlockSize() override { return blockSize_; }
-
-  // Encrypt a block of data.
-  // Length of data is equal to BlockSize().
-  Status Encrypt(char* data) override;
-
-  // Decrypt a block of data.
-  // Length of data is equal to BlockSize().
-  Status Decrypt(char* data) override;
-};
-
 // CTRCipherStream implements BlockAccessCipherStream using an
 // Counter operations mode.
 // See https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation
@@ -86,12 +61,12 @@ class CTREncryptionProvider : public EncryptionProvider {
 
  public:
   explicit CTREncryptionProvider(
-      const std::shared_ptr<BlockCipher>& c = nullptr)
-      : cipher_(c){};
+      const std::shared_ptr<BlockCipher>& c = nullptr);
   virtual ~CTREncryptionProvider() {}
 
-  const char* Name() const override;
-
+  static const char* kClassName() { return "CTR"; }
+  const char* Name() const override { return kClassName(); }
+  bool IsInstanceOf(const std::string& name) const override;
   // GetPrefixLength returns the length of the prefix that is added to every
   // file
   // and used for storing encryption options.
@@ -114,8 +89,6 @@ class CTREncryptionProvider : public EncryptionProvider {
                    size_t /*len*/, bool /*for_write*/) override;
 
  protected:
-  Status TEST_Initialize() override;
-
   // PopulateSecretPrefixPart initializes the data into a new prefix block
   // that will be encrypted. This function will store the data in plain text.
   // It will be encrypted later (before written to disk).
@@ -132,6 +105,12 @@ class CTREncryptionProvider : public EncryptionProvider {
       uint64_t initialCounter, const Slice& iv, const Slice& prefix,
       std::unique_ptr<BlockAccessCipherStream>* result);
 };
+
+Status NewEncryptedFileSystemImpl(
+    const std::shared_ptr<FileSystem>& base_fs,
+    const std::shared_ptr<EncryptionProvider>& provider,
+    std::unique_ptr<FileSystem>* fs);
+
 }  // namespace ROCKSDB_NAMESPACE
 
 #endif  // !defined(ROCKSDB_LITE)