Skip to content

Keep AWS-LC's post-quantum defaults unless the policy opts out - #3505

Open
WillChilds-Klein wants to merge 1 commit into
feat/crypto-policies-4-groups-sigalgsfrom
feat/crypto-policies-5-preserve-pq
Open

Keep AWS-LC's post-quantum defaults unless the policy opts out#3505
WillChilds-Klein wants to merge 1 commit into
feat/crypto-policies-4-groups-sigalgsfrom
feat/crypto-policies-5-preserve-pq

Conversation

@WillChilds-Klein

@WillChilds-Klein WillChilds-Klein commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Stack, split out of #3442, to merge bottom-up:

  1. Add ERR_num_errors and ERR_pop_to_count #3501 -- error-queue primitives
  2. Add a reader for the system crypto-policies OpenSSL back-end #3502 -- policy file reader
  3. Seed cipher lists and version bounds from the system crypto policy #3503 -- cipher lists and version bounds
  4. Seed groups and signature algorithms from the system crypto policy #3504 -- groups and signature algorithms
  5. Keep AWS-LC's post-quantum defaults unless the policy opts out #3505 -- post-quantum defaults (this PR)

Description

  • Keeps AWS-LC's post-quantum defaults when the policy says nothing about them. Every policy the framework ships today predates ML-KEM and ML-DSA, and the setters replace AWS-LC's defaults rather than intersect with them, so seeding downgraded every context.
  • A policy that names any post-quantum algorithm is taken at its word and nothing is added back.
  • A hybrid group returns only where the policy keeps its classical half, so a policy without secp384r1 has no SecP384r1MLKEM1024 either, and a group the policy removes with - stays out.
  • Turning post-quantum off wholesale takes a directive of AWS-LC's own, AWSLC.PostQuantum = off, since nothing the framework writes says "no post-quantum". Other readers of the file ignore an unknown key.
  • The groups to restore are derived from AWS-LC's own defaults at runtime, so they follow any change to them.

Testing / verification

  • Tests cover both directions: a silent policy keeps the post-quantum entries, and a policy naming one is left as written.
  • The opt-out is checked case-insensitively, and other values of the directive are checked to keep the defaults.
  • The hybrid rule is exercised by a policy that keeps one classical curve and drops another, and by one that removes a hybrid outright.
  • The framework's hyphenated spellings, such as x25519-mlkem768 and ml-dsa-65, are checked to resolve to AWS-LC's ids.
  • Each guard was checked by neutering it in turn, including the opt-out, the check that a policy naming post-quantum is authoritative, and the classical-half requirement.

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.

@WillChilds-Klein
WillChilds-Klein requested a review from a team as a code owner September 9, 2026 16:06
@WillChilds-Klein
WillChilds-Klein force-pushed the feat/crypto-policies-5-preserve-pq branch from 760b594 to 8c285e9 Compare September 9, 2026 19:29
@WillChilds-Klein
WillChilds-Klein force-pushed the feat/crypto-policies-5-preserve-pq branch from 8c285e9 to f97b020 Compare September 9, 2026 21:08
@WillChilds-Klein
WillChilds-Klein added this pull request to stack #3509 September 9, 2026 22:50
WillChilds-Klein added a commit that referenced this pull request Sep 11, 2026
Stack, split out of #3442, to merge bottom-up:

1. **#3501 -- error-queue primitives (this PR)**
2. #3502 -- policy file reader
3. #3503 -- cipher lists and version bounds
4. #3504 -- groups and signature algorithms
5. #3505 -- post-quantum defaults

## Description

- Adds `ERR_num_errors` and `ERR_pop_to_count`, so code that calls into
libcrypto on a caller's behalf can drop the errors it raised and leave
the queue it was handed untouched.
- The existing mark APIs cannot do this. `ERR_set_mark` needs an entry
to mark, so it is a no-op on an empty queue, and popping to a mark
consumes one the caller had already set.
- `ERR_clear_error` and `ERR_restore_state` rebuild the queue, which
dangles the data pointer the caller got from its last
`ERR_get_error_line_data`.
- A count is a position rather than a mark, so it nests inside a
caller's mark without disturbing it.

## Testing / verification

- New error-queue tests cover popping back to a recorded count, a count
taken from an empty queue, and a count at or above the queue's length.
- One case fills the ring past its capacity to confirm a stale count
leaves the caller's errors alone.
- One case wraps a nested call in the caller's own mark and an error
carrying a data string, then checks the mark still pops and the string
is intact.
- One case pins that a mark does not survive
`ERR_save_state`/`ERR_restore_state`, since a snapshot can be restored
many times and would re-arm a mark nobody set.

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.
@WillChilds-Klein
WillChilds-Klein force-pushed the feat/crypto-policies-5-preserve-pq branch from f97b020 to 577e735 Compare September 11, 2026 15:03
@codecov-commenter

codecov-commenter commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (feat/crypto-policies-4-groups-sigalgs@8e5536b). Learn more about missing BASE report.

Additional details and impacted files
@@                           Coverage Diff                            @@
##             feat/crypto-policies-4-groups-sigalgs    #3505   +/-   ##
========================================================================
  Coverage                                         ?   78.40%           
========================================================================
  Files                                            ?      700           
  Lines                                            ?   125745           
  Branches                                         ?    17386           
========================================================================
  Hits                                             ?    98589           
  Misses                                           ?    26285           
  Partials                                         ?      871           

☔ View full report in Codecov by Harness.
📢 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.

@WillChilds-Klein
WillChilds-Klein force-pushed the feat/crypto-policies-5-preserve-pq branch from 577e735 to fc6542b Compare September 11, 2026 19:53
Every policy the crypto-policies framework ships today predates ML-KEM and
ML-DSA, and the group and signature-algorithm setters replace AWS-LC's defaults
rather than intersect with them, so seeding downgraded every context. AWS-LC's
post-quantum algorithms are now restored after filtering when the policy names
none, and a policy that names any is left alone. A hybrid comes back only when
the policy keeps its classical half, and one the policy removes with '-' stays
out.

The framework's directives cannot say "no post-quantum", so turning it off
needs a directive of AWS-LC's own, AWSLC.PostQuantum.
@WillChilds-Klein
WillChilds-Klein force-pushed the feat/crypto-policies-5-preserve-pq branch from fc6542b to fcdb730 Compare September 11, 2026 20:16
@github-actions

Copy link
Copy Markdown
Contributor

🔒 Security ReviewView Report

Please review before merging.

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