9. SAS-RGM in SAS-RCS
by: saaiqSAS
Last Updated: 26/2/2025
When passing text to the SAS-RCS, the text can often contain ext-chars and the SAS-ROS step cannot process such ext-chars
that are not part of the Dynamic Key. Thus in SAS-RCS, RGM is used to overcome this by representing any ext-chars
interms of characters included in the Dynamic Key.
Example 9.1: Passing an ext-char through SAS-RGM
ext-char: Q
Base: base2
Dynamic key: { c, i, e, a, f, h, b, g, d }
[ 0, 1, 0, 1, 0, 1, 0, 1, 0 ]
Subsets:
0 → { c, e, f, b, d }
1 → { i, a, h, g }
base2 format of 'Q': 01010001
RGM encoded format of "01010001": ehdacfda
Notice how the RGM encoded value is now made up of characters from the Dynamic Key.
Now while the above example deals with a single character, consider a string with a mixture of ext-chars and local-chars.
We pass the entire string through RGM and produce an RGM encoded string, in which local-chars are kept as it is and only
ext-chars are processed, where processed ext-chars would now be strings and not a single character. How can we identify and
differentiate one another. To achieve this we introduce special characters called serps used to separate processed
ext-chars from the rest. The serps will sandwich the RGM encoded string, before including the string in the final output.
Thus upon encountering a serp, we know that the next characters until the next serp will be part of the RGM encoded string.
As SAS-ROS won't process ext-chars, the serps should also be taken within the Dynamic Key. Then, If
we characters used as serps also exist in a subset for RGM, we would be facing issues in the final output, as actual
characters of an RGM encoded string may contain serp characters, thus it would be impossible to identify actual serps
from ones inside an RGM encoded string. Thus a solution to this would be to not include any character chosen as serps in any
RGM subsets linked with a base unit (i.e. 1, 0).
Also a security concern can arise, if we use a single or a few characters as serps, as the final output may be prone to frequency
analysis, thus allowing adversaries to distinguish RGM encoded strings.
Hence to overcome all the obstacles mentioned, a RGM subset is created for just serps along with subsets for base units.
Hence every time a serp is needed, a random character can be selected from the subset linked with serps.
This method ensures that the number of serps used will increase with the key length and inroduces more securty with randomness.
Example 9.2: Subsets of SAS-RGM for base2
Base: base2
Dynamic key: { c, i, e, a, f, h, b, g, d }
[ 0, 1, 2, 0, 1, 2, 0, 1, 2 ]
Subsets:
0 → { c, a, b }
1 → { i, f, g }
serps → { e, h, d }
Thus for base2, 3 subsets will be made. For base10, 11 subsets will be made. For base16, 17 subsets will be made.
And for base64, 65 subsets will be made. Below is an example of how the final output can be with this implementation.
Example 9.3: Passing a string through SAS-RGM
String: fame
Base: base2
Dynamic key: { c, i, e, a, f, h, b, g, d }
[ 0, 1, 2, 0, 1, 2, 0, 1, 2 ]
Subsets:
0 → { c, a, b }
1 → { i, f, g }
serps → { e, h, d }
ext-chars: m
base2 format of 'm': 01101101
RGM encoded format of "01101101": cfibgfai
RGM passed output: fahcfibgfaiee
RGM passed format: fa|cfibgfai|e
serps used: h, e
Notice how in the 'output', local chars were kept as it is and only the ext-char was processed.
The above example demonstrates 'partial' RGM processing, where only ext-chars are process.
'full' RGM processing can also be implemented where all characters, both ext-chars and local-chars
are processed. In such case, serps at both the start and end of the RGM encoded strings is not necessary, thus
a single serp at either the start or end is enough to differentiate one RGM encoded string from another.
The example below demonstrates a sample 'full' RGM processing.
Example 9.4: Sample output for SAS-RGM full pass
(serp at end of RGM encoded string)
String: fame
RGM passed format: cfiggcb|igcbifa|cfibgfai|bbfiabg|
RGM passed output: cfiggcbdcfibgfaihigcbifae