-
Notifications
You must be signed in to change notification settings - Fork 155
Implement enc CLI #2877
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
base: main
Are you sure you want to change the base?
Implement enc CLI #2877
Conversation
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.
clang-tidy made some suggestions
tool-openssl/enc.cc
Outdated
| uint8_t inbuf[1024]; | ||
| bssl::UniquePtr<uint8_t> outbuf( | ||
| (uint8_t *)OPENSSL_zalloc(1024 + EVP_CIPHER_block_size(cipher))); | ||
| int inlen, outlen; |
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.
warning: variable 'inlen' is not initialized [cppcoreguidelines-init-variables]
| int inlen, outlen; | |
| int inlen = 0, outlen; |
tool-openssl/enc.cc
Outdated
| uint8_t inbuf[1024]; | ||
| bssl::UniquePtr<uint8_t> outbuf( | ||
| (uint8_t *)OPENSSL_zalloc(1024 + EVP_CIPHER_block_size(cipher))); | ||
| int inlen, outlen; |
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.
warning: variable 'outlen' is not initialized [cppcoreguidelines-init-variables]
| int inlen, outlen; | |
| int inlen, outlen = 0; |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2877 +/- ##
==========================================
- Coverage 78.23% 78.23% -0.01%
==========================================
Files 683 685 +2
Lines 117412 117646 +234
Branches 16502 16535 +33
==========================================
+ Hits 91862 92038 +176
- Misses 24662 24723 +61
+ Partials 888 885 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
tool-openssl/enc.cc
Outdated
| const EVP_CIPHER *cipher = EVP_get_cipherbyname(cipher_name.c_str()); | ||
|
|
||
| int iv_length = EVP_CIPHER_iv_length(cipher); | ||
| bssl::UniquePtr<uint8_t> iv((uint8_t *)OPENSSL_zalloc(EVP_MAX_IV_LENGTH)); |
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.
Shouldn't these pointers be to arrays?
bssl::UniquePtr<uint8_t[]> iv((uint8_t *)OPENSSL_zalloc(EVP_MAX_IV_LENGTH));
| } else { | ||
| cipher_name = cipher_name.substr(1); | ||
| } | ||
| const EVP_CIPHER *cipher = EVP_get_cipherbyname(cipher_name.c_str()); |
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.
Check for NULL.
if (cipher == nullptr) {
fprintf(stderr, "Error: Unknown cipher %s\n",
cipher_name.c_str());
return false;
}
Description of changes:
Implement enc CLI with the following options:
Testing:
Unit tests
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.