MySQL 8.4.2
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#ifndef MYSQL_ABI_CHECK
28#include <cstddef>
29#endif
30
31/**
32 @file include/mysql/service_mysql_keyring.h
33*/
34
35/**
36 @ingroup group_ext_plugin_services
37
38 This service allows plugins to interact with key store backends.
39
40 A key currently is a blob of binary data, defined by a string
41 key type, that's meaningful to the relevant backend.
42 Typical key_type values include "AES", "DES", "DSA" etc.
43 There's no length in the type, since it's defined by the number of bytes
44 the key takes.
45
46 A key is uniquely identified by the key_id and the user_id values, i.e.
47 all keys are assigned to a particular user.
48 There's only one exception to that: a single category for instance keys
49 that are not associated with any particular user id. This is signified
50 to the APIs by supplying NULL for user_id.
51 Plugins would typically pass user accounts to the user_id parameter, or
52 NULL if there's no user account to associate the key with.
53
54 Not all backends must implement all of the functions defined
55 in this interface.
56
57 The plugin service is a "bridge service", i.e. facade with no
58 real functionality that just calls the actual keyring plugin APIs.
59 This is needed to allow other plugins to call into the keyring
60 plugins and thus overcome the limitation that only the server
61 can call plugins.
62
63 @sa st_mysql_keyring
64*/
65extern "C" struct mysql_keyring_service_st {
66 /**
67 Stores a key into the keyring.
68 @sa my_key_store, st_mysql_keyring::mysql_key_store
69 */
70 int (*my_key_store_func)(const char *, const char *, const char *,
71 const void *, size_t);
72 /**
73 Receives a key from the keyring.
74 @sa my_key_fetch, st_mysql_keyring::mysql_key_fetch
75 */
76 int (*my_key_fetch_func)(const char *, char **, const char *, void **,
77 size_t *);
78
79 /**
80 Removes a key from the keyring.
81 @sa my_key_remove, st_mysql_keyring::mysql_key_remove
82 */
83 int (*my_key_remove_func)(const char *, const char *);
84 /**
85 Generates a new key inside the keyring backend
86 @sa my_key_generate, st_mysql_keyring::mysql_key_generate
87 */
88 int (*my_key_generate_func)(const char *, const char *, const char *, size_t);
90
91#ifdef MYSQL_DYNAMIC_PLUGIN
92
93#define my_key_store(key_id, key_type, user_id, key, key_len) \
94 mysql_keyring_service->my_key_store_func(key_id, key_type, user_id, key, \
95 key_len)
96#define my_key_fetch(key_id, key_type, user_id, key, key_len) \
97 mysql_keyring_service->my_key_fetch_func(key_id, key_type, user_id, key, \
98 key_len)
99#define my_key_remove(key_id, user_id) \
100 mysql_keyring_service->my_key_remove_func(key_id, user_id)
101#define my_key_generate(key_id, key_type, user_id, key_len) \
102 mysql_keyring_service->my_key_generate_func(key_id, key_type, user_id, \
103 key_len)
104#else
105
106int my_key_store(const char *, const char *, const char *, const void *,
107 size_t);
108int my_key_fetch(const char *, char **, const char *, void **, size_t *);
109int my_key_remove(const char *, const char *);
110int my_key_generate(const char *, const char *, const char *, size_t);
111
112#endif
113
114#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:65
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:88
int(* my_key_fetch_func)(const char *, char **, const char *, void **, size_t *)
Receives a key from the keyring.
Definition: service_mysql_keyring.h:76
int(* my_key_remove_func)(const char *, const char *)
Removes a key from the keyring.
Definition: service_mysql_keyring.h:83
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:70