summaryrefslogtreecommitdiffstats
path: root/crypto/libdes
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>1999-09-19 13:04:49 +0000
committermarkm <markm@FreeBSD.org>1999-09-19 13:04:49 +0000
commit4f947d680afa74c70cf3f206d4f05dcc3555aa90 (patch)
treefb49b46774fc9e5eec7f68ad03520894099d3e51 /crypto/libdes
parentb547f6c567b41efd85da3ddd236592d50e335802 (diff)
downloadFreeBSD-src-4f947d680afa74c70cf3f206d4f05dcc3555aa90.zip
FreeBSD-src-4f947d680afa74c70cf3f206d4f05dcc3555aa90.tar.gz
Big OpenSSL/KTH/FreeBSD merge, badly poisoned by $FreeBSD$'s.
Diffstat (limited to 'crypto/libdes')
-rw-r--r--crypto/libdes/asm/dx86-cpp.s3
-rw-r--r--crypto/libdes/asm/win32.asm3
-rw-r--r--crypto/libdes/cbc3_enc.c14
-rw-r--r--crypto/libdes/des.c8
-rw-r--r--crypto/libdes/des.h30
-rw-r--r--crypto/libdes/des.org12
-rw-r--r--crypto/libdes/des_enc.c3
-rw-r--r--crypto/libdes/des_locl.h16
-rw-r--r--crypto/libdes/des_locl.org20
-rw-r--r--crypto/libdes/des_ver.h7
-rw-r--r--crypto/libdes/ecb_enc.c7
-rw-r--r--crypto/libdes/ede_enc.c12
-rw-r--r--crypto/libdes/enc_read.c97
-rw-r--r--crypto/libdes/enc_writ.c72
-rw-r--r--crypto/libdes/fcrypt.c61
-rw-r--r--crypto/libdes/rand_key.c3
-rw-r--r--crypto/libdes/read_pwd.c18
-rw-r--r--crypto/libdes/rnd_keys.c80
-rw-r--r--crypto/libdes/set_key.c4
-rw-r--r--crypto/libdes/spr.h4
-rw-r--r--crypto/libdes/str2key.c4
-rw-r--r--crypto/libdes/version.h8
22 files changed, 259 insertions, 227 deletions
diff --git a/crypto/libdes/asm/dx86-cpp.s b/crypto/libdes/asm/dx86-cpp.s
index 27d6ceea..4741452 100644
--- a/crypto/libdes/asm/dx86-cpp.s
+++ b/crypto/libdes/asm/dx86-cpp.s
@@ -3,9 +3,10 @@
/* Which is a perl program used to generate the x86 assember for */
/* any of elf, a.out, Win32, or Solaris */
/* It can be found in SSLeay 0.6.5+ or in libdes 3.26+ */
- /* eric <eay@mincom.oz.au> */
+ /* eric <eay@cryptsoft.com> */
/* The inner loop instruction sequence and the IP/FP modifications */
/* are from Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk> */
+ /* $FreeBSD$ */
.file "dx86xxxx.s"
.version "01.01"
diff --git a/crypto/libdes/asm/win32.asm b/crypto/libdes/asm/win32.asm
index 29c915f..508b511 100644
--- a/crypto/libdes/asm/win32.asm
+++ b/crypto/libdes/asm/win32.asm
@@ -3,9 +3,10 @@
; Which is a perl program used to generate the x86 assember for
; any of elf, a.out, Win32, or Solaris
; It can be found in SSLeay 0.6.5+ or in libdes 3.26+
- ; eric <eay@mincom.oz.au>
+ ; eric <eay@cryptsoft.com>
; The inner loop instruction sequence and the IP/FP modifications
; are from Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>
+ ; $FreeBSD$
;
TITLE dx86xxxx.asm
diff --git a/crypto/libdes/cbc3_enc.c b/crypto/libdes/cbc3_enc.c
index 3863a67..a96f23c5 100644
--- a/crypto/libdes/cbc3_enc.c
+++ b/crypto/libdes/cbc3_enc.c
@@ -54,6 +54,8 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
*/
#include "des_locl.h"
@@ -69,11 +71,11 @@ void des_3cbc_encrypt(des_cblock *input, des_cblock *output, long length,
if (enc == DES_ENCRYPT)
{
- des_cbc_encrypt(input,output,length,ks1,iv1,enc);
+ des_cbc_encrypt((void*)input,(void*)output,length,ks1,iv1,enc);
if (length >= sizeof(des_cblock))
memcpy(niv1,output[off],sizeof(des_cblock));
- des_cbc_encrypt(output,output,l8,ks2,iv1,!enc);
- des_cbc_encrypt(output,output,l8,ks1,iv2, enc);
+ des_cbc_encrypt((void*)output,(void*)output,l8,ks2,iv1,!enc);
+ des_cbc_encrypt((void*)output,(void*)output,l8,ks1,iv2, enc);
if (length >= sizeof(des_cblock))
memcpy(niv2,output[off],sizeof(des_cblock));
}
@@ -81,11 +83,11 @@ void des_3cbc_encrypt(des_cblock *input, des_cblock *output, long length,
{
if (length >= sizeof(des_cblock))
memcpy(niv2,input[off],sizeof(des_cblock));
- des_cbc_encrypt(input,output,l8,ks1,iv2,enc);
- des_cbc_encrypt(output,output,l8,ks2,iv1,!enc);
+ des_cbc_encrypt((void*)input,(void*)output,l8,ks1,iv2,enc);
+ des_cbc_encrypt((void*)output,(void*)output,l8,ks2,iv1,!enc);
if (length >= sizeof(des_cblock))
memcpy(niv1,output[off],sizeof(des_cblock));
- des_cbc_encrypt(output,output,length,ks1,iv1, enc);
+ des_cbc_encrypt((void*)output,(void*)output,length,ks1,iv1, enc);
}
memcpy(*iv1,niv1,sizeof(des_cblock));
memcpy(*iv2,niv2,sizeof(des_cblock));
diff --git a/crypto/libdes/des.c b/crypto/libdes/des.c
index b2d7f0d..eafadbc 100644
--- a/crypto/libdes/des.c
+++ b/crypto/libdes/des.c
@@ -54,6 +54,8 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
*/
#include <stdio.h>
@@ -377,8 +379,8 @@ void doencryption(void)
if (buf == NULL)
{
- if ( (( buf=Malloc(BUFSIZE+8)) == NULL) ||
- ((obuf=Malloc(BUFSIZE+8)) == NULL))
+ if ( (( buf=malloc(BUFSIZE+8)) == NULL) ||
+ ((obuf=malloc(BUFSIZE+8)) == NULL))
{
fputs("Not enough memory\n",stderr);
Exit=10;
@@ -484,7 +486,7 @@ void doencryption(void)
if (feof(DES_IN))
{
for (i=7-rem; i>0; i--)
- RAND_bytes(buf + l++, 1);
+ des_rand_data(buf + l++, 1);
buf[l++]=rem;
ex=1;
len+=rem;
diff --git a/crypto/libdes/des.h b/crypto/libdes/des.h
index 67f90aa..4f451dc 100644
--- a/crypto/libdes/des.h
+++ b/crypto/libdes/des.h
@@ -54,6 +54,8 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
*/
#ifndef HEADER_DES_H
@@ -67,13 +69,17 @@ extern "C" {
#error DES is disabled.
#endif
-#ifdef _KERBEROS_DES_H
-#error <openssl/des.h> replaces <kerberos/des.h>.
+/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
+ * %20 speed up (longs are 8 bytes, int's are 4). */
+#ifndef DES_LONG
+#if defined(__alpha) || defined(__sparcv9)
+#define DES_LONG unsigned int
+#else /* Not a 64 bit machine */
+#define DES_LONG unsigned long
+#endif
#endif
#include <stdio.h>
-#include <openssl/opensslconf.h> /* DES_LONG */
-#include <openssl/e_os2.h> /* OPENSSL_EXTERN */
typedef unsigned char des_cblock[8];
typedef /* const */ unsigned char const_des_cblock[8];
@@ -115,9 +121,16 @@ typedef struct des_ks_struct
#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
-OPENSSL_EXTERN int des_check_key; /* defaults to false */
-OPENSSL_EXTERN int des_rw_mode; /* defaults to DES_PCBC_MODE */
-OPENSSL_EXTERN int des_set_weak_key_flag; /* set the weak key flag */
+extern int des_check_key; /* defaults to false */
+extern int des_rw_mode; /* defaults to DES_PCBC_MODE */
+extern int des_set_weak_key_flag; /* set the weak key flag */
+
+#define C_Block des_cblock
+#define Key_schedule des_key_schedule
+#ifdef KERBEROS
+#define ENCRYPT DES_ENCRYPT
+#define DECRYPT DES_DECRYPT
+#endif
const char *des_options(void);
void des_ecb3_encrypt(const_des_cblock *input, des_cblock *output,
@@ -187,6 +200,8 @@ DES_LONG des_quad_cksum(const unsigned char *input,des_cblock output[],
long length,int out_count,des_cblock *seed);
void des_random_seed(des_cblock *key);
void des_random_key(des_cblock *ret);
+void des_init_random_number_generator(des_cblock *seed);
+void des_rand_data(unsigned char *data, int size);
int des_read_password(des_cblock *key,const char *prompt,int verify);
int des_read_2passwords(des_cblock *key1,des_cblock *key2,
const char *prompt,int verify);
@@ -205,6 +220,7 @@ void des_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length,
int des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify);
/* Extra functions from Mark Murray <mark@grondar.za> */
+int des_new_random_key(des_cblock *key);
void des_cblock_print_file(const_des_cblock *cb, FILE *fp);
/* The following definitions provide compatibility with the MIT Kerberos
diff --git a/crypto/libdes/des.org b/crypto/libdes/des.org
index c1eef51..4743b9d 100644
--- a/crypto/libdes/des.org
+++ b/crypto/libdes/des.org
@@ -1,9 +1,9 @@
/* crypto/des/des.h */
-/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
+/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
- * by Eric Young (eay@mincom.oz.au).
+ * by Eric Young (eay@cryptsoft.com).
* 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@mincom.oz.au).
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* 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@mincom.oz.au)"
+ * Eric Young (eay@cryptsoft.com)"
* 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 product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -54,6 +54,8 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
*/
#ifndef HEADER_DES_H
diff --git a/crypto/libdes/des_enc.c b/crypto/libdes/des_enc.c
index 8311e10..ed42ab6 100644
--- a/crypto/libdes/des_enc.c
+++ b/crypto/libdes/des_enc.c
@@ -54,6 +54,8 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
*/
#include "des_locl.h"
@@ -290,7 +292,6 @@ void des_decrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2,
#ifndef DES_DEFAULT_OPTIONS
#undef CBC_ENC_C__DONT_UPDATE_IV
-#include "ncbc_enc.c" /* des_ncbc_encrypt */
void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
long length, des_key_schedule ks1, des_key_schedule ks2,
diff --git a/crypto/libdes/des_locl.h b/crypto/libdes/des_locl.h
index d6ea17c..8514cd6 100644
--- a/crypto/libdes/des_locl.h
+++ b/crypto/libdes/des_locl.h
@@ -54,6 +54,8 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
*/
#ifndef HEADER_DES_LOCL_H
@@ -68,16 +70,6 @@
#include <stdio.h>
#include <stdlib.h>
-#include <openssl/opensslconf.h>
-
-#ifndef MSDOS
-#if !defined(VMS) || defined(__DECC)
-#include OPENSSL_UNISTD
-#include <math.h>
-#endif
-#endif
-#include <openssl/des.h>
-
#ifdef MSDOS /* Visual C++ 2.1 (Windows NT/95) */
#include <stdlib.h>
#include <errno.h>
@@ -89,6 +81,8 @@
#include <string.h>
#endif
+#include "des.h"
+
#define ITERATIONS 16
#define HALF_ITERATIONS 8
@@ -401,7 +395,7 @@
PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \
}
-OPENSSL_EXTERN const DES_LONG des_SPtrans[8][64];
+extern const DES_LONG des_SPtrans[8][64];
void fcrypt_body(DES_LONG *out,des_key_schedule ks,
DES_LONG Eswap0, DES_LONG Eswap1);
diff --git a/crypto/libdes/des_locl.org b/crypto/libdes/des_locl.org
index 3853ddc..844d765 100644
--- a/crypto/libdes/des_locl.org
+++ b/crypto/libdes/des_locl.org
@@ -1,9 +1,9 @@
/* crypto/des/des_locl.h */
-/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
+/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
- * by Eric Young (eay@mincom.oz.au).
+ * by Eric Young (eay@cryptsoft.com).
* 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@mincom.oz.au).
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* 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@mincom.oz.au)"
+ * Eric Young (eay@cryptsoft.com)"
* 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 product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -54,14 +54,8 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
- */
-
-/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
- *
- * Always modify des_locl.org since des_locl.h is automatically generated from
- * it during SSLeay configuration.
- *
- * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
+ *
+ * $FreeBSD$
*/
#ifndef HEADER_DES_LOCL_H
diff --git a/crypto/libdes/des_ver.h b/crypto/libdes/des_ver.h
index de3c02f..70477a7 100644
--- a/crypto/libdes/des_ver.h
+++ b/crypto/libdes/des_ver.h
@@ -54,8 +54,9 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
*/
-#include <openssl/e_os2.h>
-OPENSSL_EXTERN char *DES_version; /* SSLeay version string */
-OPENSSL_EXTERN char *libdes_version; /* old libdes version string */
+extern char *DES_version; /* SSLeay version string */
+extern char *libdes_version; /* old libdes version string */
diff --git a/crypto/libdes/ecb_enc.c b/crypto/libdes/ecb_enc.c
index b261a8a..17e33fa 100644
--- a/crypto/libdes/ecb_enc.c
+++ b/crypto/libdes/ecb_enc.c
@@ -54,14 +54,15 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
*/
#include "des_locl.h"
#include "spr.h"
-#include <openssl/opensslv.h>
-OPENSSL_GLOBAL const char *libdes_version="libdes" OPENSSL_VERSION_PTEXT;
-OPENSSL_GLOBAL const char *DES_version="DES" OPENSSL_VERSION_PTEXT;
+const char *libdes_version="libdes" " 0_9_4";
+const char *DES_version="DES" " 0_9_4";
const char *des_options(void)
{
diff --git a/crypto/libdes/ede_enc.c b/crypto/libdes/ede_enc.c
index c62efac..50441db 100644
--- a/crypto/libdes/ede_enc.c
+++ b/crypto/libdes/ede_enc.c
@@ -1,9 +1,9 @@
/* crypto/des/ede_enc.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
+/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
- * by Eric Young (eay@mincom.oz.au).
+ * by Eric Young (eay@cryptsoft.com).
* 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@mincom.oz.au).
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* 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@mincom.oz.au)"
+ * Eric Young (eay@cryptsoft.com)"
* 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 product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -54,6 +54,8 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
*/
#include "des_locl.h"
diff --git a/crypto/libdes/enc_read.c b/crypto/libdes/enc_read.c
index ed3ee82..8bccda5 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-1997 Eric Young (eay@mincom.oz.au)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
- * by Eric Young (eay@mincom.oz.au).
+ * by Eric Young (eay@cryptsoft.com).
* 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@mincom.oz.au).
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* 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@mincom.oz.au)"
+ * Eric Young (eay@cryptsoft.com)"
* 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 product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -54,26 +54,41 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
*/
#include <sys/types.h>
#include <sys/uio.h>
#include <stdio.h>
#include <errno.h>
-#include <unistd.h>
+#include <unistd.h>
#include "des_locl.h"
/* This has some uglies in it but it works - even over sockets. */
-/*extern int errno;*/
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);
+/*
+ * 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)
{
/* data to be unencrypted */
int net_num=0;
@@ -81,27 +96,27 @@ des_cblock (*iv);
/* extra unencrypted data
* for when a block of 100 comes in but is des_read one byte at
* a time. */
- static char *unnet=NULL;
+ static unsigned char *unnet=NULL;
static int unnet_start=0;
static int unnet_left=0;
- static char *tmpbuf=NULL;
+ static unsigned char *tmpbuf=NULL;
int i;
long num=0,rnum;
unsigned char *p;
if (tmpbuf == NULL)
{
- tmpbuf=(char *)malloc(BSIZE);
+ tmpbuf=malloc(BSIZE);
if (tmpbuf == NULL) return(-1);
}
if (net == NULL)
{
- net=(unsigned char *)malloc(BSIZE);
+ net=malloc(BSIZE);
if (net == NULL) return(-1);
}
if (unnet == NULL)
{
- unnet=(char *)malloc(BSIZE);
+ unnet=malloc(BSIZE);
if (unnet == NULL) return(-1);
}
/* left over data from last decrypt */
@@ -113,7 +128,7 @@ des_cblock (*iv);
* with the number of bytes we have - should always
* check the return value */
memcpy(buf,&(unnet[unnet_start]),
- (unsigned int)unnet_left);
+ unnet_left);
/* eay 26/08/92 I had the next 2 lines
* reversed :-( */
i=unnet_left;
@@ -121,7 +136,7 @@ des_cblock (*iv);
}
else
{
- memcpy(buf,&(unnet[unnet_start]),(unsigned int)len);
+ memcpy(buf,&(unnet[unnet_start]),len);
unnet_start+=len;
unnet_left-=len;
i=len;
@@ -135,8 +150,10 @@ des_cblock (*iv);
/* first - get the length */
while (net_num < HDRSIZE)
{
- i=read(fd,&(net[net_num]),(unsigned int)HDRSIZE-net_num);
+ i=read(fd,&(net[net_num]),HDRSIZE-net_num);
+#ifdef EINTR
if ((i == -1) && (errno == EINTR)) continue;
+#endif
if (i <= 0) return(0);
net_num+=i;
}
@@ -155,8 +172,10 @@ des_cblock (*iv);
net_num=0;
while (net_num < rnum)
{
- i=read(fd,&(net[net_num]),(unsigned int)rnum-net_num);
+ i=read(fd,&(net[net_num]),rnum-net_num);
+#ifdef EINTR
if ((i == -1) && (errno == EINTR)) continue;
+#endif
if (i <= 0) return(0);
net_num+=i;
}
@@ -165,14 +184,12 @@ des_cblock (*iv);
if (len < num)
{
if (des_rw_mode & DES_PCBC_MODE)
- des_pcbc_encrypt((des_cblock *)net,(des_cblock *)unnet,
- num,sched,iv,DES_DECRYPT);
+ des_pcbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT);
else
- des_cbc_encrypt((des_cblock *)net,(des_cblock *)unnet,
- num,sched,iv,DES_DECRYPT);
- memcpy(buf,unnet,(unsigned int)len);
+ des_cbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT);
+ memcpy(buf,unnet,len);
unnet_start=len;
- unnet_left=(int)num-len;
+ unnet_left=num-len;
/* The following line is done because we return num
* as the number of bytes read. */
@@ -189,30 +206,26 @@ des_cblock (*iv);
{
if (des_rw_mode & DES_PCBC_MODE)
- des_pcbc_encrypt((des_cblock *)net,
- (des_cblock *)tmpbuf,
- num,sched,iv,DES_DECRYPT);
+ des_pcbc_encrypt(net,tmpbuf,num,sched,iv,
+ DES_DECRYPT);
else
- des_cbc_encrypt((des_cblock *)net,
- (des_cblock *)tmpbuf,
- num,sched,iv,DES_DECRYPT);
+ des_cbc_encrypt(net,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,(unsigned int)num);
+ memcpy(buf,tmpbuf,num);
}
else
{
if (des_rw_mode & DES_PCBC_MODE)
- des_pcbc_encrypt((des_cblock *)net,
- (des_cblock *)buf,num,sched,iv,
- DES_DECRYPT);
+ des_pcbc_encrypt(net,buf,num,sched,iv,
+ DES_DECRYPT);
else
- des_cbc_encrypt((des_cblock *)net,
- (des_cblock *)buf,num,sched,iv,
- DES_DECRYPT);
+ des_cbc_encrypt(net,buf,num,sched,iv,
+ DES_DECRYPT);
}
}
- return((int)num);
+ return num;
}
diff --git a/crypto/libdes/enc_writ.c b/crypto/libdes/enc_writ.c
index 128b151..302baaa 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-1997 Eric Young (eay@mincom.oz.au)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
- * by Eric Young (eay@mincom.oz.au).
+ * by Eric Young (eay@cryptsoft.com).
* 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@mincom.oz.au).
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* 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@mincom.oz.au)"
+ * Eric Young (eay@cryptsoft.com)"
* 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 product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -54,40 +54,52 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
*/
#include <sys/types.h>
#include <sys/uio.h>
#include <errno.h>
+#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include "des_locl.h"
-int des_enc_write(fd, buf, len, sched, iv)
-int fd;
-char *buf;
-int len;
-des_key_schedule sched;
-des_cblock (*iv);
+/*
+ * 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.
+ */
+
+int des_enc_write(int fd, const void *_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;
- char *outbuf=NULL;
- char shortbuf[8];
- char *p;
+ static unsigned char *outbuf=NULL;
+ unsigned char shortbuf[8];
+ unsigned char *p;
+ const unsigned char *cp;
static int start=1;
if (outbuf == NULL)
{
- outbuf=(char *)malloc(BSIZE+HDRSIZE);
+ outbuf=malloc(BSIZE+HDRSIZE);
if (outbuf == NULL) return(-1);
}
/* If we are sending less than 8 bytes, the same char will look
@@ -95,7 +107,6 @@ des_cblock (*iv);
if (start)
{
start=0;
- srandom((unsigned int)time(NULL));
}
/* lets recurse if we want to send the data in small chunks */
@@ -121,35 +132,32 @@ des_cblock (*iv);
/* pad short strings */
if (len < 8)
{
- p=shortbuf;
- memcpy(shortbuf,buf,(unsigned int)len);
- for (i=len; i<8; i++)
- shortbuf[i]=random();
+ cp=shortbuf;
+ memcpy(shortbuf,buf,len);
+ des_rand_data(shortbuf+len, 8-len);
rnum=8;
}
else
{
- p=buf;
+ cp=(unsigned char*)buf;
rnum=((len+7)/8*8); /* round up to nearest eight */
}
if (des_rw_mode & DES_PCBC_MODE)
- des_pcbc_encrypt((des_cblock *)p,
- (des_cblock *)&(outbuf[HDRSIZE]),
- (long)((len<8)?8:len),sched,iv,DES_ENCRYPT);
+ des_pcbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv,
+ DES_ENCRYPT);
else
- des_cbc_encrypt((des_cblock *)p,
- (des_cblock *)&(outbuf[HDRSIZE]),
- (long)((len<8)?8:len),sched,iv,DES_ENCRYPT);
+ des_cbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv,
+ DES_ENCRYPT);
/* output */
- outnum=(int)rnum+HDRSIZE;
+ outnum=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]),(unsigned int)(outnum-j));
+ i=write(fd,&(outbuf[j]),outnum-j);
if (i == -1)
{
if (errno == EINTR)
diff --git a/crypto/libdes/fcrypt.c b/crypto/libdes/fcrypt.c
index b59855c..a3ddd0e 100644
--- a/crypto/libdes/fcrypt.c
+++ b/crypto/libdes/fcrypt.c
@@ -1,4 +1,63 @@
-/* NOCW */
+/* crypto/des/fcrypt.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * 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@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * 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.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * 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 cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * 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 SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
+ */
+
#include <stdio.h>
#ifdef _OSD_POSIX
#ifndef CHARSET_EBCDIC
diff --git a/crypto/libdes/rand_key.c b/crypto/libdes/rand_key.c
index fc11792..4e89dbc 100644
--- a/crypto/libdes/rand_key.c
+++ b/crypto/libdes/rand_key.c
@@ -54,10 +54,13 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
*/
#include "des_locl.h"
#include <time.h>
+#include <unistd.h>
static int seed=0;
static des_cblock init;
diff --git a/crypto/libdes/read_pwd.c b/crypto/libdes/read_pwd.c
index fed4965..29d60a1 100644
--- a/crypto/libdes/read_pwd.c
+++ b/crypto/libdes/read_pwd.c
@@ -54,23 +54,10 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
*/
-#if !defined(MSDOS) && !defined(VMS) && !defined(WIN32)
-#include <openssl/opensslconf.h>
-#include OPENSSL_UNISTD
-/* If unistd.h defines _POSIX_VERSION, we conclude that we
- * are on a POSIX system and have sigaction and termios. */
-#if defined(_POSIX_VERSION)
-
-# define SIGACTION
-# if !defined(TERMIOS) && !defined(TERMIO) && !defined(SGTTY)
-# define TERMIOS
-# endif
-
-#endif
-#endif
-
/* #define SIGACTION */ /* Define this if you have sigaction() */
#ifdef WIN16TTY
@@ -81,7 +68,6 @@
/* 06-Apr-92 Luke Brennan Support for VMS */
#include "des_locl.h"
-#include "cryptlib.h"
#include <signal.h>
#include <stdio.h>
#include <string.h>
diff --git a/crypto/libdes/rnd_keys.c b/crypto/libdes/rnd_keys.c
index da86b89..3acc9f8 100644
--- a/crypto/libdes/rnd_keys.c
+++ b/crypto/libdes/rnd_keys.c
@@ -34,49 +34,22 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $Id$
+ * $FreeBSD$
*/
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-
-RCSID("$Id$");
-#endif
-
#include <sys/types.h>
+#include <sys/wait.h>
#include <sys/time.h>
+#include <sys/resource.h>
#include <des.h>
#include <des_locl.h>
#include <fcntl.h>
#include <signal.h>
#include <string.h>
#include <time.h>
-
-#ifdef TIME_WITH_SYS_TIME
-#include <sys/time.h>
-#include <time.h>
-#elif defined(HAVE_SYS_TIME_H)
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
#include <unistd.h>
-#endif
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-
-#ifdef HAVE_SIGNAL_H
-#include <signal.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
#ifdef HAVE_WINSOCK_H
#include <winsock.h>
@@ -128,37 +101,6 @@ sumFile (const char *name, int len, void *res)
return 0;
}
-#if 0
-static
-int
-md5sumFile (const char *name, int len, int32_t sum[4])
-{
- int32_t buf[1024*2];
- int fd, cnt;
- struct md5 md5;
-
- fd = open (name, 0);
- if (fd < 0)
- return -1;
-
- md5_init(&md5);
- while (len > 0)
- {
- int n = read(fd, buf, sizeof(buf));
- if (n < 0)
- {
- close(fd);
- return n;
- }
- md5_update(&md5, buf, n);
- len -= n;
- }
- md5_finito(&md5, (unsigned char *)sum);
- close (fd);
- return 0;
-}
-#endif
-
/*
* Create a sequence of random 64 bit blocks.
* The sequence is indexed with a long long and
@@ -257,7 +199,10 @@ static RETSIGTYPE
void
des_rand_data(unsigned char *data, int size)
{
- struct itimerval tv, otv;
+ struct itimerval tv;
+#ifdef HAVE_SETITIMER
+ struct itimerval otv;
+#endif
RETSIGTYPE (*osa)(int);
int i, j;
#ifndef HAVE_SETITIMER
@@ -467,13 +412,6 @@ des_init_random_number_generator(des_cblock *seed)
des_set_random_generator_seed(&new_key);
}
-/* This is for backwards compatibility. */
-void
-des_random_key(des_cblock ret)
-{
- des_new_random_key((des_cblock *)ret);
-}
-
#ifdef TESTRUN
int
main()
diff --git a/crypto/libdes/set_key.c b/crypto/libdes/set_key.c
index 52553a4..f4ae6d7 100644
--- a/crypto/libdes/set_key.c
+++ b/crypto/libdes/set_key.c
@@ -54,6 +54,8 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
*/
/* set_key.c v 1.4 eay 24/9/91
@@ -68,7 +70,7 @@
#include "sk.h"
static int check_parity(const_des_cblock *key);
-OPENSSL_GLOBAL int des_check_key=0;
+int des_check_key=0;
void des_set_odd_parity(des_cblock *key)
{
diff --git a/crypto/libdes/spr.h b/crypto/libdes/spr.h
index b8fbdcf..0200b5e 100644
--- a/crypto/libdes/spr.h
+++ b/crypto/libdes/spr.h
@@ -54,9 +54,11 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
*/
-OPENSSL_GLOBAL const DES_LONG des_SPtrans[8][64]={
+const DES_LONG des_SPtrans[8][64]={
{
/* nibble 0 */
0x02080800L, 0x00080000L, 0x02000002L, 0x02080802L,
diff --git a/crypto/libdes/str2key.c b/crypto/libdes/str2key.c
index 2484145..afdf59a 100644
--- a/crypto/libdes/str2key.c
+++ b/crypto/libdes/str2key.c
@@ -54,11 +54,13 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
*/
#include "des_locl.h"
-OPENSSL_EXTERN int des_check_key;
+extern int des_check_key;
void des_string_to_key(const char *str, des_cblock *key)
{
diff --git a/crypto/libdes/version.h b/crypto/libdes/version.h
index aee1190..0088f42 100644
--- a/crypto/libdes/version.h
+++ b/crypto/libdes/version.h
@@ -1,9 +1,9 @@
/* lib/des/version.h */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* Copyright (C) 1995 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This file is part of an SSL implementation written
- * by Eric Young (eay@mincom.oz.au).
+ * by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL
* specification. This library and applications are
* FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
@@ -25,7 +25,7 @@
* 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 software developed by Eric Young (eay@cryptsoft.com)
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -43,6 +43,8 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
*/
extern char *DES_version;
OpenPOWER on IntegriCloud