Skip to content

ffi: security rule enumeration API + FIPS mode foundation - #2424

Open
ronaldtse wants to merge 9 commits into
mainfrom
weak-cipher-reporting
Open

ffi: security rule enumeration API + FIPS mode foundation#2424
ronaldtse wants to merge 9 commits into
mainfrom
weak-cipher-reporting

Conversation

@ronaldtse

@ronaldtse ronaldtse commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Two related security-profile changes, combined for one review (formerly #2424 + #2427):

  1. Security rule enumeration APIrnp_get_security_rule_count() / rnp_get_security_rule_at(): enumerate the active security profile's rules (default SHA-1/MD5 rules plus user-added), covering hash/symmetric/public-key feature types, levels, timestamps and flags.
  2. FIPS-compliant mode foundationENABLE_FIPS_MODE CMake switch + rnp_is_fips_mode_enabled(): compile-time tightening of the default SecurityProfile (non-FIPS algorithms Disabled, OpenSSL backend only). See docs/security.adoc for the certification boundary — rnp consumes OpenSSL's FIPS provider, it is not a validated module itself.

Test plan

  • Enumeration tests cover PublicKey branch and PROHIBITED level
  • FIPS default rule set tested under ENABLE_FIPS_MODE build
  • CI matrix green

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.78082% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.49%. Comparing base (ce33cc6) to head (3fdd8c3).

Files with missing lines Patch % Lines
src/lib/rnp.cpp 91.54% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2424      +/-   ##
==========================================
+ Coverage   85.44%   85.49%   +0.04%     
==========================================
  Files         125      125              
  Lines       22962    23033      +71     
==========================================
+ Hits        19620    19691      +71     
  Misses       3342     3342              

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

@ronaldtse
ronaldtse requested review from antonsviridenko and ni4 July 31, 2026 16:20
@ronaldtse
ronaldtse force-pushed the weak-cipher-reporting branch from aad6962 to e34ce5b Compare August 1, 2026 08:23

@ni4 ni4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@ronaldtse
ronaldtse force-pushed the weak-cipher-reporting branch 2 times, most recently from feb9fbf to 6be024f Compare August 9, 2026 23:06
@ronaldtse
ronaldtse force-pushed the weak-cipher-reporting branch from 6be024f to c850f32 Compare August 20, 2026 10:11
@ronaldtse ronaldtse changed the title ffi: add security rule enumeration API ffi: security rule enumeration API + FIPS mode foundation Aug 20, 2026
@ronaldtse
ronaldtse force-pushed the weak-cipher-reporting branch from cd67f7d to c69d8ba Compare August 20, 2026 22:47
@ronaldtse
ronaldtse force-pushed the weak-cipher-reporting branch from 1f2f722 to e7f2b5a Compare August 29, 2026 01:42
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.
…#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.
When librnp-obj has no INTERFACE_COMPILE_DEFINITIONS set (any non-FIPS
build), get_target_property() leaves val as the literal 'val-NOTFOUND'.
set_property() then propagated it as a define, so every consumer target
compiled with -Dval-NOTFOUND, defining a macro 'val' that broke any
translation unit using 'val' as a parameter name (rnpcpp.hpp, rnpcfg.h,
...). All Linux/macOS/CodeQL builds failed with 'expected unqualified-id
before - token'.

Skip properties that come back *-NOTFOUND.
Main's lint now runs the clang-format 11.1.0 binary (a6b0b99); these
files were formatted under the previous 11.0.x pin and drifted.
…ecks

str_to_cipher()/str_to_hash_alg()/str_to_pubkey_alg() fold a backend
availability check into name resolution, so under the OpenSSL FIPS
provider every prohibited algorithm failed to resolve and
rnp_get_security_rule() returned RNP_ERROR_BAD_PARAMETERS for exactly
the algorithms whose rules users need to query (test_ffi_fips_mode_
default_rules, test_ffi_security_rule_enumeration).

get_feature_sec_value() now resolves via the name tables directly;
availability stays where it belongs, in the *_supported() queries.

Also restrict the fips-mode workflow's test step to the FIPS/security
tests: the provider prohibits legacy algorithms, so legacy fixtures
(SHA-1 signatures, EdDSA/Curve25519 keyrings, IDEA ...) cannot pass in
that job by design.
The FIPS default profile appends 12 Disabled rules and disables MD5/
SHA1 from time 0, so queries before the regular insecure cutoffs and
the rule-removal counts differ under RNP_FIPS_MODE. Guard the affected
assertions and match enumerated rules by from/flags instead of name
alone. Verified locally with -DENABLE_FIPS_MODE=On against OpenSSL 3
(both tests pass in FIPS and non-FIPS builds).
@ronaldtse
ronaldtse force-pushed the weak-cipher-reporting branch from e7f2b5a to 3fdd8c3 Compare August 30, 2026 20:37
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