Skip to content

Allow zero-length PEM passwords in callback paths#3073

Merged
geedo0 merged 4 commits intoaws:mainfrom
geedo0:f37
Mar 11, 2026
Merged

Allow zero-length PEM passwords in callback paths#3073
geedo0 merged 4 commits intoaws:mainfrom
geedo0:f37

Conversation

@geedo0
Copy link
Contributor

@geedo0 geedo0 commented Mar 5, 2026

Description of changes:

Four sites incorrectly rejected empty passwords by checking
pass_len <= 0 instead of pass_len < 0 after invoking the password
callback. The callback returns negative on error and 0 for a valid
empty password, so the check should be < 0.

Testing:

How is this change tested (unit tests, fuzz tests, etc.)? Are there any testing steps to be verified by the reviewer?

CI

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.

Four sites incorrectly rejected empty passwords by checking
pass_len <= 0 instead of pass_len < 0 after invoking the password
callback. The callback returns negative on error and 0 for a valid
empty password, so the check should be < 0.
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

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@codecov-commenter
Copy link

codecov-commenter commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.39%. Comparing base (092453f) to head (ff16d63).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3073      +/-   ##
==========================================
+ Coverage   78.36%   78.39%   +0.03%     
==========================================
  Files         689      689              
  Lines      121144   121166      +22     
  Branches    16973    16973              
==========================================
+ Hits        94935    94993      +58     
+ Misses      25314    25279      -35     
+ Partials      895      894       -1     

☔ 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.

@geedo0 geedo0 enabled auto-merge (squash) March 5, 2026 21:59
TEST(PEMTest, WriteReadPKCS8DerEmptyPassword) {
bssl::UniquePtr<EC_KEY> ec_key(EC_KEY_new_by_curve_name(NID_X9_62_prime256v1));
ASSERT_TRUE(ec_key);
ASSERT_TRUE(EC_KEY_generate_key(ec_key.get()));
Copy link
Contributor

Choose a reason for hiding this comment

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

NP: Should this be conditioned as it is in PEMTest.WriteReadECPemEmptyPassword?

#if defined(BORINGSSL_FIPS)
  ASSERT_TRUE(EC_KEY_generate_key_fips(ec_key.get()));
#else
  ASSERT_TRUE(EC_KEY_generate_key(ec_key.get()));
#endif

@geedo0 geedo0 merged commit e5747bd into aws:main Mar 11, 2026
447 of 455 checks passed
WillChilds-Klein pushed a commit to WillChilds-Klein/aws-lc that referenced this pull request Mar 11, 2026
### Description of changes: 
Four sites incorrectly rejected empty passwords by checking
pass_len <= 0 instead of pass_len < 0 after invoking the password
callback. The callback returns negative on error and 0 for a valid
empty password, so the check should be < 0.

### Testing:
How is this change tested (unit tests, fuzz tests, etc.)? Are there any
testing steps to be verified by the reviewer?

CI

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.

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

4 participants