Skip to content

File crypt_opfunc.c

FileList > cubrid > src > query > crypt_opfunc.c

Go to the source code of this file

  • #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 <sys/time.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 "thread_manager.hpp"
  • #include "base64.h"
  • #include <openssl/evp.h>
  • #include <openssl/sha.h>
  • #include <openssl/rand.h>
  • #include "memory_wrapper.hpp"

Public Types

Type Name
enum CRYPT_LIB_ERROR
enum SHA_FUNCTION
typedef std::unique_ptr< T, std::function< void(T *)> > deleted_unique_ptr

Public Static Attributes

Type Name
const char *const crypt_lib_fail_info = /* multi line expression */
const unsigned char dblink_cipher_nonce = /* multi line expression */
const char lower_hextable = "0123456789abcdef"
const char upper_hextable = "0123456789ABCDEF"

Public Functions

Type Name
void crypt_crc32 (const char * src, int src_len, int * dest)
int crypt_dblink_bin_to_str (const char * src, int src_len, char * dest, int dest_len, unsigned char * pk, long tm)
int crypt_dblink_decrypt (const unsigned char * cipher, int cipher_len, unsigned char * str_buffer, unsigned char * key)
int crypt_dblink_encrypt (const unsigned char * str, int str_len, unsigned char * cipher_buffer, unsigned char * key)
int crypt_dblink_str_to_bin (const char * src, int src_len, char * dest, int * dest_len, unsigned char * pk)
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_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_generate_random_bytes (char * dest, int length)
int crypt_md5_buffer_hex (const char * buffer, size_t len, char * resblock)
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 reverse_shake_dblink_password (char * confused, int length, char * passwd)
int shake_dblink_password (const char * passwd, char * confused, int confused_size, struct timeval * chk_time)
char * str_to_hex (THREAD_ENTRY * thread_p, const char * src, int src_len, char ** dest_p, int * dest_len_p, HEX_LETTERCASE lettercase)
void str_to_hex_prealloced (const char * src, int src_len, char * dest, int dest_len, HEX_LETTERCASE lettercase)

Public Static Functions

Type Name
void aes_default_gen_key (const char * key, int key_len, char * dest_key, int dest_key_len)
int crypt_md5_buffer_binary (const char * buffer, size_t len, char * resblock)
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)
int init_dblink_cipher (EVP_CIPHER_CTX ** ctx, const EVP_CIPHER ** cipher_type, bool is_aes_algorithm)

Macros

Type Name
define AES128_BLOCK_LEN (128/8)
define AES128_KEY_LEN (128/8)
define BYTE_2_HEX (u, b) /* multi line expression */
define DES_BLOCK_LEN (8)
define HEX_2_BYTE (h, u) /* multi line expression */
define MD5_CHECKSUM_HEX_LEN (32 + 1)
define MD5_CHECKSUM_LEN 16

Public Types Documentation

enum CRYPT_LIB_ERROR

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

enum SHA_FUNCTION {
    SHA_ONE,
    SHA_TWO_224,
    SHA_TWO_256,
    SHA_TWO_384,
    SHA_TWO_512
};

typedef deleted_unique_ptr

using deleted_unique_ptr =  std::unique_ptr<T, std::function<void (T *)> >;

Public Static Attributes Documentation

variable crypt_lib_fail_info

const char* const crypt_lib_fail_info[];

const unsigned char dblink_cipher_nonce[16];

variable lower_hextable

const char lower_hextable[];

variable upper_hextable

const char upper_hextable[];

Public Functions Documentation

function crypt_crc32

void crypt_crc32 (
    const  char * src,
    int src_len,
    int * dest
) 

int crypt_dblink_bin_to_str (
    const  char * src,
    int src_len,
    char * dest,
    int dest_len,
    unsigned  char * pk,
    long tm
) 

int crypt_dblink_decrypt (
    const  unsigned  char * cipher,
    int cipher_len,
    unsigned  char * str_buffer,
    unsigned  char * key
) 

int crypt_dblink_encrypt (
    const  unsigned  char * str,
    int str_len,
    unsigned  char * cipher_buffer,
    unsigned  char * key
) 

int crypt_dblink_str_to_bin (
    const  char * src,
    int src_len,
    char * dest,
    int * dest_len,
    unsigned  char * pk
) 

function crypt_default_decrypt

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
) 

function crypt_default_encrypt

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
) 

function crypt_generate_random_bytes

int crypt_generate_random_bytes (
    char * dest,
    int length
) 

function crypt_md5_buffer_hex

int crypt_md5_buffer_hex (
    const  char * buffer,
    size_t len,
    char * resblock
) 

function crypt_sha_one

int crypt_sha_one (
    THREAD_ENTRY * thread_p,
    const  char * src,
    int src_len,
    char ** dest_p,
    int * dest_len_p
) 

function crypt_sha_two

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 reverse_shake_dblink_password (
    char * confused,
    int length,
    char * passwd
) 

int shake_dblink_password (
    const  char * passwd,
    char * confused,
    int confused_size,
    struct  timeval * chk_time
) 

function str_to_hex

char * str_to_hex (
    THREAD_ENTRY * thread_p,
    const  char * src,
    int src_len,
    char ** dest_p,
    int * dest_len_p,
    HEX_LETTERCASE lettercase
) 

function str_to_hex_prealloced

void str_to_hex_prealloced (
    const  char * src,
    int src_len,
    char * dest,
    int dest_len,
    HEX_LETTERCASE lettercase
) 

Public Static Functions Documentation

function aes_default_gen_key

static void aes_default_gen_key (
    const  char * key,
    int key_len,
    char * dest_key,
    int dest_key_len
) 

function crypt_md5_buffer_binary

static int crypt_md5_buffer_binary (
    const  char * buffer,
    size_t len,
    char * resblock
) 

function crypt_sha_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 init_dblink_cipher (
    EVP_CIPHER_CTX ** ctx,
    const  EVP_CIPHER ** cipher_type,
    bool is_aes_algorithm
) 

Macro Definition Documentation

define AES128_BLOCK_LEN

#define AES128_BLOCK_LEN `(128/8)`

define AES128_KEY_LEN

#define AES128_KEY_LEN `(128/8)`

define BYTE_2_HEX

#define BYTE_2_HEX (
    u,
    b
) `/* multi line expression */`

define DES_BLOCK_LEN

#define DES_BLOCK_LEN `(8)`

define HEX_2_BYTE

#define HEX_2_BYTE (
    h,
    u
) `/* multi line expression */`

define MD5_CHECKSUM_HEX_LEN

#define MD5_CHECKSUM_HEX_LEN `(32 + 1)`

define MD5_CHECKSUM_LEN

#define MD5_CHECKSUM_LEN `16`


The documentation for this class was generated from the following file cubrid/src/query/crypt_opfunc.c