MySQL 8.3.0
Source Code Documentation
service_mysql_keyring.h
Go to the documentation of this file.
1/* Copyright (c) 2016, 2023, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef MYSQL_SERVICE_MYSQL_PLUGIN_KEYRING_INCLUDED
24#define MYSQL_SERVICE_MYSQL_PLUGIN_KEYRING_INCLUDED
25
26#ifndef MYSQL_ABI_CHECK
27#include <cstddef>
28#endif
29
30/**
31 @file include/mysql/service_mysql_keyring.h
32*/
33
34/**
35 @ingroup group_ext_plugin_services
36
37 This service allows plugins to interact with key store backends.
38
39 A key currently is a blob of binary data, defined by a string
40 key type, that's meaningful to the relevant backend.
41 Typical key_type values include "AES", "DES", "DSA" etc.
42 There's no length in the type, since it's defined by the number of bytes
43 the key takes.
44
45 A key is uniquely identified by the key_id and the user_id values, i.e.
46 all keys are assigned to a particular user.
47 There's only one exception to that: a single category for instance keys
48 that are not associated with any particular user id. This is signified
49 to the APIs by supplying NULL for user_id.
50 Plugins would typically pass user accounts to the user_id parameter, or
51 NULL if there's no user account to associate the key with.
52
53 Not all backends must implement all of the functions defined
54 in this interface.
55
56 The plugin service is a "bridge service", i.e. facade with no
57 real functionality that just calls the actual keyring plugin APIs.
58 This is needed to allow other plugins to call into the keyring
59 plugins and thus overcome the limitation that only the server
60 can call plugins.
61
62 @sa st_mysql_keyring
63*/
64extern "C" struct mysql_keyring_service_st {
65 /**
66 Stores a key into the keyring.
67 @sa my_key_store, st_mysql_keyring::mysql_key_store
68 */
69 int (*my_key_store_func)(const char *, const char *, const char *,
70 const void *, size_t);
71 /**
72 Receives a key from the keyring.
73 @sa my_key_fetch, st_mysql_keyring::mysql_key_fetch
74 */
75 int (*my_key_fetch_func)(const char *, char **, const char *, void **,
76 size_t *);
77
78 /**
79 Removes a key from the keyring.
80 @sa my_key_remove, st_mysql_keyring::mysql_key_remove
81 */
82 int (*my_key_remove_func)(const char *, const char *);
83 /**
84 Generates a new key inside the keyring backend
85 @sa my_key_generate, st_mysql_keyring::mysql_key_generate
86 */
87 int (*my_key_generate_func)(const char *, const char *, const char *, size_t);
89
90#ifdef MYSQL_DYNAMIC_PLUGIN
91
92#define my_key_store(key_id, key_type, user_id, key, key_len) \
93 mysql_keyring_service->my_key_store_func(key_id, key_type, user_id, key, \
94 key_len)
95#define my_key_fetch(key_id, key_type, user_id, key, key_len) \
96 mysql_keyring_service->my_key_fetch_func(key_id, key_type, user_id, key, \
97 key_len)
98#define my_key_remove(key_id, user_id) \
99 mysql_keyring_service->my_key_remove_func(key_id, user_id)
100#define my_key_generate(key_id, key_type, user_id, key_len) \
101 mysql_keyring_service->my_key_generate_func(key_id, key_type, user_id, \
102 key_len)
103#else
104
105int my_key_store(const char *, const char *, const char *, const void *,
106 size_t);
107int my_key_fetch(const char *, char **, const char *, void **, size_t *);
108int my_key_remove(const char *, const char *);
109int my_key_generate(const char *, const char *, const char *, size_t);
110
111#endif
112
113#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:124
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:140
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:165
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:153
This service allows plugins to interact with key store backends.
Definition: service_mysql_keyring.h:64
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:87
int(* my_key_fetch_func)(const char *, char **, const char *, void **, size_t *)
Receives a key from the keyring.
Definition: service_mysql_keyring.h:75
int(* my_key_remove_func)(const char *, const char *)
Removes a key from the keyring.
Definition: service_mysql_keyring.h:82
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:69