From 0b603bcc34c1d903d7fa5201dbc041962ce238f2 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Sun, 25 Sep 2011 18:11:42 +0000 Subject: [PATCH] VxWorks support. --- Configure | 2 ++ apps/speed.c | 2 +- config | 6 ++++++ crypto/rand/rand_unix.c | 39 ++++++++++++++++++++++++++++++++++-- crypto/rand/randfile.c | 6 ++++-- crypto/ui/ui_openssl.c | 4 +++- fips/fips_canister.c | 2 ++ fips/mkfipsscr.pl | 44 ++++++++++++++++++++++++++++++++++++++++- 8 files changed, 98 insertions(+), 7 deletions(-) diff --git a/Configure b/Configure index 0a8a27d826..c857bed33a 100755 --- a/Configure +++ b/Configure @@ -524,6 +524,8 @@ my %table=( "OS2-EMX", "gcc::::::::", ##### VxWorks for various targets +"vxworks-ppc60x","ccppc:-D_REENTRANT -mrtp -mhard-float -mstrict-align -fno-implicit-fp -DPPC32_fp60x -O2 -fstrength-reduce -fno-builtin -fno-strict-aliasing -Wall -DCPU=PPC32 -DTOOL_FAMILY=gnu -DTOOL=gnu -I\$(WIND_BASE)/target/usr/h -I\$(WIND_BASE)/target/usr/h/wrn/coreip:::VXWORKS:-Wl,--defsym,__wrs_rtp_base=0xe0000000 -L \$(WIND_BASE)/target/usr/lib/ppc/PPC32/common:::linux_ppc32.o:::::::::::::::ranlibppc:", +"vxworks-ppcgen","ccppc:-D_REENTRANT -mrtp -msoft-float -mstrict-align -O1 -fno-builtin -fno-strict-aliasing -Wall -DCPU=PPC32 -DTOOL_FAMILY=gnu -DTOOL=gnu -I\$(WIND_BASE)/target/usr/h -I\$(WIND_BASE)/target/usr/h/wrn/coreip:::VXWORKS:-Wl,--defsym,__wrs_rtp_base=0xe0000000 -L \$(WIND_BASE)/target/usr/lib/ppc/PPC32/sfcommon:::linux_ppc32.o:::::::::::::::ranlibppc:", "vxworks-ppc405","ccppc:-g -msoft-float -mlongcall -DCPU=PPC405 -I\$(WIND_BASE)/target/h:::VXWORKS:-r:::::", "vxworks-ppc750","ccppc:-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h \$(DEBUG_FLAG):::VXWORKS:-r:::::", "vxworks-ppc750-debug","ccppc:-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DDEBUG -g:::VXWORKS:-r:::::", diff --git a/apps/speed.c b/apps/speed.c index 85f559ed81..bfe9103aac 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -254,7 +254,7 @@ # endif #endif -#if !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_OS2) && !defined(OPENSSL_SYS_NETWARE) +#if !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_OS2) && !defined(OPENSSL_SYS_NETWARE) && !defined(OPENSSL_SYS_VXWORKS) # define HAVE_FORK 1 #endif diff --git a/config b/config index 91231f98f0..b8d81e4a8a 100755 --- a/config +++ b/config @@ -362,6 +362,10 @@ case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in NONSTOP_KERNEL*) echo "nsr-tandem-nsk"; exit 0; ;; + + vxworks*) + echo "${MACHINE}-whatever-vxworks"; exit 0; + ;; esac # @@ -524,6 +528,8 @@ case "$GUESSOS" in OUT="linux-ppc64" ;; ppc-*-linux2) OUT="linux-ppc" ;; + ppc60x-*-vxworks*) OUT="vxworks-ppc60x" ;; + ppcgen-*-vxworks*) OUT="vxworks-ppcgen" ;; ia64-*-linux?) OUT="linux-ia64" ;; sparc64-*-linux2) OUT="linux64-sparcv9" ;; diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c index 6c2be5cb96..41259f3697 100644 --- a/crypto/rand/rand_unix.c +++ b/crypto/rand/rand_unix.c @@ -323,8 +323,43 @@ int RAND_poll(void) #if defined(OPENSSL_SYS_VXWORKS) +/* Note: the existence of /dev/urandom on VxWorks platforms is uncommon +* however we check for one and use it if found for those cases where +* it is present. */ int RAND_poll(void) - { +{ + unsigned long l; +#ifdef DEVRANDOM + unsigned char buf[ENTROPY_NEEDED]; + int n = 0, r, fd; + + if ((fd = open("/dev/urandom", O_RDONLY, 0)) >= 0) + { + do + { + r = read(fd,(unsigned char *)buf+n, ENTROPY_NEEDED-n); + if (r > 0) + n += r; + } + while ((r > 0 || errno == EINTR) && n < ENTROPY_NEEDED); + + close(fd); + } + + if (n > 0) + { + RAND_add(buf,sizeof buf,(double)n); + OPENSSL_cleanse(buf,n); + } +#endif + + l=time(NULL); + RAND_add(&l,sizeof(l),0.0); + +#if defined(DEVRANDOM) + return 1; +#else return 0; - } +#endif +} #endif diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c index cec5880a8f..abe580af4a 100644 --- a/crypto/rand/randfile.c +++ b/crypto/rand/randfile.c @@ -56,8 +56,6 @@ * [including the GNU Public Licence.] */ -/* We need to define this to get macros like S_IFBLK and S_IFCHR */ -#define _XOPEN_SOURCE 500 #include #include @@ -69,6 +67,10 @@ #include #include +#if !defined(OPENSSL_SYS_VXWORKS) +/* We need to define this to get macros like S_IFBLK and S_IFCHR */ +# define _XOPEN_SOURCE 500 +#endif #ifdef OPENSSL_SYS_VMS #include #endif diff --git a/crypto/ui/ui_openssl.c b/crypto/ui/ui_openssl.c index 1f23a45a33..10111efbf2 100644 --- a/crypto/ui/ui_openssl.c +++ b/crypto/ui/ui_openssl.c @@ -122,7 +122,9 @@ * sigaction and fileno included. -pedantic would be more appropriate for * the intended purposes, but we can't prevent users from adding -ansi. */ -#define _POSIX_C_SOURCE 1 +#if !defined(OPENSSL_SYS_VXWORKS) +# define _POSIX_C_SOURCE 1 +#endif #include #include #include diff --git a/fips/fips_canister.c b/fips/fips_canister.c index 174466189b..4b0a9e814b 100644 --- a/fips/fips_canister.c +++ b/fips/fips_canister.c @@ -174,6 +174,8 @@ void *FIPS_ref_point() # else return (void *)FIPS_ref_point; # endif +#elif defined(__vxworks) + return (void *)FIPS_ref_point; /* * In case you wonder why there is no #ifdef __linux. All Linux targets * are GCC-based and therefore are covered by instruction_pointer above diff --git a/fips/mkfipsscr.pl b/fips/mkfipsscr.pl index 8f1275c7b5..16d4842aec 100644 --- a/fips/mkfipsscr.pl +++ b/fips/mkfipsscr.pl @@ -294,6 +294,10 @@ foreach (@ARGV) { $win32 = 1; } + if ($_ eq "--vxworks") + { + $vxworks = 1; + } elsif ($_ eq "--onedir") { $onedir = 1; @@ -332,6 +336,11 @@ foreach (@ARGV) } } +if ($win32 && $vxworks) { + print STDERR "Can't specify both --win32 and --vxworks\n"; + exit(1); +} + $tvdir = "." unless defined $tvdir; if ($win32) @@ -356,6 +365,21 @@ rem Test vector run script rem Auto generated by mkfipsscr.pl script rem Do not edit +END + + } +elsif ($vxworks) + { + # Always assume onedir. + $tprefix = "" unless defined $tprefix; + $outfile = "fipstests" unless defined $outfile; + open(OUT, ">$outfile"); + + print OUT < \"$rsp\"\n"; + print OUT "$tprefix$tcmd < \"$req\" > \"$rsp\"\n"; + } + elsif ($vxworks) + { + print OUT "run $tprefix$tcmd \"$req\" \"$rsp\"\n"; } else { -- 2.25.1