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