ffi: add security rule enumeration API - #2424
Open
ronaldtse wants to merge 3 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2424 +/- ##
==========================================
+ Coverage 85.36% 85.38% +0.01%
==========================================
Files 126 126
Lines 22861 22932 +71
==========================================
+ Hits 19516 19580 +64
- Misses 3345 3352 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ronaldtse
force-pushed
the
weak-cipher-reporting
branch
from
August 1, 2026 08:23
aad6962 to
e34ce5b
Compare
ronaldtse
force-pushed
the
weak-cipher-reporting
branch
from
August 4, 2026 16:24
81d3f11 to
feb9fbf
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
weak-cipher-reporting
branch
from
August 9, 2026 23:06
feb9fbf to
6be024f
Compare
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
Adds two FFI functions that let callers enumerate the security profile's rule list:
rnp_get_security_rule_count()— total number of rules (defaults + user-added)rnp_get_security_rule_at()— fetch one rule by index with type/name/level/from/flags fieldsCaller owns
typeandnamestrings; free viarnp_buffer_destroy.Why
Today the only way to inspect the active security profile is
rnp_get_security_rule(), which requires you to already know the feature type and name. There is no way to enumerate the built-in defaults (SHA-1,MD5,CAST5,3DES,IDEA,BLOWFISH,RIPEMD) or iterate the full rule list.This matters for:
Implementation
src/lib/sec_profile.{hpp,cpp}: addSecurityProfile::rules()returning a const ref to the internal vector.src/lib/rnp.cpp: add the two FFI functions. They reuse the existinghash_alg_map/symm_alg_map/pubkey_alg_maptables for feature int → name lookup, the existingret_str_value()helper for string allocation, and the existingRNP_SECURITY_*constants for output.src/tests/ffi.cpp: newtest_ffi_security_rule_enumerationcovering NULL checks, default count (3 hashes + 4 ciphers, +RIPEMD under crypto-refresh), out-of-range index, enumeration of MD5/CAST5/SHA1-data/SHA1-key rules, NULL output parameters, and that adding a rule is reflected in the count.Test plan
rnp_tests --gtest_filter=rnp_tests.test_ffi_security_rule_enumerationpasses locallyrnp_tests --gtest_filter=rnp_tests.test_ffi_security_profilestill passes (no regression)