MySQL 8.3.0
Source Code Documentation
keyring_file.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2016, 2023, 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 also distributed 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 included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23*/
24
25#ifndef MYSQL_HARNESS_KEYRING_FILE_INCLUDED
26#define MYSQL_HARNESS_KEYRING_FILE_INCLUDED
27
28#include "keyring_memory.h"
29
30namespace mysql_harness {
31
32/**
33 * KeyringFile class.
34 *
35 * Implements Keyring interface and provides additional methods for loading and
36 * saving keyring to file.
37 */
38class HARNESS_EXPORT KeyringFile : public KeyringMemory {
39 public:
40 KeyringFile() = default;
41
42 /**
43 * Sets additional data to be stored with the file but will not be
44 * encrypted.
45 *
46 * @param[in] data to store in header
47 */
48 void set_header(const std::string &data);
49
50 /**
51 * Saves keyring to file.
52 *
53 * @param[in] file_name Keyring file name.
54 * @param[in] key Key used for encryption.
55 *
56 * @exception std::exception Saving to file failed.
57 */
58 void save(const std::string &file_name, const std::string &key) const;
59
60 /**
61 * Load keyring from file.
62 *
63 * @param[in] file_name Keyring file name.
64 * @param[in] key Key used for decryption.
65 *
66 * @exception std::exception Loading from file failed.
67 */
68 void load(const std::string &file_name, const std::string &key);
69
70 /**
71 * Read header data from file.
72 *
73 * @param[in] file_name Keyring file name.
74 *
75 * @exception std::exception Loading from file failed.
76 */
77 std::string read_header(const std::string &file_name);
78
79 private:
80 std::string header_;
81};
82
83} // namespace mysql_harness
84
85#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:38
std::string header_
Definition: keyring_file.h:80
KeyringMemory class.
Definition: keyring_memory.h:47
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:307
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:93
Definition: common.h:41
required string key
Definition: replication_asynchronous_connection_failover.proto:59