CUBRID Engine  latest
tde.h File Reference
#include "storage_common.h"
Include dependency graph for tde.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tde_data_key_set
 
struct  tde_mk_file_item
 
struct  tde_cipher
 
struct  tde_keyinfo
 

Macros

#define TDE_DK_ALGORITHM   TDE_ALGORITHM_AES
 
#define TDE_DATA_PAGE_ENC_OFFSET   sizeof (FILEIO_PAGE_RESERVED)
 
#define TDE_DATA_PAGE_ENC_LENGTH   DB_PAGESIZE
 
#define TDE_LOG_PAGE_ENC_OFFSET   sizeof (LOG_HDRPAGE)
 
#define TDE_LOG_PAGE_ENC_LENGTH   ((LOG_PAGESIZE) - (TDE_LOG_PAGE_ENC_OFFSET))
 
#define TDE_DATA_PAGE_NONCE_LENGTH   16
 
#define TDE_LOG_PAGE_NONCE_LENGTH   16
 
#define TDE_DK_NONCE_LENGTH   16
 
#define TDE_MASTER_KEY_LENGTH   32
 
#define TDE_DATA_KEY_LENGTH   32
 
#define TDE_MK_FILE_CONTENTS_START   CUBRID_MAGIC_MAX_LENGTH
 
#define TDE_MK_FILE_ITEM_SIZE   (sizeof (TDE_MK_FILE_ITEM))
 
#define TDE_MK_FILE_ITEM_OFFSET(index)   (TDE_MK_FILE_CONTENTS_START + TDE_MK_FILE_ITEM_SIZE * (index))
 
#define TDE_MK_FILE_ITEM_INDEX(offset)   (((offset) - TDE_MK_FILE_CONTENTS_START) / TDE_MK_FILE_ITEM_SIZE)
 
#define TDE_MK_FILE_ITEM_COUNT_MAX   128
 
#define LOG_MAY_CONTAIN_USER_DATA(rcvindex)
 

Typedefs

typedef fileio_page FILEIO_PAGE
 
typedef log_page LOG_PAGE
 
typedef enum tde_data_key_type TDE_DATA_KEY_TYPE
 
typedef struct tde_data_key_set TDE_DATA_KEY_SET
 
typedef struct tde_mk_file_item TDE_MK_FILE_ITEM
 
typedef struct tde_cipher TDE_CIPHER
 
typedef struct tde_keyinfo TDE_KEYINFO
 

Enumerations

enum  TDE_ALGORITHM { TDE_ALGORITHM_NONE = 0, TDE_ALGORITHM_AES = 1, TDE_ALGORITHM_ARIA = 2 }
 
enum  tde_data_key_type { TDE_DATA_KEY_TYPE_PERM, TDE_DATA_KEY_TYPE_TEMP, TDE_DATA_KEY_TYPE_LOG }
 

Functions

int tde_initialize (THREAD_ENTRY *thread_p, HFID *keyinfo_hfid)
 
int tde_cipher_initialize (THREAD_ENTRY *thread_p, const HFID *keyinfo_hfid, const char *mk_path_given)
 
int tde_get_keyinfo (THREAD_ENTRY *thread_p, TDE_KEYINFO *keyinfo)
 
void tde_make_keys_file_fullname (char *keys_vol_fullname, const char *db_full_name, bool ignore_parm)
 
bool tde_validate_keys_file (int vdes)
 
int tde_copy_keys_file (THREAD_ENTRY *thread_p, const char *dest_fullname, const char *src_fullname, bool keep_dest_mount, bool keep_src_mount)
 
int tde_load_mk (int vdes, const TDE_KEYINFO *keyinfo, unsigned char *master_key)
 
int tde_change_mk (THREAD_ENTRY *thread_p, const int mk_index, const unsigned char *master_key, const time_t created_time)
 
int tde_encrypt_data_page (const FILEIO_PAGE *iopage_plain, TDE_ALGORITHM tde_algo, bool is_temp, FILEIO_PAGE *iopage_cipher)
 
int tde_decrypt_data_page (const FILEIO_PAGE *iopage_cipher, TDE_ALGORITHM tde_algo, bool is_temp, FILEIO_PAGE *iopage_plain)
 
int tde_encrypt_log_page (const LOG_PAGE *logpage_plain, TDE_ALGORITHM tde_algo, LOG_PAGE *logpage_cipher)
 
int tde_decrypt_log_page (const LOG_PAGE *logpage_cipher, TDE_ALGORITHM tde_algo, LOG_PAGE *logpage_plain)
 
int tde_create_mk (unsigned char *master_key, time_t *created_time)
 
