Skip to content
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

Merged
merged 1 commit into from
Nov 2, 2018
Merged

Rewrite aes encryption #257 #264

merged 1 commit into from
Nov 2, 2018

Conversation

kangpinghuang
Copy link
Contributor

No description provided.

@@ -0,0 +1,171 @@
// Copyright (c) 2018, Baidu.com, Inc. All Rights Reserved
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -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)
Copy link
Contributor

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??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
}

int do_decrypt(EVP_CIPHER_CTX* aes_ctx, const EVP_CIPHER* cipher,
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@kangpinghuang kangpinghuang force-pushed the master branch 3 times, most recently from 1b04f7b to c5a9a59 Compare November 1, 2018 12:14
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)) {
Copy link
Contributor

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"

Copy link
Contributor Author

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;
Copy link
Contributor

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

Copy link
Contributor Author

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


const EVP_CIPHER* get_evp_type(const AesMode mode) {
switch (mode) {
case AES_128_ECB:
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@kangpinghuang kangpinghuang force-pushed the master branch 3 times, most recently from 144219d to 6b97f89 Compare November 2, 2018 02:18
@kangpinghuang kangpinghuang changed the title Update #257: rewrite aes encryption Rewrite aes encryption #257 Nov 2, 2018
imay
imay previously approved these changes Nov 2, 2018
Copy link
Contributor

@imay imay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@imay imay merged commit d57e91d into apache:master Nov 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants