MySQL 8.4.0
Source Code Documentation
keyring_file.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2016, 2024, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef MYSQL_HARNESS_KEYRING_FILE_INCLUDED
27#define MYSQL_HARNESS_KEYRING_FILE_INCLUDED
28
29#include "keyring_memory.h"
30
31namespace mysql_harness {
32
33/**
34 * KeyringFile class.
35 *
36 * Implements Keyring interface and provides additional methods for loading and
37 * saving keyring to file.
38 */
39class HARNESS_EXPORT KeyringFile : public KeyringMemory {
40 public:
41 KeyringFile() = default;
42
43 /**
44 * Sets additional data to be stored with the file but will not be
45 * encrypted.
46 *
47 * @param[in] data to store in header
48 */
49 void set_header(const std::string &data);
50
51 /**
52 * Saves keyring to file.
53 *
54 * @param[in] file_name Keyring file name.
55 * @param[in] key Key used for encryption.
56 *
57 * @exception std::exception Saving to file failed.
58 */
59 void save(const std::string &file_name, const std::string &key) const;
60
61 /**
62 * Load keyring from file.
63 *
64 * @param[in] file_name Keyring file name.
65 * @param[in] key Key used for decryption.
66 *
67 * @exception std::exception Loading from file failed.
68 */
69 void load(const std::string &file_name, const std::string &key);
70
71 /**
72 * Read header data from file.
73 *
74 * @param[in] file_name Keyring file name.
75 *
76 * @exception std::exception Loading from file failed.
77 */
78 std::string read_header(const std::string &file_name);
79
80 private:
81 std::string header_;
82};
83
84} // namespace mysql_harness
85
86#endif // MYSQL_HARNESS_KEYRING_FILE_INCLUDED
void read_header(azio_stream *s, unsigned char *buffer)
Definition: azio.cc:332
KeyringFile class.
Definition: keyring_file.h:39
std::string header_
Definition: keyring_file.h:81
KeyringMemory class.
Definition: keyring_memory.h:48
bool load(THD *, const dd::String_type &fname, dd::String_type *buf)
Read an sdi file from disk and store in a buffer.
Definition: sdi_file.cc:308
std::string file_name(Log_file_id file_id)
Provides name of the log file with the given file id, e.g.
Definition: log0pre_8_0_30.cc:94
Definition: common.h:42
required string key
Definition: replication_asynchronous_connection_failover.proto:60