diff options
Diffstat (limited to 'crypto/libdes/xcbc_enc.c')
-rw-r--r-- | crypto/libdes/xcbc_enc.c | 68 |
1 files changed, 28 insertions, 40 deletions
diff --git a/crypto/libdes/xcbc_enc.c b/crypto/libdes/xcbc_enc.c index 6a8626171dfb..51e17e6b8a64 100644 --- a/crypto/libdes/xcbc_enc.c +++ b/crypto/libdes/xcbc_enc.c @@ -1,9 +1,9 @@ /* crypto/des/xcbc_enc.c */ -/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written - * by Eric Young (eay@mincom.oz.au). + * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as @@ -11,7 +11,7 @@ * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@mincom.oz.au). + * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. @@ -31,12 +31,12 @@ * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by - * Eric Young (eay@mincom.oz.au)" + * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@mincom.oz.au)" + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -79,18 +79,14 @@ static unsigned char desx_white_in2out[256]={ 0xA7,0x1C,0xC9,0x09,0x69,0x9A,0x83,0xCF,0x29,0x39,0xB9,0xE9,0x4C,0xFF,0x43,0xAB, }; -void des_xwhite_in2out(des_key,in_white,out_white) -des_cblock (*des_key); -des_cblock (*in_white); -des_cblock (*out_white); +void des_xwhite_in2out(const_des_cblock *des_key, const_des_cblock *in_white, + des_cblock *out_white) { - unsigned char *key,*in,*out; int out0,out1; int i; - - key=(unsigned char *)des_key; - in=(unsigned char *)in_white; - out=(unsigned char *)out_white; + const unsigned char *key = &(*des_key)[0]; + const unsigned char *in = &(*in_white)[0]; + unsigned char *out = &(*out_white)[0]; out[0]=out[1]=out[2]=out[3]=out[4]=out[5]=out[6]=out[7]=0; out0=out1=0; @@ -111,36 +107,28 @@ des_cblock (*out_white); } } -void des_xcbc_encrypt(input, output, length, schedule, ivec, inw,outw,encrypt) -des_cblock (*input); -des_cblock (*output); -long length; -des_key_schedule schedule; -des_cblock (*ivec); -des_cblock (*inw); -des_cblock (*outw); -int encrypt; +void des_xcbc_encrypt(const unsigned char *in, unsigned char *out, + long length, des_key_schedule schedule, des_cblock *ivec, + const_des_cblock *inw, const_des_cblock *outw, int enc) { register DES_LONG tin0,tin1; register DES_LONG tout0,tout1,xor0,xor1; register DES_LONG inW0,inW1,outW0,outW1; - register unsigned char *in,*out; + register const unsigned char *in2; register long l=length; DES_LONG tin[2]; unsigned char *iv; - in=(unsigned char *)inw; - c2l(in,inW0); - c2l(in,inW1); - in=(unsigned char *)outw; - c2l(in,outW0); - c2l(in,outW1); + in2 = &(*inw)[0]; + c2l(in2,inW0); + c2l(in2,inW1); + in2 = &(*outw)[0]; + c2l(in2,outW0); + c2l(in2,outW1); - in=(unsigned char *)input; - out=(unsigned char *)output; - iv=(unsigned char *)ivec; + iv = &(*ivec)[0]; - if (encrypt) + if (enc) { c2l(iv,tout0); c2l(iv,tout1); @@ -150,7 +138,7 @@ int encrypt; c2l(in,tin1); tin0^=tout0^inW0; tin[0]=tin0; tin1^=tout1^inW1; tin[1]=tin1; - des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT); + des_encrypt(tin,schedule,DES_ENCRYPT); tout0=tin[0]^outW0; l2c(tout0,out); tout1=tin[1]^outW1; l2c(tout1,out); } @@ -159,11 +147,11 @@ int encrypt; c2ln(in,tin0,tin1,l+8); tin0^=tout0^inW0; tin[0]=tin0; tin1^=tout1^inW1; tin[1]=tin1; - des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT); + des_encrypt(tin,schedule,DES_ENCRYPT); tout0=tin[0]^outW0; l2c(tout0,out); tout1=tin[1]^outW1; l2c(tout1,out); } - iv=(unsigned char *)ivec; + iv = &(*ivec)[0]; l2c(tout0,iv); l2c(tout1,iv); } @@ -175,7 +163,7 @@ int encrypt; { c2l(in,tin0); tin[0]=tin0^outW0; c2l(in,tin1); tin[1]=tin1^outW1; - des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT); + des_encrypt(tin,schedule,DES_DECRYPT); tout0=tin[0]^xor0^inW0; tout1=tin[1]^xor1^inW1; l2c(tout0,out); @@ -187,7 +175,7 @@ int encrypt; { c2l(in,tin0); tin[0]=tin0^outW0; c2l(in,tin1); tin[1]=tin1^outW1; - des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT); + des_encrypt(tin,schedule,DES_DECRYPT); tout0=tin[0]^xor0^inW0; tout1=tin[1]^xor1^inW1; l2cn(tout0,tout1,out,l+8); @@ -195,7 +183,7 @@ int encrypt; xor1=tin1; } - iv=(unsigned char *)ivec; + iv = &(*ivec)[0]; l2c(xor0,iv); l2c(xor1,iv); } |