MySQL 8.4.2
Source Code Documentation
keyring_encryption_service_definition.h
Go to the documentation of this file.
1/* Copyright (c) 2021, 2024, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License, version 2.0, for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef KEYRING_ENCRYPTION_SERVICE_IMPL_INCLUDED
25#define KEYRING_ENCRYPTION_SERVICE_IMPL_INCLUDED
26
29
31
32namespace keyring_common {
33namespace service_definition {
34
36 public:
37 /**
38 Retrieve required out buffer length information
39
40 @param [in] input_length Length of input text
41 @param [in] mode AES mode
42 @param [in] block_size AES block size information
43 @param [out] out_size Size of output buffer
44
45 @returns Output buffer length or error
46 @retval false Success
47 @retval true Error processing given mode and/or block size
48 */
49 static DEFINE_BOOL_METHOD(get_size, (size_t input_length, const char *mode,
50 size_t block_size, size_t *out_size));
51
52 /**
53 Encrypt given piece of plaintext
54
55 @param [in] data_id Name of the key
56 @param [in] auth_id Owner of the key
57 @param [in] mode AES mode
58 @param [in] block_size AES block size information
59 @param [in] iv Initialization vector
60 @param [in] padding padding preference (0 implies no padding)
61 @param [in] data_buffer Input buffer
62 @param [in] data_buffer_length Input buffer length
63 @param [out] out_buffer Output buffer
64 @param [in] out_buffer_length Output buffer length
65 @param [out] out_length Length of encrypted data
66
67 @returns status of the operation
68 @retval false Success
69 @retval true Failure
70
71 */
72 static DEFINE_BOOL_METHOD(
73 encrypt, (const char *data_id, const char *auth_id, const char *mode,
74 size_t block_size, const unsigned char *iv, int padding,
75 const unsigned char *data_buffer, size_t data_buffer_length,
76 unsigned char *out_buffer, size_t out_buffer_length,
77 size_t *out_length));
78
79 /**
80 Decrypt given piece ciphertext
81
82 @param [in] data_id Name of the key
83 @param [in] auth_id Owner of the key
84 @param [in] mode AES mode
85 @param [in] block_size AES block size information
86 @param [in] iv Initialization vector
87 @param [in] padding padding preference (0 implies no padding)
88 @param [in] data_buffer Input buffer
89 @param [in] data_buffer_length Input buffer length
90 @param [out] out_buffer Output buffer
91 @param [in] out_buffer_length Output buffer length
92 @param [out] out_length Length of decrypted data
93
94 @returns status of the operation
95 @retval false Success
96 @retval true Failure
97
98 */
99 static DEFINE_BOOL_METHOD(
100 decrypt, (const char *data_id, const char *auth_id, const char *mode,
101 size_t block_size, const unsigned char *iv, int padding,
102 const unsigned char *data_buffer, size_t data_buffer_length,
103 unsigned char *out_buffer, size_t out_buffer_length,
104 size_t *out_length));
105};
106
107} // namespace service_definition
108} // namespace keyring_common
109
110#define KEYRING_AES_IMPLEMENTOR(component_name) \
111 BEGIN_SERVICE_IMPLEMENTATION(component_name, keyring_aes) \
112 keyring_common::service_definition::Keyring_aes_service_impl::get_size, \
113 keyring_common::service_definition::Keyring_aes_service_impl::encrypt, \
114 keyring_common::service_definition::Keyring_aes_service_impl::decrypt \
115 END_SERVICE_IMPLEMENTATION()
116
117#endif // KEYRING_ENCRYPTION_SERVICE_IMPL_INCLUDED
Definition: keyring_encryption_service_definition.h:35
static mysql_service_status_t decrypt(const char *data_id, const char *auth_id, const char *mode, size_t block_size, const unsigned char *iv, int padding, const unsigned char *data_buffer, size_t data_buffer_length, unsigned char *out_buffer, size_t out_buffer_length, size_t *out_length) noexcept
Decrypt given piece ciphertext.
Definition: keyring_encryption_service_definition.cc:64
static mysql_service_status_t encrypt(const char *data_id, const char *auth_id, const char *mode, size_t block_size, const unsigned char *iv, int padding, const unsigned char *data_buffer, size_t data_buffer_length, unsigned char *out_buffer, size_t out_buffer_length, size_t *out_length) noexcept
Encrypt given piece of plaintext.
Definition: keyring_encryption_service_definition.cc:52
static mysql_service_status_t get_size(size_t input_length, const char *mode, size_t block_size, size_t *out_size) noexcept
Retrieve required out buffer length information.
Definition: keyring_encryption_service_definition.cc:42
Specifies macros to define Components.
Definition: keyring_encryption_service_definition.h:32
mode
Definition: file_handle.h:61
Specifies macros to define Service Implementations.
#define DEFINE_BOOL_METHOD(name, args)
A short macro to define method that returns bool, which is the most common case.
Definition: service_implementation.h:88