summaryrefslogtreecommitdiff
path: root/plugin/debug_key_management/debug_key_management_plugin.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-03-27 15:58:02 +0100
committerSergei Golubchik <serg@mariadb.org>2015-04-08 10:58:48 +0200
commit88632726e88471d492a6125f0cd4a4a3c25a6923 (patch)
tree6a4980f2500b6262369858dee073443d0c746aec /plugin/debug_key_management/debug_key_management_plugin.cc
parent817a63f273a3797bf2cb6317d89fca196c0b0bfc (diff)
downloadmariadb-git-88632726e88471d492a6125f0cd4a4a3c25a6923.tar.gz
rename plugins to remove "_plugin" from the plugin name
Diffstat (limited to 'plugin/debug_key_management/debug_key_management_plugin.cc')
-rw-r--r--plugin/debug_key_management/debug_key_management_plugin.cc92
1 files changed, 92 insertions, 0 deletions
diff --git a/plugin/debug_key_management/debug_key_management_plugin.cc b/plugin/debug_key_management/debug_key_management_plugin.cc
new file mode 100644
index 00000000000..1d332e62381
--- /dev/null
+++ b/plugin/debug_key_management/debug_key_management_plugin.cc
@@ -0,0 +1,92 @@
+/*
+ Copyright (c) 2015 MariaDB Corporation
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+/**
+ Debug key management plugin.
+ It's used to debug the encryption code with a fixed keys that change
+ only on user request.
+
+ THIS IS AN EXAMPLE ONLY! ENCRYPTION KEYS ARE HARD-CODED AND *NOT* SECRET!
+ DO NOT USE THIS PLUGIN IN PRODUCTION! EVER!
+*/
+
+#include <my_global.h>
+#include <mysql/plugin_encryption_key_management.h>
+#include <string.h>
+#include <myisampack.h>
+
+static uint key_version;
+
+static MYSQL_SYSVAR_UINT(version, key_version, PLUGIN_VAR_RQCMDARG,
+ "Latest key version", NULL, NULL, 1, 0, UINT_MAX, 1);
+
+static struct st_mysql_sys_var* sysvars[] = {
+ MYSQL_SYSVAR(version),
+ NULL
+};
+
+static unsigned int get_latest_key_version()
+{
+ return key_version;
+}
+
+static int get_key(unsigned int version, unsigned char* dstbuf, unsigned buflen)
+{
+ if (buflen < 4)
+ return 1;
+ memset(dstbuf, 0, buflen);
+ mi_int4store(dstbuf, version);
+ return 0;
+}
+
+static unsigned int has_key(unsigned int ver)
+{
+ return 1;
+}
+
+static unsigned int get_key_size(unsigned int ver)
+{
+ return 16;
+}
+
+struct st_mariadb_encryption_key_management debug_key_management_plugin= {
+ MariaDB_ENCRYPTION_KEY_MANAGEMENT_INTERFACE_VERSION,
+ get_latest_key_version,
+ has_key,
+ get_key_size,
+ get_key
+};
+
+/*
+ Plugin library descriptor
+*/
+maria_declare_plugin(debug_key_management)
+{
+ MariaDB_ENCRYPTION_KEY_MANAGEMENT_PLUGIN,
+ &debug_key_management_plugin,
+ "debug_key_management",
+ "Sergei Golubchik",
+ "Debug key management plugin",
+ PLUGIN_LICENSE_GPL,
+ NULL,
+ NULL,
+ 0x0100,
+ NULL,
+ sysvars,
+ "1.0",
+ MariaDB_PLUGIN_MATURITY_EXPERIMENTAL
+}
+maria_declare_plugin_end;