Skip to content

Conversation

@nhatnghiho
Copy link
Contributor

Description of changes:

Implement enc CLI with the following options:

  • e
  • d
  • aes-128-cbc
  • K
  • in
  • out
  • iv

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.

@nhatnghiho nhatnghiho requested a review from a team as a code owner December 3, 2025 17:38
Copy link
Contributor

@github-actions github-actions bot left a 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

uint8_t inbuf[1024];
bssl::UniquePtr<uint8_t> outbuf(
(uint8_t *)OPENSSL_zalloc(1024 + EVP_CIPHER_block_size(cipher)));
int inlen, outlen;
Copy link
Contributor

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]

Suggested change
int inlen, outlen;
int inlen = 0, outlen;

uint8_t inbuf[1024];
bssl::UniquePtr<uint8_t> outbuf(
(uint8_t *)OPENSSL_zalloc(1024 + EVP_CIPHER_block_size(cipher)));
int inlen, outlen;
Copy link
Contributor

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]

Suggested change
int inlen, outlen;
int inlen, outlen = 0;

@codecov-commenter
Copy link

codecov-commenter commented Dec 3, 2025

Codecov Report

❌ Patch coverage is 78.20513% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.23%. Comparing base (9f3de9b) to head (66b47f1).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
tool-openssl/enc_test.cc 75.00% 33 Missing ⚠️
tool-openssl/enc.cc 82.35% 18 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

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

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;
  }

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.

3 participants