diff options
author | Sergei Golubchik <serg@mariadb.org> | 2015-03-31 19:00:51 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2015-04-08 10:58:50 +0200 |
commit | ef5b4889c2bc1d463291d4d80091c79183ec1196 (patch) | |
tree | 41a4b6c7aa57daee2cb617045b87c59c5d520706 /plugin/example_key_management | |
parent | c91e3260e2678078c0bb29d8daa90fb52cefaab7 (diff) | |
download | mariadb-git-ef5b4889c2bc1d463291d4d80091c79183ec1196.tar.gz |
optimize encryption api
only one encryption key lookup in most cases instead of three
(has_key, get_key_size, get_key).
Diffstat (limited to 'plugin/example_key_management')
-rw-r--r-- | plugin/example_key_management/example_key_management_plugin.cc | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/plugin/example_key_management/example_key_management_plugin.cc b/plugin/example_key_management/example_key_management_plugin.cc index 6548baef20c..28cae3c311e 100644 --- a/plugin/example_key_management/example_key_management_plugin.cc +++ b/plugin/example_key_management/example_key_management_plugin.cc @@ -58,32 +58,21 @@ get_latest_key_version() return key_version; } -static int -get_key(unsigned int version, unsigned char* dstbuf, unsigned buflen) +static unsigned int +get_key(unsigned int version, unsigned char* dstbuf, unsigned *buflen) { - unsigned char *dst = dstbuf; - unsigned len = 0; - for (; len + MD5_HASH_SIZE <= buflen; len += MD5_HASH_SIZE) - { - compute_md5_hash(dst, (const char*)&version, sizeof(version)); - dst += MD5_HASH_SIZE; - version++; - } - if (len < buflen) + if (*buflen < MD5_HASH_SIZE) { - memset(dst, 0, buflen - len); + *buflen= MD5_HASH_SIZE; + return KEY_BUFFER_TOO_SMALL; } - return 0; -} + *buflen= MD5_HASH_SIZE; + if (!dstbuf) + return 0; -static unsigned int has_key_func(unsigned int keyID) -{ - return true; -} + my_md5(dstbuf, (const char*)&version, sizeof(version)); -static unsigned int get_key_size(unsigned int keyID) -{ - return 16; + return 0; } static int example_key_management_plugin_init(void *p) @@ -115,8 +104,6 @@ static int example_key_management_plugin_deinit(void *p) 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 }; |