Debian Codegraph @

storage/innobase/include/log0encryption.h

raw
1 /*****************************************************************************
2
3 Copyright (c) 1995, 2026, Oracle and/or its affiliates.
4
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8
9 This program is designed to work with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation. The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have either included with
15 the program or referenced in the documentation.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20 for more details.
21
22 You should have received a copy of the GNU General Public License along with
23 this program; if not, write to the Free Software Foundation, Inc.,
24 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26 *****************************************************************************/
27
28 /**************************************************/ /**
29 @file include/log0encryption.h
30
31 Redo log - encryption.
32
33 *******************************************************/
34
35 #ifndef log0encryption_h
36 #define log0encryption_h
37
38 #ifndef UNIV_HOTBACKUP
39
40 /* byte */
41 #include "univ.i"
42
43 /**************************************************/ /**
44
45 @name Log - encryption management.
46
47 *******************************************************/
48
49 /** @{ */
50
51 /** Writes encryption information to log header.
52 @param[in] encryption_metadata encryption metadata (algorithm, key, iv)
53 @param[in] encrypt_key encrypt with master key
54 @param[in,out] buf log file encryption header */
55 bool log_file_header_fill_encryption(
56 const Encryption_metadata &encryption_metadata, bool encrypt_key,
57 byte *buf);
58
59 /** Reads the log encryption header to get the redo log encryption information.
60 Read is done using the file which contains the current checkpoint_lsn.
61 Updates: log.m_encryption_metadata and log.m_encryption_buf.
62 @param[in,out] log redo log
63 @return DB_SUCCESS or DB_ERROR */
64 dberr_t log_encryption_read(log_t &log);
65
66 /** Reads the log encryption header to get the redo log encryption information.
67 Read is done using the provided file.
68 Updates: log.m_encryption_metadata and log.m_encryption_buf.
69 @param[in,out] log redo log
70 @param[in] file redo file to read from
71 @return DB_SUCCESS or DB_ERROR */
72 dberr_t log_encryption_read(log_t &log, const Log_file &file);
73
74 /** Enables the redo log encryption and generates new encryption metadata.
75 Writes the generated metadata to the log encryption header in the log file
76 containing the current checkpoint lsn (log.last_checkpoint_lsn).
77 @param[in,out] log redo log
78 @return DB_SUCCESS or DB_ERROR */
79 dberr_t log_encryption_generate_metadata(log_t &log);
80
81 /** Re-encrypts the redo log's encryption metadata using the current master key
82 and writes it encrypted to the log encryption header in the log file containing
83 the current checkpoint lsn (log.last_checkpoint_lsn)).
84 @remarks This is called after the new master key has been generated.
85 @return DB_SUCCESS or DB_ERROR */
86 dberr_t log_encryption_on_master_key_changed(log_t &log);
87
88 /** @return true iff redo log is encrypted (checks in-memory metadata in log_t).
89 */
90 bool log_can_encrypt(const log_t &log);
91
92 /** @} */
93
94 #endif /* !UNIV_HOTBACKUP */
95
96 #endif /* !log0encryption_h */