2015-03-26 11:12:02 +01:00
|
|
|
/*
|
|
|
|
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>
|
2015-03-27 09:45:22 +01:00
|
|
|
#include <mysql/plugin_encryption.h>
|
2015-03-26 11:12:02 +01:00
|
|
|
#include <string.h>
|
|
|
|
#include <myisampack.h>
|
|
|
|
|
2015-03-31 19:00:51 +02:00
|
|
|
#define KEY_SIZE 16
|
|
|
|
|
2015-03-26 11:12:02 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-03-31 19:00:51 +02:00
|
|
|
static unsigned int get_key(unsigned int version, unsigned char* dstbuf, unsigned *buflen)
|
2015-03-26 11:12:02 +01:00
|
|
|
{
|
2015-03-31 19:00:51 +02:00
|
|
|
if (*buflen < KEY_SIZE)
|
|
|
|
{
|
|
|
|
*buflen= KEY_SIZE;
|
|
|
|
return KEY_BUFFER_TOO_SMALL;
|
|
|
|
}
|
|
|
|
*buflen= KEY_SIZE;
|
|
|
|
if (!dstbuf)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
memset(dstbuf, 0, KEY_SIZE);
|
2015-03-26 11:12:02 +01:00
|
|
|
mi_int4store(dstbuf, version);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-03-27 09:45:22 +01:00
|
|
|
struct st_mariadb_encryption debug_key_management_plugin= {
|
|
|
|
MariaDB_ENCRYPTION_INTERFACE_VERSION,
|
2015-03-26 11:12:02 +01:00
|
|
|
get_latest_key_version,
|
2015-03-26 14:01:39 +01:00
|
|
|
get_key
|
2015-03-26 11:12:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Plugin library descriptor
|
|
|
|
*/
|
2015-03-27 15:58:02 +01:00
|
|
|
maria_declare_plugin(debug_key_management)
|
2015-03-26 11:12:02 +01:00
|
|
|
{
|
2015-03-27 09:45:22 +01:00
|
|
|
MariaDB_ENCRYPTION_PLUGIN,
|
2015-03-26 11:12:02 +01:00
|
|
|
&debug_key_management_plugin,
|
2015-03-27 15:58:02 +01:00
|
|
|
"debug_key_management",
|
2015-03-26 11:12:02 +01:00
|
|
|
"Sergei Golubchik",
|
|
|
|
"Debug key management plugin",
|
|
|
|
PLUGIN_LICENSE_GPL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0x0100,
|
|
|
|
NULL,
|
|
|
|
sysvars,
|
|
|
|
"1.0",
|
|
|
|
MariaDB_PLUGIN_MATURITY_EXPERIMENTAL
|
|
|
|
}
|
|
|
|
maria_declare_plugin_end;
|