MySQL 9.1.0
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
33
35 public:
36 /**
37 Retrieve required out buffer length information
38
39 @param [in] input_length Length of input text
40 @param [in] mode AES mode
41 @param [in] block_size AES block size information
42 @param [out] out_size Size of output buffer
43
44 @returns Output buffer length or error
45 @retval false Success
46 @retval true Error processing given mode and/or block size
47 */
48 static DEFINE_BOOL_METHOD(get_size, (size_t input_length, const char *mode,
49 size_t block_size, size_t *out_size));
50
51 /**
52 Encrypt given piece of plaintext
53
54 @param [in] data_id Name of the key
55 @param [in] auth_id Owner of the key
56 @param [in] mode AES mode
57 @param [in] block_size AES block size information
58 @param [in] iv Initialization vector
59 @param [in] padding padding preference (0 implies no padding)
60 @param [in] data_buffer Input buffer
61 @param [in] data_buffer_length Input buffer length
62 @param [out] out_buffer Output buffer
63 @param [in] out_buffer_length Output buffer length
64 @param [out] out_length Length of encrypted data
65
66 @returns status of the operation
67 @retval false Success
68 @retval true Failure
69
70 */
71 static DEFINE_BOOL_METHOD(
72 encrypt, (const char *data_id, const char *auth_id, const char *mode,
73 size_t block_size, const unsigned char *iv, int padding,
74 const unsigned char *data_buffer, size_t data_buffer_length,
75 unsigned char *out_buffer, size_t out_buffer_length,
76 size_t *out_length));
77
78 /**
79 Decrypt given piece ciphertext
80
81 @param [in] data_id Name of the key
82 @param [in] auth_id Owner of the key
83 @param [in] mode AES mode
84 @param [in] block_size AES block size information
85 @param [in] iv Initialization vector
86 @param [in] padding padding preference (0 implies no padding)
87 @param [in] data_buffer Input buffer
88 @param [in] data_buffer_length Input buffer length
89 @param [out] out_buffer Output buffer
90 @param [in] out_buffer_length Output buffer length
91 @param [out] out_length Length of decrypted data
92
93 @returns status of the operation
94 @retval false Success
95 @retval true Failure
96
97 */
98 static DEFINE_BOOL_METHOD(
99 decrypt, (const char *data_id, const char *auth_id, const char *mode,
100 size_t block_size, const unsigned char *iv, int padding,
101 const unsigned char *data_buffer, size_t data_buffer_length,
102 unsigned char *out_buffer, size_t out_buffer_length,
103 size_t *out_length));
104};
105
106} // namespace keyring_common::service_definition
107
108#define KEYRING_AES_IMPLEMENTOR(component_name) \
109 BEGIN_SERVICE_IMPLEMENTATION(component_name, keyring_aes) \
110 keyring_common::service_definition::Keyring_aes_service_impl::get_size, \
111 keyring_common::service_definition::Keyring_aes_service_impl::encrypt, \
112 keyring_common::service_definition::Keyring_aes_service_impl::decrypt \
113 END_SERVICE_IMPLEMENTATION()
114
115#endif // KEYRING_ENCRYPTION_SERVICE_IMPL_INCLUDED
Definition: keyring_encryption_service_definition.h:34
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:66
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:53
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:43
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