RC6 Encryption
Site Map Feedback
Up Scrambler CryptBytes RC4 RC6

Effective Encryption

I've put together a simple class that will compress, encrypt, and turn it into a text string that can be simply stored in a database or sent through the Internet.
RC6 is trademark of RSA Data Security, Inc.
They're American, so they're patenting it, too.

The difficulty of breaking RC6 is estimated as being min(2^(8*KeyBytes),2^704)
The algorithm can have many variants.
The variant is described as follows:
RC6-/W/R/B
W = Word Size in bits (Default is 32) I made a version with a templated base class to handle different values of W, but found no advantages, particularly as there are no official test vectors for the non-32 bit algorithm.
R = Number of Rounds (R=(Depth+2)<<2; Minimum is Depth=0 (R=4), Default is Depth=3 (R=20), my code has maximum Depth=65535 (R=262148) which would use a 2MB State Table.
B = Key Length in Bytes ((0 <= B <= 255) Default is 16)
AES Submission required W=32 and R=20

The constructor handles the parameter ranges by taking integer and creating a valid value from it:
So the number of rounds, R, can be entered as a Depth; The actual value used is R=(Depth+2)<<2; which puts it in the correct range.
The Key will be truncated if it exceeds 255 Bytes to suit the RC6 Standard.

Usage:
  CString key("Patently obvious");
  CString S("This is the message that will get encrypted.");
  CRC6(Key, S); // This encrypts S using default RC6 settings. The length of S increases by one Byte (unless S is an empty string) - the first Byte is 0xFF to indicate encrypted data.
  ...do something with S here
  CRC6(Key, S); // This decrypts S.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


 (3488) Last modified: Tue, 03 Feb 2009 18:26:26 +0000