int tde_add_mk (int vdes, const unsigned char *master_key, time_t created_time, int *mk_index)
 
int tde_find_mk (int vdes, int mk_index, unsigned char *master_key, time_t *created_time)
 
int tde_find_first_mk (int vdes, int *mk_index, unsigned char *master_key, time_t *created_time)
 
int tde_delete_mk (int vdes, const int mk_index)
 
void tde_print_mk (const unsigned char *master_key)
 
int tde_dump_mks (int vdes, bool print_value)
 
const char * tde_get_algorithm_name (TDE_ALGORITHM tde_algo)
 

Variables

TDE_CIPHER tde_Cipher
 

Macro Definition Documentation

#define LOG_MAY_CONTAIN_USER_DATA (   rcvindex)
Value:
((rcvindex) == RVHF_INSERT \
|| (rcvindex) == RVHF_DELETE \
|| (rcvindex) == RVHF_UPDATE \
|| (rcvindex) == RVHF_MVCC_INSERT \
|| (rcvindex) == RVHF_MVCC_DELETE_MODIFY_HOME \
|| (rcvindex) == RVHF_UPDATE_NOTIFY_VACUUM \
|| (rcvindex) == RVHF_INSERT_NEWHOME \
|| (rcvindex) == RVHF_MVCC_REDISTRIBUTE \
|| (rcvindex) == RVHF_MVCC_UPDATE_OVERFLOW \
|| (rcvindex) == RVOVF_NEWPAGE_INSERT \
|| (rcvindex) == RVOVF_PAGE_UPDATE \
|| (rcvindex) == RVBT_INS_PGRECORDS \
|| (rcvindex) == RVBT_NDRECORD_UPD \
|| (rcvindex) == RVBT_NDRECORD_INS \
|| (rcvindex) == RVBT_NDRECORD_DEL \
|| (rcvindex) == RVBT_COPYPAGE \
|| (rcvindex) == RVBT_DELETE_OBJECT_PHYSICAL \
|| (rcvindex) == RVBT_NON_MVCC_INSERT_OBJECT \
|| (rcvindex) == RVBT_MVCC_INSERT_OBJECT \
|| (rcvindex) == RVBT_MVCC_INSERT_OBJECT_UNQ \
|| (rcvindex) == RVBT_RECORD_MODIFY_UNDOREDO \
|| (rcvindex) == RVBT_RECORD_MODIFY_NO_UNDO \
|| (rcvindex) == RVBT_RECORD_MODIFY_COMPENSATE \
|| (rcvindex) == RVREPL_DATA_INSERT \
|| (rcvindex) == RVREPL_DATA_UPDATE \
|| (rcvindex) == RVREPL_DATA_DELETE \
|| (rcvindex) == RVREPL_DATA_UPDATE_START \
|| (rcvindex) == RVREPL_DATA_UPDATE_END \

Definition at line 107 of file tde.h.

Referenced by log_append_compensate_internal(), log_append_postpone(), log_append_redo_crumbs(), log_append_run_postpone(), log_append_sysop_end(), log_append_undo_crumbs(), log_append_undoredo_crumbs(), and log_sysop_end_logical_undo().

#define TDE_DATA_KEY_LENGTH   32
#define TDE_DATA_PAGE_ENC_LENGTH   DB_PAGESIZE

Definition at line 44 of file tde.h.

Referenced by tde_decrypt_data_page(), and tde_encrypt_data_page().

#define TDE_DATA_PAGE_ENC_OFFSET   sizeof (FILEIO_PAGE_RESERVED)

Definition at line 43 of file tde.h.

Referenced by tde_decrypt_data_page(), and tde_encrypt_data_page().

#define TDE_DATA_PAGE_NONCE_LENGTH   16

Definition at line 49 of file tde.h.

Referenced by tde_decrypt_data_page(), and tde_encrypt_data_page().

#define TDE_DK_ALGORITHM   TDE_ALGORITHM_AES

Definition at line 40 of file tde.h.

Referenced by tde_decrypt_dk(), and tde_encrypt_dk().

#define TDE_DK_NONCE_LENGTH   16

Definition at line 51 of file tde.h.

Referenced by tde_decrypt_dk(), tde_dk_nonce(), and tde_encrypt_dk().

#define TDE_LOG_PAGE_ENC_LENGTH   ((LOG_PAGESIZE) - (TDE_LOG_PAGE_ENC_OFFSET))

Definition at line 46 of file tde.h.

Referenced by tde_decrypt_log_page(), and tde_encrypt_log_page().

#define TDE_LOG_PAGE_ENC_OFFSET   sizeof (LOG_HDRPAGE)

Definition at line 45 of file tde.h.

Referenced by tde_decrypt_log_page(), and tde_encrypt_log_page().

#define TDE_LOG_PAGE_NONCE_LENGTH   16

Definition at line 50 of file tde.h.

Referenced by tde_decrypt_log_page(), and tde_encrypt_log_page().

#define TDE_MK_FILE_CONTENTS_START   CUBRID_MAGIC_MAX_LENGTH

Definition at line 58 of file tde.h.

Referenced by tde_add_mk(), and tde_dump_mks().

#define TDE_MK_FILE_ITEM_COUNT_MAX   128

Definition at line 65 of file tde.h.

Referenced by tde_add_mk().

#define TDE_MK_FILE_ITEM_INDEX (   offset)    (((offset) - TDE_MK_FILE_CONTENTS_START) / TDE_MK_FILE_ITEM_SIZE)

Definition at line 62 of file tde.h.

Referenced by tde_add_mk(), and tde_dump_mks().

#define TDE_MK_FILE_ITEM_OFFSET (   index)    (TDE_MK_FILE_CONTENTS_START + TDE_MK_FILE_ITEM_SIZE * (index))

Definition at line 60 of file tde.h.

Referenced by tde_delete_mk(), tde_find_first_mk(), and tde_find_mk().

#define TDE_MK_FILE_ITEM_SIZE   (sizeof (TDE_MK_FILE_ITEM))

Definition at line 59 of file tde.h.

Referenced by tde_add_mk(), tde_delete_mk(), tde_dump_mks(), tde_find_first_mk(), and tde_find_mk().

Typedef Documentation

Definition at line 35 of file tde.h.

typedef log_page LOG_PAGE

Definition at line 37 of file tde.h.

typedef struct tde_cipher TDE_CIPHER
typedef struct tde_keyinfo TDE_KEYINFO

Enumeration Type Documentation

Enumerator
TDE_ALGORITHM_NONE 
TDE_ALGORITHM_AES 
TDE_ALGORITHM_ARIA 

Definition at line 71 of file tde.h.

Enumerator
TDE_DATA_KEY_TYPE_PERM 
TDE_DATA_KEY_TYPE_TEMP 
TDE_DATA_KEY_TYPE_LOG 

Definition at line 78 of file tde.h.

Function Documentation

int tde_change_mk ( THREAD_ENTRY thread_p,
const int  mk_index,
const unsigned char *  master_key,
const time_t  created_time 
)
int tde_create_mk ( unsigned char *  master_key,
time_t *  created_time 
)

Definition at line 1311 of file tde.c.

References ARG_FILE_LINE, assert, ER_ERROR_SEVERITY, er_set(), ER_TDE_KEY_CREATION_FAIL, NO_ERROR, NULL, and TDE_MASTER_KEY_LENGTH.

Referenced by tde(), and tde_initialize().

Here is the caller graph for this function:

int tde_delete_mk ( int  vdes,
const int  mk_index 
)

Definition at line 1569 of file tde.c.

References ARG_FILE_LINE, tde_mk_file_item::created_time, ER_ERROR_SEVERITY, er_set(), ER_TDE_MASTER_KEY_NOT_FOUND, NO_ERROR, off_signals, restore_signals, TDE_MK_FILE_ITEM_OFFSET, and TDE_MK_FILE_ITEM_SIZE.

Referenced by tde().

Here is the caller graph for this function:

int tde_dump_mks ( int  vdes,
bool  print_value 
)
int tde_find_first_mk ( int  vdes,
int *  mk_index,
unsigned char *  master_key,
time_t *  created_time 
)
int tde_find_mk ( int  vdes,
int  mk_index,
unsigned char *  master_key,
time_t *  created_time 
)
int tde_load_mk ( int  vdes,
const TDE_KEYINFO keyinfo,
unsigned char *  master_key 
)
void tde_print_mk ( const unsigned char *  master_key)

Definition at line 1332 of file tde.c.

References i, and TDE_MASTER_KEY_LENGTH.

Referenced by tde(), and tde_dump_mks().

Here is the caller graph for this function:

bool tde_validate_keys_file ( int  vdes)

Definition at line 358 of file tde.c.

References CUBRID_MAGIC_KEYS, CUBRID_MAGIC_MAX_LENGTH, off_signals, and restore_signals.

Referenced by boot_reset_mk_after_restart_from_backup(), logpb_restore(), tde_cipher_initialize(), tde_copy_keys_file(), and tde_initialize().

Here is the caller graph for this function:

Variable Documentation