Shorter topoh callid - ff1-alnum62 - #4229
Open
digipigeon wants to merge 2 commits into
Open
Conversation
This commit introduces a new codec for encoding and decoding Call-IDs using the FF1 algorithm, which preserves radix and enhances security. The following changes were made: - Implemented `topo_hiding_codec.c` and `topo_hiding_codec.h` to define the FF1 encoding scheme and related functions. - Updated `topo_hiding_logic.c` to utilize the new codec for encoding and decoding Call-IDs, replacing the previous XOR-based method. - Modified `topology_hiding.c` to include configuration parameters for the new encoding scheme and initialize the codec during module initialization. - Added unit tests for the new encoding and decoding functions to ensure correctness. This enhancement allows for more secure handling of Call-IDs in the topology hiding module, supporting both legacy and new encoding schemes.
…module - Update bounds for FF1 processing and structured payloads in documentation. - Introduce safe legacy plaintext checks to prevent malformed SIP headers. - Adjust maximum lengths for plaintext and structured payloads in codec implementation. - Add warning for loop protection's impact on Call-ID encoding.
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
This PR adds an optional
ff1-alnum62Call-ID encoding scheme to thetopology_hidingmodule.The new scheme reduces the size of topology-hiding Call-IDs compared with the existing XOR/word64 encoding, particularly when Call-IDs are processed by multiple topology-hiding hops. The historical
xor-word64scheme remains the default for backward compatibility.Details
When topology hiding is enabled with the
Cflag, OpenSIPS replaces the original Call-ID before sending the dialog toward the callee. The existing implementation applies repeating-key XOR followed by word64 encoding.Word64 expands the encoded data by approximately 33%. This can produce unnecessarily long Call-IDs, especially when several topology-hiding systems successively encode an already encoded Call-ID.
For example, using the same two-character prefix for both methods:
xor-word64lengthff1-alnum62lengthThe new implementation also avoids modifying the original Call-ID buffer while encoding it.
This is an optional new feature rather than a change to the default wire format.
Solution
The PR introduces the
th_callid_encode_schememodule parameter with two supported values:xor-word64: the existing encoding and the default.ff1-alnum62: the new AES-256 FF1 format-preserving encoding.The new format is:
The marker identifies how the input was represented:
A: the original Call-ID was already alphanumeric and was encrypted directly in radix 62.B: an RFC 3261-compliant Call-ID containing punctuation or@was ranked in the complete SIP Call-ID domain, converted to radix 62 and encrypted.C: the input could not use the FF1 domain and was encoded using the historical XOR/word64 fallback.RFC 3261 defines a Call-ID as:
The implementation supports the complete RFC
wordalphabet and preserves the position of the optional@through reversible domain ranking.FF1 uses:
The configured
th_callid_passwdis used as HKDF input with a fixed, versioned and module-specific salt and context. The default password is rejected forff1-alnum62, and a high-entropy password of at least 32 characters is recommended.Additional robustness measures include:
The implementation includes tests for:
@separator;SIPp end-to-end tests were also performed using complete:
dialogs. Both the old and new schemes completed all tested dialogs without SIPp errors. Additional full-dialog tests covered RFC punctuation/
@markerBand non-compliant fallback markerC.Compatibility
The default remains
xor-word64, so existing configurations retain their current wire format and behavior.To enable the new scheme:
Compatibility considerations:
ff1-alnum62requires an alphanumeric, non-emptyth_callid_prefix. The existing default prefix contains_, so deployments enabling FF1 must configure a new prefix.Cand the legacy fallback. Control characters are rejected.th_callid_loop_protectionis enabled, its internal separator is outside the RFC Call-ID alphabet. The combined Call-ID and loop tag therefore use markerC. Loop protection remains functional but does not receive the FF1 length reduction.libcrypto, even when the default legacy scheme is selected.xor-word64output remains byte-for-byte compatible for compliant existing Call-IDs.Closing issues
No linked issue.