|
CUBRID Engine
latest
|
#include "config.h"#include <stdio.h>#include <stdlib.h>#include <memory>#include <memory.h>#include <string.h>#include <math.h>#include <assert.h>#include <errno.h>#include <netinet/in.h>#include <arpa/inet.h>#include "CRC.h"#include "thread_compat.hpp"#include "porting.h"#include "error_code.h"#include "error_manager.h"#include "memory_alloc.h"#include "crypt_opfunc.h"#include <openssl/evp.h>#include <openssl/sha.h>#include <openssl/rand.h>Go to the source code of this file.
Macros | |
| #define | AES128_BLOCK_LEN (128/8) |
| #define | AES128_KEY_LEN (128/8) |
| #define | DES_BLOCK_LEN (8) |
| #define | MD5_CHECKSUM_LEN 16 |
| #define | MD5_CHECKSUM_HEX_LEN (32 + 1) |
Typedefs | |
| template<typename T > | |
| using | deleted_unique_ptr = std::unique_ptr< T, std::function< void(T *)>> |
Enumerations | |
| enum | CRYPT_LIB_ERROR { CRYPT_LIB_INIT_ERR = 0, CRYPT_LIB_OPEN_CIPHER_ERR, CRYPT_LIB_SET_KEY_ERR, CRYPT_LIB_CRYPT_ERR, CRYPT_LIB_UNKNOWN_ERR } |
| enum | SHA_FUNCTION { SHA_ONE, SHA_TWO_224, SHA_TWO_256, SHA_TWO_384, SHA_TWO_512 } |
Functions | |
| static int | crypt_sha_functions (THREAD_ENTRY *thread_p, const char *src, int src_len, SHA_FUNCTION sha_func, char **dest_p, int *dest_len_p) |
| static int | crypt_md5_buffer_binary (const char *buffer, size_t len, char *resblock) |
| static void | aes_default_gen_key (const char *key, int key_len, char *dest_key, int dest_key_len) |
| void | str_to_hex_prealloced (const char *src, int src_len, char *dest, int dest_len, HEX_LETTERCASE lettercase) |
| char * | str_to_hex (THREAD_ENTRY *thread_p, const char *src, int src_len, char **dest_p, int *dest_len_p, HEX_LETTERCASE lettercase) |
| int | crypt_default_encrypt (THREAD_ENTRY *thread_p, const char *src, int src_len, const char *key, int key_len, char **dest_p, int *dest_len_p, CIPHER_ENCRYPTION_TYPE enc_type) |
| int | crypt_default_decrypt (THREAD_ENTRY *thread_p, const char *src, int src_len, const char *key, int key_len, char **dest_p, int *dest_len_p, CIPHER_ENCRYPTION_TYPE enc_type) |
| int | crypt_sha_one (THREAD_ENTRY *thread_p, const char *src, int src_len, char **dest_p, int *dest_len_p) |
| int | crypt_sha_two (THREAD_ENTRY *thread_p, const char *src, int src_len, int need_hash_len, char **dest_p, int *dest_len_p) |
| int | crypt_md5_buffer_hex (const char *buffer, size_t len, char *resblock) |
| void | crypt_crc32 (const char *src, int src_len, int *dest) |
| int | crypt_generate_random_bytes (char *dest, int length) |
Variables | |
| static const char *const | crypt_lib_fail_info [] |
| static const char | lower_hextable [] = "0123456789abcdef" |
| static const char | upper_hextable [] = "0123456789ABCDEF" |
| #define AES128_BLOCK_LEN (128/8) |
Definition at line 57 of file crypt_opfunc.c.
Referenced by crypt_default_decrypt(), and crypt_default_encrypt().
| #define AES128_KEY_LEN (128/8) |
Definition at line 58 of file crypt_opfunc.c.
Referenced by crypt_default_decrypt(), and crypt_default_encrypt().
| #define DES_BLOCK_LEN (8) |
Definition at line 59 of file crypt_opfunc.c.
Referenced by crypt_default_decrypt(), and crypt_default_encrypt().
| #define MD5_CHECKSUM_HEX_LEN (32 + 1) |
Definition at line 61 of file crypt_opfunc.c.
Referenced by crypt_md5_buffer_hex().
| #define MD5_CHECKSUM_LEN 16 |
Definition at line 60 of file crypt_opfunc.c.
Referenced by crypt_md5_buffer_hex().
| using deleted_unique_ptr = std::unique_ptr<T, std::function<void (T *)>> |
Definition at line 83 of file crypt_opfunc.c.
| enum CRYPT_LIB_ERROR |
| Enumerator | |
|---|---|
| CRYPT_LIB_INIT_ERR | |
| CRYPT_LIB_OPEN_CIPHER_ERR | |
| CRYPT_LIB_SET_KEY_ERR | |
| CRYPT_LIB_CRYPT_ERR | |
| CRYPT_LIB_UNKNOWN_ERR | |
Definition at line 63 of file crypt_opfunc.c.
| enum SHA_FUNCTION |
| Enumerator | |
|---|---|
| SHA_ONE | |
| SHA_TWO_224 | |
| SHA_TWO_256 | |
| SHA_TWO_384 | |
| SHA_TWO_512 | |
Definition at line 72 of file crypt_opfunc.c.
|
static |
Definition at line 181 of file crypt_opfunc.c.
References assert, i, and NULL.
Referenced by crypt_default_decrypt(), and crypt_default_encrypt().

