I am trying to port an encryption routine to the Jackrabbit but keep getting the erroneous pointer error. I am sure that it is a stupid error that I will be mad that I didn’t see it, but can anyone clear this up and explain the problem clearly?
Thanks!
void encode(long* v, long k);
void decode(long v, long *k);
//////////////////////////////////////////////////
void main( void )
{
long v[2];//plaintext
long k[4];//key
k[0]=0;
k[1]=1;
k[2]=2;
k[3]=3;
v[0]=1111;
v[1]=2222;
printf("Before encode v[0]: %u
",v[0]);
printf("Before encode v[1]: %u
",v[1]);
encode(v,k);
printf("After encode v[0]: %u
",v[0]);
printf("After encode v[1]: %u
",v[1]);
decode(v,k);
printf("After decode v[0]: %u
",v[0]);
printf("After decode v[1]: %u
",v[1]);
}
//////////////////////////////////////////////////////////
void encode( long* v, long* k )
{
static long sum,delta, n,y,z; /* set up /
y=v[0];
z=v[1];
sum=0;
delta=0x9e3779b9;
n=32 ; / a key schedule constant */
while (n-->0)
{ /* basic cycle start */
sum += delta ;
y += (z<<4)+k[0] ^ z+sum ^ (z>>5)+k[1] ;
z += (y<<4)+k[2] ^ y+sum ^ (y>>5)+k[3] ; /* end cycle */
}
v[0]=y ;
v[1]=z ;
}
/////////////////////////////////////////////////////////
void decode( long* v,long* k )
{
static long n, sum, delta,y,z;
delta=0x9e3779b9 ;
y=v[0];
z=v[1];
sum=delta<<5;
n=32;
/* start cycle */
while (n-->0)
{
z-= (y<<4)+k[2] ^ y+sum ^ (y>>5)+k[3] ;
y-= (z<<4)+k[0] ^ z+sum ^ (z>>5)+k[1] ;
sum-=delta ;
}
/* end cycle */
v[0]=y ;
v[1]=z ;
}
/////////////////////////////////////////////////////////