-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite aes encryption #257 #264
Conversation
be/src/aes/aes.cpp
Outdated
@@ -0,0 +1,171 @@ | |||
// Copyright (c) 2018, Baidu.com, Inc. All Rights Reserved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use ASF's header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
be/CMakeLists.txt
Outdated
@@ -585,6 +585,7 @@ if (${MAKE_TEST} STREQUAL "ON") | |||
add_subdirectory(${TEST_DIR}/exprs) | |||
add_subdirectory(${TEST_DIR}/runtime) | |||
add_subdirectory(${TEST_DIR}/http) | |||
add_subdirectory(${TEST_DIR}/aes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need this 'aes' directory
you can put aes.h and aes.cpp to be/src/util, and rename these to aes_util.h??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
be/src/aes/aes.cpp
Outdated
} | ||
} | ||
|
||
int do_decrypt(EVP_CIPHER_CTX* aes_ctx, const EVP_CIPHER* cipher, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function should be static
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
1b04f7b
to
c5a9a59
Compare
be/src/util/aes_util.cpp
Outdated
unsigned char encrypt_key[AES_MAX_KEY_LENGTH / 8]; | ||
aes_create_key(key, key_length, encrypt_key, mode); | ||
|
||
if (!cipher || (EVP_CIPHER_iv_length(cipher) > 0 && !iv)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when compare pointer use "cipher != nullptr", compare integer use "ret != 0", check bool use "!is_success"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
aes_create_key(key, key_length, encrypt_key, mode); | ||
|
||
if (!cipher || (EVP_CIPHER_iv_length(cipher) > 0 && !iv)) { | ||
return AES_BAD_DATA; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when cipher is not null, cipher's memory leak
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cipher can not be delete by manually or it will core dump
be/src/util/aes_util.cpp
Outdated
|
||
const EVP_CIPHER* get_evp_type(const AesMode mode) { | ||
switch (mode) { | ||
case AES_128_ECB: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the indent is not right, 'case" align with switch, no need to indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
144219d
to
6b97f89
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Resolve apache#257
No description provided.