source: trunk/cscrypt/rc6.h@ 3996

Last change on this file since 3996 was 3996, checked in by hapeba, 10 years ago

fixed Compilation of ppc

File size: 1.8 KB
Line 
1/* rc6 (TM)
2* Unoptimized sample implementation of Ron Rivest's submission to the
3* AES bakeoff.
4*
5* Salvo Salasio, 19 June 1998
6*
7* Intellectual property notes: The name of the algorithm (RC6) is
8* trademarked; any property rights to the algorithm or the trademark
9* should be discussed with discussed with the authors of the defining
10* paper "The RC6(TM) Block Cipher": Ronald L. Rivest (MIT),
11* M.J.B. Robshaw (RSA Labs), R. Sidney (RSA Labs), and Y.L. Yin (RSA Labs),
12* distributed 18 June 1998 and available from the lead author's web site.
13*
14* This sample implementation is placed in the public domain by the author,
15* Salvo Salasio. The ROTL and ROTR definitions were cribbed from RSA Labs'
16* RC5 reference implementation.
17*/
18
19/* RC6 is parameterized for w-bit words, b bytes of key, and
20 * r rounds. The AES version of RC6 specifies b=16, 24, or 32;
21 * w=32; and r=20.
22 */
23
24#define w 32 /* word size in bits */
25#define r 20 /* based on security estimates */
26
27#define P32 0xB7E15163 /* Magic constants for key setup */
28#define Q32 0x9E3779B9
29
30/* derived constants */
31#define bytes (w / 8) /* bytes per word */
32#define c ((b + bytes - 1) / bytes) /* key in words, rounded up */
33#define R24 (2 * r + 4)
34#define lgw 5 /* log2(w) -- wussed out */
35
36#define rc6keylen R24 - 1 /* Key schedule */
37
38typedef unsigned int RC6KEY[rc6keylen];
39
40/*
41 * K=plain key
42 * b=plain key len
43 * S=prepared key by setup
44 * pt=uncrypted data
45 * ct=crypted data
46 * block size is always 16bytes
47 */
48void rc6_key_setup(unsigned char *K, int b, unsigned int *S);
49void rc6_block_encrypt(unsigned int *pt, unsigned int *ct, unsigned int *S);
50void rc6_block_decrypt(unsigned int *ct, unsigned int *pt, unsigned int *S);
51
Note: See TracBrowser for help on using the repository browser.