| void crypt_crc32 | ( | const char * | src, |
| int | src_len, | ||
| int * | dest | ||
| ) |
Definition at line 672 of file crypt_opfunc.c.
References assert, CRC::Calculate(), CRC::CRC_32(), and NULL.
Referenced by db_crc32_dbval(), logpb_compute_page_checksum(), and logwr_check_page_checksum().

| int crypt_default_decrypt | ( | THREAD_ENTRY * | thread_p, |
| const char * | src, | ||
| int | src_len, | ||
| const char * | key, | ||
| int | key_len, | ||
| char ** | dest_p, | ||
| int * | dest_len_p, | ||
| CIPHER_ENCRYPTION_TYPE | enc_type | ||
| ) |
Definition at line 334 of file crypt_opfunc.c.
References AES128_BLOCK_LEN, AES128_KEY_LEN, AES_128_ECB, aes_default_gen_key(), ARG_FILE_LINE, assert, CRYPT_LIB_CRYPT_ERR, crypt_lib_fail_info, CRYPT_LIB_INIT_ERR, db_private_alloc, db_private_free_and_init, DES_BLOCK_LEN, DES_ECB, ER_ENCRYPTION_LIB_FAILED, ER_ERROR_SEVERITY, ER_FAILED, ER_OUT_OF_VIRTUAL_MEMORY, er_set(), i, NO_ERROR, NULL, and thread_get_thread_entry_info().
Referenced by db_string_aes_decrypt().

| int crypt_default_encrypt | ( | THREAD_ENTRY * | thread_p, |
| const char * | src, | ||
| int | src_len, | ||
| const char * | key, | ||
| int | key_len, | ||
| char ** | dest_p, | ||
| int * | dest_len_p, | ||
| CIPHER_ENCRYPTION_TYPE | enc_type | ||
| ) |
Definition at line 212 of file crypt_opfunc.c.
References AES128_BLOCK_LEN, AES128_KEY_LEN, AES_128_ECB, aes_default_gen_key(), ARG_FILE_LINE, assert, CRYPT_LIB_CRYPT_ERR, crypt_lib_fail_info, CRYPT_LIB_INIT_ERR, db_private_alloc, db_private_free_and_init, DES_BLOCK_LEN, DES_ECB, ER_ENCRYPTION_LIB_FAILED, ER_ERROR_SEVERITY, ER_FAILED, ER_OUT_OF_VIRTUAL_MEMORY, er_set(), NO_ERROR, NULL, and thread_get_thread_entry_info().
Referenced by crypt_encrypt_printable(), and db_string_aes_encrypt().

| int crypt_generate_random_bytes | ( | char * | dest, |
| int | length | ||
| ) |
Definition at line 688 of file crypt_opfunc.c.
References ARG_FILE_LINE, assert, CRYPT_LIB_CRYPT_ERR, crypt_lib_fail_info, ER_ENCRYPTION_LIB_FAILED, ER_ERROR_SEVERITY, er_set(), NO_ERROR, and NULL.
Referenced by db_guid().

