Add a reader for the system crypto-policies OpenSSL back-end - #3502
Conversation
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.
Amazon Linux 2023 and Fedora render the operator-selected system TLS posture to an OpenSSL back-end config file, which AWS-LC ignores. This reads that file behind an off-by-default build flag; nothing consumes the result yet.
Both are now AWSLC_CRYPTO_POLICY_FILE; the macro holding the value they fall back to is AWSLC_CRYPTO_POLICY_DEFAULT_FILE, so no identifier means two things.
c1639d5
46b9dc9 to
c1639d5
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3502 +/- ##
==========================================
+ Coverage 78.37% 78.41% +0.03%
==========================================
Files 700 700
Lines 125744 125758 +14
Branches 17388 17384 -4
==========================================
+ Hits 98553 98612 +59
+ Misses 26318 26275 -43
+ Partials 873 871 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
🔒 Security Review — View Report Please review before merging. |
fgets stops on error the same way it stops at EOF, so a file that broke part way through was reported as a policy that simply ended.
Comparing real and effective ids misses AT_SECURE cases that leave them equal: a binary with file capabilities, or a set-uid program that already dropped privileges.
The merge-base changed after approval.
| // Half a group list is not a weaker version of the operator's policy, it is a | ||
| // different policy nobody chose, so an over-long value is dropped whole and the | ||
| // field left empty. | ||
| TEST(CryptoPolicyParseTest, OverlongValueIsDroppedNotTruncated) { |
There was a problem hiding this comment.
I think there is a gap in behavior for the scenario where there is a valid value, and then an over-long value following it. The old valid value is retained and does not cause it to be treated as "not-present" based on the last key winning logic.
example: "Groups = X25519\nGroups = <1025 chars>"
There was a problem hiding this comment.
so in that case, we'd "fail open" and fall back to AWS-LC's defualts. over-large value is an unlikely edge case; that behavior seems appropriate to me.
The last occurrence of a key is the operator's choice. Leaving the previous value in place when that one will not fit applies a policy they replaced.
Stack, split out of #3442, to merge bottom-up (#3501, the error-queue primitives, has landed): 1. #3502 -- policy file reader 2. **#3527 -- shared-build symbol export and CI (this PR)** 3. #3503 -- cipher lists and version bounds 4. #3504 -- groups and signature algorithms 5. #3505 -- post-quantum defaults ## Description - Exports the two policy-reader internals the tests call and registers them in the libssl symbol registry. A shared build needs both: hidden visibility keeps them out of the library, and the version script an `ENABLE_DIST_PKG` build applies keeps them out again. - Runs the symbol extractor once more with the crypto-policies build flag defined, so declarations sitting behind that guard reach the registry at all. - Adds the Amazon Linux 2023 CI job for the feature: the suite with the flag on in stock CMake and in the shared, symbol-versioned `ENABLE_DIST_PKG` build a distribution packages, a run against the policy file the system renders, and a build with libssl off. - The job's seeding-specific parts, the neutralizing path override and the require-system flag, are inert until #3503 adds seeding and the test hook that reads them. - The build flag stays off by default, so no shipped configuration changes. ## Testing / verification - Ran both build configurations the job runs and the policy tests in each. Only the distribution one fails to link without this change, which is why a stock build alone let the gap through. - Reverting only the generated version script brings the undefined references back, so the registry entries earn their place alongside the export attribute. - Regenerating the version script from the registry is byte-identical, the invariant the symbol-check job's `mapcheck` mode enforces. 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.
Stack, split out of #3442, to merge bottom-up (#3501, the error-queue primitives, has landed):
Description
-DENABLE_CRYPTO_POLICIES, and a reader for the OpenSSL back-end file that Amazon Linux 2023 and Fedora render from the operator's chosen system policy.AWSLC_CRYPTO_POLICY_FILErelocates that file at build time and is declared in the CMake cache, socmake -Land cmake-gui list it for a packager who is not reading the CMakeLists.Testing / verification
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.