X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fdes%2Fdes.c;h=16e5ab9eb22da995f9517c4f20404417bc5a1241;hp=aabd01cc8a6aa8e79ffff50ede81ae5770776819;hb=0cff93341672f188e492101307dc56756489108d;hpb=e7f97e2d22e386df60c8da63277727a931bf22b7 diff --git a/crypto/des/des.c b/crypto/des/des.c index aabd01cc8a..16e5ab9eb2 100644 --- a/crypto/des/des.c +++ b/crypto/des/des.c @@ -58,25 +58,26 @@ #include #include -#ifndef MSDOS -#ifndef VMS +#include #include +#ifndef OPENSSL_SYS_MSDOS +#ifndef OPENSSL_SYS_VMS #include OPENSSL_UNISTD -#else /* VMS */ +#else /* OPENSSL_SYS_VMS */ #ifdef __DECC #include #else /* not __DECC */ #include #endif /* __DECC */ -#endif /* VMS */ -#else +#endif /* OPENSSL_SYS_VMS */ +#else /* OPENSSL_SYS_MSDOS */ #include #endif #include #include "des_ver.h" -#ifdef VMS +#ifdef OPENSSL_SYS_VMS #include #include #else @@ -87,10 +88,7 @@ #endif #include #include - -#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS) -#include -#endif +#include void usage(void); void doencryption(void); @@ -102,7 +100,7 @@ int uudecode(unsigned char *in,int num,unsigned char *out); void des_3cbc_encrypt(des_cblock *input,des_cblock *output,long length, des_key_schedule sk1,des_key_schedule sk2, des_cblock *ivec1,des_cblock *ivec2,int enc); -#ifdef VMS +#ifdef OPENSSL_SYS_VMS #define EXIT(a) exit(a&0x10000000L) #else #define EXIT(a) exit(a) @@ -261,12 +259,12 @@ int main(int argc, char **argv) #endif if ( (in != NULL) && (out != NULL) && -#ifndef MSDOS +#ifndef OPENSSL_SYS_MSDOS (stat(in,&ins) != -1) && (stat(out,&outs) != -1) && (ins.st_dev == outs.st_dev) && (ins.st_ino == outs.st_ino)) -#else /* MSDOS */ +#else /* OPENSSL_SYS_MSDOS */ (strcmp(in,out) == 0)) #endif { @@ -301,7 +299,7 @@ int main(int argc, char **argv) EXIT(5); } -#ifdef MSDOS +#ifdef OPENSSL_SYS_MSDOS /* This should set the file to binary mode. */ { #include @@ -325,11 +323,11 @@ void usage(void) "des [input-file [output-file]]", "options:", "-v : des(1) version number", -"-e : encrypt using sunOS compatible user key to DES key conversion.", +"-e : encrypt using SunOS compatible user key to DES key conversion.", "-E : encrypt ", -"-d : decrypt using sunOS compatible user key to DES key conversion.", +"-d : decrypt using SunOS compatible user key to DES key conversion.", "-D : decrypt ", -"-c[ckname] : generate a cbc_cksum using sunOS compatible user key to", +"-c[ckname] : generate a cbc_cksum using SunOS compatible user key to", " DES key conversion and output to ckname (stdout default,", " stderr if data being output on stdout). The checksum is", " generated before encryption and after decryption if used", @@ -340,10 +338,10 @@ void usage(void) " that is used directly as the des key", "-u[uuname] : input file is uudecoded if -[dD] or output uuencoded data if -[eE]", " (uuname is the filename to put in the uuencode header).", -"-b : encrypt using DES in ecb encryption mode, the defaut is cbc mode.", -"-3 : encrypt using tripple DES encryption. This uses 2 keys", +"-b : encrypt using DES in ecb encryption mode, the default is cbc mode.", +"-3 : encrypt using triple DES encryption. This uses 2 keys", " generated from the input key. If the input key is less", -" than 8 characters long, this is equivelent to normal", +" than 8 characters long, this is equivalent to normal", " encryption. Default is triple cbc, -b makes it triple ecb.", NULL }; @@ -370,15 +368,15 @@ void doencryption(void) des_cblock kk,k2; FILE *O; int Exit=0; -#ifndef MSDOS +#ifndef OPENSSL_SYS_MSDOS static unsigned char buf[BUFSIZE+8],obuf[BUFSIZE+8]; #else static unsigned char *buf=NULL,*obuf=NULL; if (buf == NULL) { - if ( (( buf=Malloc(BUFSIZE+8)) == NULL) || - ((obuf=Malloc(BUFSIZE+8)) == NULL)) + if ( (( buf=OPENSSL_malloc(BUFSIZE+8)) == NULL) || + ((obuf=OPENSSL_malloc(BUFSIZE+8)) == NULL)) { fputs("Not enough memory\n",stderr); Exit=10; @@ -425,7 +423,7 @@ void doencryption(void) else k2[i-8]=k; } - des_set_key_unchecked(&k2,ks2); + des_set_key_unchecked(&k2,&ks2); memset(k2,0,sizeof(k2)); } else if (longk || flag3) @@ -433,7 +431,7 @@ void doencryption(void) if (flag3) { des_string_to_2keys(key,&kk,&k2); - des_set_key_unchecked(&k2,ks2); + des_set_key_unchecked(&k2,&ks2); memset(k2,0,sizeof(k2)); } else @@ -455,7 +453,7 @@ void doencryption(void) kk[i]=key[i]|0x80; } - des_set_key_unchecked(&kk,ks); + des_set_key_unchecked(&kk,&ks); memset(key,0,sizeof(key)); memset(kk,0,sizeof(kk)); /* woops - A bug that does not showup under unix :-( */ @@ -495,7 +493,7 @@ void doencryption(void) if (cflag) { des_cbc_cksum(buf,&cksum, - (long)len,ks,&cksum); + (long)len,&ks,&cksum); if (!eflag) { if (feof(DES_IN)) break; @@ -508,13 +506,13 @@ void doencryption(void) des_ecb_encrypt( (des_cblock *)&(buf[i]), (des_cblock *)&(obuf[i]), - ks,do_encrypt); + &ks,do_encrypt); else if (flag3 && bflag) for (i=0; i= 8) memcpy(iv,&(obuf[l-8]),8); } if (rem) memcpy(buf,&(buf[l]),(unsigned int)rem); @@ -587,13 +585,13 @@ void doencryption(void) des_ecb_encrypt( (des_cblock *)&(buf[i]), (des_cblock *)&(obuf[i]), - ks,do_encrypt); + &ks,do_encrypt); else if (flag3 && bflag) for (i=0; i= 8) memcpy(iv,&(buf[l-8]),8); } @@ -631,7 +629,7 @@ void doencryption(void) } i=0; if (cflag) des_cbc_cksum(obuf, - (des_cblock *)cksum,(long)l/8*8,ks, + (des_cblock *)cksum,(long)l/8*8,&ks, (des_cblock *)cksum); while (i != l) { @@ -667,8 +665,8 @@ void doencryption(void) problems: memset(buf,0,sizeof(buf)); memset(obuf,0,sizeof(obuf)); - memset(ks,0,sizeof(ks)); - memset(ks2,0,sizeof(ks2)); + memset(&ks,0,sizeof(ks)); + memset(&ks2,0,sizeof(ks2)); memset(iv,0,sizeof(iv)); memset(iv2,0,sizeof(iv2)); memset(kk,0,sizeof(kk));