From 3e1beaf43e741b47c4bd03e864881d7294cebea7 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Sun, 14 Oct 2012 12:03:34 +0000 Subject: Add BSD-ppc85xx support and avoid copying overlapping buffers in fips_dssvs.c --- Configure | 2 ++ config | 34 ++++++++++++++++++++++------------ fips/aes/fips_gcmtest.c | 4 ++++ fips/dsa/fips_dssvs.c | 3 ++- fips/fips_canister.c | 1 + 5 files changed, 31 insertions(+), 13 deletions(-) diff --git a/Configure b/Configure index 90b108baaa..99b386b7c0 100755 --- a/Configure +++ b/Configure @@ -409,6 +409,8 @@ my %table=( "BSD-x86-elf", "gcc:-DL_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer -Wall::${BSDthreads}:::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-BSD-x86-elf", "gcc:-DL_ENDIAN -DTERMIOS -O3 -Wall -g::${BSDthreads}:::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "BSD-sparcv8", "gcc:-DB_ENDIAN -DTERMIOS -O3 -mv8 -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${sparcv8_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +"BSD-ppc85xx","gcc:-DTERMIOS -O3 -fomit-frame-pointer -msoft-float -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +"debug-BSD-ppc85xx","gcc:-DTERMIOS -O0 -fomit-frame-pointer -msoft-float -Wall -g::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "BSD-generic64","gcc:-DTERMIOS -O3 -Wall::${BSDthreads}:::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", # -DMD32_REG_T=int doesn't actually belong in sparc64 target, it diff --git a/config b/config index 851a161136..93dde30168 100755 --- a/config +++ b/config @@ -219,7 +219,11 @@ case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in ;; NetBSD:*:*:*386*) - echo "`(/usr/sbin/sysctl -n hw.model || /sbin/sysctl -n hw.model) | sed 's,.*\(.\)86-class.*,i\186,'`-whatever-netbsd"; exit 0 + if [ -z ${CROSS_COMPILE} ]; then + echo "`(/usr/sbin/sysctl -n hw.model || /sbin/sysctl -n hw.model) | sed 's,.*\(.\)86-class.*,i\186,'`-whatever-netbsd"; exit 0 + else + echo "${MACHINE}-whatever-netbsd"; exit 0 + fi ;; NetBSD:*) @@ -734,17 +738,23 @@ case "$GUESSOS" in sparc64-*-*bsd*) OUT="BSD-sparc64" ;; ia64-*-*bsd*) OUT="BSD-ia64" ;; amd64-*-*bsd*) OUT="BSD-x86_64" ;; - *86*-*-*bsd*) # mimic ld behaviour when it's looking for libc... - if [ -L /usr/lib/libc.so ]; then # [Free|Net]BSD - libc=/usr/lib/libc.so - else # OpenBSD - # ld searches for highest libc.so.* and so do we - libc=`(ls /usr/lib/libc.so.* | tail -1) 2>/dev/null` - fi - case "`(file -L $libc) 2>/dev/null`" in - *ELF*) OUT="BSD-x86-elf" ;; - *) OUT="BSD-x86"; options="$options no-sse2" ;; - esac ;; + *86*-*-*bsd*) if [ -z ${CROSS_COMPILE} ]; then + # mimic ld behaviour when it's looking for libc... + if [ -L /usr/lib/libc.so ]; then # [Free|Net]BSD + libc=/usr/lib/libc.so + else # OpenBSD + # ld searches for highest libc.so.* and so do we + libc=`(ls /usr/lib/libc.so.* | tail -1) 2>/dev/null` + fi + echo "libc = $libc" + case "`(file -L $libc) 2>/dev/null`" in + *ELF*) OUT="BSD-x86-elf" ;; + *) OUT="BSD-x86"; options="$options no-sse2" ;; + esac + else + OUT="BSD-x86-elf" + fi;; + ppc85xx-*-*bsd*) OUT="BSD-ppc85xx" ;; # MPC85XX has no hardware FP accelerator *-*-*bsd*) OUT="BSD-generic32" ;; *-*-osf) OUT="osf1-alpha-cc" ;; diff --git a/fips/aes/fips_gcmtest.c b/fips/aes/fips_gcmtest.c index 30e4bcc0f4..4000e0763f 100644 --- a/fips/aes/fips_gcmtest.c +++ b/fips/aes/fips_gcmtest.c @@ -208,6 +208,8 @@ static void gcmtest(FILE *in, FILE *out, int encrypt) ct = OPENSSL_malloc(ptlen); rv = FIPS_cipher(&ctx, ct, pt, ptlen); } + else + FIPS_cipher(&ctx, iv, iv, 0); FIPS_cipher(&ctx, NULL, NULL, 0); FIPS_cipher_ctx_ctrl(&ctx, EVP_CTRL_GCM_GET_TAG, taglen, tag); @@ -242,6 +244,8 @@ static void gcmtest(FILE *in, FILE *out, int encrypt) pt = OPENSSL_malloc(ptlen); rv = FIPS_cipher(&ctx, pt, ct, ptlen); } + else + FIPS_cipher(&ctx, iv, iv, 0); rv = FIPS_cipher(&ctx, NULL, NULL, 0); if (rv < 0) fprintf(out, "FAIL" RESP_EOL); diff --git a/fips/dsa/fips_dssvs.c b/fips/dsa/fips_dssvs.c index e2f2297f00..cee5fb398e 100644 --- a/fips/dsa/fips_dssvs.c +++ b/fips/dsa/fips_dssvs.c @@ -46,7 +46,8 @@ static int parse_mod(char *line, int *pdsa2, int *pL, int *pN, if (strcmp(keyword, "L")) return 0; *pL = atoi(value); - strcpy(line, p + 1); + strcpy(lbuf, p + 1); + strcpy(line, lbuf); if (pmd) p = strchr(line, ','); else diff --git a/fips/fips_canister.c b/fips/fips_canister.c index afe55a1bc7..016d94c976 100644 --- a/fips/fips_canister.c +++ b/fips/fips_canister.c @@ -32,6 +32,7 @@ const void *FIPS_text_end(void); defined(__i386__)|| defined(__i386))) || \ (defined(__vxworks) && (defined(__ppc__) || defined(__ppc) || \ defined(__mips__)|| defined(__mips))) || \ + (defined(__NetBSD__) && (defined(__powerpc__) || defined(__i386))) || \ (defined(__linux) && ((defined(__PPC__) && !defined(__PPC64__)) || \ defined(__arm__) || defined(__arm))) || \ (defined(__APPLE__) /* verified on all MacOS X & iOS flavors */)|| \ -- cgit v1.2.3