-
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.22% 78.21% -0.01%
==========================================
Files 683 685 +2
Lines 117441 117675 +234
Branches 16502 16537 +35
==========================================
+ Hits 91870 92043 +173
- Misses 24683 24745 +62
+ Partials 888 887 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| unsigned 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.
If you unconditionally allocate EVP_MAX_IV_LENGTH, why not make iv a stack value?
| uint8_t inbuf[BUF_SIZE]; | ||
| bssl::UniquePtr<uint8_t[]> outbuf( | ||
| (uint8_t *)OPENSSL_zalloc(BUF_SIZE + EVP_CIPHER_block_size(cipher))); | ||
| int inlen = 0, outlen = 0; |
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.
NP: You could also keep outbuf on the stack as long as you assume a large enough block size. (I believe 16 is the largest block size we support.)
| } | ||
| } | ||
|
|
||
| bssl::UniquePtr<uint8_t[]> key((uint8_t *)OPENSSL_zalloc(EVP_MAX_KEY_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.
Similarly here, key can be a stack value if you're always allocating a constant size, EVP_MAX_KEY_LENGTH.
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.