32 changed files with 198 additions and 193 deletions
-
16include/mysql/plugin_audit.h.pp
-
16include/mysql/plugin_auth.h.pp
-
16include/mysql/plugin_encryption.h.pp
-
16include/mysql/plugin_ftparser.h.pp
-
16include/mysql/plugin_password_validation.h.pp
-
78include/mysql/service_encryption.h
-
71include/mysql/service_encryption_keys.h
-
2include/mysql/services.h
-
2include/service_versions.h
-
2libmysqld/CMakeLists.txt
-
2libservices/CMakeLists.txt
-
2libservices/encryption_service.c
-
2plugin/debug_key_management/debug_key_management_plugin.cc
-
2plugin/example_key_management/example_key_management_plugin.cc
-
4plugin/file_key_management/file_key_management_plugin.cc
-
2sql/CMakeLists.txt
-
38sql/encryption.cc
-
2sql/sql_plugin_services.h
-
14storage/innobase/fil/fil0crypt.cc
-
2storage/innobase/fil/fil0fil.cc
-
2storage/innobase/handler/ha_innodb.cc
-
6storage/innobase/include/fsp0pageencryption.ic
-
2storage/innobase/include/log0crypt.h
-
8storage/innobase/log/log0crypt.cc
-
4storage/maria/ma_check_standalone.h
-
14storage/maria/ma_crypt.c
-
22storage/xtradb/fil/fil0crypt.cc
-
2storage/xtradb/fil/fil0fil.cc
-
2storage/xtradb/handler/ha_innodb.cc
-
6storage/xtradb/include/fsp0pageencryption.ic
-
2storage/xtradb/include/log0crypt.h
-
16storage/xtradb/log/log0crypt.cc
@ -0,0 +1,78 @@ |
|||
#ifndef MYSQL_SERVICE_ENCRYPTION_INCLUDED |
|||
/* Copyright (c) 2015, MariaDB |
|||
|
|||
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 */ |
|||
|
|||
/** |
|||
@file |
|||
encryption service |
|||
|
|||
Functions to support data encryption and encryption key management. |
|||
They are normally implemented in an encryption plugin, so this service |
|||
connects encryption *consumers* (storage engines) to the encryption |
|||
*provider* (encryption plugin). |
|||
*/ |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
/* returned from encryption_key_get_latest_version() */ |
|||
#define ENCRYPTION_KEY_VERSION_INVALID (~(unsigned int)0) |
|||
#define ENCRYPTION_KEY_VERSION_NOT_ENCRYPTED (0) |
|||
|
|||
/* returned from encryption_key_get() */ |
|||
#define ENCRYPTION_KEY_BUFFER_TOO_SMALL (100) |
|||
|
|||
typedef int (*encrypt_decrypt_func)(const unsigned char* src, unsigned int slen, |
|||
unsigned char* dst, unsigned int* dlen, |
|||
const unsigned char* key, unsigned int klen, |
|||
const unsigned char* iv, unsigned int ivlen, |
|||
int no_padding, unsigned int key_version); |
|||
|
|||
struct encryption_service_st { |
|||
unsigned int (*encryption_key_get_latest_version_func)(); |
|||
unsigned int (*encryption_key_exists_func)(unsigned int); |
|||
unsigned int (*encryption_key_get_func)(unsigned int, unsigned char*, unsigned int*); |
|||
encrypt_decrypt_func encryption_encrypt_func; |
|||
encrypt_decrypt_func encryption_decrypt_func; |
|||
}; |
|||
|
|||
#ifdef MYSQL_DYNAMIC_PLUGIN |
|||
|
|||
extern struct encryption_service_st *encryption_service; |
|||
|
|||
#define encryption_key_get_latest_version() encryption_service->encryption_key_get_latest_version_func() |
|||
#define encryption_key_exists(V) encryption_service->encryption_key_exists_func(V) |
|||
#define encryption_key_get(V,K,S) encryption_service->encryption_key_get_func((V), (K), (S)) |
|||
#define encryption_encrypt(S,SL,D,DL,K,KL,I,IL,NP,KV) encryption_service->encryption_encrypt_func(S,SL,D,DL,K,KL,I,IL,NP,KV) |
|||
#define encryption_decrypt(S,SL,D,DL,K,KL,I,IL,NP,KV) encryption_service->encryption_decrypt_func(S,SL,D,DL,K,KL,I,IL,NP,KV) |
|||
#else |
|||
|
|||
extern struct encryption_service_st encryption_handler; |
|||
|
|||
#define encryption_key_get_latest_version() encryption_handler.encryption_key_get_latest_version_func() |
|||
#define encryption_key_exists(V) encryption_handler.encryption_key_exists_func(V) |
|||
#define encryption_key_get(V,K,S) encryption_handler.encryption_key_get_func((V), (K), (S)) |
|||
#define encryption_encrypt(S,SL,D,DL,K,KL,I,IL,NP,KV) encryption_handler.encryption_encrypt_func(S,SL,D,DL,K,KL,I,IL,NP,KV) |
|||
#define encryption_decrypt(S,SL,D,DL,K,KL,I,IL,NP,KV) encryption_handler.encryption_decrypt_func(S,SL,D,DL,K,KL,I,IL,NP,KV) |
|||
#endif |
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
|
|||
#define MYSQL_SERVICE_ENCRYPTION_INCLUDED |
|||
#endif |
|||
|
|||
@ -1,71 +0,0 @@ |
|||
#ifndef MYSQL_SERVICE_ENCRYPTION_KEYS_INCLUDED |
|||
/* Copyright (c) 2015, MariaDB |
|||
|
|||
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 */ |
|||
|
|||
/** |
|||
@file |
|||
encryption keys service |
|||
|
|||
Functions to get encryption keys from the encryption plugin |
|||
*/ |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
#define BAD_ENCRYPTION_KEY_VERSION (~(unsigned int)0) |
|||
#define KEY_BUFFER_TOO_SMALL (100) |
|||
|
|||
typedef int (*encrypt_decrypt_func)(const unsigned char* src, unsigned int slen, |
|||
unsigned char* dst, unsigned int* dlen, |
|||
const unsigned char* key, unsigned int klen, |
|||
const unsigned char* iv, unsigned int ivlen, |
|||
int no_padding, unsigned int key_version); |
|||
|
|||
struct encryption_keys_service_st { |
|||
unsigned int (*get_latest_encryption_key_version_func)(); |
|||
unsigned int (*has_encryption_key_func)(unsigned int); |
|||
unsigned int (*get_encryption_key_func)(unsigned int, unsigned char*, unsigned int*); |
|||
encrypt_decrypt_func encrypt_data_func; |
|||
encrypt_decrypt_func decrypt_data_func; |
|||
}; |
|||
|
|||
#ifdef MYSQL_DYNAMIC_PLUGIN |
|||
|
|||
extern struct encryption_keys_service_st *encryption_keys_service; |
|||
|
|||
#define get_latest_encryption_key_version() encryption_keys_service->get_latest_encryption_key_version_func() |
|||
#define has_encryption_key(V) encryption_keys_service->has_encryption_key_func(V) |
|||
#define get_encryption_key(V,K,S) encryption_keys_service->get_encryption_key_func((V), (K), (S)) |
|||
#define encrypt_data(S,SL,D,DL,K,KL,I,IL,NP,KV) encryption_keys_service->encrypt_data_func(S,SL,D,DL,K,KL,I,IL,NP,KV) |
|||
#define decrypt_data(S,SL,D,DL,K,KL,I,IL,NP,KV) encryption_keys_service->decrypt_data_func(S,SL,D,DL,K,KL,I,IL,NP,KV) |
|||
#else |
|||
|
|||
extern struct encryption_keys_service_st encryption_keys_handler; |
|||
|
|||
#define get_latest_encryption_key_version() encryption_keys_handler.get_latest_encryption_key_version_func() |
|||
#define has_encryption_key(V) encryption_keys_handler.has_encryption_key_func(V) |
|||
#define get_encryption_key(V,K,S) encryption_keys_handler.get_encryption_key_func((V), (K), (S)) |
|||
#define encrypt_data(S,SL,D,DL,K,KL,I,IL,NP,KV) encryption_keys_handler.encrypt_data_func(S,SL,D,DL,K,KL,I,IL,NP,KV) |
|||
#define decrypt_data(S,SL,D,DL,K,KL,I,IL,NP,KV) encryption_keys_handler.decrypt_data_func(S,SL,D,DL,K,KL,I,IL,NP,KV) |
|||
#endif |
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
|
|||
#define MYSQL_SERVICE_ENCRYPTION_KEYS_INCLUDED |
|||
#endif |
|||
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue