diff --git a/lib/des/cbc3_enc.c b/lib/des/cbc3_enc.c index 11aa3ff4d..3b3f2821d 100644 --- a/lib/des/cbc3_enc.c +++ b/lib/des/cbc3_enc.c @@ -1,17 +1,22 @@ -/* lib/des/cbc3_enc.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/cbc3_enc.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -58,7 +69,7 @@ des_cblock (*iv1); des_cblock (*iv2); int encrypt; { - int off=(length-1)/8; + int off=((int)length-1)/8; long l8=((length+7)/8)*8; des_cblock niv1,niv2; diff --git a/lib/des/cbc_cksm.c b/lib/des/cbc_cksm.c index e5cf1b615..5dfa9b8a6 100644 --- a/lib/des/cbc_cksm.c +++ b/lib/des/cbc_cksm.c @@ -1,17 +1,22 @@ -/* lib/des/cbc_cksm.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/cbc_cksm.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE diff --git a/lib/des/cbc_enc.c b/lib/des/cbc_enc.c index 4cf7d66b1..e7a90ce98 100644 --- a/lib/des/cbc_enc.c +++ b/lib/des/cbc_enc.c @@ -1,17 +1,22 @@ -/* lib/des/cbc_enc.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/cbc_enc.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -70,15 +81,19 @@ int encrypt; { c2l(iv,tout0); c2l(iv,tout1); - for (; l>0; l-=8) + for (l-=8; l>=0; l-=8) { - if (l >= 8) - { - c2l(in,tin0); - c2l(in,tin1); - } - else - c2ln(in,tin0,tin1,l); + c2l(in,tin0); + c2l(in,tin1); + tin0^=tout0; tin[0]=tin0; + tin1^=tout1; tin[1]=tin1; + des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT); + tout0=tin[0]; l2c(tout0,out); + tout1=tin[1]; l2c(tout1,out); + } + if (l != -8) + { + c2ln(in,tin0,tin1,l+8); tin0^=tout0; tin[0]=tin0; tin1^=tout1; tin[1]=tin1; des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT); @@ -90,23 +105,29 @@ int encrypt; { c2l(iv,xor0); c2l(iv,xor1); - for (; l>0; l-=8) + for (l-=8; l>=0; l-=8) { c2l(in,tin0); tin[0]=tin0; c2l(in,tin1); tin[1]=tin1; des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT); tout0=tin[0]^xor0; tout1=tin[1]^xor1; - if (l >= 8) - { - l2c(tout0,out); - l2c(tout1,out); - } - else - l2cn(tout0,tout1,out,l); + l2c(tout0,out); + l2c(tout1,out); xor0=tin0; xor1=tin1; } + if (l != -8) + { + c2l(in,tin0); tin[0]=tin0; + c2l(in,tin1); tin[1]=tin1; + des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT); + tout0=tin[0]^xor0; + tout1=tin[1]^xor1; + l2cn(tout0,tout1,out,l+8); + /* xor0=tin0; + xor1=tin1; */ + } } tin0=tin1=tout0=tout1=xor0=xor1=0; tin[0]=tin[1]=0; diff --git a/lib/des/cfb64ede.c b/lib/des/cfb64ede.c index 13c9e3814..b1e127a1e 100644 --- a/lib/des/cfb64ede.c +++ b/lib/des/cfb64ede.c @@ -1,17 +1,22 @@ -/* lib/des/cfb64ede.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/cfb64ede.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -62,7 +73,8 @@ int *num; int encrypt; { register DES_LONG v0,v1; - register long l=length,n=*num; + register long l=length; + register int n= *num; DES_LONG ti[2]; unsigned char *iv,c,cc; @@ -76,18 +88,12 @@ int encrypt; c2l(iv,v0); c2l(iv,v1); - IP(v0,v1); - ti[0]=v0; ti[1]=v1; - des_encrypt2((DES_LONG *)ti,ks1,DES_ENCRYPT); - des_encrypt2((DES_LONG *)ti,ks2,DES_DECRYPT); - des_encrypt2((DES_LONG *)ti,ks3,DES_ENCRYPT); + des_encrypt3((DES_LONG *)ti,ks1,ks2,ks3); v0=ti[0]; v1=ti[1]; - FP(v1,v0); - iv=(unsigned char *)ivec; l2c(v0,iv); l2c(v1,iv); @@ -108,19 +114,12 @@ int encrypt; c2l(iv,v0); c2l(iv,v1); - IP(v0,v1); - ti[0]=v0; ti[1]=v1; - des_encrypt2((DES_LONG *)ti,ks1,DES_ENCRYPT); - des_encrypt2((DES_LONG *)ti,ks2,DES_DECRYPT); - des_encrypt2((DES_LONG *)ti,ks3,DES_ENCRYPT); - + des_encrypt3((DES_LONG *)ti,ks1,ks2,ks3); v0=ti[0]; v1=ti[1]; - FP(v1,v0); - iv=(unsigned char *)ivec; l2c(v0,iv); l2c(v1,iv); diff --git a/lib/des/cfb64enc.c b/lib/des/cfb64enc.c index a0e77fe49..66c944a82 100644 --- a/lib/des/cfb64enc.c +++ b/lib/des/cfb64enc.c @@ -1,17 +1,22 @@ -/* lib/des/cfb64enc.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/cfb64enc.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -62,7 +73,8 @@ int *num; int encrypt; { register DES_LONG v0,v1; - register long l=length,n=*num; + register long l=length; + register int n= *num; DES_LONG ti[2]; unsigned char *iv,c,cc; diff --git a/lib/des/cfb_enc.c b/lib/des/cfb_enc.c index 921384dde..52a360dcb 100644 --- a/lib/des/cfb_enc.c +++ b/lib/des/cfb_enc.c @@ -1,17 +1,22 @@ -/* lib/des/cfb_enc.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/cfb_enc.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE diff --git a/lib/des/des.c b/lib/des/des.c index dc3d3b191..a8d0bc5e2 100644 --- a/lib/des/des.c +++ b/lib/des/des.c @@ -1,17 +1,22 @@ -/* lib/des/des.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/des.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -60,7 +71,7 @@ #endif #include -#include "version.h" +#include "des_ver.h" #ifdef VMS #include @@ -246,7 +257,7 @@ char **argv; if (vflag) { #ifndef _Windows - fprintf(stderr,"des(1) built with %s\n",DES_version); + fprintf(stderr,"des(1) built with %s\n",libdes_version); #endif EXIT(1); } @@ -254,7 +265,7 @@ char **argv; } #ifndef _Windows - if (vflag) fprintf(stderr,"des(1) built with %s\n",DES_version); + if (vflag) fprintf(stderr,"des(1) built with %s\n",libdes_version); #endif if ( (in != NULL) && (out != NULL) && @@ -376,8 +387,8 @@ void doencryption() if (buf == NULL) { - if ( (( buf=(unsigned char *)malloc(BUFSIZE+8)) == NULL) || - ((obuf=(unsigned char *)malloc(BUFSIZE+8)) == NULL)) + if ( (( buf=(unsigned char *)Malloc(BUFSIZE+8)) == NULL) || + ((obuf=(unsigned char *)Malloc(BUFSIZE+8)) == NULL)) { fputs("Not enough memory\n",stderr); Exit=10; diff --git a/lib/des/destest.c b/lib/des/destest.c index 0c882a04c..3537a291e 100644 --- a/lib/des/destest.c +++ b/lib/des/destest.c @@ -1,17 +1,22 @@ -/* lib/des/destest.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/destest.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -49,6 +60,12 @@ #include #endif +#if defined(WIN32) || defined(WIN16) || defined(WINDOWS) +#ifndef MSDOS +#define MSDOS +#endif +#endif + #include #include #include @@ -219,6 +236,13 @@ static unsigned char cbc_ok[32]={ 0x46,0x8e,0x91,0x15,0x78,0x88,0xba,0x68, 0x1d,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4}; +static unsigned char xcbc_ok[32]={ + 0x86,0x74,0x81,0x0D,0x61,0xA4,0xA5,0x48, + 0xB9,0x93,0x03,0xE1,0xB8,0xBB,0xBD,0xBD, + 0x64,0x30,0x0B,0xB9,0x06,0x65,0x81,0x76, + 0x04,0x1D,0x77,0x62,0x17,0xCA,0x2B,0xD2, + }; + static unsigned char cbc3_ok[32]={ 0x3F,0xE3,0x01,0xC9,0x62,0xAC,0x01,0xD0, 0x22,0x13,0x76,0x3C,0x1C,0xBD,0x4C,0xDC, @@ -300,7 +324,7 @@ char *argv[]; printf("Doing ecb\n"); for (i=0; i - * for pointing this out. */ - l=(r<<1)|(r>>31); - r=(u<<1)|(u>>31); - - /* clear the top bits on machines with 8byte longs */ - l&=0xffffffffL; - r&=0xffffffffL; - - 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) - { - D_ENCRYPT(l,r,i+0); /* 1 */ - D_ENCRYPT(r,l,i+2); /* 2 */ - } - } - else - { - for (i=30; i>0; i-=4) - { - D_ENCRYPT(l,r,i-0); /* 16 */ - D_ENCRYPT(r,l,i-2); /* 15 */ - } - } - l=(l>>1)|(l<<31); - r=(r>>1)|(r<<31); - /* clear the top bits on machines with 8byte longs */ - l&=0xffffffffL; - r&=0xffffffffL; - - FP(r,l); - data[0]=l; - data[1]=r; - l=r=t=u=0; - } - -void des_encrypt2(data, ks, encrypt) -DES_LONG *data; -des_key_schedule ks; -int encrypt; - { - register DES_LONG l,r,t,u; -#ifdef DES_USE_PTR - register unsigned char *des_SP=(unsigned char *)des_SPtrans; -#endif -#ifdef MSDOS - union fudge { - DES_LONG l; - unsigned short s[2]; - unsigned char c[4]; - } U,T; -#endif - register int i; - register DES_LONG *s; - - u=data[0]; - r=data[1]; - - /* Things have been modified so that the initial rotate is - * done outside the loop. This required the - * des_SPtrans values in sp.h to be rotated 1 bit to the right. - * One perl script later and things have a 5% speed up on a sparc2. - * Thanks to Richard Outerbridge <71755.204@CompuServe.COM> - * for pointing this out. */ - l=(r<<1)|(r>>31); - r=(u<<1)|(u>>31); - - /* clear the top bits on machines with 8byte longs */ - l&=0xffffffffL; - r&=0xffffffffL; - - 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) - { - D_ENCRYPT(l,r,i+0); /* 1 */ - D_ENCRYPT(r,l,i+2); /* 2 */ - } - } - else - { - for (i=30; i>0; i-=4) - { - D_ENCRYPT(l,r,i-0); /* 16 */ - D_ENCRYPT(r,l,i-2); /* 15 */ - } - } - l=(l>>1)|(l<<31); - r=(r>>1)|(r<<31); - /* clear the top bits on machines with 8byte longs */ - l&=0xffffffffL; - r&=0xffffffffL; - - data[0]=l; - data[1]=r; - l=r=t=u=0; - } diff --git a/lib/des/ede_enc.c b/lib/des/ede_enc.c index 96781d60c..c62efac4e 100644 --- a/lib/des/ede_enc.c +++ b/lib/des/ede_enc.c @@ -1,17 +1,22 @@ -/* lib/des/ede_enc.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/ede_enc.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -72,29 +83,33 @@ int encrypt; { c2l(iv,tout0); c2l(iv,tout1); - for (; l>0; l-=8) + for (l-=8; l>=0; l-=8) { - if (l >= 8) - { - c2l(in,tin0); - c2l(in,tin1); - } - else - c2ln(in,tin0,tin1,l); + c2l(in,tin0); + c2l(in,tin1); tin0^=tout0; tin1^=tout1; - IP(tin0,tin1); - tin[0]=tin0; tin[1]=tin1; - des_encrypt2((DES_LONG *)tin,ks1,DES_ENCRYPT); - des_encrypt2((DES_LONG *)tin,ks2,DES_DECRYPT); - des_encrypt2((DES_LONG *)tin,ks3,DES_ENCRYPT); + des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); tout0=tin[0]; tout1=tin[1]; - FP(tout1,tout0); + l2c(tout0,out); + l2c(tout1,out); + } + if (l != -8) + { + c2ln(in,tin0,tin1,l+8); + tin0^=tout0; + tin1^=tout1; + + tin[0]=tin0; + tin[1]=tin1; + des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); + tout0=tin[0]; + tout1=tin[1]; l2c(tout0,out); l2c(tout1,out); @@ -105,38 +120,48 @@ int encrypt; } else { + register DES_LONG t0,t1; + c2l(iv,xor0); c2l(iv,xor1); - for (; l>0; l-=8) + for (l-=8; l>=0; l-=8) { - register DES_LONG t0,t1; - c2l(in,tin0); c2l(in,tin1); t0=tin0; t1=tin1; - IP(tin0,tin1); tin[0]=tin0; tin[1]=tin1; - des_encrypt2((DES_LONG *)tin,ks3,DES_DECRYPT); - des_encrypt2((DES_LONG *)tin,ks2,DES_ENCRYPT); - des_encrypt2((DES_LONG *)tin,ks1,DES_DECRYPT); + des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); tout0=tin[0]; tout1=tin[1]; - FP(tout1,tout0); /**/ + tout0^=xor0; + tout1^=xor1; + l2c(tout0,out); + l2c(tout1,out); + xor0=t0; + xor1=t1; + } + if (l != -8) + { + c2l(in,tin0); + c2l(in,tin1); + + t0=tin0; + t1=tin1; + + tin[0]=tin0; + tin[1]=tin1; + des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); + tout0=tin[0]; + tout1=tin[1]; tout0^=xor0; tout1^=xor1; - if (l >= 8) - { - l2c(tout0,out); - l2c(tout1,out); - } - else - l2cn(tout0,tout1,out,l); + l2cn(tout0,tout1,out,l+8); xor0=t0; xor1=t1; } @@ -161,3 +186,4 @@ int enc; des_ede3_cbc_encrypt(input,output,length,ks1,ks2,ks1,ivec,enc); } #endif + diff --git a/lib/des/enc_read.c b/lib/des/enc_read.c index 11a6c5a82..2d79d3119 100644 --- a/lib/des/enc_read.c +++ b/lib/des/enc_read.c @@ -1,17 +1,22 @@ -/* lib/des/enc_read.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/enc_read.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -50,7 +61,7 @@ #include "des_locl.h" /* This has some uglies in it but it works - even over sockets. */ -extern int errno; +/*extern int errno;*/ int des_rw_mode=DES_PCBC_MODE; int des_enc_read(fd, buf, len, sched, iv) @@ -62,17 +73,33 @@ des_cblock (*iv); { /* data to be unencrypted */ int net_num=0; - unsigned char net[BSIZE]; + static unsigned char *net=NULL; /* extra unencrypted data * for when a block of 100 comes in but is des_read one byte at * a time. */ - static char unnet[BSIZE]; + static char *unnet=NULL; static int unnet_start=0; static int unnet_left=0; + static char *tmpbuf=NULL; int i; long num=0,rnum; unsigned char *p; + if (tmpbuf == NULL) + { + tmpbuf=(char *)malloc(BSIZE); + if (tmpbuf == NULL) return(-1); + } + if (net == NULL) + { + net=(unsigned char *)malloc(BSIZE); + if (net == NULL) return(-1); + } + if (unnet == NULL) + { + unnet=(char *)malloc(BSIZE); + if (unnet == NULL) return(-1); + } /* left over data from last decrypt */ if (unnet_left != 0) { @@ -102,7 +129,6 @@ des_cblock (*iv); if (len > MAXWRITE) len=MAXWRITE; /* first - get the length */ - net_num=0; while (net_num < HDRSIZE) { i=read(fd,&(net[net_num]),(unsigned int)HDRSIZE-net_num); @@ -113,7 +139,7 @@ des_cblock (*iv); /* we now have at net_num bytes in net */ p=net; - num=0; + /* num=0; */ n2l(p,num); /* num should be rounded up to the next group of eight * we make sure that we have read a multiple of 8 bytes from the net. @@ -135,14 +161,14 @@ des_cblock (*iv); if (len < num) { if (des_rw_mode & DES_PCBC_MODE) - pcbc_encrypt((des_cblock *)net,(des_cblock *)unnet, + des_pcbc_encrypt((des_cblock *)net,(des_cblock *)unnet, num,sched,iv,DES_DECRYPT); else - cbc_encrypt((des_cblock *)net,(des_cblock *)unnet, + des_cbc_encrypt((des_cblock *)net,(des_cblock *)unnet, num,sched,iv,DES_DECRYPT); memcpy(buf,unnet,(unsigned int)len); unnet_start=len; - unnet_left=num-len; + unnet_left=(int)num-len; /* The following line is done because we return num * as the number of bytes read. */ @@ -157,14 +183,13 @@ des_cblock (*iv); * FIXED - Should be ok now 18-9-90 - eay */ if (len < rnum) { - char tmpbuf[BSIZE]; if (des_rw_mode & DES_PCBC_MODE) - pcbc_encrypt((des_cblock *)net, + des_pcbc_encrypt((des_cblock *)net, (des_cblock *)tmpbuf, num,sched,iv,DES_DECRYPT); else - cbc_encrypt((des_cblock *)net, + des_cbc_encrypt((des_cblock *)net, (des_cblock *)tmpbuf, num,sched,iv,DES_DECRYPT); @@ -175,15 +200,15 @@ des_cblock (*iv); else { if (des_rw_mode & DES_PCBC_MODE) - pcbc_encrypt((des_cblock *)net, + des_pcbc_encrypt((des_cblock *)net, (des_cblock *)buf,num,sched,iv, DES_DECRYPT); else - cbc_encrypt((des_cblock *)net, + des_cbc_encrypt((des_cblock *)net, (des_cblock *)buf,num,sched,iv, DES_DECRYPT); } } - return(num); + return((int)num); } diff --git a/lib/des/enc_writ.c b/lib/des/enc_writ.c index e0d50751f..cf6138271 100644 --- a/lib/des/enc_writ.c +++ b/lib/des/enc_writ.c @@ -1,17 +1,22 @@ -/* lib/des/enc_writ.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/enc_writ.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -65,11 +76,16 @@ des_cblock (*iv); long rnum; int i,j,k,outnum; - char outbuf[BSIZE+HDRSIZE]; + char *outbuf=NULL; char shortbuf[8]; char *p; static int start=1; + if (outbuf == NULL) + { + outbuf=(char *)malloc(BSIZE+HDRSIZE); + if (outbuf == NULL) return(-1); + } /* If we are sending less than 8 bytes, the same char will look * the same if we don't pad it out with random bytes */ if (start) @@ -114,14 +130,16 @@ des_cblock (*iv); } if (des_rw_mode & DES_PCBC_MODE) - pcbc_encrypt((des_cblock *)p,(des_cblock *)&(outbuf[HDRSIZE]), + des_pcbc_encrypt((des_cblock *)p, + (des_cblock *)&(outbuf[HDRSIZE]), (long)((len<8)?8:len),sched,iv,DES_ENCRYPT); else - cbc_encrypt((des_cblock *)p,(des_cblock *)&(outbuf[HDRSIZE]), + des_cbc_encrypt((des_cblock *)p, + (des_cblock *)&(outbuf[HDRSIZE]), (long)((len<8)?8:len),sched,iv,DES_ENCRYPT); /* output */ - outnum=rnum+HDRSIZE; + outnum=(int)rnum+HDRSIZE; for (j=0; j>16; \ + t=R^u; \ + u=t&E0; t=t&E1; \ + tmp=(u<<16); u^=R^s[S ]; u^=tmp; \ + tmp=(t<<16); t^=R^s[S+1]; t^=tmp + +#define DES_FCRYPT +#include "des_locl.h" +#undef DES_FCRYPT + +#undef PERM_OP +#define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\ + (b)^=(t),\ + (a)^=((t)<<(n))) + +#undef HPERM_OP +#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ + (a)=(a)^(t)^(t>>(16-(n))))\ + +#ifdef PARA +#define STATIC +#else +#define STATIC static #endif /* It is really only FreeBSD that still suffers from MD5 based crypts, @@ -206,447 +247,15 @@ crypt_md5(pw, salt) } #endif /* MD5_CRYPT_SUPPORT */ -typedef unsigned char des_cblock[8]; - -typedef struct des_ks_struct - { - union { - des_cblock _; - /* make sure things are correct size on machines with - * 8 byte longs */ - unsigned long pad[2]; - } ks; -#define _ ks._ - } des_key_schedule[16]; - -#define DES_KEY_SZ (sizeof(des_cblock)) -#define DES_ENCRYPT 1 -#define DES_DECRYPT 0 - -#define ITERATIONS 16 -#define HALF_ITERATIONS 8 - -#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ - l|=((unsigned long)(*((c)++)))<< 8, \ - l|=((unsigned long)(*((c)++)))<<16, \ - l|=((unsigned long)(*((c)++)))<<24) - -#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16)&0xff), \ - *((c)++)=(unsigned char)(((l)>>24)&0xff)) - -static const unsigned long SPtrans[8][64]={ -{ -/* nibble 0 */ -0x00820200L, 0x00020000L, 0x80800000L, 0x80820200L, -0x00800000L, 0x80020200L, 0x80020000L, 0x80800000L, -0x80020200L, 0x00820200L, 0x00820000L, 0x80000200L, -0x80800200L, 0x00800000L, 0x00000000L, 0x80020000L, -0x00020000L, 0x80000000L, 0x00800200L, 0x00020200L, -0x80820200L, 0x00820000L, 0x80000200L, 0x00800200L, -0x80000000L, 0x00000200L, 0x00020200L, 0x80820000L, -0x00000200L, 0x80800200L, 0x80820000L, 0x00000000L, -0x00000000L, 0x80820200L, 0x00800200L, 0x80020000L, -0x00820200L, 0x00020000L, 0x80000200L, 0x00800200L, -0x80820000L, 0x00000200L, 0x00020200L, 0x80800000L, -0x80020200L, 0x80000000L, 0x80800000L, 0x00820000L, -0x80820200L, 0x00020200L, 0x00820000L, 0x80800200L, -0x00800000L, 0x80000200L, 0x80020000L, 0x00000000L, -0x00020000L, 0x00800000L, 0x80800200L, 0x00820200L, -0x80000000L, 0x80820000L, 0x00000200L, 0x80020200L, -},{ -/* nibble 1 */ -0x10042004L, 0x00000000L, 0x00042000L, 0x10040000L, -0x10000004L, 0x00002004L, 0x10002000L, 0x00042000L, -0x00002000L, 0x10040004L, 0x00000004L, 0x10002000L, -0x00040004L, 0x10042000L, 0x10040000L, 0x00000004L, -0x00040000L, 0x10002004L, 0x10040004L, 0x00002000L, -0x00042004L, 0x10000000L, 0x00000000L, 0x00040004L, -0x10002004L, 0x00042004L, 0x10042000L, 0x10000004L, -0x10000000L, 0x00040000L, 0x00002004L, 0x10042004L, -0x00040004L, 0x10042000L, 0x10002000L, 0x00042004L, -0x10042004L, 0x00040004L, 0x10000004L, 0x00000000L, -0x10000000L, 0x00002004L, 0x00040000L, 0x10040004L, -0x00002000L, 0x10000000L, 0x00042004L, 0x10002004L, -0x10042000L, 0x00002000L, 0x00000000L, 0x10000004L, -0x00000004L, 0x10042004L, 0x00042000L, 0x10040000L, -0x10040004L, 0x00040000L, 0x00002004L, 0x10002000L, -0x10002004L, 0x00000004L, 0x10040000L, 0x00042000L, -},{ -/* nibble 2 */ -0x41000000L, 0x01010040L, 0x00000040L, 0x41000040L, -0x40010000L, 0x01000000L, 0x41000040L, 0x00010040L, -0x01000040L, 0x00010000L, 0x01010000L, 0x40000000L, -0x41010040L, 0x40000040L, 0x40000000L, 0x41010000L, -0x00000000L, 0x40010000L, 0x01010040L, 0x00000040L, -0x40000040L, 0x41010040L, 0x00010000L, 0x41000000L, -0x41010000L, 0x01000040L, 0x40010040L, 0x01010000L, -0x00010040L, 0x00000000L, 0x01000000L, 0x40010040L, -0x01010040L, 0x00000040L, 0x40000000L, 0x00010000L, -0x40000040L, 0x40010000L, 0x01010000L, 0x41000040L, -0x00000000L, 0x01010040L, 0x00010040L, 0x41010000L, -0x40010000L, 0x01000000L, 0x41010040L, 0x40000000L, -0x40010040L, 0x41000000L, 0x01000000L, 0x41010040L, -0x00010000L, 0x01000040L, 0x41000040L, 0x00010040L, -0x01000040L, 0x00000000L, 0x41010000L, 0x40000040L, -0x41000000L, 0x40010040L, 0x00000040L, 0x01010000L, -},{ -/* nibble 3 */ -0x00100402L, 0x04000400L, 0x00000002L, 0x04100402L, -0x00000000L, 0x04100000L, 0x04000402L, 0x00100002L, -0x04100400L, 0x04000002L, 0x04000000L, 0x00000402L, -0x04000002L, 0x00100402L, 0x00100000L, 0x04000000L, -0x04100002L, 0x00100400L, 0x00000400L, 0x00000002L, -0x00100400L, 0x04000402L, 0x04100000L, 0x00000400L, -0x00000402L, 0x00000000L, 0x00100002L, 0x04100400L, -0x04000400L, 0x04100002L, 0x04100402L, 0x00100000L, -0x04100002L, 0x00000402L, 0x00100000L, 0x04000002L, -0x00100400L, 0x04000400L, 0x00000002L, 0x04100000L, -0x04000402L, 0x00000000L, 0x00000400L, 0x00100002L, -0x00000000L, 0x04100002L, 0x04100400L, 0x00000400L, -0x04000000L, 0x04100402L, 0x00100402L, 0x00100000L, -0x04100402L, 0x00000002L, 0x04000400L, 0x00100402L, -0x00100002L, 0x00100400L, 0x04100000L, 0x04000402L, -0x00000402L, 0x04000000L, 0x04000002L, 0x04100400L, -},{ -/* nibble 4 */ -0x02000000L, 0x00004000L, 0x00000100L, 0x02004108L, -0x02004008L, 0x02000100L, 0x00004108L, 0x02004000L, -0x00004000L, 0x00000008L, 0x02000008L, 0x00004100L, -0x02000108L, 0x02004008L, 0x02004100L, 0x00000000L, -0x00004100L, 0x02000000L, 0x00004008L, 0x00000108L, -0x02000100L, 0x00004108L, 0x00000000L, 0x02000008L, -0x00000008L, 0x02000108L, 0x02004108L, 0x00004008L, -0x02004000L, 0x00000100L, 0x00000108L, 0x02004100L, -0x02004100L, 0x02000108L, 0x00004008L, 0x02004000L, -0x00004000L, 0x00000008L, 0x02000008L, 0x02000100L, -0x02000000L, 0x00004100L, 0x02004108L, 0x00000000L, -0x00004108L, 0x02000000L, 0x00000100L, 0x00004008L, -0x02000108L, 0x00000100L, 0x00000000L, 0x02004108L, -0x02004008L, 0x02004100L, 0x00000108L, 0x00004000L, -0x00004100L, 0x02004008L, 0x02000100L, 0x00000108L, -0x00000008L, 0x00004108L, 0x02004000L, 0x02000008L, -},{ -/* nibble 5 */ -0x20000010L, 0x00080010L, 0x00000000L, 0x20080800L, -0x00080010L, 0x00000800L, 0x20000810L, 0x00080000L, -0x00000810L, 0x20080810L, 0x00080800L, 0x20000000L, -0x20000800L, 0x20000010L, 0x20080000L, 0x00080810L, -0x00080000L, 0x20000810L, 0x20080010L, 0x00000000L, -0x00000800L, 0x00000010L, 0x20080800L, 0x20080010L, -0x20080810L, 0x20080000L, 0x20000000L, 0x00000810L, -0x00000010L, 0x00080800L, 0x00080810L, 0x20000800L, -0x00000810L, 0x20000000L, 0x20000800L, 0x00080810L, -0x20080800L, 0x00080010L, 0x00000000L, 0x20000800L, -0x20000000L, 0x00000800L, 0x20080010L, 0x00080000L, -0x00080010L, 0x20080810L, 0x00080800L, 0x00000010L, -0x20080810L, 0x00080800L, 0x00080000L, 0x20000810L, -0x20000010L, 0x20080000L, 0x00080810L, 0x00000000L, -0x00000800L, 0x20000010L, 0x20000810L, 0x20080800L, -0x20080000L, 0x00000810L, 0x00000010L, 0x20080010L, -},{ -/* nibble 6 */ -0x00001000L, 0x00000080L, 0x00400080L, 0x00400001L, -0x00401081L, 0x00001001L, 0x00001080L, 0x00000000L, -0x00400000L, 0x00400081L, 0x00000081L, 0x00401000L, -0x00000001L, 0x00401080L, 0x00401000L, 0x00000081L, -0x00400081L, 0x00001000L, 0x00001001L, 0x00401081L, -0x00000000L, 0x00400080L, 0x00400001L, 0x00001080L, -0x00401001L, 0x00001081L, 0x00401080L, 0x00000001L, -0x00001081L, 0x00401001L, 0x00000080L, 0x00400000L, -0x00001081L, 0x00401000L, 0x00401001L, 0x00000081L, -0x00001000L, 0x00000080L, 0x00400000L, 0x00401001L, -0x00400081L, 0x00001081L, 0x00001080L, 0x00000000L, -0x00000080L, 0x00400001L, 0x00000001L, 0x00400080L, -0x00000000L, 0x00400081L, 0x00400080L, 0x00001080L, -0x00000081L, 0x00001000L, 0x00401081L, 0x00400000L, -0x00401080L, 0x00000001L, 0x00001001L, 0x00401081L, -0x00400001L, 0x00401080L, 0x00401000L, 0x00001001L, -},{ -/* nibble 7 */ -0x08200020L, 0x08208000L, 0x00008020L, 0x00000000L, -0x08008000L, 0x00200020L, 0x08200000L, 0x08208020L, -0x00000020L, 0x08000000L, 0x00208000L, 0x00008020L, -0x00208020L, 0x08008020L, 0x08000020L, 0x08200000L, -0x00008000L, 0x00208020L, 0x00200020L, 0x08008000L, -0x08208020L, 0x08000020L, 0x00000000L, 0x00208000L, -0x08000000L, 0x00200000L, 0x08008020L, 0x08200020L, -0x00200000L, 0x00008000L, 0x08208000L, 0x00000020L, -0x00200000L, 0x00008000L, 0x08000020L, 0x08208020L, -0x00008020L, 0x08000000L, 0x00000000L, 0x00208000L, -0x08200020L, 0x08008020L, 0x08008000L, 0x00200020L, -0x08208000L, 0x00000020L, 0x00200020L, 0x08008000L, -0x08208020L, 0x00200000L, 0x08200000L, 0x08000020L, -0x00208000L, 0x00008020L, 0x08008020L, 0x08200000L, -0x00000020L, 0x08208000L, 0x00208020L, 0x00000000L, -0x08000000L, 0x08200020L, 0x00008000L, 0x00208020L}}; -static const unsigned long skb[8][64]={ -{ -/* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ -0x00000000L,0x00000010L,0x20000000L,0x20000010L, -0x00010000L,0x00010010L,0x20010000L,0x20010010L, -0x00000800L,0x00000810L,0x20000800L,0x20000810L, -0x00010800L,0x00010810L,0x20010800L,0x20010810L, -0x00000020L,0x00000030L,0x20000020L,0x20000030L, -0x00010020L,0x00010030L,0x20010020L,0x20010030L, -0x00000820L,0x00000830L,0x20000820L,0x20000830L, -0x00010820L,0x00010830L,0x20010820L,0x20010830L, -0x00080000L,0x00080010L,0x20080000L,0x20080010L, -0x00090000L,0x00090010L,0x20090000L,0x20090010L, -0x00080800L,0x00080810L,0x20080800L,0x20080810L, -0x00090800L,0x00090810L,0x20090800L,0x20090810L, -0x00080020L,0x00080030L,0x20080020L,0x20080030L, -0x00090020L,0x00090030L,0x20090020L,0x20090030L, -0x00080820L,0x00080830L,0x20080820L,0x20080830L, -0x00090820L,0x00090830L,0x20090820L,0x20090830L, -},{ -/* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ -0x00000000L,0x02000000L,0x00002000L,0x02002000L, -0x00200000L,0x02200000L,0x00202000L,0x02202000L, -0x00000004L,0x02000004L,0x00002004L,0x02002004L, -0x00200004L,0x02200004L,0x00202004L,0x02202004L, -0x00000400L,0x02000400L,0x00002400L,0x02002400L, -0x00200400L,0x02200400L,0x00202400L,0x02202400L, -0x00000404L,0x02000404L,0x00002404L,0x02002404L, -0x00200404L,0x02200404L,0x00202404L,0x02202404L, -0x10000000L,0x12000000L,0x10002000L,0x12002000L, -0x10200000L,0x12200000L,0x10202000L,0x12202000L, -0x10000004L,0x12000004L,0x10002004L,0x12002004L, -0x10200004L,0x12200004L,0x10202004L,0x12202004L, -0x10000400L,0x12000400L,0x10002400L,0x12002400L, -0x10200400L,0x12200400L,0x10202400L,0x12202400L, -0x10000404L,0x12000404L,0x10002404L,0x12002404L, -0x10200404L,0x12200404L,0x10202404L,0x12202404L, -},{ -/* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ -0x00000000L,0x00000001L,0x00040000L,0x00040001L, -0x01000000L,0x01000001L,0x01040000L,0x01040001L, -0x00000002L,0x00000003L,0x00040002L,0x00040003L, -0x01000002L,0x01000003L,0x01040002L,0x01040003L, -0x00000200L,0x00000201L,0x00040200L,0x00040201L, -0x01000200L,0x01000201L,0x01040200L,0x01040201L, -0x00000202L,0x00000203L,0x00040202L,0x00040203L, -0x01000202L,0x01000203L,0x01040202L,0x01040203L, -0x08000000L,0x08000001L,0x08040000L,0x08040001L, -0x09000000L,0x09000001L,0x09040000L,0x09040001L, -0x08000002L,0x08000003L,0x08040002L,0x08040003L, -0x09000002L,0x09000003L,0x09040002L,0x09040003L, -0x08000200L,0x08000201L,0x08040200L,0x08040201L, -0x09000200L,0x09000201L,0x09040200L,0x09040201L, -0x08000202L,0x08000203L,0x08040202L,0x08040203L, -0x09000202L,0x09000203L,0x09040202L,0x09040203L, -},{ -/* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ -0x00000000L,0x00100000L,0x00000100L,0x00100100L, -0x00000008L,0x00100008L,0x00000108L,0x00100108L, -0x00001000L,0x00101000L,0x00001100L,0x00101100L, -0x00001008L,0x00101008L,0x00001108L,0x00101108L, -0x04000000L,0x04100000L,0x04000100L,0x04100100L, -0x04000008L,0x04100008L,0x04000108L,0x04100108L, -0x04001000L,0x04101000L,0x04001100L,0x04101100L, -0x04001008L,0x04101008L,0x04001108L,0x04101108L, -0x00020000L,0x00120000L,0x00020100L,0x00120100L, -0x00020008L,0x00120008L,0x00020108L,0x00120108L, -0x00021000L,0x00121000L,0x00021100L,0x00121100L, -0x00021008L,0x00121008L,0x00021108L,0x00121108L, -0x04020000L,0x04120000L,0x04020100L,0x04120100L, -0x04020008L,0x04120008L,0x04020108L,0x04120108L, -0x04021000L,0x04121000L,0x04021100L,0x04121100L, -0x04021008L,0x04121008L,0x04021108L,0x04121108L, -},{ -/* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ -0x00000000L,0x10000000L,0x00010000L,0x10010000L, -0x00000004L,0x10000004L,0x00010004L,0x10010004L, -0x20000000L,0x30000000L,0x20010000L,0x30010000L, -0x20000004L,0x30000004L,0x20010004L,0x30010004L, -0x00100000L,0x10100000L,0x00110000L,0x10110000L, -0x00100004L,0x10100004L,0x00110004L,0x10110004L, -0x20100000L,0x30100000L,0x20110000L,0x30110000L, -0x20100004L,0x30100004L,0x20110004L,0x30110004L, -0x00001000L,0x10001000L,0x00011000L,0x10011000L, -0x00001004L,0x10001004L,0x00011004L,0x10011004L, -0x20001000L,0x30001000L,0x20011000L,0x30011000L, -0x20001004L,0x30001004L,0x20011004L,0x30011004L, -0x00101000L,0x10101000L,0x00111000L,0x10111000L, -0x00101004L,0x10101004L,0x00111004L,0x10111004L, -0x20101000L,0x30101000L,0x20111000L,0x30111000L, -0x20101004L,0x30101004L,0x20111004L,0x30111004L, -},{ -/* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ -0x00000000L,0x08000000L,0x00000008L,0x08000008L, -0x00000400L,0x08000400L,0x00000408L,0x08000408L, -0x00020000L,0x08020000L,0x00020008L,0x08020008L, -0x00020400L,0x08020400L,0x00020408L,0x08020408L, -0x00000001L,0x08000001L,0x00000009L,0x08000009L, -0x00000401L,0x08000401L,0x00000409L,0x08000409L, -0x00020001L,0x08020001L,0x00020009L,0x08020009L, -0x00020401L,0x08020401L,0x00020409L,0x08020409L, -0x02000000L,0x0A000000L,0x02000008L,0x0A000008L, -0x02000400L,0x0A000400L,0x02000408L,0x0A000408L, -0x02020000L,0x0A020000L,0x02020008L,0x0A020008L, -0x02020400L,0x0A020400L,0x02020408L,0x0A020408L, -0x02000001L,0x0A000001L,0x02000009L,0x0A000009L, -0x02000401L,0x0A000401L,0x02000409L,0x0A000409L, -0x02020001L,0x0A020001L,0x02020009L,0x0A020009L, -0x02020401L,0x0A020401L,0x02020409L,0x0A020409L, -},{ -/* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ -0x00000000L,0x00000100L,0x00080000L,0x00080100L, -0x01000000L,0x01000100L,0x01080000L,0x01080100L, -0x00000010L,0x00000110L,0x00080010L,0x00080110L, -0x01000010L,0x01000110L,0x01080010L,0x01080110L, -0x00200000L,0x00200100L,0x00280000L,0x00280100L, -0x01200000L,0x01200100L,0x01280000L,0x01280100L, -0x00200010L,0x00200110L,0x00280010L,0x00280110L, -0x01200010L,0x01200110L,0x01280010L,0x01280110L, -0x00000200L,0x00000300L,0x00080200L,0x00080300L, -0x01000200L,0x01000300L,0x01080200L,0x01080300L, -0x00000210L,0x00000310L,0x00080210L,0x00080310L, -0x01000210L,0x01000310L,0x01080210L,0x01080310L, -0x00200200L,0x00200300L,0x00280200L,0x00280300L, -0x01200200L,0x01200300L,0x01280200L,0x01280300L, -0x00200210L,0x00200310L,0x00280210L,0x00280310L, -0x01200210L,0x01200310L,0x01280210L,0x01280310L, -},{ -/* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ -0x00000000L,0x04000000L,0x00040000L,0x04040000L, -0x00000002L,0x04000002L,0x00040002L,0x04040002L, -0x00002000L,0x04002000L,0x00042000L,0x04042000L, -0x00002002L,0x04002002L,0x00042002L,0x04042002L, -0x00000020L,0x04000020L,0x00040020L,0x04040020L, -0x00000022L,0x04000022L,0x00040022L,0x04040022L, -0x00002020L,0x04002020L,0x00042020L,0x04042020L, -0x00002022L,0x04002022L,0x00042022L,0x04042022L, -0x00000800L,0x04000800L,0x00040800L,0x04040800L, -0x00000802L,0x04000802L,0x00040802L,0x04040802L, -0x00002800L,0x04002800L,0x00042800L,0x04042800L, -0x00002802L,0x04002802L,0x00042802L,0x04042802L, -0x00000820L,0x04000820L,0x00040820L,0x04040820L, -0x00000822L,0x04000822L,0x00040822L,0x04040822L, -0x00002820L,0x04002820L,0x00042820L,0x04042820L, -0x00002822L,0x04002822L,0x00042822L,0x04042822L, -} }; - -/* See ecb_encrypt.c for a pseudo description of these macros. */ -#define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\ - (b)^=(t),\ - (a)^=((t)<<(n))) - -#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ - (a)=(a)^(t)^(t>>(16-(n))))\ - -static const int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; - #ifndef NOPROTO -static int body(unsigned long *out0, unsigned long *out1, - des_key_schedule ks, unsigned long Eswap0, unsigned long Eswap1); -static int des_set_key(des_cblock (*key), des_key_schedule schedule); + +STATIC int fcrypt_body(DES_LONG *out0, DES_LONG *out1, + des_key_schedule ks, DES_LONG Eswap0, DES_LONG Eswap1); + #else -static int body(); -static int des_set_key(); -#endif -static int des_set_key(key, schedule) -des_cblock (*key); -des_key_schedule schedule; - { - register unsigned long c,d,t,s; - register unsigned char *in; - register unsigned long *k; - register int i; +STATIC int fcrypt_body(); - k=(unsigned long *)schedule; - in=(unsigned char *)key; - - c2l(in,c); - c2l(in,d); - - /* I now do it in 47 simple operations :-) - * Thanks to John Fletcher (john_fletcher@lccmail.ocf.llnl.gov) - * for the inspiration. :-) */ - PERM_OP (d,c,t,4,0x0f0f0f0fL); - HPERM_OP(c,t,-2,0xcccc0000L); - HPERM_OP(d,t,-2,0xcccc0000L); - PERM_OP (d,c,t,1,0x55555555L); - PERM_OP (c,d,t,8,0x00ff00ffL); - PERM_OP (d,c,t,1,0x55555555L); - d= (((d&0x000000ffL)<<16)| (d&0x0000ff00L) | - ((d&0x00ff0000L)>>16)|((c&0xf0000000L)>>4)); - c&=0x0fffffffL; - - for (i=0; i>2)|(c<<26)); d=((d>>2)|(d<<26)); } - else - { c=((c>>1)|(c<<27)); d=((d>>1)|(d<<27)); } - c&=0x0fffffffL; - d&=0x0fffffffL; - /* could be a few less shifts but I am to lazy at this - * point in time to investigate */ - s= skb[0][ (c )&0x3f ]| - skb[1][((c>> 6L)&0x03)|((c>> 7L)&0x3c)]| - skb[2][((c>>13L)&0x0f)|((c>>14L)&0x30)]| - skb[3][((c>>20L)&0x01)|((c>>21L)&0x06) | - ((c>>22L)&0x38)]; - t= skb[4][ (d )&0x3f ]| - skb[5][((d>> 7L)&0x03)|((d>> 8L)&0x3c)]| - skb[6][ (d>>15L)&0x3f ]| - skb[7][((d>>21L)&0x0f)|((d>>22L)&0x30)]; - - /* table contained 0213 4657 */ - *(k++)=((t<<16)|(s&0x0000ffffL))&0xffffffffL; - s= ((s>>16)|(t&0xffff0000L)); - - s=(s<<4)|(s>>28); - *(k++)=s&0xffffffffL; - } - return(0); - } - -/****************************************************************** - * modified stuff for crypt. - ******************************************************************/ - -/* The changes to this macro may help or hinder, depending on the - * compiler and the achitecture. gcc2 always seems to do well :-). - * Inspired by Dana How - * DO NOT use the alternative version on machines with 8 byte longs. - */ -#ifdef DES_USE_PTR -#define D_ENCRYPT(L,R,S) \ - t=(R^(R>>16)); \ - u=(t&E0); \ - t=(t&E1); \ - u=((u^(u<<16))^R^s[S ])<<2; \ - t=(t^(t<<16))^R^s[S+1]; \ - t=(t>>2)|(t<<30); \ - L^= \ - *(unsigned long *)(des_SP+0x0100+((t )&0xfc))+ \ - *(unsigned long *)(des_SP+0x0300+((t>> 8)&0xfc))+ \ - *(unsigned long *)(des_SP+0x0500+((t>>16)&0xfc))+ \ - *(unsigned long *)(des_SP+0x0700+((t>>24)&0xfc))+ \ - *(unsigned long *)(des_SP+ ((u )&0xfc))+ \ - *(unsigned long *)(des_SP+0x0200+((u>> 8)&0xfc))+ \ - *(unsigned long *)(des_SP+0x0400+((u>>16)&0xfc))+ \ - *(unsigned long *)(des_SP+0x0600+((u>>24)&0xfc)); -#else /* original version */ -#define D_ENCRYPT(L,R,S) \ - t=(R^(R>>16)); \ - u=(t&E0); \ - t=(t&E1); \ - u=(u^(u<<16))^R^s[S ]; \ - t=(t^(t<<16))^R^s[S+1]; \ - t=(t>>4)|(t<<28); \ - L^= SPtrans[1][(t )&0x3f]| \ - SPtrans[3][(t>> 8)&0x3f]| \ - SPtrans[5][(t>>16)&0x3f]| \ - SPtrans[7][(t>>24)&0x3f]| \ - SPtrans[0][(u )&0x3f]| \ - SPtrans[2][(u>> 8)&0x3f]| \ - SPtrans[4][(u>>16)&0x3f]| \ - SPtrans[6][(u>>24)&0x3f]; #endif /* Added more values to handle illegal salt values the way normal @@ -685,9 +294,9 @@ static unsigned const char cov_2char[64]={ #ifndef NOPROTO #ifdef PERL5 -char *des_crypt(char *buf,char *salt); +char *des_crypt(const char *buf,const char *salt); #else -char *crypt(char *buf,char *salt); +char *crypt(const char *buf,const char *salt); #endif #else #ifdef PERL5 @@ -702,15 +311,25 @@ char *des_crypt(buf,salt) #else char *crypt(buf,salt) #endif -char *buf; -char *salt; +const char *buf; +const char *salt; + { + static char buff[14]; + + return(des_fcrypt(buf,salt,buff)); + } + + +char *des_fcrypt(buf,salt,ret) +const char *buf; +const char *salt; +char *ret; { unsigned int i,j,x,y; - unsigned long Eswap0=0,Eswap1=0; - unsigned long out[2],ll; + DES_LONG Eswap0,Eswap1; + DES_LONG out[2],ll; des_cblock key; des_key_schedule ks; - static unsigned char buff[20]; unsigned char bb[9]; unsigned char *b=bb; unsigned char c,u; @@ -728,11 +347,15 @@ char *salt; * crypt to "*". This was found when replacing the crypt in * our shared libraries. People found that the disbled * accounts effectivly had no passwd :-(. */ - x=buff[0]=((salt[0] == '\0')?'A':salt[0]); - Eswap0=con_salt[x]; - x=buff[1]=((salt[1] == '\0')?'A':salt[1]); - Eswap1=con_salt[x]<<4; + x=ret[0]=((salt[0] == '\0')?'A':salt[0]); + Eswap0=con_salt[x]<<2; + x=ret[1]=((salt[1] == '\0')?'A':salt[1]); + Eswap1=con_salt[x]<<6; +/* EAY +r=strlen(buf); +r=(r+7)/8; +*/ for (i=0; i<8; i++) { c= *(buf++); @@ -743,7 +366,7 @@ char *salt; key[i]=0; des_set_key((des_cblock *)(key),ks); - body(&(out[0]),&(out[1]),ks,Eswap0,Eswap1); + fcrypt_body(&(out[0]),&(out[1]),ks,Eswap0,Eswap1); ll=out[0]; l2c(ll,b); ll=out[1]; l2c(ll,b); @@ -764,60 +387,79 @@ char *salt; u=0x80; } } - buff[i]=cov_2char[c]; + ret[i]=cov_2char[c]; } - buff[13]='\0'; - return((char *)buff); + ret[13]='\0'; + return(ret); } -static int body(out0, out1, ks, Eswap0, Eswap1) -unsigned long *out0; -unsigned long *out1; +STATIC int fcrypt_body(out0, out1, ks, Eswap0, Eswap1) +DES_LONG *out0; +DES_LONG *out1; des_key_schedule ks; -unsigned long Eswap0; -unsigned long Eswap1; +DES_LONG Eswap0; +DES_LONG Eswap1; { - register unsigned long l,r,t,u; -#ifdef DES_USE_PTR - register unsigned char *des_SP=(unsigned char *)SPtrans; + register DES_LONG l,r,t,u; +#ifdef DES_PTR + register unsigned char *des_SP=(unsigned char *)des_SPtrans; #endif - register unsigned long *s; - register int i,j; - register unsigned long E0,E1; + register DES_LONG *s; + register int j; + register DES_LONG E0,E1; l=0; r=0; - s=(unsigned long *)ks; + s=(DES_LONG *)ks; E0=Eswap0; E1=Eswap1; for (j=0; j<25; j++) { - for (i=0; i<(ITERATIONS*2); i+=4) +#ifdef DES_UNROLL + register int i; + + for (i=0; i<32; i+=8) { - D_ENCRYPT(l,r, i); /* 1 */ - D_ENCRYPT(r,l, i+2); /* 2 */ + 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 + D_ENCRYPT(l,r, 0); /* 1 */ + D_ENCRYPT(r,l, 2); /* 2 */ + D_ENCRYPT(l,r, 4); /* 3 */ + D_ENCRYPT(r,l, 6); /* 4 */ + D_ENCRYPT(l,r, 8); /* 5 */ + D_ENCRYPT(r,l,10); /* 6 */ + D_ENCRYPT(l,r,12); /* 7 */ + D_ENCRYPT(r,l,14); /* 8 */ + D_ENCRYPT(l,r,16); /* 9 */ + D_ENCRYPT(r,l,18); /* 10 */ + D_ENCRYPT(l,r,20); /* 11 */ + D_ENCRYPT(r,l,22); /* 12 */ + D_ENCRYPT(l,r,24); /* 13 */ + D_ENCRYPT(r,l,26); /* 14 */ + D_ENCRYPT(l,r,28); /* 15 */ + D_ENCRYPT(r,l,30); /* 16 */ +#endif t=l; l=r; r=t; } - t=r; - r=(l>>1L)|(l<<31L); - l=(t>>1L)|(t<<31L); - /* clear the top bits on machines with 8byte longs */ - l&=0xffffffffL; - r&=0xffffffffL; + l=ROTATE(l,3)&0xffffffffL; + r=ROTATE(r,3)&0xffffffffL; - PERM_OP(r,l,t, 1,0x55555555L); - PERM_OP(l,r,t, 8,0x00ff00ffL); - PERM_OP(r,l,t, 2,0x33333333L); - PERM_OP(l,r,t,16,0x0000ffffL); - PERM_OP(r,l,t, 4,0x0f0f0f0fL); + PERM_OP(l,r,t, 1,0x55555555L); + PERM_OP(r,l,t, 8,0x00ff00ffL); + PERM_OP(l,r,t, 2,0x33333333L); + PERM_OP(r,l,t,16,0x0000ffffL); + PERM_OP(l,r,t, 4,0x0f0f0f0fL); - *out0=l; - *out1=r; + *out0=r; + *out1=l; return(0); } diff --git a/lib/des/ncbc_enc.c b/lib/des/ncbc_enc.c index 7416d3b9c..4a972ac54 100644 --- a/lib/des/ncbc_enc.c +++ b/lib/des/ncbc_enc.c @@ -1,17 +1,22 @@ -/* lib/des/ncbc_enc.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/ncbc_enc.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -70,15 +81,19 @@ int encrypt; { c2l(iv,tout0); c2l(iv,tout1); - for (; l>0; l-=8) + for (l-=8; l>=0; l-=8) { - if (l >= 8) - { - c2l(in,tin0); - c2l(in,tin1); - } - else - c2ln(in,tin0,tin1,l); + c2l(in,tin0); + c2l(in,tin1); + tin0^=tout0; tin[0]=tin0; + tin1^=tout1; tin[1]=tin1; + des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT); + tout0=tin[0]; l2c(tout0,out); + tout1=tin[1]; l2c(tout1,out); + } + if (l != -8) + { + c2ln(in,tin0,tin1,l+8); tin0^=tout0; tin[0]=tin0; tin1^=tout1; tin[1]=tin1; des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT); @@ -93,20 +108,26 @@ int encrypt; { c2l(iv,xor0); c2l(iv,xor1); - for (; l>0; l-=8) + for (l-=8; l>=0; l-=8) { c2l(in,tin0); tin[0]=tin0; c2l(in,tin1); tin[1]=tin1; des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT); tout0=tin[0]^xor0; tout1=tin[1]^xor1; - if (l >= 8) - { - l2c(tout0,out); - l2c(tout1,out); - } - else - l2cn(tout0,tout1,out,l); + l2c(tout0,out); + l2c(tout1,out); + xor0=tin0; + xor1=tin1; + } + if (l != -8) + { + c2l(in,tin0); tin[0]=tin0; + c2l(in,tin1); tin[1]=tin1; + des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT); + tout0=tin[0]^xor0; + tout1=tin[1]^xor1; + l2cn(tout0,tout1,out,l+8); xor0=tin0; xor1=tin1; } diff --git a/lib/des/ofb64ede.c b/lib/des/ofb64ede.c index 6aa2b3fb4..b33deef10 100644 --- a/lib/des/ofb64ede.c +++ b/lib/des/ofb64ede.c @@ -1,17 +1,22 @@ -/* lib/des/ofb64ede.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/ofb64ede.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -60,7 +71,7 @@ des_cblock (*ivec); int *num; { register DES_LONG v0,v1; - register int n=*num; + register int n= *num; register long l=length; des_cblock d; register char *dp; @@ -80,24 +91,18 @@ int *num; { if (n == 0) { - IP(v0,v1); - ti[0]=v0; ti[1]=v1; - des_encrypt2((DES_LONG *)ti,k1,DES_ENCRYPT); - des_encrypt2((DES_LONG *)ti,k2,DES_DECRYPT); - des_encrypt2((DES_LONG *)ti,k3,DES_ENCRYPT); + des_encrypt3((DES_LONG *)ti,k1,k2,k3); v0=ti[0]; v1=ti[1]; - FP(v1,v0); - dp=(char *)d; l2c(v0,dp); l2c(v1,dp); save++; } - *(out++)=*(in++)^d[n]; + *(out++)= *(in++)^d[n]; n=(n+1)&0x07; } if (save) diff --git a/lib/des/ofb64enc.c b/lib/des/ofb64enc.c index 415109534..041f5b52b 100644 --- a/lib/des/ofb64enc.c +++ b/lib/des/ofb64enc.c @@ -1,17 +1,22 @@ -/* lib/des/ofb64enc.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/ofb64enc.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -60,7 +71,7 @@ des_cblock (*ivec); int *num; { register DES_LONG v0,v1,t; - register int n=*num; + register int n= *num; register long l=length; des_cblock d; register char *dp; @@ -86,7 +97,7 @@ int *num; t=ti[1]; l2c(t,dp); save++; } - *(out++)=*(in++)^d[n]; + *(out++)= *(in++)^d[n]; n=(n+1)&0x07; } if (save) diff --git a/lib/des/ofb_enc.c b/lib/des/ofb_enc.c index 10fc3c900..d0506100d 100644 --- a/lib/des/ofb_enc.c +++ b/lib/des/ofb_enc.c @@ -1,17 +1,22 @@ -/* lib/des/ofb_enc.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/ofb_enc.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE diff --git a/lib/des/pcbc_enc.c b/lib/des/pcbc_enc.c index 7aef96e1a..cb2e785cf 100644 --- a/lib/des/pcbc_enc.c +++ b/lib/des/pcbc_enc.c @@ -1,17 +1,22 @@ -/* lib/des/pcbc_enc.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/pcbc_enc.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE diff --git a/lib/des/qud_cksm.c b/lib/des/qud_cksm.c index fde9721db..783274854 100644 --- a/lib/des/qud_cksm.c +++ b/lib/des/qud_cksm.c @@ -1,17 +1,22 @@ -/* lib/des/qud_cksm.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/qud_cksm.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -53,10 +64,10 @@ #include "des_locl.h" /* bug fix for dos - 7/6/91 - Larry hughes@logos.ucs.indiana.edu */ -#define B0(a) (((DES_LONG)(a))) -#define B1(a) (((DES_LONG)(a))<<8) -#define B2(a) (((DES_LONG)(a))<<16) -#define B3(a) (((DES_LONG)(a))<<24) +#define Q_B0(a) (((DES_LONG)(a))) +#define Q_B1(a) (((DES_LONG)(a))<<8) +#define Q_B2(a) (((DES_LONG)(a))<<16) +#define Q_B3(a) (((DES_LONG)(a))<<24) /* used to scramble things a bit */ /* Got the value MIT uses via brute force :-) 2/10/90 eay */ @@ -71,7 +82,7 @@ DES_LONG des_quad_cksum(input, output, length, out_count, seed) { DES_LONG z0,z1,t0,t1; int i; - long l=0; + long l; #ifdef _CRAY typedef struct { unsigned int a:32; @@ -86,8 +97,8 @@ DES_LONG des_quad_cksum(input, output, length, out_count, seed) if (out_count < 1) out_count=1; lp=(XXX*)output; - z0=B0((*seed)[0])|B1((*seed)[1])|B2((*seed)[2])|B3((*seed)[3]); - z1=B0((*seed)[4])|B1((*seed)[5])|B2((*seed)[6])|B3((*seed)[7]); + z0=Q_B0((*seed)[0])|Q_B1((*seed)[1])|Q_B2((*seed)[2])|Q_B3((*seed)[3]); + z1=Q_B0((*seed)[4])|Q_B1((*seed)[5])|Q_B2((*seed)[6])|Q_B3((*seed)[7]); for (i=0; ((i<4)&&(i 1) { t0= (DES_LONG)(*(cp++)); - t0|=(DES_LONG)B1(*(cp++)); + t0|=(DES_LONG)Q_B1(*(cp++)); l--; } else diff --git a/lib/des/rand_key.c b/lib/des/rand_key.c index 7bc47c3cd..fd4c5ef4d 100644 --- a/lib/des/rand_key.c +++ b/lib/des/rand_key.c @@ -1,17 +1,22 @@ -/* lib/des/rand_key.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/rand_key.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE diff --git a/lib/des/read_pwd.c b/lib/des/read_pwd.c index 646b6906f..2f4b9ee19 100644 --- a/lib/des/read_pwd.c +++ b/lib/des/read_pwd.c @@ -1,17 +1,22 @@ -/* lib/des/read_pwd.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/read_pwd.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -45,34 +56,40 @@ * [including the GNU Public Licence.] */ +#ifdef WIN16TTY +#undef WIN16 +#undef _WINDOWS +#include +#endif + /* 06-Apr-92 Luke Brennan Support for VMS */ #include "des_locl.h" #include #include #include +#include -#ifdef WIN32 /* Visual C++ 4.0 (Windows95/NT) */ -#include "passwd_dlg.h" -#endif /* WIN32 */ - /* There are 5 types of terminal interface supported, * TERMIO, TERMIOS, VMS, MSDOS and SGTTY */ -/* Now there are also support for Windows95/NT inteface - * d93-jka 960530 - */ -#if defined(sgi) || defined(__sgi) +#if defined(__sgi) && !defined(TERMIOS) #define TERMIOS #undef TERMIO #undef SGTTY #endif +#if defined(linux) && !defined(TERMIO) +#undef TERMIOS +#define TERMIO +#undef SGTTY +#endif + #ifdef _LIBC #define TERMIO #endif -#if !defined(TERMIO) && !defined(TERMIOS) && !defined(VMS) && !defined(MSDOS) && !defined(WIN32) +#if !defined(TERMIO) && !defined(TERMIOS) && !defined(VMS) && !defined(MSDOS) #define SGTTY #endif @@ -100,7 +117,7 @@ #define TTY_set(tty,data) ioctl(tty,TIOCSETP,data) #endif -#if !defined(_LIBC) && !defined(MSDOS) && !defined(WIN32) +#if !defined(_LIBC) && !defined(MSDOS) && !defined(VMS) #include #endif @@ -115,10 +132,10 @@ #include #include struct IOSB { - short iosb$w_value; - short iosb$w_count; - long iosb$l_info; -}; + short iosb$w_value; + short iosb$w_count; + long iosb$l_info; + }; #endif #ifndef NX509_SIG @@ -131,7 +148,7 @@ static int read_pw(char *buf, char *buff, int size, char *prompt, int verify); static void recsig(int); static void pushsig(void); static void popsig(void); -#ifdef MSDOS +#if defined(MSDOS) && !defined(WIN16) static int noecho_fgets(char *buf, int size, FILE *tty); #endif #else @@ -140,257 +157,294 @@ static int read_pw(); static void recsig(); static void pushsig(); static void popsig(); -#ifdef MSDOS +#if defined(MSDOS) && !defined(WIN16) static int noecho_fgets(); #endif #endif +#ifndef NOPROTO +static void (*savsig[NX509_SIG])(int ); +#else static void (*savsig[NX509_SIG])(); +#endif static jmp_buf save; int des_read_password(key, prompt, verify) - des_cblock (*key); - char *prompt; - int verify; -{ - int ok; - char buf[BUFSIZ],buff[BUFSIZ]; +des_cblock (*key); +char *prompt; +int verify; + { + int ok; + char buf[BUFSIZ],buff[BUFSIZ]; - if ((ok=read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) - des_string_to_key(buf,key); - memset(buf,0,BUFSIZ); - memset(buff,0,BUFSIZ); - return(ok); -} + if ((ok=read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) + des_string_to_key(buf,key); + memset(buf,0,BUFSIZ); + memset(buff,0,BUFSIZ); + return(ok); + } int des_read_2passwords(key1, key2, prompt, verify) - des_cblock (*key1); - des_cblock (*key2); - char *prompt; - int verify; -{ - int ok; - char buf[BUFSIZ],buff[BUFSIZ]; +des_cblock (*key1); +des_cblock (*key2); +char *prompt; +int verify; + { + int ok; + char buf[BUFSIZ],buff[BUFSIZ]; - if ((ok=read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) - des_string_to_2keys(buf,key1,key2); - memset(buf,0,BUFSIZ); - memset(buff,0,BUFSIZ); - return(ok); -} + if ((ok=read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) + des_string_to_2keys(buf,key1,key2); + memset(buf,0,BUFSIZ); + memset(buff,0,BUFSIZ); + return(ok); + } int des_read_pw_string(buf, length, prompt, verify) - char *buf; - int length; - char *prompt; - int verify; -{ - char buff[BUFSIZ]; - int ret; +char *buf; +int length; +char *prompt; +int verify; + { + char buff[BUFSIZ]; + int ret; - ret=read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify); - memset(buff,0,BUFSIZ); - return(ret); -} + ret=read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify); + memset(buff,0,BUFSIZ); + return(ret); + } + +#ifndef WIN16 static void read_till_nl(in) - FILE *in; -{ +FILE *in; + { #define SIZE 4 - char buf[SIZE+1]; + char buf[SIZE+1]; + + do { + fgets(buf,SIZE,in); + } while (strchr(buf,'\n') == NULL); + } - do { - fgets(buf,SIZE,in); - } while (strchr(buf,'\n') == NULL); -} /* return 0 if ok, 1 (or -1) otherwise */ static int read_pw(buf, buff, size, prompt, verify) - char *buf; - char *buff; - int size; - char *prompt; - int verify; -{ -#ifdef WIN32 /* Visual C++ 4.0 (Windows95/NT) */ - return pwd_dialog(buf, size); -#else /* !WIN32 */ +char *buf; +char *buff; +int size; +char *prompt; +int verify; + { #ifdef VMS - struct IOSB iosb; - $DESCRIPTOR(terminal,"TT"); - long tty_orig[3], tty_new[3]; - long status; - unsigned short channel = 0; + struct IOSB iosb; + $DESCRIPTOR(terminal,"TT"); + long tty_orig[3], tty_new[3]; + long status; + unsigned short channel = 0; #else #ifndef MSDOS - TTY_STRUCT tty_orig,tty_new; + TTY_STRUCT tty_orig,tty_new; #endif #endif - int number=5; - int ok=0; - int ps=0; - FILE *tty=NULL; - char *p; + int number=5; + int ok=0; + int ps=0; + int is_a_tty=1; + + FILE *tty=NULL; + char *p; #ifdef __CYGWIN32__ - tty = stdin; + tty = stdin; #elif !defined(MSDOS) - if ((tty=fopen("/dev/tty","r")) == NULL) - tty=stdin; + if ((tty=fopen("/dev/tty","r")) == NULL) + tty=stdin; #else /* MSDOS */ - if ((tty=fopen("con","r")) == NULL) - tty=stdin; + if ((tty=fopen("con","r")) == NULL) + tty=stdin; #endif /* MSDOS */ #if defined(TTY_get) && !defined(VMS) - if (TTY_get(fileno(tty),&tty_orig) == -1) - return(-1); - memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig)); + if (TTY_get(fileno(tty),&tty_orig) == -1) + { +#ifdef ENOTTY + if (errno == ENOTTY) + is_a_tty=0; + else +#endif + return(-1); + } + memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig)); #endif #ifdef VMS - status = SYS$ASSIGN(&terminal,&channel,0,0); - if (status != SS$_NORMAL) - return(-1); - status=SYS$QIOW(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0); - if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) - return(-1); + status = SYS$ASSIGN(&terminal,&channel,0,0); + if (status != SS$_NORMAL) + return(-1); + status=SYS$QIOW(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0); + if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) + return(-1); #endif - if (setjmp(save)) - { - ok=0; - goto error; - } - pushsig(); - ps=1; + if (setjmp(save)) + { + ok=0; + goto error; + } + pushsig(); + ps=1; #ifdef TTY_FLAGS - tty_new.TTY_FLAGS &= ~ECHO; + tty_new.TTY_FLAGS &= ~ECHO; #endif #if defined(TTY_set) && !defined(VMS) - if (TTY_set(fileno(tty),&tty_new) == -1) - return(-1); + if (is_a_tty && (TTY_set(fileno(tty),&tty_new) == -1)) + return(-1); #endif #ifdef VMS - tty_new[0] = tty_orig[0]; - tty_new[1] = tty_orig[1] | TT$M_NOECHO; - tty_new[2] = tty_orig[2]; - status = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0); - if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) - return(-1); + tty_new[0] = tty_orig[0]; + tty_new[1] = tty_orig[1] | TT$M_NOECHO; + tty_new[2] = tty_orig[2]; + status = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0); + if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) + return(-1); #endif - ps=2; + ps=2; - while ((!ok) && (number--)) - { - fputs(prompt,stderr); - fflush(stderr); - - buf[0]='\0'; - fgets(buf,size,tty); - if (feof(tty)) goto error; - if ((p=(char *)strchr(buf,'\n')) != NULL) - *p='\0'; - else read_till_nl(tty); - if (verify) + while ((!ok) && (number--)) { - fprintf(stderr,"\nVerifying password %s",prompt); - fflush(stderr); - buff[0]='\0'; - fgets(buff,size,tty); - if (feof(tty)) goto error; - if ((p=(char *)strchr(buff,'\n')) != NULL) + fputs(prompt,stderr); + fflush(stderr); + + buf[0]='\0'; + fgets(buf,size,tty); + if (feof(tty)) goto error; + if (ferror(tty)) goto error; + if ((p=(char *)strchr(buf,'\n')) != NULL) *p='\0'; - else read_till_nl(tty); - - if (strcmp(buf,buff) != 0) + else read_till_nl(tty); + if (verify) { - fprintf(stderr,"\nVerify failure"); - fflush(stderr); - break; - /* continue; */ + fprintf(stderr,"\nVerifying password - %s",prompt); + fflush(stderr); + buff[0]='\0'; + fgets(buff,size,tty); + if (feof(tty)) goto error; + if ((p=(char *)strchr(buff,'\n')) != NULL) + *p='\0'; + else read_till_nl(tty); + + if (strcmp(buf,buff) != 0) + { + fprintf(stderr,"\nVerify failure"); + fflush(stderr); + break; + /* continue; */ + } } + ok=1; } - ok=1; - } error: - fprintf(stderr,"\n"); - /* What can we do if there is an error? */ + fprintf(stderr,"\n"); +#ifdef DEBUG + perror("fgets(tty)"); +#endif + /* What can we do if there is an error? */ #if defined(TTY_set) && !defined(VMS) - if (ps >= 2) TTY_set(fileno(tty),&tty_orig); + if (ps >= 2) TTY_set(fileno(tty),&tty_orig); #endif #ifdef VMS - if (ps >= 2) - status = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0 - ,tty_orig,12,0,0,0,0); + if (ps >= 2) + status = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0 + ,tty_orig,12,0,0,0,0); #endif - if (ps >= 1) popsig(); - if (stdin != tty) fclose(tty); + if (ps >= 1) popsig(); + if (stdin != tty) fclose(tty); #ifdef VMS - status = SYS$DASSGN(channel); + status = SYS$DASSGN(channel); +#endif + return(!ok); + } + +#else /* WIN16 */ + +static int read_pw(buf, buff, size, prompt, verify) +char *buf; +char *buff; +int size; +char *prompt; +int verify; + { + memset(buf,0,size); + memset(buff,0,size); + return(0); + } + #endif - return(!ok); -#endif /* !WIN32 */ -} -#ifndef WIN32 /* Visual C++ 4.0 (Windows95/NT) */ static void pushsig() -{ - int i; + { + int i; - for (i=1; ides_key,ks); diff --git a/lib/des/rpw.c b/lib/des/rpw.c index 433b2f17a..3ca4cec85 100644 --- a/lib/des/rpw.c +++ b/lib/des/rpw.c @@ -1,17 +1,22 @@ -/* lib/des/rpw.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/rpw.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE diff --git a/lib/des/set_key.c b/lib/des/set_key.c index c6d945668..6714256da 100644 --- a/lib/des/set_key.c +++ b/lib/des/set_key.c @@ -1,17 +1,22 @@ -/* lib/des/set_key.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/set_key.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -140,8 +151,6 @@ des_cblock (*key); #define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ (a)=(a)^(t)^(t>>(16-(n)))) -static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; - /* return 0 if key parity is odd (correct), * return -1 if key parity error, * return -2 if illegal weak key. @@ -150,7 +159,8 @@ int des_set_key(key, schedule) des_cblock (*key); des_key_schedule schedule; { - register DES_LONG c,d,t,s; + static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; + register DES_LONG c,d,t,s,t2; register unsigned char *in; register DES_LONG *k; register int i; @@ -217,11 +227,11 @@ des_key_schedule schedule; des_skb[7][((d>>21L)&0x0f)|((d>>22L)&0x30)]; /* table contained 0213 4657 */ - *(k++)=((t<<16L)|(s&0x0000ffffL))&0xffffffffL; - s= ((s>>16L)|(t&0xffff0000L)); - - s=(s<<4L)|(s>>28L); - *(k++)=s&0xffffffffL; + t2=((t<<16L)|(s&0x0000ffffL))&0xffffffffL; + *(k++)=ROTATE(t2,30)&0xffffffffL; + + t2=((s>>16L)|(t&0xffff0000L)); + *(k++)=ROTATE(t2,26)&0xffffffffL; } return(0); } diff --git a/lib/des/speed.c b/lib/des/speed.c index e5e76eac5..61179941e 100644 --- a/lib/des/speed.c +++ b/lib/des/speed.c @@ -1,17 +1,22 @@ -/* lib/des/speed.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/speed.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -105,7 +116,7 @@ struct tms { #endif #endif -#define BUFSIZE ((long)1024*8) +#define BUFSIZE ((long)1024) long run=0; #ifndef NOPROTO @@ -189,7 +200,7 @@ char **argv; static des_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34}; des_key_schedule sch,sch2,sch3; double a,b,c,d,e; -#ifndef SIGALARM +#ifndef SIGALRM long ca,cb,cc,cd,ce; #endif @@ -202,17 +213,17 @@ char **argv; des_set_key((C_Block *)key3,sch3); #ifndef SIGALRM - printf("First we calculate the aproximate speed ...\n"); + printf("First we calculate the approximate speed ...\n"); des_set_key((C_Block *)key,sch); count=10; do { long i; + DES_LONG data[2]; count*=2; Time_F(START); for (i=count; i; i--) - des_ecb_encrypt((C_Block *)buf,(C_Block *)buf, - &(sch[0]),DES_ENCRYPT); + des_encrypt(data,&(sch[0]),DES_ENCRYPT); d=Time_F(STOP); } while (d < 3.0); ca=count; @@ -239,17 +250,20 @@ char **argv; a=((double)COUNT(ca))/d; #ifdef SIGALRM - printf("Doing des_ecb_encrypt's for 10 seconds\n"); + printf("Doing des_encrypt's for 10 seconds\n"); alarm(10); #else - printf("Doing des_ecb_encrypt %ld times\n",cb); + printf("Doing des_encrypt %ld times\n",cb); #endif Time_F(START); for (count=0,run=1; COND(cb); count++) - des_ecb_encrypt((C_Block *)buf,(C_Block *)buf, - &(sch[0]),DES_ENCRYPT); + { + DES_LONG data[2]; + + des_encrypt(data,&(sch[0]),DES_ENCRYPT); + } d=Time_F(STOP); - printf("%ld des_ecb_encrypt's in %.2f second\n",count,d); + printf("%ld des_encrypt's in %.2f second\n",count,d); b=((double)COUNT(cb)*8)/d; #ifdef SIGALRM @@ -262,7 +276,7 @@ char **argv; #endif Time_F(START); for (count=0,run=1; COND(cc); count++) - des_cbc_encrypt((C_Block *)buf,(C_Block *)buf,BUFSIZE,&(sch[0]), + des_ncbc_encrypt((C_Block *)buf,(C_Block *)buf,BUFSIZE,&(sch[0]), (C_Block *)&(key[0]),DES_ENCRYPT); d=Time_F(STOP); printf("%ld des_cbc_encrypt's of %ld byte blocks in %.2f second\n", @@ -304,12 +318,12 @@ char **argv; e=((double)COUNT(ce))/e; printf("set_key per sec = %12.2f (%5.1fuS)\n",a,1.0e6/a); - printf("DES ecb bytes per sec = %12.2f (%5.1fuS)\n",b,8.0e6/b); + printf("DES raw ecb bytes per sec = %12.2f (%5.1fuS)\n",b,8.0e6/b); printf("DES cbc bytes per sec = %12.2f (%5.1fuS)\n",c,8.0e6/c); printf("DES ede cbc bytes per sec = %12.2f (%5.1fuS)\n",d,8.0e6/d); printf("crypt per sec = %12.2f (%5.1fuS)\n",e,1.0e6/e); exit(0); -#ifdef LINT +#if defined(LINT) || defined(MSDOS) return(0); #endif } diff --git a/lib/des/str2key.c b/lib/des/str2key.c index 278ba0f92..e81f34817 100644 --- a/lib/des/str2key.c +++ b/lib/des/str2key.c @@ -1,17 +1,22 @@ -/* lib/des/str2key.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/str2key.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE diff --git a/lib/des/supp.c b/lib/des/supp.c index 8cd9289f0..d8a65b87e 100644 --- a/lib/des/supp.c +++ b/lib/des/supp.c @@ -1,17 +1,22 @@ -/* lib/des/supp.c */ -/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) +/* crypto/des/supp.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. - * - * This file is part of an SSL implementation written + * + * This package is an SSL implementation written * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL - * specification. This library and applications are - * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE - * as long as the following conditions are aheared to. + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * 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). * * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. If this code is used in a product, - * Eric Young should be given attribution as the author of the parts used. + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * @@ -25,7 +30,13 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Eric Young (eay@mincom.oz.au) + * "This product includes cryptographic software written by + * Eric Young (eay@mincom.oz.au)" + * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE