summaryrefslogtreecommitdiffstats
path: root/crypto/libdes
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/libdes')
-rw-r--r--crypto/libdes/enc_read.c102
-rw-r--r--crypto/libdes/enc_writ.c76
-rw-r--r--crypto/libdes/rnd_keys.c20
3 files changed, 95 insertions, 103 deletions
diff --git a/crypto/libdes/enc_read.c b/crypto/libdes/enc_read.c
index 694970c..ed3ee82 100644
--- a/crypto/libdes/enc_read.c
+++ b/crypto/libdes/enc_read.c
@@ -1,9 +1,9 @@
/* crypto/des/enc_read.c */
-/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This package is an SSL implementation written
- * by Eric Young (eay@cryptsoft.com).
+ * by Eric Young (eay@mincom.oz.au).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
@@ -11,7 +11,7 @@
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
- * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ * 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.
@@ -31,12 +31,12 @@
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* "This product includes cryptographic software written by
- * Eric Young (eay@cryptsoft.com)"
+ * 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@cryptsoft.com)"
+ * "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
@@ -56,36 +56,24 @@
* [including the GNU Public Licence.]
*/
+#include <sys/types.h>
+#include <sys/uio.h>
#include <stdio.h>
#include <errno.h>
-#include "cryptlib.h"
+#include <unistd.h>
+
#include "des_locl.h"
/* This has some uglies in it but it works - even over sockets. */
/*extern int errno;*/
-OPENSSL_GLOBAL int des_rw_mode=DES_PCBC_MODE;
-
-
-/*
- * WARNINGS:
- *
- * - The data format used by des_enc_write() and des_enc_read()
- * has a cryptographic weakness: When asked to write more
- * than MAXWRITE bytes, des_enc_write will split the data
- * into several chunks that are all encrypted
- * using the same IV. So don't use these functions unless you
- * are sure you know what you do (in which case you might
- * not want to use them anyway).
- *
- * - This code cannot handle non-blocking sockets.
- *
- * - This function uses an internal state and thus cannot be
- * used on multiple files.
- */
-
-
-int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
- des_cblock *iv)
+int des_rw_mode=DES_PCBC_MODE;
+
+int des_enc_read(fd, buf, len, sched, iv)
+int fd;
+char *buf;
+int len;
+des_key_schedule sched;
+des_cblock (*iv);
{
/* data to be unencrypted */
int net_num=0;
@@ -93,27 +81,27 @@ int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
/* extra unencrypted data
* for when a block of 100 comes in but is des_read one byte at
* a time. */
- static unsigned char *unnet=NULL;
+ static char *unnet=NULL;
static int unnet_start=0;
static int unnet_left=0;
- static unsigned char *tmpbuf=NULL;
+ static char *tmpbuf=NULL;
int i;
long num=0,rnum;
unsigned char *p;
if (tmpbuf == NULL)
{
- tmpbuf=Malloc(BSIZE);
+ tmpbuf=(char *)malloc(BSIZE);
if (tmpbuf == NULL) return(-1);
}
if (net == NULL)
{
- net=Malloc(BSIZE);
+ net=(unsigned char *)malloc(BSIZE);
if (net == NULL) return(-1);
}
if (unnet == NULL)
{
- unnet=Malloc(BSIZE);
+ unnet=(char *)malloc(BSIZE);
if (unnet == NULL) return(-1);
}
/* left over data from last decrypt */
@@ -125,7 +113,7 @@ int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
* with the number of bytes we have - should always
* check the return value */
memcpy(buf,&(unnet[unnet_start]),
- unnet_left);
+ (unsigned int)unnet_left);
/* eay 26/08/92 I had the next 2 lines
* reversed :-( */
i=unnet_left;
@@ -133,7 +121,7 @@ int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
}
else
{
- memcpy(buf,&(unnet[unnet_start]),len);
+ memcpy(buf,&(unnet[unnet_start]),(unsigned int)len);
unnet_start+=len;
unnet_left-=len;
i=len;
@@ -147,10 +135,8 @@ int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
/* first - get the length */
while (net_num < HDRSIZE)
{
- i=read(fd,&(net[net_num]),HDRSIZE-net_num);
-#ifdef EINTR
+ i=read(fd,&(net[net_num]),(unsigned int)HDRSIZE-net_num);
if ((i == -1) && (errno == EINTR)) continue;
-#endif
if (i <= 0) return(0);
net_num+=i;
}
@@ -169,10 +155,8 @@ int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
net_num=0;
while (net_num < rnum)
{
- i=read(fd,&(net[net_num]),rnum-net_num);
-#ifdef EINTR
+ i=read(fd,&(net[net_num]),(unsigned int)rnum-net_num);
if ((i == -1) && (errno == EINTR)) continue;
-#endif
if (i <= 0) return(0);
net_num+=i;
}
@@ -181,12 +165,14 @@ int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
if (len < num)
{
if (des_rw_mode & DES_PCBC_MODE)
- des_pcbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT);
+ des_pcbc_encrypt((des_cblock *)net,(des_cblock *)unnet,
+ num,sched,iv,DES_DECRYPT);
else
- des_cbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT);
- memcpy(buf,unnet,len);
+ 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. */
@@ -203,26 +189,30 @@ int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
{
if (des_rw_mode & DES_PCBC_MODE)
- des_pcbc_encrypt(net,tmpbuf,num,sched,iv,
- DES_DECRYPT);
+ des_pcbc_encrypt((des_cblock *)net,
+ (des_cblock *)tmpbuf,
+ num,sched,iv,DES_DECRYPT);
else
- des_cbc_encrypt(net,tmpbuf,num,sched,iv,
- DES_DECRYPT);
+ des_cbc_encrypt((des_cblock *)net,
+ (des_cblock *)tmpbuf,
+ num,sched,iv,DES_DECRYPT);
/* eay 26/08/92 fix a bug that returned more
* bytes than you asked for (returned len bytes :-( */
- memcpy(buf,tmpbuf,num);
+ memcpy(buf,tmpbuf,(unsigned int)num);
}
else
{
if (des_rw_mode & DES_PCBC_MODE)
- des_pcbc_encrypt(net,buf,num,sched,iv,
- DES_DECRYPT);
+ des_pcbc_encrypt((des_cblock *)net,
+ (des_cblock *)buf,num,sched,iv,
+ DES_DECRYPT);
else
- des_cbc_encrypt(net,buf,num,sched,iv,
- DES_DECRYPT);
+ des_cbc_encrypt((des_cblock *)net,
+ (des_cblock *)buf,num,sched,iv,
+ DES_DECRYPT);
}
}
- return num;
+ return((int)num);
}
diff --git a/crypto/libdes/enc_writ.c b/crypto/libdes/enc_writ.c
index ba3f082..128b151 100644
--- a/crypto/libdes/enc_writ.c
+++ b/crypto/libdes/enc_writ.c
@@ -1,9 +1,9 @@
/* crypto/des/enc_writ.c */
-/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This package is an SSL implementation written
- * by Eric Young (eay@cryptsoft.com).
+ * by Eric Young (eay@mincom.oz.au).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
@@ -11,7 +11,7 @@
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
- * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ * 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.
@@ -31,12 +31,12 @@
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* "This product includes cryptographic software written by
- * Eric Young (eay@cryptsoft.com)"
+ * 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@cryptsoft.com)"
+ * "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
@@ -56,46 +56,38 @@
* [including the GNU Public Licence.]
*/
+#include <sys/types.h>
+#include <sys/uio.h>
#include <errno.h>
#include <time.h>
-#include <stdio.h>
-#include "cryptlib.h"
-#include "des_locl.h"
-#include <openssl/rand.h>
+#include <unistd.h>
-/*
- * WARNINGS:
- *
- * - The data format used by des_enc_write() and des_enc_read()
- * has a cryptographic weakness: When asked to write more
- * than MAXWRITE bytes, des_enc_write will split the data
- * into several chunks that are all encrypted
- * using the same IV. So don't use these functions unless you
- * are sure you know what you do (in which case you might
- * not want to use them anyway).
- *
- * - This code cannot handle non-blocking sockets.
- */
+#include "des_locl.h"
-int des_enc_write(int fd, const void *_buf, int len,
- des_key_schedule sched, des_cblock *iv)
+int des_enc_write(fd, buf, len, sched, iv)
+int fd;
+char *buf;
+int len;
+des_key_schedule sched;
+des_cblock (*iv);
{
#ifdef _LIBC
+ extern int srandom();
extern unsigned long time();
+ extern int random();
extern int write();
#endif
- const unsigned char *buf=_buf;
+
long rnum;
int i,j,k,outnum;
- static unsigned char *outbuf=NULL;
- unsigned char shortbuf[8];
- unsigned char *p;
- const unsigned char *cp;
+ char *outbuf=NULL;
+ char shortbuf[8];
+ char *p;
static int start=1;
if (outbuf == NULL)
{
- outbuf=Malloc(BSIZE+HDRSIZE);
+ outbuf=(char *)malloc(BSIZE+HDRSIZE);
if (outbuf == NULL) return(-1);
}
/* If we are sending less than 8 bytes, the same char will look
@@ -103,6 +95,7 @@ int des_enc_write(int fd, const void *_buf, int len,
if (start)
{
start=0;
+ srandom((unsigned int)time(NULL));
}
/* lets recurse if we want to send the data in small chunks */
@@ -128,32 +121,35 @@ int des_enc_write(int fd, const void *_buf, int len,
/* pad short strings */
if (len < 8)
{
- cp=shortbuf;
- memcpy(shortbuf,buf,len);
- RAND_bytes(shortbuf+len, 8-len);
+ p=shortbuf;
+ memcpy(shortbuf,buf,(unsigned int)len);
+ for (i=len; i<8; i++)
+ shortbuf[i]=random();
rnum=8;
}
else
{
- cp=(unsigned char*)buf;
+ p=buf;
rnum=((len+7)/8*8); /* round up to nearest eight */
}
if (des_rw_mode & DES_PCBC_MODE)
- des_pcbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv,
- DES_ENCRYPT);
+ des_pcbc_encrypt((des_cblock *)p,
+ (des_cblock *)&(outbuf[HDRSIZE]),
+ (long)((len<8)?8:len),sched,iv,DES_ENCRYPT);
else
- des_cbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv,
- DES_ENCRYPT);
+ 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<outnum; j+=i)
{
/* eay 26/08/92 I was not doing writing from where we
* got upto. */
- i=write(fd,&(outbuf[j]),outnum-j);
+ i=write(fd,&(outbuf[j]),(unsigned int)(outnum-j));
if (i == -1)
{
if (errno == EINTR)
diff --git a/crypto/libdes/rnd_keys.c b/crypto/libdes/rnd_keys.c
index 8800060..da86b89 100644
--- a/crypto/libdes/rnd_keys.c
+++ b/crypto/libdes/rnd_keys.c
@@ -39,18 +39,17 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-RCSID("$Id: rnd_keys.c,v 1.55 1999/03/19 23:17:13 assar Exp $");
+RCSID("$Id$");
#endif
+#include <sys/types.h>
+#include <sys/time.h>
#include <des.h>
#include <des_locl.h>
-#ifdef KRB5
-#include <krb5-types.h>
-#elif defined(KRB4)
-#include <ktypes.h>
-#endif
-
+#include <fcntl.h>
+#include <signal.h>
#include <string.h>
+#include <time.h>
#ifdef TIME_WITH_SYS_TIME
#include <sys/time.h>
@@ -83,6 +82,13 @@ RCSID("$Id: rnd_keys.c,v 1.55 1999/03/19 23:17:13 assar Exp $");
#include <winsock.h>
#endif
+#ifndef RETSIGTYPE
+#define RETSIGTYPE void
+#define SIGRETURN(x) return
+#else
+#define SIGRETURN(x) return (RETSIGTYPE)(x)
+#endif
+
/*
* Generate "random" data by checksumming a file.
*
OpenPOWER on IntegriCloud