diff options
author | Matt Turner <mattst88@gmail.com> | 2008-11-11 23:00:38 +0000 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2008-11-11 23:00:38 +0000 |
commit | 5a7f0d2e7b4265153ccc70051bdae8b851617ede (patch) | |
tree | b29e974f32a1ddba669359100bb6748c72cbfd1e /idea.c | |
parent | bef5cb4c61e44ee8784f233eb2ec230c776dbda6 (diff) |
Remove stupid datatypes. Begin code cleanup
git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@5 0d43b9a7-5ab2-4d7b-af9d-f64450cef757
Diffstat (limited to 'idea.c')
-rw-r--r-- | idea.c | 92 |
1 files changed, 46 insertions, 46 deletions
@@ -22,14 +22,14 @@ void DoIDEA(void) IDEAStruct *locideastruct; /* Loc pointer to global structure */ int i; IDEAkey Z,DK; -u16 userkey[8]; -ulong accumtime; +uint16_t userkey[8]; +unsigned long accumtime; double iterations; char *errorcontext; int systemerror; -faruchar *plain1; /* First plaintext buffer */ -faruchar *crypt1; /* Encryption buffer */ -faruchar *plain2; /* Second plaintext buffer */ +unsigned char *plain1; /* First plaintext buffer */ +unsigned char *crypt1; /* Encryption buffer */ +unsigned char *plain2; /* Second plaintext buffer */ /* ** Link to global data @@ -45,14 +45,14 @@ errorcontext="CPU:IDEA"; ** Re-init random-number generator. */ /* randnum(3L); */ -randnum((int32)3); +randnum(3); /* ** Build an encryption/decryption key */ for (i=0;i<8;i++) - /* userkey[i]=(u16)(abs_randwc(60000L) & 0xFFFF); */ - userkey[i]=(u16)(abs_randwc((int32)60000) & 0xFFFF); + /* userkey[i]=(uint16_t)(abs_randwc(60000L) & 0xFFFF); */ + userkey[i]=(uint16_t)(abs_randwc((int32_t)60000) & 0xFFFF); for(i=0;i<KEYLEN;i++) Z[i]=0; @@ -69,27 +69,27 @@ de_key_idea(Z,DK); ** So, plain1 and plain2 should match. ** Also, fill up plain1 with sample text. */ -plain1=(faruchar *)AllocateMemory(locideastruct->arraysize,&systemerror); +plain1=(unsigned char *)AllocateMemory(locideastruct->arraysize,&systemerror); if(systemerror) { ReportError(errorcontext,systemerror); ErrorExit(); } -crypt1=(faruchar *)AllocateMemory(locideastruct->arraysize,&systemerror); +crypt1=(unsigned char *)AllocateMemory(locideastruct->arraysize,&systemerror); if(systemerror) { ReportError(errorcontext,systemerror); - FreeMemory((farvoid *)plain1,&systemerror); + FreeMemory((void *)plain1,&systemerror); ErrorExit(); } -plain2=(faruchar *)AllocateMemory(locideastruct->arraysize,&systemerror); +plain2=(unsigned char *)AllocateMemory(locideastruct->arraysize,&systemerror); if(systemerror) { ReportError(errorcontext,systemerror); - FreeMemory((farvoid *)plain1,&systemerror); - FreeMemory((farvoid *)crypt1,&systemerror); + FreeMemory((void *)plain1,&systemerror); + FreeMemory((void *)crypt1,&systemerror); ErrorExit(); } /* @@ -97,7 +97,7 @@ if(systemerror) ** the array up with random numbers. */ for(i=0;i<locideastruct->arraysize;i++) - plain1[i]=(uchar)(abs_randwc(255) & 0xFF); + plain1[i]=(unsigned char)(abs_randwc(255) & 0xFF); /* ** See if we need to perform self adjustment loop. @@ -135,9 +135,9 @@ do { ** Clean up, calculate results, and go home. Be sure to ** show that we don't have to rerun adjustment code. */ -FreeMemory((farvoid *)plain1,&systemerror); -FreeMemory((farvoid *)crypt1,&systemerror); -FreeMemory((farvoid *)plain2,&systemerror); +FreeMemory((void *)plain1,&systemerror); +FreeMemory((void *)crypt1,&systemerror); +FreeMemory((void *)plain2,&systemerror); locideastruct->iterspersec=iterations / TicksToFracSecs(accumtime); if(locideastruct->adjust==0) @@ -154,17 +154,17 @@ return; ** Actually, a single iteration is one encryption and one ** decryption. */ -static ulong DoIDEAIteration(faruchar *plain1, - faruchar *crypt1, - faruchar *plain2, - ulong arraysize, - ulong nloops, +static unsigned long DoIDEAIteration(unsigned char *plain1, + unsigned char *crypt1, + unsigned char *plain2, + unsigned long arraysize, + unsigned long nloops, IDEAkey Z, IDEAkey DK) { -register ulong i; -register ulong j; -ulong elapsed; +register unsigned long i; +register unsigned long j; +unsigned long elapsed; #ifdef DEBUG int status=0; #endif @@ -179,11 +179,11 @@ elapsed=StartStopwatch(); */ for(i=0;i<nloops;i++) { - for(j=0;j<arraysize;j+=(sizeof(u16)*4)) - cipher_idea((u16 *)(plain1+j),(u16 *)(crypt1+j),Z); /* Encrypt */ + for(j=0;j<arraysize;j+=(sizeof(uint16_t)*4)) + cipher_idea((uint16_t *)(plain1+j),(uint16_t *)(crypt1+j),Z); /* Encrypt */ - for(j=0;j<arraysize;j+=(sizeof(u16)*4)) - cipher_idea((u16 *)(crypt1+j),(u16 *)(plain2+j),DK); /* Decrypt */ + for(j=0;j<arraysize;j+=(sizeof(uint16_t)*4)) + cipher_idea((uint16_t *)(crypt1+j),(uint16_t *)(plain2+j),DK); /* Decrypt */ } #ifdef DEBUG @@ -208,14 +208,14 @@ return(StopStopwatch(elapsed)); ** on the assumption that untaken branches are cheaper than taken ** branches, and that the compiler doesn't schedule branches. */ -static u16 mul(register u16 a, register u16 b) +static uint16_t mul(register uint16_t a, register uint16_t b) { -register u32 p; +register uint32_t p; if(a) { if(b) - { p=(u32)(a*b); + { p=(uint32_t)(a*b); b=low16(p); - a=(u16)(p>>16); + a=(uint16_t)(p>>16); return(b-a+(b<a)); } else @@ -233,10 +233,10 @@ else ** to avoid swapping the meaning of the registers. And ** some subtracts are changed to adds. */ -static u16 inv(u16 x) +static uint16_t inv(uint16_t x) { -u16 t0, t1; -u16 q, y; +uint16_t t0, t1; +uint16_t q, y; if(x<=1) return(x); /* 0 and 1 are self-inverse */ @@ -262,7 +262,7 @@ return(low16(1-t1)); ***************** ** Compute IDEA encryption subkeys Z */ -static void en_key_idea(u16 *userkey, u16 *Z) +static void en_key_idea(uint16_t *userkey, uint16_t *Z) { int i,j; @@ -290,9 +290,9 @@ static void de_key_idea(IDEAkey Z, IDEAkey DK) { IDEAkey TT; int j; -u16 t1, t2, t3; -u16 *p; -p=(u16 *)(TT+KEYLEN); +uint16_t t1, t2, t3; +uint16_t *p; +p=(uint16_t *)(TT+KEYLEN); t1=inv(*Z++); t2=-*Z++; @@ -349,13 +349,13 @@ return; ***************** ** IDEA encryption/decryption algorithm. */ -static void cipher_idea(u16 in[4], - u16 out[4], +static void cipher_idea(uint16_t in[4], + uint16_t out[4], register IDEAkey Z) { -register u16 x1, x2, x3, x4, t1, t2; -/* register u16 t16; -register u16 t32; */ +register uint16_t x1, x2, x3, x4, t1, t2; +/* register uint16_t t16; +register uint16_t t32; */ int r=ROUNDS; x1=*in++; |