diff options
Diffstat (limited to 'secure/lib/libdes/ecb_enc.c')
-rw-r--r-- | secure/lib/libdes/ecb_enc.c | 84 |
1 files changed, 55 insertions, 29 deletions
diff --git a/secure/lib/libdes/ecb_enc.c b/secure/lib/libdes/ecb_enc.c index d7eaa96..a39c6ed 100644 --- a/secure/lib/libdes/ecb_enc.c +++ b/secure/lib/libdes/ecb_enc.c @@ -1,5 +1,5 @@ -/* lib/des/ecb_enc.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/ecb_enc.c */ +/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au) * All rights reserved. * * This file is part of an SSL implementation written @@ -48,7 +48,24 @@ #include "des_locl.h" #include "spr.h" -const char *DES_version="libdes v 3.22 - 95/11/29 - eay"; +char *libdes_version="libdes v 3.24 - 20-Apr-1996 - eay"; +char *DES_version="DES part of SSLeay 0.6.1 12-Jul-1996"; + +char *des_options() + { +#ifdef DES_PTR + if (sizeof(DES_LONG) != sizeof(long)) + return("des(ptr,int)"); + else + return("des(ptr,long)"); +#else + if (sizeof(DES_LONG) != sizeof(long)) + return("des(idx,int)"); + else + return("des(idx,long)"); +#endif + } + void des_ecb_encrypt(input, output, ks, encrypt) des_cblock (*input); @@ -56,38 +73,38 @@ des_cblock (*output); des_key_schedule ks; int encrypt; { - register unsigned long l0,l1; + register DES_LONG l; register unsigned char *in,*out; - unsigned long ll[2]; + DES_LONG ll[2]; in=(unsigned char *)input; out=(unsigned char *)output; - c2l(in,l0); ll[0]=l0; - c2l(in,l1); ll[1]=l1; + c2l(in,l); ll[0]=l; + c2l(in,l); ll[1]=l; des_encrypt(ll,ks,encrypt); - l0=ll[0]; l2c(l0,out); - l1=ll[1]; l2c(l1,out); - l0=l1=ll[0]=ll[1]=0; + l=ll[0]; l2c(l,out); + l=ll[1]; l2c(l,out); + l=ll[0]=ll[1]=0; } void des_encrypt(data, ks, encrypt) -unsigned long *data; +DES_LONG *data; des_key_schedule ks; int encrypt; { - register unsigned long l,r,t,u; -#ifdef DES_USE_PTR + register DES_LONG l,r,t,u; +#ifdef DES_PTR register unsigned char *des_SP=(unsigned char *)des_SPtrans; #endif -#ifdef MSDOS +#ifdef undef union fudge { - unsigned long l; + DES_LONG l; unsigned short s[2]; unsigned char c[4]; } U,T; #endif register int i; - register unsigned long *s; + register DES_LONG *s; u=data[0]; r=data[1]; @@ -106,23 +123,28 @@ int encrypt; l&=0xffffffffL; r&=0xffffffffL; - s=(unsigned long *)ks; + s=(DES_LONG *)ks; /* I don't know if it is worth the effort of loop unrolling the - * inner loop */ + * inner loop + */ if (encrypt) { - for (i=0; i<32; i+=4) + for (i=0; i<32; i+=8) { D_ENCRYPT(l,r,i+0); /* 1 */ D_ENCRYPT(r,l,i+2); /* 2 */ + D_ENCRYPT(l,r,i+4); /* 3 */ + D_ENCRYPT(r,l,i+6); /* 4 */ } } else { - for (i=30; i>0; i-=4) + for (i=30; i>0; i-=8) { D_ENCRYPT(l,r,i-0); /* 16 */ D_ENCRYPT(r,l,i-2); /* 15 */ + D_ENCRYPT(l,r,i-4); /* 14 */ + D_ENCRYPT(r,l,i-6); /* 13 */ } } l=(l>>1)|(l<<31); @@ -138,23 +160,23 @@ int encrypt; } void des_encrypt2(data, ks, encrypt) -unsigned long *data; +DES_LONG *data; des_key_schedule ks; int encrypt; { - register unsigned long l,r,t,u; -#ifdef DES_USE_PTR + register DES_LONG l,r,t,u; +#ifdef DES_PTR register unsigned char *des_SP=(unsigned char *)des_SPtrans; #endif -#ifdef MSDOS +#ifdef undef union fudge { - unsigned long l; + DES_LONG l; unsigned short s[2]; unsigned char c[4]; } U,T; #endif register int i; - register unsigned long *s; + register DES_LONG *s; u=data[0]; r=data[1]; @@ -172,23 +194,27 @@ int encrypt; l&=0xffffffffL; r&=0xffffffffL; - s=(unsigned long *)ks; + s=(DES_LONG *)ks; /* I don't know if it is worth the effort of loop unrolling the * inner loop */ if (encrypt) { - for (i=0; i<32; i+=4) + for (i=0; i<32; i+=8) { D_ENCRYPT(l,r,i+0); /* 1 */ D_ENCRYPT(r,l,i+2); /* 2 */ + D_ENCRYPT(l,r,i+4); /* 3 */ + D_ENCRYPT(r,l,i+6); /* 4 */ } } else { - for (i=30; i>0; i-=4) + for (i=30; i>0; i-=8) { D_ENCRYPT(l,r,i-0); /* 16 */ D_ENCRYPT(r,l,i-2); /* 15 */ + D_ENCRYPT(l,r,i-4); /* 14 */ + D_ENCRYPT(r,l,i-6); /* 13 */ } } l=(l>>1)|(l<<31); |