[Hardware] The market of ASICs (One GigaKey / Second?)
jbass at dmsd.com
jbass at dmsd.com
Mon Aug 9 00:51:53 EDT 2004
Hi Guys,
Here is RC5Test.c which goes with the RC5Gen.c tool I previously
posted. The RC5Gen tool outputs an extra "]" that needs to be
removed.
The VHDL tool also created as many L terms as S terms, so the
wires didn't have any extra logic, plus 26 E terms, and function
calls for the 26 bit shift registers.
John
/*
* Testbench for RC5 core
* John L. Bass, Copyright 2001
* compiles as: cc -O3 -DTest40 RC5Test.c
*/
#define RB(x) \
(((x) >> 24) | (((x) >> 8) & 0x0000FF00) | \
(((x) << 8) & 0x00FF0000) | ((x) << 24))
#define ROTL3(x) ((x << 3) | (x >> 29))
#define ROTL(x,n) (((x) << (n % 32)) | ((x) >> (32-(n % 32))))
main()
{
unsigned long L0, L1, E0, E1;
unsigned long S26, S27, S28, S29;
unsigned long S30, S31, S32, S33, S34, S35, S36, S37, S38, S39;
unsigned long S40, S41, S42, S43, S44, S45, S46, S47, S48, S49;
unsigned long S50, S51, S52, S53, S54, S55, S56, S57, S58, S59;
unsigned long S60, S61, S62, S63, S64, S65, S66, S67, S68, S69;
unsigned long S70, S71, S72, S73, S74, S75, S76, S77, S78, S79;
unsigned long S80, S81, S82, S83, S84, S85, S86, S87, S88, S89;
unsigned long S90, S91, S92, S93, S94, S95, S96, S97, S98, S99;
unsigned long S100, S101, S102, S103;
unsigned long key0 = 0x0;
unsigned long key1 = 0x0;
#ifdef Test40
/* plain text is: 54 68 65 20 75 6e 6b 6e */
/* IV text is: f6 75 17 1a 59 b7 ea d0 */
unsigned long plain0 = 0x20656854 ^ 0x1a1775f6;
unsigned long plain1 = 0x6e6b6e75 ^ 0xd0eab759;
/* cypher text is: b4 0a 53 88 b1 38 82 ad */
unsigned long cypher0 = 0x88530ab4;
unsigned long cypher1 = 0xad8238b1;
unsigned long long max = 0xffffffffff;
unsigned long long count = 0x43d2000000;
#endif
#ifdef Test48
/* plain text is: 54 68 65 20 75 6e 6b 6e */
/* IV text is: 23 8c 3c c9 b0 fd 9f 9e */
unsigned long plain0 = 0x20656854 ^ 0xc93c8c23;
unsigned long plain1 = 0x6e6b6e75 ^ 0x9e9ffdb0;
/* cypher text is: bf 88 86 d2 a9 50 84 1c */
unsigned long cypher0 = 0xd28688bf;
unsigned long cypher1 = 0x1c8450a9;
unsigned long long max = 0xffffffffffff;
unsigned long long count = 0x510678040000;
#endif
#ifdef Test56
/* plain text is: 54 68 65 20 75 6e 6b 6e */
/* IV text is: fb b2 e9 e4 12 d0 ec bc */
unsigned long plain0 = 0x20656854 ^ 0xe4e9b2fb;
unsigned long plain1 = 0x6e6b6e75 ^ 0xbcecd012;
/* cypher text is: 39 de 1b 56 3f 1d 5c 25 */
unsigned long cypher0 = 0x561bde39;
unsigned long cypher1 = 0x255c1d3f;
unsigned long long max = 0xffffffffffffff;
/* key is: 14 11 b3 5a 9a 98 da */
unsigned long long count = 0xda989a5a000000;
#endif
#ifdef Test64
/* plain text is: 54 68 65 20 75 6e 6b 6e */
/* IV text is: d9 a5 39 f8 c1 78 1f c4 */
unsigned long plain0 = 0x20656854 ^ 0xf839a5d9;
unsigned long plain1 = 0x6e6b6e75 ^ 0xc41f78c1;
/* cypher text is: 41 e0 4b b7 29 ef 6d 49 */
unsigned long cypher0 = 0xb74be041;
unsigned long cypher1 = 0x496def29;
unsigned long long max = 0xffffffffffffffff;
/* key is: 82 e5 1b 9f 9c c7 18 f9 */
unsigned long long count = 0xf918c79c9f000000;
#endif
/*
* constants produced by round 0
* const RC5_WORD P = 0xB7E15163;
* const RC5_WORD Q = 0x9E3779B9;
* S[0] = P;
* for (i=1;i<26;i++)
* S[i] = S[i-1] + Q;
*/
while (++count < max)
{
if((count & 0xfffff) == 0) { printf("0x%08x 0x%08x\r",RB(count&0xffffffff), RB(count>>32)); fflush(0); }
#include "RC5Core.c"
/* test for found key */
if (cypher0 == E0 && cypher1 == E1)
break;
}
printf("0x%08x 0x%08x\n",RB(key0), RB(key1));
}
More information about the Hardware
mailing list