diff options
author | dinoex <dinoex@FreeBSD.org> | 2003-01-30 04:00:43 +0800 |
---|---|---|
committer | dinoex <dinoex@FreeBSD.org> | 2003-01-30 04:00:43 +0800 |
commit | 1fec25d13a3eb564b9dbc684be7a7445a64d45c9 (patch) | |
tree | a82d3b809c4a0195e53373cbf4e5cc71f0242ef7 /security/openssl/files | |
parent | b1d6c3e3b81851f1b3c5d3b4d32f9fe8e6514ac8 (diff) | |
download | freebsd-ports-gnome-1fec25d13a3eb564b9dbc684be7a7445a64d45c9.tar.gz freebsd-ports-gnome-1fec25d13a3eb564b9dbc684be7a7445a64d45c9.tar.zst freebsd-ports-gnome-1fec25d13a3eb564b9dbc684be7a7445a64d45c9.zip |
- Update to 0.9.7
- rnd_keys.c now in distribution
- drop lib/libRSAglue.a
- build on i386, alpha, sparc64, ia64
- build on 2.2.8 with the gas-patch as noted in FAQ
Diffstat (limited to 'security/openssl/files')
-rw-r--r-- | security/openssl/files/patch-ab | 9 | ||||
-rw-r--r-- | security/openssl/files/patch-ac | 35 | ||||
-rw-r--r-- | security/openssl/files/patch-ag | 20 | ||||
-rw-r--r-- | security/openssl/files/patch-ak | 16 | ||||
-rw-r--r-- | security/openssl/files/patch-config | 10 | ||||
-rw-r--r-- | security/openssl/files/patch-rnd_keys | 33 | ||||
-rw-r--r-- | security/openssl/files/rnd_keys.c | 444 |
7 files changed, 41 insertions, 526 deletions
diff --git a/security/openssl/files/patch-ab b/security/openssl/files/patch-ab index c5bd5f73382a..2aeb3617967e 100644 --- a/security/openssl/files/patch-ab +++ b/security/openssl/files/patch-ab @@ -9,15 +9,6 @@ MAN1=1 MAN3=3 SHELL=/bin/sh -@@ -178,7 +178,7 @@ - ONEDIRS=out tmp - EDIRS= times doc bugs util include certs ms shlib mt demos perl sf dep VMS - WDIRS= windows --LIBS= libcrypto.a libssl.a -+LIBS= libcrypto.a libssl.a libRSAglue.a - SHARED_CRYPTO=libcrypto$(SHLIB_EXT) - SHARED_SSL=libssl$(SHLIB_EXT) - SHARED_LIBS= @@ -250,6 +250,21 @@ done diff --git a/security/openssl/files/patch-ac b/security/openssl/files/patch-ac index 7695196e55e4..e0c621fba728 100644 --- a/security/openssl/files/patch-ac +++ b/security/openssl/files/patch-ac @@ -1,23 +1,24 @@ ---- Configure.orig Fri Nov 15 02:28:38 2002 -+++ Configure Wed Dec 11 22:05:06 2002 -@@ -311,7 +311,8 @@ +--- Configure.orig Fri Dec 27 17:35:11 2002 ++++ Configure Sat Jan 11 01:44:38 2003 +@@ -350,7 +350,9 @@ # # This probably belongs in a different section. # --"FreeBSD-alpha","gcc:-DTERMIOS -O -fomit-frame-pointer::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC2::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", -+"FreeBSD-alpha","$ENV{CC}:-DTERMIOS $ENV{CFLAGS}::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC2:::", -+"FreeBSD-sparc64","$ENV{CC}:-DB_ENDIAN -DTERMIOS -DULTRASPARC -DBN_DIV2W $ENV{CFLAGS}::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::asm/md5-sparcv9.o:", +-"FreeBSD-alpha","gcc:-DTERMIOS -O -fomit-frame-pointer::(unknown):::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC2::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"FreeBSD-alpha","$ENV{CC}:-DTERMIOS $ENV{CFLAGS}::(unknown):::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC2::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"FreeBSD-sparc64","$ENV{CC}:-DTERMIOS -DB_ENDIAN -DULTRASPARC -DBN_DIV2W $ENV{CFLAGS}::(unknown):::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"FreeBSD-ia64","$ENV{CC}:-DL_ENDIAN -DTERMIOS $ENV{CFLAGS}::(unknown):::SIXTY_FOUR_BIT_LONG RC4_CHUNK RC4_CHAR:asm/ia64-cpp.o:::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", #### Alpha Linux with GNU C and Compaq C setups # Special notes: -@@ -350,8 +351,8 @@ - "NetBSD-sparc", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -mv8 -Wall -DB_ENDIAN::(unknown)::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", - "NetBSD-m68", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall -DB_ENDIAN::(unknown)::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", - "NetBSD-x86", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -m486 -Wall::(unknown)::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", --"FreeBSD-elf", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::-pthread -D_REENTRANT -D_THREAD_SAFE -D_THREADSAFE::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", --"FreeBSD", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown)::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}", -+"FreeBSD-elf", "$ENV{CC}:-DTERMIOS -DL_ENDIAN $ENV{CFLAGS}::(unknown)::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}", -+"FreeBSD", "$ENV{CC}:-DTERMIOS -DL_ENDIAN $ENV{CFLAGS}::(unknown)::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}", - "bsdi-gcc", "gcc:-O3 -ffast-math -DL_ENDIAN -DPERL5 -m486::(unknown)::RSA_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_bsdi_asm}", - "bsdi-elf-gcc", "gcc:-DPERL5 -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown):-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", - "nextstep", "cc:-O -Wall:<libc.h>:(unknown)::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:::", +@@ -395,8 +397,8 @@ + "NetBSD-sparc", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -mv8 -Wall -DB_ENDIAN::(unknown):::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", + "NetBSD-m68", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall -DB_ENDIAN::(unknown):::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", + "NetBSD-x86", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -m486 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +-"FreeBSD-elf", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::-pthread -D_REENTRANT -D_THREAD_SAFE -D_THREADSAFE:::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +-"FreeBSD", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}", ++"FreeBSD-elf", "$ENV{CC}:-DTERMIOS -DL_ENDIAN $ENV{CFLAGS} -Wall::-pthread -D_REENTRANT -D_THREAD_SAFE -D_THREADSAFE:::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"FreeBSD", "$ENV{CC}:-DTERMIOS -DL_ENDIAN $ENV{CFLAGS} -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}", + "bsdi-gcc", "gcc:-O3 -ffast-math -DL_ENDIAN -DPERL5 -m486::(unknown):::RSA_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_bsdi_asm}", + "bsdi-elf-gcc", "gcc:-DPERL5 -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown)::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", + "nextstep", "cc:-O -Wall:<libc.h>:(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:::", diff --git a/security/openssl/files/patch-ag b/security/openssl/files/patch-ag index e0faf51d9bfa..b768d1ec5012 100644 --- a/security/openssl/files/patch-ag +++ b/security/openssl/files/patch-ag @@ -1,11 +1,11 @@ ---- apps/dgst.c.orig Thu Apr 5 13:08:50 2001 -+++ apps/dgst.c Fri Apr 13 00:58:32 2001 -@@ -318,7 +318,7 @@ - err++; - continue; +--- apps/dgst.c.orig Tue Jun 11 13:41:17 2002 ++++ apps/dgst.c Sat Aug 10 14:40:26 2002 +@@ -340,7 +340,7 @@ + if(!out_bin) + { + tmp=tofree=OPENSSL_malloc(strlen(name)+strlen(argv[i])+5); +- sprintf(tmp,"%s(%s)= ",name,argv[i]); ++ sprintf(tmp,"%s(%s) = ",name,argv[i]); } -- if(!out_bin) BIO_printf(out, "%s(%s)= ",name,argv[i]); -+ if(!out_bin) BIO_printf(out, "%s(%s) = ",name,argv[i]); - do_fp(out, buf,inp,separator, out_bin, sigkey, - sigbuf, siglen); - (void)BIO_reset(bmd); + else + tmp=""; diff --git a/security/openssl/files/patch-ak b/security/openssl/files/patch-ak index 819def697e15..cdc35edc1a3a 100644 --- a/security/openssl/files/patch-ak +++ b/security/openssl/files/patch-ak @@ -1,13 +1,11 @@ ---- apps/Makefile.ssl.orig Sun May 23 14:36:09 1999 -+++ apps/Makefile.ssl Fri May 28 22:29:19 1999 -@@ -101,8 +101,8 @@ - cp $$i $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i; \ - chmod 755 $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i ); \ +--- apps/Makefile.ssl.orig Tue Dec 24 11:50:16 2002 ++++ apps/Makefile.ssl Thu Jan 2 17:58:03 2003 +@@ -111,7 +111,7 @@ done -- @cp openssl.cnf $(INSTALL_PREFIX)$(OPENSSLDIR); \ -- chmod 644 $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf -+ @cp openssl.cnf $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.sample; \ -+ chmod 644 $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.sample + @cp openssl.cnf $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new; \ + chmod 644 $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new; \ +- mv -f $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf ++ mv -f $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.sample tags: ctags $(SRC) diff --git a/security/openssl/files/patch-config b/security/openssl/files/patch-config index 8b31a44cfa03..13e7a230da9f 100644 --- a/security/openssl/files/patch-config +++ b/security/openssl/files/patch-config @@ -1,18 +1,20 @@ ---- config.orig Thu Nov 14 08:30:29 2002 -+++ config Wed Dec 11 23:10:05 2002 -@@ -180,6 +180,7 @@ +--- config.orig Fri Dec 6 08:45:11 2002 ++++ config Sat Jan 11 01:37:40 2003 +@@ -206,6 +206,8 @@ Pentium\ II*) MACH="i686" ;; Pentium* ) MACH="i586" ;; Alpha* ) MACH="alpha" ;; + UltraSparc* ) MACH="sparc64" ;; ++ Itanium* ) MACH="ia64" ;; * ) MACH="$MACHINE" ;; esac case ${MACH} in -@@ -585,6 +586,7 @@ +@@ -640,6 +642,8 @@ *86*-*-solaris2) OUT="solaris-x86-$CC" ;; *-*-sunos4) OUT="sunos-$CC" ;; alpha*-*-freebsd*) OUT="FreeBSD-alpha" ;; + sparc64*-*-freebsd*) OUT="FreeBSD-sparc64" ;; ++ ia64*-*-freebsd*) OUT="FreeBSD-ia64" ;; *-freebsd[3-9]*) OUT="FreeBSD-elf" ;; *-freebsd[1-2]*) OUT="FreeBSD" ;; *86*-*-netbsd) OUT="NetBSD-x86" ;; diff --git a/security/openssl/files/patch-rnd_keys b/security/openssl/files/patch-rnd_keys deleted file mode 100644 index 20d38b47ce7b..000000000000 --- a/security/openssl/files/patch-rnd_keys +++ /dev/null @@ -1,33 +0,0 @@ ---- crypto/des/Makefile.ssl.bak Thu Oct 17 10:21:30 2002 -+++ crypto/des/Makefile.ssl Thu Oct 17 10:31:20 2002 -@@ -32,14 +32,14 @@ - fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \ - qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \ - des_enc.c fcrypt_b.c read2pwd.c \ -- xcbc_enc.c \ -+ xcbc_enc.c rnd_keys.c \ - str2key.c cfb64ede.c ofb64ede.c ede_cbcm_enc.c - - LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \ - ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \ - enc_read.o enc_writ.o ofb64enc.o \ - ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \ -- ${DES_ENC} read2pwd.o \ -+ ${DES_ENC} read2pwd.o rnd_keys.o \ - fcrypt.o xcbc_enc.o read_pwd.o rpc_enc.o cbc_cksm.o \ - ede_cbcm_enc.o - ---- crypto/des/des.h.bak Thu Oct 17 10:25:47 2002 -+++ crypto/des/des.h Thu Oct 17 10:30:00 2002 -@@ -200,6 +200,11 @@ - 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); -+ -+int des_new_random_key(des_cblock *key); -+void des_init_random_number_generator(des_cblock *seed); -+void des_rand_data(unsigned char *data, int size); -+ - int des_random_key(des_cblock *ret); - int des_read_password(des_cblock *key,const char *prompt,int verify); - int des_read_2passwords(des_cblock *key1,des_cblock *key2, diff --git a/security/openssl/files/rnd_keys.c b/security/openssl/files/rnd_keys.c deleted file mode 100644 index 454ceb43ae7d..000000000000 --- a/security/openssl/files/rnd_keys.c +++ /dev/null @@ -1,444 +0,0 @@ -/* - * Copyright (c) 1995, 1996, 1997, 1999 Kungliga Tekniska Högskolan - * (Royal Institute of Technology, Stockholm, Sweden). - * All rights reserved. - * - * 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 above 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 software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``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 INSTITUTE 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. - * - * $Id$ - * $FreeBSD: /tmp/pcvs/ports/security/openssl/files/Attic/rnd_keys.c,v 1.1 2002-10-25 20:41:47 dinoex Exp $ - */ - -#include <openssl/des.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/time.h> -#include <sys/resource.h> -#include <fcntl.h> -#include <signal.h> -#include <string.h> -#include <time.h> -#include <unistd.h> - -#ifndef RETSIGTYPE -#define RETSIGTYPE void -#define SIGRETURN(x) return -#else -#define SIGRETURN(x) return (RETSIGTYPE)(x) -#endif - -/* - * Generate "random" data by checksumming a file. - * - * Returns -1 if there were any problems with permissions or I/O - * errors. - */ -static -int -sumFile (const char *name, int len, void *res) -{ - u_int32_t sum[2]; - u_int32_t buf[1024*2]; - int fd, i; - - fd = open (name, 0); - if (fd < 0) - return -1; - - while (len > 0) - { - int n = read(fd, buf, sizeof(buf)); - if (n < 0) - { - close(fd); - return n; - } - for (i = 0; i < (n/sizeof(buf[0])); i++) - { - sum[0] += buf[i]; - i++; - sum[1] += buf[i]; - } - len -= n; - } - close (fd); - memcpy (res, &sum, sizeof(sum)); - return 0; -} - -/* - * Create a sequence of random 64 bit blocks. - * The sequence is indexed with a long long and - * based on an initial des key used as a seed. - */ -static des_key_schedule sequence_seed; -static u_int32_t sequence_index[2]; - -/* - * Random number generator based on ideas from truerand in cryptolib - * as described on page 424 in Applied Cryptography 2 ed. by Bruce - * Schneier. - */ - -static volatile int counter; -static volatile unsigned char *gdata; /* Global data */ -static volatile int igdata; /* Index into global data */ -static int gsize; - -#if !defined(WIN32) && !defined(__EMX__) && !defined(__OS2__) && !defined(__CYGWIN32__) -/* Visual C++ 4.0 (Windows95/NT) */ - -static -RETSIGTYPE -sigALRM(int sig) -{ - if (igdata < gsize) - gdata[igdata++] ^= counter & 0xff; - -#ifndef HAVE_SIGACTION - signal(SIGALRM, sigALRM); /* Reinstall SysV signal handler */ -#endif - SIGRETURN(0); -} - -#endif - -#if !defined(HAVE_RANDOM) && defined(HAVE_RAND) -#ifndef srandom -#define srandom srand -#endif -#ifndef random -#define random rand -#endif -#endif - -static void -des_not_rand_data(unsigned char *data, int size) -{ - int i; - - srandom (time (NULL)); - - for(i = 0; i < size; ++i) - data[i] ^= random() % 0x100; -} - -#if !defined(WIN32) && !defined(__EMX__) && !defined(__OS2__) && !defined(__CYGWIN32__) - -#ifndef HAVE_SETITIMER -static void -pacemaker(struct timeval *tv) -{ - fd_set fds; - pid_t pid; - pid = getppid(); - while(1){ - FD_ZERO(&fds); - FD_SET(0, &fds); - select(1, &fds, NULL, NULL, tv); - kill(pid, SIGALRM); - } -} -#endif - -#ifdef HAVE_SIGACTION -/* XXX ugly hack, should perhaps use function from roken */ -static RETSIGTYPE -(*fake_signal(int sig, RETSIGTYPE (*f)(int)))(int) -{ - struct sigaction sa, osa; - sa.sa_handler = f; - sa.sa_flags = 0; - sigemptyset(&sa.sa_mask); - sigaction(sig, &sa, &osa); - return osa.sa_handler; -} -#define signal(S, F) fake_signal((S), (F)) -#endif - -/* - * Generate size bytes of "random" data using timed interrupts. - * It takes about 40ms/byte random data. - * It's not neccessary to be root to run it. - */ -void -des_rand_data(unsigned char *data, int size) -{ - struct itimerval tv; -#ifdef HAVE_SETITIMER - struct itimerval otv; -#endif - RETSIGTYPE (*osa)(int); - int i, j; -#ifndef HAVE_SETITIMER - RETSIGTYPE (*ochld)(int); - pid_t pid; -#endif - char *rnd_devices[] = {"/dev/random", - "/dev/srandom", - "/dev/urandom", - NULL}; - char **p; - - for(p = rnd_devices; *p; p++) { - int fd = open(*p, O_RDONLY | O_NDELAY); - - if(fd >= 0 && read(fd, data, size) == size) { - close(fd); - return; - } - close(fd); - } - - /* Paranoia? Initialize data from /dev/mem if we can read it. */ - if (size >= 8) - sumFile("/dev/mem", (1024*1024*2), data); - - gdata = data; - gsize = size; - igdata = 0; - - osa = signal(SIGALRM, sigALRM); - - /* Start timer */ - tv.it_value.tv_sec = 0; - tv.it_value.tv_usec = 10 * 1000; /* 10 ms */ - tv.it_interval = tv.it_value; -#ifdef HAVE_SETITIMER - setitimer(ITIMER_REAL, &tv, &otv); -#else - ochld = signal(SIGCHLD, SIG_IGN); - pid = fork(); - if(pid == -1){ - signal(SIGCHLD, ochld != SIG_ERR ? ochld : SIG_DFL); - des_not_rand_data(data, size); - return; - } - if(pid == 0) - pacemaker(&tv.it_interval); -#endif - - for(i = 0; i < 4; i++) { - for (igdata = 0; igdata < size;) /* igdata++ in sigALRM */ - counter++; - for (j = 0; j < size; j++) /* Only use 2 bits each lap */ - gdata[j] = (gdata[j]>>2) | (gdata[j]<<6); - } -#ifdef HAVE_SETITIMER - setitimer(ITIMER_REAL, &otv, 0); -#else - kill(pid, SIGKILL); - while(waitpid(pid, NULL, 0) != pid); - signal(SIGCHLD, ochld != SIG_ERR ? ochld : SIG_DFL); -#endif - signal(SIGALRM, osa != SIG_ERR ? osa : SIG_DFL); -} -#else -void -des_rand_data(unsigned char *p, int s) -{ - des_not_rand_data (p, s); -} -#endif - -void -des_generate_random_block(des_cblock *block) -{ - des_rand_data((unsigned char *)block, sizeof(*block)); -} - -/* - * Generate a "random" DES key. - */ -void -des_rand_data_key(des_cblock *key) -{ - unsigned char data[8]; - des_key_schedule sched; - do { - des_rand_data(data, sizeof(data)); - des_rand_data((unsigned char*)key, sizeof(des_cblock)); - des_set_odd_parity(key); - des_key_sched(key, sched); - des_ecb_encrypt(&data, key, sched, DES_ENCRYPT); - memset(&data, 0, sizeof(data)); - memset(&sched, 0, sizeof(sched)); - des_set_odd_parity(key); - } while(des_is_weak_key(key)); -} - -/* - * Generate "random" data by checksumming /dev/mem - * - * It's neccessary to be root to run it. Returns -1 if there were any - * problems with permissions. - */ -int -des_mem_rand8(unsigned char *data) -{ - return 1; -} - -/* - * In case the generator does not get initialized use this as fallback. - */ -static int initialized; - -static void -do_initialize(void) -{ - des_cblock default_seed; - do { - des_generate_random_block(&default_seed); - des_set_odd_parity(&default_seed); - } while (des_is_weak_key(&default_seed)); - des_init_random_number_generator(&default_seed); -} - -#define zero_long_long(ll) do { ll[0] = ll[1] = 0; } while (0) - -#define incr_long_long(ll) do { if (++ll[0] == 0) ++ll[1]; } while (0) - -#define set_sequence_number(ll) \ -memcpy((char *)sequence_index, (ll), sizeof(sequence_index)); - -/* - * Set the sequnce number to this value (a long long). - */ -void -des_set_sequence_number(unsigned char *ll) -{ - set_sequence_number(ll); -} - -/* - * Set the generator seed and reset the sequence number to 0. - */ -void -des_set_random_generator_seed(des_cblock *seed) -{ - des_key_sched(seed, sequence_seed); - zero_long_long(sequence_index); - initialized = 1; -} - -/* - * Generate a sequence of random des keys - * using the random block sequence, fixup - * parity and skip weak keys. - */ -int -des_new_random_key(des_cblock *key) -{ - if (!initialized) - do_initialize(); - - do { - des_ecb_encrypt((des_cblock *) sequence_index, - key, - sequence_seed, - DES_ENCRYPT); - incr_long_long(sequence_index); - /* random key must have odd parity and not be weak */ - des_set_odd_parity(key); - } while (des_is_weak_key(key)); - return(0); -} - -/* - * des_init_random_number_generator: - * - * Initialize the sequence of random 64 bit blocks. The input seed - * can be a secret key since it should be well hidden and is also not - * kept. - * - */ -void -des_init_random_number_generator(des_cblock *seed) -{ - struct timeval now; - des_cblock uniq; - des_cblock new_key; - - gettimeofday(&now, (struct timezone *)0); - des_generate_random_block(&uniq); - - /* Pick a unique random key from the shared sequence. */ - des_set_random_generator_seed(seed); - set_sequence_number((unsigned char *)&uniq); - des_new_random_key(&new_key); - - /* Select a new nonshared sequence, */ - des_set_random_generator_seed(&new_key); - - /* and use the current time to pick a key for the new sequence. */ - set_sequence_number((unsigned char *)&now); - des_new_random_key(&new_key); - des_set_random_generator_seed(&new_key); -} - -#ifdef TESTRUN -int -main() -{ - unsigned char data[8]; - int i; - - while (1) - { - if (sumFile("/dev/mem", (1024*1024*8), data) != 0) - { perror("sumFile"); exit(1); } - for (i = 0; i < 8; i++) - printf("%02x", data[i]); - printf("\n"); - } -} -#endif - -#ifdef TESTRUN2 -int -main() -{ - des_cblock data; - int i; - - while (1) - { - do_initialize(); - des_random_key(data); - for (i = 0; i < 8; i++) - printf("%02x", data[i]); - printf("\n"); - } -} -#endif |