|
static |
Definition at line 603 of file crypt_opfunc.c.
References ARG_FILE_LINE, assert, CRYPT_LIB_CRYPT_ERR, crypt_lib_fail_info, CRYPT_LIB_INIT_ERR, ER_ENCRYPTION_LIB_FAILED, ER_ERROR_SEVERITY, ER_FAILED, er_set(), NO_ERROR, and NULL.
Referenced by crypt_md5_buffer_hex().

| int crypt_md5_buffer_hex | ( | const char * | buffer, |
| size_t | len, | ||
| char * | resblock | ||
| ) |
Definition at line 646 of file crypt_opfunc.c.
References assert, crypt_md5_buffer_binary(), ER_FAILED, HEX_LOWERCASE, MD5_CHECKSUM_HEX_LEN, MD5_CHECKSUM_LEN, NO_ERROR, NULL, and str_to_hex_prealloced().
Referenced by db_string_md5(), locale_compute_coll_checksum(), locale_compute_locale_checksum(), qmgr_get_sql_id(), sm_default_constraint_name(), and tzc_compute_timezone_checksum().

|
static |
Definition at line 516 of file crypt_opfunc.c.
References ARG_FILE_LINE, assert, CRYPT_LIB_CRYPT_ERR, crypt_lib_fail_info, CRYPT_LIB_INIT_ERR, ER_ENCRYPTION_LIB_FAILED, ER_ERROR_SEVERITY, ER_FAILED, ER_OUT_OF_VIRTUAL_MEMORY, er_set(), HEX_UPPERCASE, NO_ERROR, NULL, rc, SHA_ONE, SHA_TWO_224, SHA_TWO_256, SHA_TWO_384, SHA_TWO_512, str_to_hex(), and thread_get_thread_entry_info().
Referenced by crypt_sha_one(), and crypt_sha_two().

| int crypt_sha_one | ( | THREAD_ENTRY * | thread_p, |
| const char * | src, | ||
| int | src_len, | ||
| char ** | dest_p, | ||
| int * | dest_len_p | ||
| ) |
Definition at line 473 of file crypt_opfunc.c.
References crypt_sha_functions(), and SHA_ONE.
Referenced by db_string_sha_one().

| int crypt_sha_two | ( | THREAD_ENTRY * | thread_p, |
| const char * | src, | ||
| int | src_len, | ||
| int | need_hash_len, | ||
| char ** | dest_p, | ||
| int * | dest_len_p | ||
| ) |
Definition at line 490 of file crypt_opfunc.c.
References crypt_sha_functions(), NO_ERROR, SHA_TWO_224, SHA_TWO_256, SHA_TWO_384, and SHA_TWO_512.
Referenced by db_string_sha_two(), and encrypt_password_sha2_512().

| char* str_to_hex | ( | THREAD_ENTRY * | thread_p, |
| const char * | src, | ||
| int | src_len, | ||
| char ** | dest_p, | ||
| int * | dest_len_p, | ||
| HEX_LETTERCASE | lettercase | ||
| ) |
Definition at line 141 of file crypt_opfunc.c.
References assert, db_private_alloc, i, NULL, str_to_hex_prealloced(), and thread_get_thread_entry_info().
Referenced by crypt_sha_functions().

| void str_to_hex_prealloced | ( | const char * | src, |
| int | src_len, | ||
| char * | dest, | ||
| int | dest_len, | ||
| HEX_LETTERCASE | lettercase | ||
| ) |
Definition at line 103 of file crypt_opfunc.c.
References assert, HEX_UPPERCASE, i, lower_hextable, NULL, and upper_hextable.
Referenced by crypt_md5_buffer_hex(), and str_to_hex().

Definition at line 86 of file crypt_opfunc.c.
Referenced by crypt_default_decrypt(), crypt_default_encrypt(), crypt_generate_random_bytes(), crypt_md5_buffer_binary(), and crypt_sha_functions().
|
static |
Definition at line 94 of file crypt_opfunc.c.
Referenced by str_to_hex_prealloced().
|
static |
Definition at line 95 of file crypt_opfunc.c.
Referenced by str_to_hex_prealloced().