YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/encryption/header_manager.h
Line
Count
Source
1
// Copyright (c) YugaByte, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4
// in compliance with the License.  You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software distributed under the License
9
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10
// or implied.  See the License for the specific language governing permissions and limitations
11
// under the License.
12
//
13
14
#ifndef YB_ENCRYPTION_HEADER_MANAGER_H
15
#define YB_ENCRYPTION_HEADER_MANAGER_H
16
17
#include <memory>
18
19
#include "yb/util/status_fwd.h"
20
21
namespace yb {
22
23
class Slice;
24
25
namespace encryption {
26
27
struct EncryptionParams;
28
typedef std::unique_ptr<EncryptionParams> EncryptionParamsPtr;
29
30
struct FileEncryptionStatus;
31
32
// Class for managing encryption headers of files.
33
class HeaderManager {
34
 public:
35
321
  virtual ~HeaderManager() {}
36
37
  // Slice starts from GetEncryptionMetadataStartIndex() and has length header_size from calling
38
  // GetFileEncryptionStatusFromPrefix. Generate encryption params for the given file, used when
39
  // creating a readable file.
40
  virtual Result<EncryptionParamsPtr> DecodeEncryptionParamsFromEncryptionMetadata(
41
      const Slice& s) = 0;
42
  // Given encryption params, create a file header. Used when creating a writable file.
43
  virtual Result<std::string> SerializeEncryptionParams(
44
      const EncryptionParams& encryption_info) = 0;
45
  // Start index of the encryption file metadata for the given file.
46
  virtual uint32_t GetEncryptionMetadataStartIndex() = 0;
47
  // Returns whether the file is encrypted and if so, what is the size of the header. Slice starts
48
  // from 0 and has length GetEncryptionMetadataStartIndex().
49
  virtual Result<FileEncryptionStatus> GetFileEncryptionStatusFromPrefix(const Slice& s) = 0;
50
  // Is encryption enabled for new files.
51
  virtual bool IsEncryptionEnabled() = 0;
52
};
53
54
} // namespace encryption
55
} // namespace yb
56
57
#endif // YB_ENCRYPTION_HEADER_MANAGER_H