encryption key management plugin api

This commit is contained in:
Sergei Golubchik 2015-01-05 13:36:14 +01:00
commit cf8bf0b68e
50 changed files with 696 additions and 344 deletions

View file

@ -1 +1,2 @@
MYSQL_ADD_PLUGIN(EXAMPLE_KEY_MANAGEMENT_PLUGIN example_key_management_plugin.cc MANDATORY)
MYSQL_ADD_PLUGIN(EXAMPLE_KEY_MANAGEMENT_PLUGIN example_key_management_plugin.cc
MODULE_ONLY)

View file

@ -1,10 +1,9 @@
// Copyright (C) 2014 Google Inc.
#include <mysql_version.h>
#include <my_global.h>
#include <my_pthread.h>
#include <my_aes.h>
#include <my_crypt_key_management.h>
#include <mysql/plugin_encryption_key_management.h>
#include <my_md5.h>
#include <my_rnd.h>
@ -17,8 +16,7 @@ static unsigned int key_version = 0;
static unsigned int next_key_version = 0;
static pthread_mutex_t mutex;
static
int
static unsigned int
get_latest_key_version()
{
uint now = time(0);
@ -34,8 +32,7 @@ get_latest_key_version()
return key_version;
}
static
int
static int
get_key(unsigned int version, unsigned char* dstbuf, unsigned buflen)
{
char *dst = (char*)dstbuf; // md5 function takes char* as argument...
@ -58,7 +55,7 @@ static unsigned int has_key_func(unsigned int keyID)
return true;
}
static int get_key_size(unsigned int keyID)
static unsigned int get_key_size(unsigned int keyID)
{
return 16;
}
@ -87,13 +84,6 @@ static int example_key_management_plugin_init(void *p)
pthread_mutex_init(&mutex, NULL);
struct CryptoKeyFuncs_t func;
func.getLatestCryptoKeyVersionFunc = get_latest_key_version;
func.hasCryptoKeyFunc = has_key_func;
func.getCryptoKeySize = get_key_size;
func.getCryptoKeyFunc = get_key;
func.getCryptoIVFunc = get_iv;
InstallCryptoKeyFunctions(&func);
return 0;
}
@ -103,8 +93,13 @@ static int example_key_management_plugin_deinit(void *p)
return 0;
}
struct st_mysql_daemon example_key_management_plugin= {
MYSQL_DAEMON_INTERFACE_VERSION
struct st_mariadb_encryption_key_management example_key_management_plugin= {
MariaDB_ENCRYPTION_KEY_MANAGEMENT_INTERFACE_VERSION,
get_latest_key_version,
has_key_func,
get_key_size,
get_key,
get_iv
};
/*
@ -112,7 +107,7 @@ struct st_mysql_daemon example_key_management_plugin= {
*/
maria_declare_plugin(example_key_management_plugin)
{
MYSQL_DAEMON_PLUGIN,
MariaDB_ENCRYPTION_KEY_MANAGEMENT_PLUGIN,
&example_key_management_plugin,
"example_key_management_plugin",
"Jonas Oreland",
@ -124,6 +119,6 @@ maria_declare_plugin(example_key_management_plugin)
NULL, /* status variables */
NULL, /* system variables */
"1.0",
MariaDB_PLUGIN_MATURITY_UNKNOWN
MariaDB_PLUGIN_MATURITY_EXPERIMENTAL
}
maria_declare_plugin_end;