#include <stdio.h>
#include <stdlib.h>
-#ifndef MSDOS
-#ifndef VMS
+#include <string.h>
#include <openssl/opensslconf.h>
+#ifndef OPENSSL_SYS_MSDOS
+#ifndef OPENSSL_SYS_VMS
#include OPENSSL_UNISTD
-#else /* VMS */
+#else /* OPENSSL_SYS_VMS */
#ifdef __DECC
#include <unistd.h>
#else /* not __DECC */
#include <math.h>
#endif /* __DECC */
-#endif /* VMS */
-#else
+#endif /* OPENSSL_SYS_VMS */
+#else /* OPENSSL_SYS_MSDOS */
#include <io.h>
#endif
#include <time.h>
#include "des_ver.h"
-#ifdef VMS
+#ifdef OPENSSL_SYS_VMS
#include <types.h>
#include <stat.h>
#else
#endif
#include <openssl/des.h>
#include <openssl/rand.h>
-
-#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS)
-#include <string.h>
-#endif
+#include <openssl/ui_compat.h>
void usage(void);
void doencryption(void);
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)
#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
{
EXIT(5);
}
-#ifdef MSDOS
+#ifdef OPENSSL_SYS_MSDOS
/* This should set the file to binary mode. */
{
#include <fcntl.h>
"des <options> [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",
" 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
};
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;
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)
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
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 :-( */
if (cflag)
{
des_cbc_cksum(buf,&cksum,
- (long)len,ks,&cksum);
+ (long)len,&ks,&cksum);
if (!eflag)
{
if (feof(DES_IN)) break;
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<l; i+=8)
des_ecb2_encrypt(
(des_cblock *)&(buf[i]),
(des_cblock *)&(obuf[i]),
- ks,ks2,do_encrypt);
+ &ks,&ks2,do_encrypt);
else if (flag3 && !bflag)
{
char tmpbuf[8];
{
des_cbc_encrypt(
buf,obuf,
- (long)l,ks,&iv,do_encrypt);
+ (long)l,&ks,&iv,do_encrypt);
if (l >= 8) memcpy(iv,&(obuf[l-8]),8);
}
if (rem) memcpy(buf,&(buf[l]),(unsigned int)rem);
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<l; i+=8)
des_ecb2_encrypt(
(des_cblock *)&(buf[i]),
(des_cblock *)&(obuf[i]),
- ks,ks2,do_encrypt);
+ &ks,&ks2,do_encrypt);
else if (flag3 && !bflag)
{
des_3cbc_encrypt(
{
des_cbc_encrypt(
buf,obuf,
- (long)l,ks,&iv,do_encrypt);
+ (long)l,&ks,&iv,do_encrypt);
if (l >= 8) memcpy(iv,&(buf[l-8]),8);
}
}
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)
{
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));