MySQL 8.0.39
Source Code Documentation
service_mysql_keyring.h
Go to the documentation of this file.
1/* Copyright (c) 2016, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
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, version 2.0, 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#ifndef MYSQL_SERVICE_MYSQL_PLUGIN_KEYRING_INCLUDED
25#define MYSQL_SERVICE_MYSQL_PLUGIN_KEYRING_INCLUDED
26
27/**
28 @file include/mysql/service_mysql_keyring.h
29*/
30
31/**
32 @ingroup group_ext_plugin_services
33
34 This service allows plugins to interact with key store backends.
35
36 A key currently is a blob of binary data, defined by a string
37 key type, that's meaningful to the relevant backend.
38 Typical key_type values include "AES", "DES", "DSA" etc.
39 There's no length in the type, since it's defined by the number of bytes
40 the key takes.
41
42 A key is uniquely identified by the key_id and the user_id values, i.e.
43 all keys are assigned to a particular user.
44 There's only one exception to that: a single category for instance keys
45 that are not associated with any particular user id. This is signified
46 to the APIs by supplying NULL for user_id.
47 Plugins would typically pass user accounts to the user_id parameter, or
48 NULL if there's no user account to associate the key with.
49
50 Not all backends must implement all of the functions defined
51 in this interface.
52
53 The plugin service is a "bridge service", i.e. facade with no
54 real functionality that just calls the actual keyring plugin APIs.
55 This is needed to allow other plugins to call into the keyring
56 plugins and thus overcome the limitation that only the server
57 can call plugins.
58
59 @sa st_mysql_keyring
60*/
61extern "C" struct mysql_keyring_service_st {
62 /**
63 Stores a key into the keyring.
64 @sa my_key_store, st_mysql_keyring::mysql_key_store
65 */
66 int (*my_key_store_func)(const char *, const char *, const char *,
67 const void *, size_t);
68 /**
69 Receives a key from the keyring.
70 @sa my_key_fetch, st_mysql_keyring::mysql_key_fetch
71 */
72 int (*my_key_fetch_func)(const char *, char **, const char *, void **,
73 size_t *);
74
75 /**
76 Removes a key from the keyring.
77 @sa my_key_remove, st_mysql_keyring::mysql_key_remove
78 */
79 int (*my_key_remove_func)(const char *, const char *);
80 /**
81 Generates a new key inside the keyring backend
82 @sa my_key_generate, st_mysql_keyring::mysql_key_generate
83 */
84 int (*my_key_generate_func)(const char *, const char *, const char *, size_t);
86
87#ifdef MYSQL_DYNAMIC_PLUGIN
88
89#define my_key_store(key_id, key_type, user_id, key, key_len) \
90 mysql_keyring_service->my_key_store_func(key_id, key_type, user_id, key, \
91 key_len)
92#define my_key_fetch(key_id, key_type, user_id, key, key_len) \
93 mysql_keyring_service->my_key_fetch_func(key_id, key_type, user_id, key, \
94 key_len)
95#define my_key_remove(key_id, user_id) \
96 mysql_keyring_service->my_key_remove_func(key_id, user_id)
97#define my_key_generate(key_id, key_type, user_id, key_len) \
98 mysql_keyring_service->my_key_generate_func(key_id, key_type, user_id, \
99 key_len)
100#else
101
102int my_key_store(const char *, const char *, const char *, const void *,
103 size_t);
104int my_key_fetch(const char *, char **, const char *, void **, size_t *);
105int my_key_remove(const char *, const char *);
106int my_key_generate(const char *, const char *, const char *, size_t);
107
108#endif
109
110#endif // MYSQL_SERVICE_MYSQL_PLUGIN_KEYRING_INCLUDED
struct mysql_keyring_service_st * mysql_keyring_service
int my_key_fetch(const char *, char **, const char *, void **, size_t *)
Iterates over all active keyring plugins and calls the mysql_key_fetch API for the first one found.
Definition: keyring_service.cc:125
int my_key_store(const char *, const char *, const char *, const void *, size_t)
Iterates over all active keyring plugins calls the mysql_key_store API for the first one found.
Definition: keyring_service.cc:141
int my_key_generate(const char *, const char *, const char *, size_t)
Iterates over all active keyring plugins and calls the mysql_key_generate API for the first one found...
Definition: keyring_service.cc:166
int my_key_remove(const char *, const char *)
Iterates over all active keyring plugins and calls the mysql_key_remove API for the first one found.
Definition: keyring_service.cc:154
This service allows plugins to interact with key store backends.
Definition: service_mysql_keyring.h:61
int(* my_key_generate_func)(const char *, const char *, const char *, size_t)
Generates a new key inside the keyring backend.
Definition: service_mysql_keyring.h:84
int(* my_key_fetch_func)(const char *, char **, const char *, void **, size_t *)
Receives a key from the keyring.
Definition: service_mysql_keyring.h:72
int(* my_key_remove_func)(const char *, const char *)
Removes a key from the keyring.
Definition: service_mysql_keyring.h:79
int(* my_key_store_func)(const char *, const char *, const char *, const void *, size_t)
Stores a key into the keyring.
Definition: service_mysql_keyring.h:66