ffi: FIPS-compliant mode foundation (#06) - #2427
Closed
ronaldtse wants to merge 5 commits into
Closed
Conversation
ronaldtse
force-pushed
the
fips-mode-foundation
branch
from
August 10, 2026 02:09
e60d483 to
5d27b9d
Compare
Allows callers to enumerate the security profile's rule list, including the built-in defaults (SHA-1, MD5, CAST5/3DES/IDEA/BLOWFISH, RIPEMD). Useful for diagnostics, tooling, and letting downstream consumers report which features rnp considers insecure.
Extends test_ffi_security_rule_enumeration to also add a public-key rule (EdDSA, PROHIBITED) so the case rnp::FeatureType::PublicKey branch in rnp_get_security_rule_at and the SecurityLevel::Disabled → RNP_SECURITY_PROHIBITED mapping are exercised. Adds the same RNP_FEATURE_PK_ALG handling to get_feature_sec_value() that hash and cipher types already enjoy, so rnp_add_security_rule, rnp_get_security_rule, and rnp_remove_security_rule accept public-key features symmetrically with the other two types.
ronaldtse
force-pushed
the
fips-mode-foundation
branch
from
August 20, 2026 10:11
5d27b9d to
1a7bb99
Compare
…#6) Foundation for FIPS-compliant mode. Adds a cmake build switch ENABLE_FIPS_MODE that: - forces CRYPTO_BACKEND=openssl (Botan has no validated FIPS provider) - requires OpenSSL 3.x (FIPS provider is a 3.x feature) - defines RNP_FIPS_MODE throughout the library - adds Disabled-level default security rules for non-FIPS algorithms (Twofish, CAST5, IDEA, Blowfish, SM4, MD5, SHA1, RIPEMD160, EdDSA, SM2, ElGamal) Adds the FFI query rnp_is_fips_mode_enabled() so callers can detect the compile-time setting at runtime. Documents the certification boundary in docs/security.adoc: rnp is a consumer of OpenSSL's validated FIPS provider module, not a validated module itself. Adds a CI leg that builds and tests under -DENABLE_FIPS_MODE=On. This is foundation only. Constant-time audit, zeroization, Argon2 → PBKDF2 S2K migration, and FIPS provider loading ceremony are intentionally out of scope and will land in follow-up PRs.
Adds test_ffi_fips_mode_default_rules which is compiled in only when RNP_FIPS_MODE is defined. It queries each algorithm the FIPS default profile marks Disabled (CAST5, IDEA, BLOWFISH, MD5, SHA1, RIPEMD160, EDDSA, ELGAMAL) via rnp_get_security_rule and asserts the level is RNP_SECURITY_PROHIBITED. AES-256 is sanity-checked to remain DEFAULT. Extends get_feature_sec_value() in the FFI to also accept RNP_FEATURE_PK_ALG so the Disabled public-key rules can be queried through the same API as hash and cipher rules.
ronaldtse
force-pushed
the
fips-mode-foundation
branch
from
August 20, 2026 10:43
1a7bb99 to
cd67f7d
Compare
Contributor
Author
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Foundation for FIPS-compliant mode (roadmap item #6). Adds the build switch, runtime query, and default algorithm policy. The full FIPS effort is a multi-PR initiative; this PR lays the groundwork only.
What's in this PR
CMakeLists.txt: new optionENABLE_FIPS_MODE(default Off). When On, forcesCRYPTO_BACKEND=openssl(Botan rejected with helpful error) and requires OpenSSL 3.x.src/lib/CMakeLists.txt: definesRNP_FIPS_MODEonlibrnp-obj(PUBLIC). Propagates tolibrnpandlibrnp-staticviaINTERFACE_COMPILE_DEFINITIONS(added to the existing foreach that copies interface properties).src/lib/sec_profile.cpp: whenRNP_FIPS_MODEis defined, theSecurityContextconstructor addsDisabled-level rules for non-FIPS-approved algorithms:include/rnp/rnp.h+src/lib/rnp.cpp: new FFI functionrnp_is_fips_mode_enabled()returning whether the library was built withENABLE_FIPS_MODE=On.docs/security.adoc(new): documents the certification boundary, required OpenSSL version, how to enable, how to query, and current limitations. Makes clear that rnp is a consumer of OpenSSL's validated FIPS provider module, not a validated module itself.src/tests/ffi.cpp: new testtest_ffi_fips_mode_queryverifying the FFI query..github/workflows/fips-mode.yml(new): CI leg building and testing under-DENABLE_FIPS_MODE=On.Why
FIPS 140-3 certification (or its successors) is required for OpenPGP libraries used in US federal, Canadian federal, and many regulated industries. Without a FIPS mode, rnp is invisible to that procurement channel. This PR doesn't get us to certification, but it puts the right bones in place: a clean compile-time switch, an algorithm policy expressed through the existing security-rule registry (not scattered
#ifdefs), and a clear certification-boundary statement.Out of scope (follow-up PRs)
Test plan
-DCRYPTO_BACKEND=openssl -DENABLE_FIPS_MODE=Onsucceeds (Botan correctly rejected, OpenSSL 1.1.1 would be rejected)test_ffi_fips_mode_querypasses (returns 1 in FIPS build, 0 in default build via#if defined(RNP_FIPS_MODE))fips-modeworkflowrnp_testsunder FIPS mode currently fails ~37 tests because they use disabled algorithms (DSA, EdDSA, MD5, SHA1, etc.). Adapting these tests is follow-up work; the foundation PR deliberately lands the policy first so we can see what breaks.