diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt index 08d2f81b7d..251ed8f846 100644 --- a/be/CMakeLists.txt +++ b/be/CMakeLists.txt @@ -450,7 +450,6 @@ set(PALO_LINK_LIBS PaloGen Webserver TestUtil - AES ${WL_END_GROUP} ) @@ -541,7 +540,6 @@ add_subdirectory(${SRC_DIR}/udf) add_subdirectory(${SRC_DIR}/runtime) add_subdirectory(${SRC_DIR}/testutil) add_subdirectory(${SRC_DIR}/rpc) -add_subdirectory(${SRC_DIR}/aes) # Utility CMake function to make specifying tests and benchmarks less verbose FUNCTION(ADD_BE_TEST TEST_NAME) diff --git a/be/src/aes/CMakeLists.txt b/be/src/aes/CMakeLists.txt deleted file mode 100644 index 0e6177c5e6..0000000000 --- a/be/src/aes/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2017, Baidu.com, Inc. All Rights Reserved - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# under the License. - -# where to put generated libraries -set(LIBRARY_OUTPUT_PATH "${BUILD_DIR}/src/aes") - -# where to put generated binaries -set(EXECUTABLE_OUTPUT_PATH "${BUILD_DIR}/src/aes") - -add_library(AES STATIC - my_aes.cpp - my_aes_openssl.cpp -) diff --git a/be/src/aes/my_aes.cpp b/be/src/aes/my_aes.cpp deleted file mode 100644 index 4cae2f8e02..0000000000 --- a/be/src/aes/my_aes.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2017, Baidu.com, Inc. All Rights Reserved - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#include "my_aes.h" -#include "my_aes_impl.h" -#include - -/** - Transforms an arbitrary long key into a fixed length AES key - - AES keys are of fixed length. This routine takes an arbitrary long key - iterates over it in AES key length increment and XORs the bytes with the - AES key buffer being prepared. - The bytes from the last incomplete iteration are XORed to the start - of the key until their depletion. - Needed since crypto function routines expect a fixed length key. - - @param key [in] Key to use for real key creation - @param key_length [in] Length of the key - @param rkey [out] Real key (used by OpenSSL/YaSSL) - @param opmode [out] encryption mode -*/ -namespace palo { -void my_aes_create_key(const unsigned char *key, uint key_length, - uint8 *rkey, enum my_aes_opmode opmode) -{ - const uint key_size= my_aes_opmode_key_sizes[opmode] / 8; - uint8 *rkey_end; /* Real key boundary */ - uint8 *ptr; /* Start of the real key*/ - uint8 *sptr; /* Start of the working key */ - uint8 *key_end= ((uint8 *)key) + key_length; /* Working key boundary*/ - - rkey_end= rkey + key_size; - - memset(rkey, 0, key_size); /* Set initial key */ - - for (ptr= rkey, sptr= (uint8 *)key; sptr < key_end; ptr++, sptr++) - { - if (ptr == rkey_end) - /* Just loop over tmp_key until we used all key */ - ptr= rkey; - *ptr^= *sptr; - } -} -} diff --git a/be/src/aes/my_aes.h b/be/src/aes/my_aes.h deleted file mode 100644 index d65987e51d..0000000000 --- a/be/src/aes/my_aes.h +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) 2017, Baidu.com, Inc. All Rights Reserved - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef MY_AES_INCLUDED -#define MY_AES_INCLUDED - -/* Header file for my_aes.c */ -/* Wrapper to give simple interface for MySQL to AES standard encryption */ - -//C_MODE_START -#include - -/** AES IV size is 16 bytes for all supported ciphers except ECB */ -#define MY_AES_IV_SIZE 16 - -/** AES block size is fixed to be 128 bits for CBC and ECB */ -#define MY_AES_BLOCK_SIZE 16 -typedef uint32_t uint32; -typedef bool my_bool; -typedef uint32_t uint; - - -/** Supported AES cipher/block mode combos */ -enum my_aes_opmode -{ - my_aes_128_ecb, - my_aes_192_ecb, - my_aes_256_ecb, - my_aes_128_cbc, - my_aes_192_cbc, - my_aes_256_cbc -#ifndef HAVE_YASSL - ,my_aes_128_cfb1, - my_aes_192_cfb1, - my_aes_256_cfb1, - my_aes_128_cfb8, - my_aes_192_cfb8, - my_aes_256_cfb8, - my_aes_128_cfb128, - my_aes_192_cfb128, - my_aes_256_cfb128, - my_aes_128_ofb, - my_aes_192_ofb, - my_aes_256_ofb -#endif -}; - -#define MY_AES_BEGIN my_aes_128_ecb -#ifdef HAVE_YASSL -#define MY_AES_END my_aes_256_cbc -#else -#define MY_AES_END my_aes_256_ofb -#endif - -/* If bad data discovered during decoding */ -#define MY_AES_BAD_DATA -1 - -/** String representations of the supported AES modes. Keep in sync with my_aes_opmode */ -extern const char *my_aes_opmode_names[]; -namespace palo { -/** - Encrypt a buffer using AES - - @param source [in] Pointer to data for encryption - @param source_length [in] Size of encryption data - @param dest [out] Buffer to place encrypted data (must be large enough) - @param key [in] Key to be used for encryption - @param key_length [in] Length of the key. Will handle keys of any length - @param mode [in] encryption mode - @param iv [in] 16 bytes initialization vector if needed. Otherwise NULL - @param padding [in] if padding needed. - @return size of encrypted data, or negative in case of error -*/ - -int my_aes_encrypt(const unsigned char *source, uint32 source_length, - unsigned char *dest, - const unsigned char *key, uint32 key_length, - enum my_aes_opmode mode, const unsigned char *iv, - bool padding = true); - -/** - Decrypt an AES encrypted buffer - - @param source Pointer to data for decryption - @param source_length size of encrypted data - @param dest buffer to place decrypted data (must be large enough) - @param key Key to be used for decryption - @param key_length Length of the key. Will handle keys of any length - @param mode encryption mode - @param iv 16 bytes initialization vector if needed. Otherwise NULL - @param padding if padding needed. - @return size of original data. -*/ - - -int my_aes_decrypt(const unsigned char *source, uint32 source_length, - unsigned char *dest, - const unsigned char *key, uint32 key_length, - enum my_aes_opmode mode, const unsigned char *iv, - bool padding = true); - -/** - Calculate the size of a buffer large enough for encrypted data - - @param source_length length of data to be encrypted - @param mode encryption mode - @return size of buffer required to store encrypted data -*/ - -int my_aes_get_size(uint32 source_length, enum my_aes_opmode mode); - -/** - Return true if the AES cipher and block mode requires an IV - - SYNOPSIS - my_aes_needs_iv() - @param mode encryption mode - - @retval TRUE IV needed - @retval FALSE IV not needed -*/ - -my_bool my_aes_needs_iv(my_aes_opmode opmode); -} -//C_MODE_END - -#endif /* MY_AES_INCLUDED */ diff --git a/be/src/aes/my_aes_impl.h b/be/src/aes/my_aes_impl.h deleted file mode 100644 index 82c710c5e2..0000000000 --- a/be/src/aes/my_aes_impl.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2017, Baidu.com, Inc. All Rights Reserved - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef BDG_PALO_BE_EXPRS_MY_AES_IMPL_H -#define BDG_PALO_BE_EXPRS_MY_AES_IMPL_H - -/** Maximum supported key kength */ -const int MAX_AES_KEY_LENGTH = 256; - -/* TODO: remove in a future version */ -/* Guard against using an old export control restriction #define */ -#ifdef AES_USE_KEY_BITS -#error AES_USE_KEY_BITS not supported -#endif -typedef uint32_t uint; -typedef uint8_t uint8; - -namespace palo { - -extern uint *my_aes_opmode_key_sizes; -void my_aes_create_key(const unsigned char *key, uint key_length, - uint8 *rkey, enum my_aes_opmode opmode); -} - -#endif diff --git a/be/src/aes/my_aes_openssl.cpp b/be/src/aes/my_aes_openssl.cpp deleted file mode 100644 index 72f3eb6447..0000000000 --- a/be/src/aes/my_aes_openssl.cpp +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright (c) 2017, Baidu.com, Inc. All Rights Reserved - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#include "my_aes.h" -#include "my_aes_impl.h" -#include -#include - -#include -#include -#include - -#define DBUG_ASSERT(A) assert(A) -#define TRUE true -#define FALSE false -namespace palo { -/* keep in sync with enum my_aes_opmode in my_aes.h */ -const char *my_aes_opmode_names[]= -{ - "aes-128-ecb", - "aes-192-ecb", - "aes-256-ecb", - "aes-128-cbc", - "aes-192-cbc", - "aes-256-cbc", - "aes-128-cfb1", - "aes-192-cfb1", - "aes-256-cfb1", - "aes-128-cfb8", - "aes-192-cfb8", - "aes-256-cfb8", - "aes-128-cfb128", - "aes-192-cfb128", - "aes-256-cfb128", - "aes-128-ofb", - "aes-192-ofb", - "aes-256-ofb", - NULL /* needed for the type enumeration */ -}; - - -/* keep in sync with enum my_aes_opmode in my_aes.h */ -static uint my_aes_opmode_key_sizes_impl[]= -{ - 128 /* aes-128-ecb */, - 192 /* aes-192-ecb */, - 256 /* aes-256-ecb */, - 128 /* aes-128-cbc */, - 192 /* aes-192-cbc */, - 256 /* aes-256-cbc */, - 128 /* aes-128-cfb1 */, - 192 /* aes-192-cfb1 */, - 256 /* aes-256-cfb1 */, - 128 /* aes-128-cfb8 */, - 192 /* aes-192-cfb8 */, - 256 /* aes-256-cfb8 */, - 128 /* aes-128-cfb128 */, - 192 /* aes-192-cfb128 */, - 256 /* aes-256-cfb128 */, - 128 /* aes-128-ofb */, - 192 /* aes-192-ofb */, - 256 /* aes-256-ofb */ -}; - -uint *my_aes_opmode_key_sizes= my_aes_opmode_key_sizes_impl; - - - -static const EVP_CIPHER * -aes_evp_type(const my_aes_opmode mode) -{ - switch (mode) - { - case my_aes_128_ecb: return EVP_aes_128_ecb(); - case my_aes_128_cbc: return EVP_aes_128_cbc(); - case my_aes_128_cfb1: return EVP_aes_128_cfb1(); - case my_aes_128_cfb8: return EVP_aes_128_cfb8(); - case my_aes_128_cfb128: return EVP_aes_128_cfb128(); - case my_aes_128_ofb: return EVP_aes_128_ofb(); - case my_aes_192_ecb: return EVP_aes_192_ecb(); - case my_aes_192_cbc: return EVP_aes_192_cbc(); - case my_aes_192_cfb1: return EVP_aes_192_cfb1(); - case my_aes_192_cfb8: return EVP_aes_192_cfb8(); - case my_aes_192_cfb128: return EVP_aes_192_cfb128(); - case my_aes_192_ofb: return EVP_aes_192_ofb(); - case my_aes_256_ecb: return EVP_aes_256_ecb(); - case my_aes_256_cbc: return EVP_aes_256_cbc(); - case my_aes_256_cfb1: return EVP_aes_256_cfb1(); - case my_aes_256_cfb8: return EVP_aes_256_cfb8(); - case my_aes_256_cfb128: return EVP_aes_256_cfb128(); - case my_aes_256_ofb: return EVP_aes_256_ofb(); - default: return NULL; - } -} - - -int my_aes_encrypt(const unsigned char *source, uint32 source_length, - unsigned char *dest, - const unsigned char *key, uint32 key_length, - enum my_aes_opmode mode, const unsigned char *iv, - bool padding) -{ - EVP_CIPHER_CTX ctx; - const EVP_CIPHER *cipher= aes_evp_type(mode); - int u_len, f_len; - /* The real key to be used for encryption */ - unsigned char rkey[MAX_AES_KEY_LENGTH / 8]; - my_aes_create_key(key, key_length, rkey, mode); - - if (!cipher || (EVP_CIPHER_iv_length(cipher) > 0 && !iv)) - return MY_AES_BAD_DATA; - - if (!EVP_EncryptInit(&ctx, cipher, rkey, iv)) - goto aes_error; /* Error */ - if (!EVP_CIPHER_CTX_set_padding(&ctx, padding)) - goto aes_error; /* Error */ - if (!EVP_EncryptUpdate(&ctx, dest, &u_len, source, source_length)) - goto aes_error; /* Error */ - - if (!EVP_EncryptFinal(&ctx, dest + u_len, &f_len)) - goto aes_error; /* Error */ - - EVP_CIPHER_CTX_cleanup(&ctx); - return u_len + f_len; - -aes_error: - /* need to explicitly clean up the error if we want to ignore it */ - ERR_clear_error(); - EVP_CIPHER_CTX_cleanup(&ctx); - return MY_AES_BAD_DATA; -} - -int my_aes_decrypt(const unsigned char *source, uint32 source_length, - unsigned char *dest, - const unsigned char *key, uint32 key_length, - enum my_aes_opmode mode, const unsigned char *iv, - bool padding) -{ - - EVP_CIPHER_CTX ctx; - const EVP_CIPHER *cipher= aes_evp_type(mode); - int u_len, f_len; - - /* The real key to be used for decryption */ - unsigned char rkey[MAX_AES_KEY_LENGTH / 8]; - - my_aes_create_key(key, key_length, rkey, mode); - if (!cipher || (EVP_CIPHER_iv_length(cipher) > 0 && !iv)) - return MY_AES_BAD_DATA; - - EVP_CIPHER_CTX_init(&ctx); - - if (!EVP_DecryptInit(&ctx, aes_evp_type(mode), rkey, iv)) - goto aes_error; /* Error */ - if (!EVP_CIPHER_CTX_set_padding(&ctx, padding)) - goto aes_error; /* Error */ - if (!EVP_DecryptUpdate(&ctx, dest, &u_len, source, source_length)) - goto aes_error; /* Error */ - if (!EVP_DecryptFinal_ex(&ctx, dest + u_len, &f_len)) - goto aes_error; /* Error */ - - EVP_CIPHER_CTX_cleanup(&ctx); - return u_len + f_len; - -aes_error: - /* need to explicitly clean up the error if we want to ignore it */ - ERR_clear_error(); - EVP_CIPHER_CTX_cleanup(&ctx); - return MY_AES_BAD_DATA; -} - -int my_aes_get_size(uint32 source_length, my_aes_opmode opmode) -{ - const EVP_CIPHER *cipher= aes_evp_type(opmode); - size_t block_size; - - block_size= EVP_CIPHER_block_size(cipher); - - return block_size > 1 ? - block_size * (source_length / block_size) + block_size : - source_length; -} - -/** - Return true if the AES cipher and block mode requires an IV - - SYNOPSIS - my_aes_needs_iv() - @param mode encryption mode - - @retval TRUE IV needed - @retval FALSE IV not needed -*/ - -my_bool my_aes_needs_iv(my_aes_opmode opmode) -{ - const EVP_CIPHER *cipher= aes_evp_type(opmode); - int iv_length; - - iv_length= EVP_CIPHER_iv_length(cipher); - DBUG_ASSERT(iv_length == 0 || iv_length == MY_AES_IV_SIZE); - return iv_length != 0 ? TRUE : FALSE; -} -} diff --git a/be/src/common/daemon.cpp b/be/src/common/daemon.cpp index 82f5b8e105..0ef622e84e 100644 --- a/be/src/common/daemon.cpp +++ b/be/src/common/daemon.cpp @@ -44,7 +44,6 @@ #include "exprs/string_functions.h" #include "exprs/cast_functions.h" #include "exprs/math_functions.h" -#include "exprs/encryption_functions.h" #include "exprs/timestamp_functions.h" #include "exprs/decimal_operators.h" #include "exprs/utility_functions.h" @@ -154,7 +153,6 @@ void init_daemon(int argc, char** argv) { CastFunctions::init(); InPredicate::init(); MathFunctions::init(); - EncryptionFunctions::init(); TimestampFunctions::init(); DecimalOperators::init(); UtilityFunctions::init(); diff --git a/be/src/exprs/CMakeLists.txt b/be/src/exprs/CMakeLists.txt index 2670e332d5..3d4e42a914 100644 --- a/be/src/exprs/CMakeLists.txt +++ b/be/src/exprs/CMakeLists.txt @@ -26,7 +26,6 @@ set(EXECUTABLE_OUTPUT_PATH "${BUILD_DIR}/src/exprs") add_library(Exprs base64.cpp - encryption_functions.cpp aggregate_functions.cpp agg_fn_evaluator.cpp anyval_util.cpp diff --git a/be/src/exprs/encryption_functions.cpp b/be/src/exprs/encryption_functions.cpp deleted file mode 100644 index 4875ceb05d..0000000000 --- a/be/src/exprs/encryption_functions.cpp +++ /dev/null @@ -1,153 +0,0 @@ -// Modifications copyright (C) 2017, Baidu.com, Inc. -// Copyright 2017 The Apache Software Foundation - -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#include "exprs/encryption_functions.h" - -#include -#include "aes/my_aes.h" -#include "exprs/anyval_util.h" -#include "exprs/expr.h" -#include "util/debug_util.h" -#include "runtime/tuple_row.h" -#include "exprs/base64.h" -#include -#include "runtime/string_value.h" - -namespace palo { -void EncryptionFunctions::init() { -} - -StringVal EncryptionFunctions::aes_encrypt(FunctionContext* ctx, - const StringVal &src, const StringVal &key) { - if (src.len == 0) { - return StringVal::null(); - } - - // cipher_len = (clearLen/16 + 1) * 16; - int cipher_len = src.len + 16; - boost::scoped_array p; - p.reset(new char[cipher_len]); - - int ret_code = my_aes_encrypt((unsigned char *)src.ptr, src.len, - (unsigned char*)p.get(), (unsigned char *)key.ptr, key.len, my_aes_128_ecb, NULL); - if (ret_code < 0) { - return StringVal::null(); - } - return AnyValUtil::from_buffer_temp(ctx, p.get(), ret_code); -} - -StringVal EncryptionFunctions::aes_decrypt(FunctionContext* ctx, - const StringVal &src, const StringVal &key) { - if (src.len == 0) { - return StringVal::null(); - } - - int cipher_len = src.len; - boost::scoped_array p; - p.reset(new char[cipher_len]); - - int ret_code = my_aes_decrypt((unsigned char *)src.ptr, src.len, (unsigned char*)p.get(), - (unsigned char *)key.ptr, key.len, my_aes_128_ecb, NULL); - if (ret_code < 0) { - return StringVal::null(); - } - return AnyValUtil::from_buffer_temp(ctx, p.get(), ret_code); -} - -StringVal EncryptionFunctions::from_base64(FunctionContext* ctx, const StringVal &src) { - if (src.len == 0) { - return StringVal::null(); - } - - int cipher_len = src.len; - boost::scoped_array p; - p.reset(new char[cipher_len]); - - int ret_code = base64_decode2((const char *)src.ptr, src.len, p.get()); - if (ret_code < 0) { - return StringVal::null(); - } - return AnyValUtil::from_buffer_temp(ctx, p.get(), ret_code); -} - -StringVal EncryptionFunctions::to_base64(FunctionContext* ctx, const StringVal &src) { - if (src.len == 0) { - return StringVal::null(); - } - - int cipher_len = src.len * 4 / 3 + 1; - boost::scoped_array p; - p.reset(new char[cipher_len]); - - int ret_code = base64_encode2((unsigned char *)src.ptr, src.len, (unsigned char *)p.get()); - if (ret_code < 0) { - return StringVal::null(); - } - return AnyValUtil::from_buffer_temp(ctx, p.get(), ret_code); -} - -StringVal EncryptionFunctions::md5sum( - FunctionContext* ctx, int num_args, const StringVal* args) { - MD5_CTX md5_ctx; - MD5_Init(&md5_ctx); - for (int i = 0; i < num_args; ++i) { - const StringVal& arg = args[i]; - if (arg.is_null) { - continue; - } - MD5_Update(&md5_ctx, arg.ptr, arg.len); - } - unsigned char buf[MD5_DIGEST_LENGTH]; - MD5_Final(buf, &md5_ctx); - unsigned char hex_buf[2 * MD5_DIGEST_LENGTH]; - - static char dig_vec_lower[] = "0123456789abcdef"; - unsigned char* to = hex_buf; - for (int i = 0; i < MD5_DIGEST_LENGTH; ++i) { - *to++= dig_vec_lower[buf[i] >> 4]; - *to++= dig_vec_lower[buf[i] & 0x0F]; - } - - return AnyValUtil::from_buffer_temp(ctx, (char*)hex_buf, 2 * MD5_DIGEST_LENGTH); -} - -StringVal EncryptionFunctions::md5(FunctionContext* ctx, const StringVal& src) { - if (src.is_null) { - return StringVal::null(); - } - MD5_CTX md5_ctx; - MD5_Init(&md5_ctx); - MD5_Update(&md5_ctx, src.ptr, src.len); - - unsigned char buf[MD5_DIGEST_LENGTH]; - MD5_Final(buf, &md5_ctx); - unsigned char hex_buf[2 * MD5_DIGEST_LENGTH]; - - static char dig_vec_lower[] = "0123456789abcdef"; - unsigned char* to = hex_buf; - for (int i = 0; i < MD5_DIGEST_LENGTH; ++i) { - *to++= dig_vec_lower[buf[i] >> 4]; - *to++= dig_vec_lower[buf[i] & 0x0F]; - } - - return AnyValUtil::from_buffer_temp(ctx, (char*)hex_buf, 2 * MD5_DIGEST_LENGTH); -} - -} diff --git a/be/src/exprs/encryption_functions.h b/be/src/exprs/encryption_functions.h deleted file mode 100644 index 98c86ea962..0000000000 --- a/be/src/exprs/encryption_functions.h +++ /dev/null @@ -1,53 +0,0 @@ -// Modifications copyright (C) 2017, Baidu.com, Inc. -// Copyright 2017 The Apache Software Foundation - -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef BDG_PALO_BE_SRC_QUERY_EXPRS_ENCRYPTION_FUNCTIONS_H -#define BDG_PALO_BE_SRC_QUERY_EXPRS_ENCRYPTION_FUNCTIONS_H - -#include -#include "udf/udf.h" -#include "udf/udf_internal.h" - -namespace palo { - -class Expr; -struct ExprValue; -class TupleRow; - -class EncryptionFunctions { -public: - static void init(); - static palo_udf::StringVal aes_encrypt(palo_udf::FunctionContext* context, - const palo_udf::StringVal& val1, const palo_udf::StringVal& val2); - static palo_udf::StringVal aes_decrypt(palo_udf::FunctionContext* context, - const palo_udf::StringVal& val1, const palo_udf::StringVal& val2); - static palo_udf::StringVal from_base64(palo_udf::FunctionContext* context, - const palo_udf::StringVal& val1); - static palo_udf::StringVal to_base64(palo_udf::FunctionContext* context, - const palo_udf::StringVal& val1); - static palo_udf::StringVal md5sum(palo_udf::FunctionContext* ctx, - int num_args, const palo_udf::StringVal* args); - static palo_udf::StringVal md5(palo_udf::FunctionContext* ctx, - const palo_udf::StringVal& src); -}; - -} - -#endif