|
64 | 64 | #include "mysql/components/services/psi_memory_bits.h"
|
65 | 65 | #include "mysql/components/services/psi_stage_bits.h"
|
66 | 66 | #include "mysql/psi/psi_base.h"
|
| 67 | +#include "sql/stream_cipher.h" |
67 | 68 |
|
68 | 69 | struct CHARSET_INFO;
|
69 | 70 | struct MY_CHARSET_LOADER;
|
@@ -472,6 +473,10 @@ struct IO_CACHE /* Used when cacheing files */
|
472 | 473 | somewhere else
|
473 | 474 | */
|
474 | 475 | bool alloced_buffer{false};
|
| 476 | + // This is an encryptor for encrypting the temporary file of the IO cache. |
| 477 | + Stream_cipher *m_encryptor = nullptr; |
| 478 | + // This is a decryptor for decrypting the temporary file of the IO cache. |
| 479 | + Stream_cipher *m_decryptor = nullptr; |
475 | 480 | };
|
476 | 481 |
|
477 | 482 | typedef int (*qsort2_cmp)(const void *, const void *, const void *);
|
@@ -975,4 +980,69 @@ extern MYSQL_FILE *mysql_stdin;
|
975 | 980 | @} (end of group MYSYS)
|
976 | 981 | */
|
977 | 982 |
|
| 983 | +// True if the temporary file of binlog cache is encrypted. |
| 984 | +#ifndef DBUG_OFF |
| 985 | +extern bool binlog_cache_temporary_file_is_encrypted; |
| 986 | +#endif |
| 987 | + |
| 988 | +/** |
| 989 | + This is a wrapper around mysql_file_seek. Seek to a position in the |
| 990 | + temporary file of a binlog cache, and set the encryption/decryption |
| 991 | + stream offset if binlog_encryption is on. |
| 992 | +
|
| 993 | + @param cache The handler of a binlog cache to seek. |
| 994 | + @param pos The expected position (absolute or relative) |
| 995 | + @param whence A direction parameter and one of |
| 996 | + {SEEK_SET, SEEK_CUR, SEEK_END} |
| 997 | + @param flags The bitmap of different flags |
| 998 | + MY_WME | MY_FAE | MY_NABP | MY_FNABP | |
| 999 | + MY_DONT_CHECK_FILESIZE and so on. |
| 1000 | +
|
| 1001 | + @retval The new position in the file, or MY_FILEPOS_ERROR on error. |
| 1002 | +*/ |
| 1003 | +my_off_t mysql_encryption_file_seek(IO_CACHE *cache, my_off_t pos, int whence, |
| 1004 | + myf flags); |
| 1005 | +/** |
| 1006 | + This is a wrapper around mysql_file_read. Read data from the temporary |
| 1007 | + file of a binlog cache, and take care of decrypting the data if |
| 1008 | + binlog_encryption is on. |
| 1009 | +
|
| 1010 | +
|
| 1011 | + @param cache The handler of a binlog cache to read. |
| 1012 | + @param[out] buffer The memory buffer to write to. |
| 1013 | + @param count The length of data in the temporary file to be read in bytes. |
| 1014 | + @param flags The bitmap of different flags |
| 1015 | + MY_WME | MY_FAE | MY_NABP | MY_FNABP | |
| 1016 | + MY_DONT_CHECK_FILESIZE and so on. |
| 1017 | +
|
| 1018 | + @retval The length of bytes to be read, or MY_FILE_ERROR on error. |
| 1019 | +*/ |
| 1020 | +size_t mysql_encryption_file_read(IO_CACHE *cache, uchar *buffer, size_t count, |
| 1021 | + myf flags); |
| 1022 | +/** |
| 1023 | + This is a wrapper around mysql_file_write. Write data in buffer to the |
| 1024 | + temporary file of a binlog cache, and take care of encrypting the data |
| 1025 | + if binlog_encryption is on. |
| 1026 | +
|
| 1027 | + @param cache The handler of a binlog cache to write. |
| 1028 | + @param buffer The memory buffer to write from. |
| 1029 | + @param count The length of data in buffer to be written in bytes. |
| 1030 | + @param flags The bitmap of different flags |
| 1031 | + MY_WME | MY_FAE | MY_NABP | MY_FNABP | |
| 1032 | + MY_DONT_CHECK_FILESIZE and so on |
| 1033 | +
|
| 1034 | + if (flags & (MY_NABP | MY_FNABP)) { |
| 1035 | + @retval 0 if count == 0 |
| 1036 | + @retval 0 success |
| 1037 | + @retval MY_FILE_ERROR error |
| 1038 | + } else { |
| 1039 | + @retval 0 if count == 0 |
| 1040 | + @retval The number of bytes written on success. |
| 1041 | + @retval MY_FILE_ERROR error |
| 1042 | + @retval The actual number of bytes written on partial success (if |
| 1043 | + less than count bytes were written). |
| 1044 | + } |
| 1045 | +*/ |
| 1046 | +size_t mysql_encryption_file_write(IO_CACHE *cache, const uchar *buffer, |
| 1047 | + size_t count, myf flags); |
978 | 1048 | #endif /* _my_sys_h */
|
0 commit comments