[Hardware] The market of ASICs (One GigaKey / Second?)

Dan Oetting dan_oetting at uswest.net
Sat Aug 7 11:15:48 EDT 2004


On Aug 7, 2004, at 3:16 AM, david fleischer wrote:

> Hi,
> I was wondering, has anyone done analysis of the code
> that is available? (the source code) There is the
> assembly code and also an ansiC version, but little if
> any description of which part goes with which.
> Am I supposed to figure this out from the code alone?

What type of analysis are you looking for? One of the first thing I did 
when starting to work on optimizing the cores was build a simple 
reference core to understand what was going on. Here is my RC5-64 
reference core. The only major change for RC5-72 is the key and L[ ] 
need to be 3 words (big enough to hold 72 bits) instead of 2 and the 
index j in the inner loop needs to cycle 0,1,2,0,1,2... This should 
give you an idea of what the hardware needs to do.

#include "RC5UnitWork.h"	// interface definitions
#include "rotate.h"			// Inline rotate macros for most platforms

// reverse the bytes in a word (belongs in rotate.h)
#define reverse_bytes(x) \
	((((x) >> 24) & 0x000000FF) | \
	 (((x) >>  8) & 0x0000FF00) | \
	 (((x) <<  8) & 0x00FF0000) | \
	 (((x) << 24) & 0xFF000000))

WorkPrototype RC5_Reference;
unsigned long RC5_Reference( RC5UnitWork *work, unsigned long 
itterations )
{
	const RC5_WORD P = 0xB7E15163;
	const RC5_WORD Q = 0x9E3779B9;
	
	RC5_WORD S[26],L[2];
	RC5_WORD A, B;
	
	int i, j, k;
	unsigned long count;

	count = itterations;


	while (count)
	{
		/* round 0 */
		S[0] = P;
		for (i=1;i<26;i++)
			S[i] = S[i-1] + Q;

		L[0] = work->L0.lo;
		L[1] = work->L0.hi;
		
		/* rounds 1,2,3 */
		A = B = 0;
		j = 0;
		for (k=1;k<4;k++)
		{
			for (i=j=0;i<26;i++,j=1-j)
			{
				A = S[i] = ROTL3(S[i] + A + B);
				B = L[j] = ROTL(L[j] + A + B, A + B);
			}
		}
		
		/* encryption */
		A = work->plain.lo + S[0];
		B = work->plain.hi + S[1];

		
		for (i=2; i<26; i+=2)
		{
			A = ROTL(A ^ B, B) + S[i];
			B = ROTL(B ^ A, A) + S[i+1];
		}

                 /* test for found key */
		if ((A == work->cypher.lo) && (B == work->cypher.hi))
			break;
		
		/* increment key */
		work->L0.hi = reverse_bytes(reverse_bytes(work->L0.hi)+1);
		if (work->L0.hi == 0)
			work->L0.lo = reverse_bytes(reverse_bytes(work->L0.lo)+1);
		
		count--;
	}/* while (count) */

	return (itterations - count);
}



More information about the Hardware mailing list