Eric Rescorla <[EMAIL PROTECTED]> writes:

>There are a set of techniques that allow you to encrypt elements of arbitrary
>sets back onto that set.

... and most of them seem to be excessively complicated for what they end up
achieving.  Just for reference the mechanism from the sci.crypt thread of more
than a decade ago was:

    KSG_RANGE = ( 256 / RANGE ) * RANGE;

        val = ksg();
    while( val >= KSG_RANGE );

  The worst-case scenario is when RANGE = 129, when nearly 50% of the ksg()
  output will be discarded.  A more typical case when RANGE = 96 (ASCII text)
  loses 25% of the output, and RANGE = 10 (digits) loses 2% of the output. The
  full process then becomes:


        val = ksg();
    while( val >= KSG_RANGE );
    cipher = ( ( ( plain - BASE ) + val ) % RANGE ) + BASE;


        val = ksg();
    while( val >= KSG_RANGE );
    plain = ( ( ( cipher - BASE ) - val ) % RANGE );
    while( plain < 0 )
        plain += RANGE;
    plain += BASE; 
This takes any cipher (block or stream) and, by using it as a KSG, allows
encryption of arbitrary (including discontinuous) data ranges.

Another advantage of the KSG use is that you can precalculate the key stream
offline, the implementation I used at the time pre-generated 4K of keystream
and then used it to encrypt bursty text messages with real-time constraints
that didn't allow for pauses to run the cipher.

(The thread contains lots of tweaks and variations of this).


The Cryptography Mailing List
Unsubscribe by sending "unsubscribe cryptography" to [EMAIL PROTECTED]

Reply via email to