Compare commits
32 Commits
OpenSSL-fi
...
OpenSSL-fi
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1278ce48a5 | ||
![]() |
a0f8d282d7 | ||
![]() |
0f38e9cd78 | ||
![]() |
34f39b062c | ||
![]() |
6db8e3bdc9 | ||
![]() |
50e2a0ea46 | ||
![]() |
3f137e6f1d | ||
![]() |
97fbb0c88c | ||
![]() |
5837e90f08 | ||
![]() |
874faf2ffb | ||
![]() |
0b45df73d2 | ||
![]() |
2bd3976ed0 | ||
![]() |
c6d109051d | ||
![]() |
083ed53def | ||
![]() |
b84813ec01 | ||
![]() |
7447e65fcc | ||
![]() |
60cd2b7206 | ||
![]() |
7fb7844f3b | ||
![]() |
005563bbce | ||
![]() |
3b43568d5b | ||
![]() |
2659a2aa7c | ||
![]() |
200f249b8c | ||
![]() |
4089bd6080 | ||
![]() |
baab0cf780 | ||
![]() |
7e98d95f56 | ||
![]() |
b0ee17ad47 | ||
![]() |
4f6c4c1896 | ||
![]() |
2d183e4c44 | ||
![]() |
7049d13c5f | ||
![]() |
c616200172 | ||
![]() |
7b899c10cd | ||
![]() |
6b2e340bdd |
70
.gitignore
vendored
70
.gitignore
vendored
@@ -1,70 +0,0 @@
|
||||
# Object files
|
||||
*.o
|
||||
|
||||
# Top level excludes
|
||||
/Makefile.bak
|
||||
/Makefile
|
||||
/*.a
|
||||
/include
|
||||
/*.pc
|
||||
/rehash.time
|
||||
|
||||
# Most *.c files under test/ are symlinks
|
||||
/test/*.c
|
||||
# Apart from these
|
||||
!/test/asn1test.c
|
||||
!/test/methtest.c
|
||||
!/test/dummytest.c
|
||||
!/test/igetest.c
|
||||
!/test/r160test.c
|
||||
!/test/fips_algvs.c
|
||||
|
||||
# Certificate symbolic links
|
||||
*.0
|
||||
|
||||
# Links under apps
|
||||
/apps/CA.pl
|
||||
/apps/md4.c
|
||||
|
||||
|
||||
# Auto generated headers
|
||||
/crypto/buildinf.h
|
||||
/crypto/opensslconf.h
|
||||
|
||||
# Auto generated assembly language source files
|
||||
*.s
|
||||
!/crypto/bn/asm/pa-risc2.s
|
||||
!/crypto/bn/asm/pa-risc2W.s
|
||||
|
||||
# Executables
|
||||
/apps/openssl
|
||||
/test/sha256t
|
||||
/test/sha512t
|
||||
/test/*test
|
||||
/test/fips_aesavs
|
||||
/test/fips_desmovs
|
||||
/test/fips_dhvs
|
||||
/test/fips_drbgvs
|
||||
/test/fips_dssvs
|
||||
/test/fips_ecdhvs
|
||||
/test/fips_ecdsavs
|
||||
/test/fips_rngvs
|
||||
/test/fips_test_suite
|
||||
*.so*
|
||||
*.dylib*
|
||||
*.dll*
|
||||
# Exceptions
|
||||
!/test/bctest
|
||||
!/crypto/des/times/486-50.sol
|
||||
|
||||
# Misc auto generated files
|
||||
/tools/c_rehash
|
||||
/test/evptests.txt
|
||||
lib
|
||||
Makefile.save
|
||||
*.bak
|
||||
# FIPS module specific files.
|
||||
/fips/fips_auth.h
|
||||
/fips/fips_standalone_sha1
|
||||
/fips/fipscanister.o.sha1
|
||||
|
26
Configure
26
Configure
@@ -357,6 +357,8 @@ my %table=(
|
||||
"linux-ia64-ecc","ecc:-DL_ENDIAN -DTERMIO -O2 -Wall -no_cpprt::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"linux-ia64-icc","icc:-DL_ENDIAN -DTERMIO -O2 -Wall -no_cpprt::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"linux-x86_64", "gcc:-m64 -DL_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
|
||||
"linux-x86_64-cross", "gcc:-m64 -DL_ENDIAN -DTERMIO -O3 -Wall -DFIPS_REF_POINT_IS_CROSS_COMPILER_AWARE::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
|
||||
"linux-i686-cross", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -DFIPS_REF_POINT_IS_CROSS_COMPILER_AWARE::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"linux64-s390x", "gcc:-m64 -DB_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${s390x_asm}:64:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
|
||||
#### So called "highgprs" target for z/Architecture CPUs
|
||||
# "Highgprs" is kernel feature first implemented in Linux 2.6.32, see
|
||||
@@ -398,6 +400,8 @@ my %table=(
|
||||
"linux-alpha+bwx-gcc","gcc:-O3 -DL_ENDIAN -DTERMIO::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL:${alpha_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"linux-alpha-ccc","ccc:-fast -readonly_strings -DL_ENDIAN -DTERMIO::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}",
|
||||
"linux-alpha+bwx-ccc","ccc:-fast -readonly_strings -DL_ENDIAN -DTERMIO::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}",
|
||||
# eCos ARMv4/5
|
||||
"ecos-armv4", "gcc:-D__ECOS__ -I\$(ECOSCFG)/include -Wall -Wpointer-arith -Wstrict-prototypes -Wundef -Wno-write-strings -mno-thumb-interwork -mcpu=arm926ej-s -g -O2 -fno-exceptions::-D_REENTRANT::-nostartfiles -L\$(ECOSCFG)/lib -Ttarget.ld::".eval{my $asm=$armv4_asm;$asm=~s/armcap.o//;$asm},
|
||||
|
||||
# Android: linux-* but without -DTERMIO and pointers to headers and libs.
|
||||
"android","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
@@ -433,6 +437,7 @@ my %table=(
|
||||
# QNX
|
||||
"qnx4", "cc:-DL_ENDIAN -DTERMIO::(unknown):::${x86_gcc_des} ${x86_gcc_opts}:",
|
||||
"QNX6", "gcc:-DTERMIOS::::-lsocket::${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"QNX6-armv4", "gcc:-DTERMIOS -O2 -Wall:::::BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"QNX6-i386", "gcc:-DL_ENDIAN -DTERMIOS -O2 -Wall::::-lsocket:${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
|
||||
# BeOS
|
||||
@@ -465,8 +470,8 @@ my %table=(
|
||||
"aix64-gcc","gcc:-maix64 -O -DB_ENDIAN::-pthread:AIX::SIXTY_FOUR_BIT_LONG RC4_CHAR:${ppc64_asm}:aix64:dlfcn:aix-shared::-maix64 -shared -Wl,-G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X64",
|
||||
# Below targets assume AIX 5. Idea is to effectively disregard $OBJECT_MODE
|
||||
# at build time. $OBJECT_MODE is respected at ./config stage!
|
||||
"aix-cc", "cc:-q32 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst::-qthreaded -D_THREAD_SAFE:AIX::BN_LLONG RC4_CHAR:${ppc32_asm}:aix32:dlfcn:aix-shared::-q32 -G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 32",
|
||||
"aix64-cc", "cc:-q64 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst::-qthreaded -D_THREAD_SAFE:AIX::SIXTY_FOUR_BIT_LONG RC4_CHAR:${ppc64_asm}:aix64:dlfcn:aix-shared::-q64 -G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 64",
|
||||
"aix-cc", "cc:-q32 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst::-qthreaded:AIX::BN_LLONG RC4_CHAR:${ppc32_asm}:aix32:dlfcn:aix-shared::-q32 -G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 32",
|
||||
"aix64-cc", "cc:-q64 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst::-qthreaded:AIX::SIXTY_FOUR_BIT_LONG RC4_CHAR:${ppc64_asm}:aix64:dlfcn:aix-shared::-q64 -G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 64",
|
||||
|
||||
#
|
||||
# Cray T90 and similar (SDSC)
|
||||
@@ -583,21 +588,7 @@ my %table=(
|
||||
"darwin64-x86_64-cc","cc:-arch x86_64 -O3 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
"debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
# iPhoneOS/iOS
|
||||
#
|
||||
# It takes three prior-set environment variables to make it work:
|
||||
#
|
||||
# CROSS_COMPILE=/where/toolchain/is/usr/bin/ [note ending slash]
|
||||
# CROSS_TOP=/where/SDKs/are
|
||||
# CROSS_SDK=iPhoneOSx.y.sdk
|
||||
#
|
||||
# Exact paths vary with Xcode releases, but for couple of last ones
|
||||
# they would look like this:
|
||||
#
|
||||
# CROSS_COMPILE=`xcode-select --print-path`/Toolchains/XcodeDefault.xctoolchain/usr/bin/
|
||||
# CROSS_TOP=`xcode-select --print-path`/Platforms/iPhoneOS.platform/Developer
|
||||
# CROSS_SDK=iPhoneOS7.0.sdk
|
||||
#
|
||||
"iphoneos-cross","cc:-O3 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fomit-frame-pointer -fno-common::-D_REENTRANT:iOS:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
"iphoneos-cross","llvm-gcc:-O3 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fomit-frame-pointer -fno-common::-D_REENTRANT:iOS:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
"ios-cross","cc:-O3 -arch armv7 -mios-version-min=7.0.0 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fno-common::-D_REENTRANT:iOS:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:armcap.o armv4cpuid_ios.o:bn_asm.o armv4-mont.o armv4-gf2m.o::aes_cbc.o aes-armv4.o:::sha1-armv4-large.o sha256-armv4.o sha512-armv4.o:::::::ghash-armv4.o::ios32:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
"ios64-cross","cc:-O3 -arch arm64 -mios-version-min=7.0.0 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fno-common::-D_REENTRANT:iOS:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR -RC4_CHUNK DES_INT DES_UNROLL -BF_PTR:${aarch64_asm}:ios64:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
|
||||
@@ -623,6 +614,7 @@ my %table=(
|
||||
"vxworks-ppc860","ccppc:-nostdinc -msoft-float -DCPU=PPC860 -DNO_STRINGS_H -I\$(WIND_BASE)/target/h:::VXWORKS:-r:::::",
|
||||
"vxworks-simlinux","ccpentium:-B\$(WIND_BASE)/host/\$(WIND_HOST_TYPE)/lib/gcc-lib/ -D_VSB_CONFIG_FILE=\"\$(WIND_BASE)/target/lib/h/config/vsbConfig.h\" -DL_ENDIAN -DCPU=SIMLINUX -DTOOL_FAMILY=gnu -DTOOL=gnu -fno-builtin -fno-defer-pop -DNO_STRINGS_H -I\$(WIND_BASE)/target/h -I\$(WIND_BASE)/target/h/wrn/coreip -DOPENSSL_NO_HW_PADLOCK:::VXWORKS:-r::${no_asm}::::::ranlibpentium:",
|
||||
"vxworks-mips","ccmips:-mrtp -mips2 -O -G 0 -B\$(WIND_BASE)/host/\$(WIND_HOST_TYPE)/lib/gcc-lib/ -D_VSB_CONFIG_FILE=\"\$(WIND_BASE)/target/lib/h/config/vsbConfig.h\" -DCPU=MIPS32 -msoft-float -mno-branch-likely -DTOOL_FAMILY=gnu -DTOOL=gnu -fno-builtin -fno-defer-pop -DNO_STRINGS_H -I\$(WIND_BASE)/target/usr/h -I\$(WIND_BASE)/target/h/wrn/coreip::-D_REENTRANT:VXWORKS:-Wl,--defsym,__wrs_rtp_base=0xe0000000 -L \$(WIND_BASE)/target/usr/lib/mips/MIPSI32/sfcommon::${mips32_asm}:o32::::::ranlibmips:",
|
||||
"vxworks-pentium","ccpentium:-Os -B\$(WIND_BASE)/host/\$(WIND_HOST_TYPE)/lib/gcc-lib/ -D_VSB_CONFIG_FILE=\"\$(WIND_BASE)/target/lib/h/config/vsbConfig.h\" -DL_ENDIAN -DCPU=PENTIUM4 -DTOOL_FAMILY=gnu -DTOOL=gnu -fno-builtin -fno-defer-pop -D_WRS_KERNEL -D_WRS_VX_SMP -I\$(WIND_BASE)/target/h -I\$(WIND_BASE)/target/h/wrn/coreip -DOPENSSL_NO_HW_PADLOCK:::VXWORKS:-r::${no_asm}::::::ranlibpentium:",
|
||||
|
||||
##### Compaq Non-Stop Kernel (Tandem)
|
||||
"tandem-c89","c89:-Ww -D__TANDEM -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1 -D_TANDEM_SOURCE -DB_ENDIAN::(unknown):::THIRTY_TWO_BIT:::",
|
||||
|
40
TABLE
40
TABLE
@@ -862,7 +862,7 @@ $multilib =
|
||||
$cc = cc
|
||||
$cflags = -q32 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst
|
||||
$unistd =
|
||||
$thread_cflag = -qthreaded -D_THREAD_SAFE
|
||||
$thread_cflag = -qthreaded
|
||||
$sys_id = AIX
|
||||
$lflags =
|
||||
$bn_ops = BN_LLONG RC4_CHAR
|
||||
@@ -961,7 +961,7 @@ $multilib =
|
||||
$cc = cc
|
||||
$cflags = -q64 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst
|
||||
$unistd =
|
||||
$thread_cflag = -qthreaded -D_THREAD_SAFE
|
||||
$thread_cflag = -qthreaded
|
||||
$sys_id = AIX
|
||||
$lflags =
|
||||
$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHAR
|
||||
@@ -3465,42 +3465,8 @@ $ranlib =
|
||||
$arflags =
|
||||
$multilib =
|
||||
|
||||
*** ios64-cross
|
||||
$cc = cc
|
||||
$cflags = -O3 -arch arm64 -mios-version-min=7.0.0 -isysroot $(CROSS_TOP)/SDKs/$(CROSS_SDK) -fno-common
|
||||
$unistd =
|
||||
$thread_cflag = -D_REENTRANT
|
||||
$sys_id = iOS
|
||||
$lflags = -Wl,-search_paths_first%
|
||||
$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHAR -RC4_CHUNK DES_INT DES_UNROLL -BF_PTR
|
||||
$cpuid_obj =
|
||||
$bn_obj =
|
||||
$ec_obj =
|
||||
$des_obj =
|
||||
$aes_obj =
|
||||
$bf_obj =
|
||||
$md5_obj =
|
||||
$sha1_obj =
|
||||
$cast_obj =
|
||||
$rc4_obj =
|
||||
$rmd160_obj =
|
||||
$rc5_obj =
|
||||
$wp_obj =
|
||||
$cmll_obj =
|
||||
$modes_obj =
|
||||
$engines_obj =
|
||||
$perlasm_scheme = void
|
||||
$dso_scheme = dlfcn
|
||||
$shared_target= darwin-shared
|
||||
$shared_cflag = -fPIC -fno-common
|
||||
$shared_ldflag = -dynamiclib
|
||||
$shared_extension = .$(SHLIB_MAJOR).$(SHLIB_MINOR).dylib
|
||||
$ranlib =
|
||||
$arflags =
|
||||
$multilib =
|
||||
|
||||
*** iphoneos-cross
|
||||
$cc = cc
|
||||
$cc = llvm-gcc
|
||||
$cflags = -O3 -isysroot $(CROSS_TOP)/SDKs/$(CROSS_SDK) -fomit-frame-pointer -fno-common
|
||||
$unistd =
|
||||
$thread_cflag = -D_REENTRANT
|
||||
|
16
config
16
config
@@ -134,6 +134,10 @@ case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
|
||||
echo "${MACHINE}-dg-dgux"; exit 0
|
||||
;;
|
||||
|
||||
ecos:*)
|
||||
echo "${MACHINE}-whatever-ecos"; exit 0
|
||||
;;
|
||||
|
||||
HI-UX:*)
|
||||
echo "${MACHINE}-hi-hiux"; exit 0
|
||||
;;
|
||||
@@ -162,6 +166,14 @@ case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
|
||||
echo "mips4-sgi-irix64"; exit 0
|
||||
;;
|
||||
|
||||
Linux:*:cross:i686)
|
||||
echo "${MACHINE}-cross-linux"; exit 0
|
||||
;;
|
||||
|
||||
Linux:[2-9].*:cross:x86_64)
|
||||
echo "${MACHINE}-cross-linux"; exit 0
|
||||
;;
|
||||
|
||||
Linux:[2-9].*)
|
||||
echo "${MACHINE}-whatever-linux2"; exit 0
|
||||
;;
|
||||
@@ -654,6 +666,7 @@ case "$GUESSOS" in
|
||||
|
||||
options="$options -DB_ENDIAN -mschedule=$CPUSCHEDULE -march=$CPUARCH"
|
||||
OUT="linux-generic32" ;;
|
||||
armv[45]*-*-ecos) OUT="ecos-armv4" ;;
|
||||
armv[1-3]*-*-linux2) OUT="linux-generic32" ;;
|
||||
armv[7-9]*-*-linux2) OUT="linux-armv4"; options="$options -march=armv7-a" ;;
|
||||
arm*-*-linux2) OUT="linux-armv4" ;;
|
||||
@@ -688,6 +701,8 @@ case "$GUESSOS" in
|
||||
fi ;;
|
||||
*-*-linux1) OUT="linux-aout" ;;
|
||||
*-*-linux2) OUT="linux-generic32" ;;
|
||||
i686-cross-linux) OUT="linux-i686-cross" ;;
|
||||
*-cross-linux) OUT="linux-x86_64-cross" ;;
|
||||
sun4[uv]*-*-solaris2)
|
||||
OUT="solaris-sparcv9-$CC"
|
||||
ISA64=`(isalist) 2>/dev/null | grep sparcv9`
|
||||
@@ -857,6 +872,7 @@ case "$GUESSOS" in
|
||||
j90-cray-unicos) OUT="cray-j90" ;;
|
||||
nsr-tandem-nsk) OUT="tandem-c89" ;;
|
||||
beos-*) OUT="$GUESSOS" ;;
|
||||
armv4-*-qnx6) OUT="QNX6-armv4" ;;
|
||||
x86pc-*-qnx6) OUT="QNX6-i386" ;;
|
||||
*-*-qnx6) OUT="QNX6" ;;
|
||||
x86-*-android|i?86-*-android) OUT="android-x86" ;;
|
||||
|
@@ -77,17 +77,19 @@ struct CMAC_CTX_st
|
||||
|
||||
/* Make temporary keys K1 and K2 */
|
||||
|
||||
static void make_kn(unsigned char *k1, const unsigned char *l, int bl)
|
||||
static void make_kn(unsigned char *k1, unsigned char *l, int bl)
|
||||
{
|
||||
int i;
|
||||
unsigned char c = l[0], carry = c>>7, cnext;
|
||||
|
||||
/* Shift block to left, including carry */
|
||||
for (i = 0; i < bl-1; i++, c = cnext)
|
||||
k1[i] = (c << 1) | ((cnext=l[i+1]) >> 7);
|
||||
|
||||
for (i = 0; i < bl; i++)
|
||||
{
|
||||
k1[i] = l[i] << 1;
|
||||
if (i < bl - 1 && l[i + 1] & 0x80)
|
||||
k1[i] |= 1;
|
||||
}
|
||||
/* If MSB set fixup with R */
|
||||
k1[i] = (c << 1) ^ ((0-carry)&(bl==16?0x87:0x1b));
|
||||
if (l[0] & 0x80)
|
||||
k1[bl - 1] ^= bl == 16 ? 0x87 : 0x1b;
|
||||
}
|
||||
|
||||
CMAC_CTX *CMAC_CTX_new(void)
|
||||
@@ -151,8 +153,6 @@ int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen,
|
||||
return 0;
|
||||
if (!M_EVP_EncryptInit_ex(&ctx->cctx, NULL, NULL, NULL, zero_iv))
|
||||
return 0;
|
||||
memset(ctx->tbl, 0, M_EVP_CIPHER_CTX_block_size(&ctx->cctx));
|
||||
ctx->nlast_block = 0;
|
||||
return 1;
|
||||
}
|
||||
/* Initialiase context */
|
||||
|
@@ -297,7 +297,7 @@ void OPENSSL_showfatal (const char *fmta,...)
|
||||
DWORD out;
|
||||
|
||||
va_start (ap,fmta);
|
||||
len=_vsnprintf((char *)buf,sizeof(buf),fmta,ap);
|
||||
len=_vsnprintf((char *)buf,sizeof(buf),fmt,ap);
|
||||
WriteFile(h,buf,len<0?sizeof(buf):(DWORD)len,&out,NULL);
|
||||
va_end (ap);
|
||||
return;
|
||||
|
@@ -857,28 +857,6 @@ static int aes_gcm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
|
||||
/* Extra padding: tag appended to record */
|
||||
return EVP_GCM_TLS_TAG_LEN;
|
||||
|
||||
case EVP_CTRL_COPY:
|
||||
{
|
||||
EVP_CIPHER_CTX *out = ptr;
|
||||
EVP_AES_GCM_CTX *gctx_out = out->cipher_data;
|
||||
if (gctx->gcm.key)
|
||||
{
|
||||
if (gctx->gcm.key != &gctx->ks)
|
||||
return 0;
|
||||
gctx_out->gcm.key = &gctx_out->ks;
|
||||
}
|
||||
if (gctx->iv == c->iv)
|
||||
gctx_out->iv = out->iv;
|
||||
else
|
||||
{
|
||||
gctx_out->iv = OPENSSL_malloc(gctx->ivlen);
|
||||
if (!gctx_out->iv)
|
||||
return 0;
|
||||
memcpy(gctx_out->iv, gctx->iv, gctx->ivlen);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
default:
|
||||
return -1;
|
||||
|
||||
@@ -1115,8 +1093,7 @@ static int aes_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
|
||||
#define CUSTOM_FLAGS (EVP_CIPH_FLAG_DEFAULT_ASN1 \
|
||||
| EVP_CIPH_CUSTOM_IV | EVP_CIPH_FLAG_CUSTOM_CIPHER \
|
||||
| EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT \
|
||||
| EVP_CIPH_CUSTOM_COPY)
|
||||
| EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT)
|
||||
|
||||
BLOCK_CIPHER_custom(NID_aes,128,1,12,gcm,GCM,
|
||||
EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS)
|
||||
@@ -1128,25 +1105,7 @@ BLOCK_CIPHER_custom(NID_aes,256,1,12,gcm,GCM,
|
||||
static int aes_xts_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
|
||||
{
|
||||
EVP_AES_XTS_CTX *xctx = c->cipher_data;
|
||||
if (type == EVP_CTRL_COPY)
|
||||
{
|
||||
EVP_CIPHER_CTX *out = ptr;
|
||||
EVP_AES_XTS_CTX *xctx_out = out->cipher_data;
|
||||
if (xctx->xts.key1)
|
||||
{
|
||||
if (xctx->xts.key1 != &xctx->ks1)
|
||||
return 0;
|
||||
xctx_out->xts.key1 = &xctx_out->ks1;
|
||||
}
|
||||
if (xctx->xts.key2)
|
||||
{
|
||||
if (xctx->xts.key2 != &xctx->ks2)
|
||||
return 0;
|
||||
xctx_out->xts.key2 = &xctx_out->ks2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else if (type != EVP_CTRL_INIT)
|
||||
if (type != EVP_CTRL_INIT)
|
||||
return -1;
|
||||
/* key1 and key2 are used as an indicator both key and IV are set */
|
||||
xctx->xts.key1 = NULL;
|
||||
@@ -1266,8 +1225,7 @@ static int aes_xts_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
#define aes_xts_cleanup NULL
|
||||
|
||||
#define XTS_FLAGS (EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CUSTOM_IV \
|
||||
| EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT \
|
||||
| EVP_CIPH_CUSTOM_COPY)
|
||||
| EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT)
|
||||
|
||||
BLOCK_CIPHER_custom(NID_aes,128,1,16,xts,XTS,EVP_CIPH_FLAG_FIPS|XTS_FLAGS)
|
||||
BLOCK_CIPHER_custom(NID_aes,256,1,16,xts,XTS,EVP_CIPH_FLAG_FIPS|XTS_FLAGS)
|
||||
@@ -1317,19 +1275,6 @@ static int aes_ccm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
|
||||
cctx->len_set = 0;
|
||||
return 1;
|
||||
|
||||
case EVP_CTRL_COPY:
|
||||
{
|
||||
EVP_CIPHER_CTX *out = ptr;
|
||||
EVP_AES_CCM_CTX *cctx_out = out->cipher_data;
|
||||
if (cctx->ccm.key)
|
||||
{
|
||||
if (cctx->ccm.key != &cctx->ks)
|
||||
return 0;
|
||||
cctx_out->ccm.key = &cctx_out->ks;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
default:
|
||||
return -1;
|
||||
|
||||
@@ -1363,7 +1308,6 @@ static int aes_ccm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
vpaes_set_encrypt_key(key, ctx->key_len*8, &cctx->ks);
|
||||
CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L,
|
||||
&cctx->ks, (block128_f)vpaes_encrypt);
|
||||
cctx->str = NULL;
|
||||
cctx->key_set = 1;
|
||||
break;
|
||||
}
|
||||
|
@@ -1422,7 +1422,7 @@ int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx,const unsigned char *tag,
|
||||
void (*gcm_gmult_p)(u64 Xi[2],const u128 Htable[16]) = ctx->gmult;
|
||||
#endif
|
||||
|
||||
if (ctx->mres || ctx->ares)
|
||||
if (ctx->mres)
|
||||
GCM_MUL(ctx,Xi);
|
||||
|
||||
if (is_endian.little) {
|
||||
|
@@ -26,10 +26,16 @@ typedef unsigned int u32;
|
||||
typedef unsigned char u8;
|
||||
|
||||
#define STRICT_ALIGNMENT 1
|
||||
#if defined(__i386) || defined(__i386__) || \
|
||||
defined(__x86_64) || defined(__x86_64__) || \
|
||||
defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || \
|
||||
defined(__s390__) || defined(__s390x__)
|
||||
#if defined(__i386) || defined(__i386__) || \
|
||||
defined(__x86_64) || defined(__x86_64__) || \
|
||||
defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || \
|
||||
defined(__s390__) || defined(__s390x__) || \
|
||||
( \
|
||||
( (defined(__arm__) || defined(__arm)) && \
|
||||
(defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \
|
||||
defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__)) ) && \
|
||||
!( defined(__arm__) && defined(__APPLE__) ) \
|
||||
)
|
||||
# undef STRICT_ALIGNMENT
|
||||
#endif
|
||||
|
||||
|
@@ -494,7 +494,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
|
||||
if (padding == RSA_X931_PADDING)
|
||||
{
|
||||
BN_sub(f, rsa->n, ret);
|
||||
if (BN_cmp(ret, f) > 0)
|
||||
if (BN_cmp(ret, f))
|
||||
res = f;
|
||||
else
|
||||
res = ret;
|
||||
|
8
e_os.h
8
e_os.h
@@ -306,7 +306,7 @@ static unsigned int _strlen31(const char *str)
|
||||
# undef isupper
|
||||
# undef isxdigit
|
||||
# endif
|
||||
# if defined(_MSC_VER) && !defined(_WIN32_WCE) && !defined(_DLL) && defined(stdin)
|
||||
# if defined(_MSC_VER) && !defined(_DLL) && defined(stdin)
|
||||
# if _MSC_VER>=1300
|
||||
# undef stdin
|
||||
# undef stdout
|
||||
@@ -332,10 +332,8 @@ static unsigned int _strlen31(const char *str)
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
# if !defined(OPENSSL_FIPSCANISTER)
|
||||
# include <io.h>
|
||||
# include <fcntl.h>
|
||||
# endif
|
||||
# include <io.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
# ifdef OPENSSL_SYS_WINCE
|
||||
# define OPENSSL_NO_POSIX_IO
|
||||
|
@@ -83,7 +83,7 @@ static const struct
|
||||
|
||||
int FIPS_selftest_des()
|
||||
{
|
||||
int n, ret = 1;
|
||||
int n, ret = 0;
|
||||
EVP_CIPHER_CTX ctx;
|
||||
FIPS_cipher_ctx_init(&ctx);
|
||||
|
||||
@@ -93,8 +93,10 @@ int FIPS_selftest_des()
|
||||
if (!fips_cipher_test(FIPS_TEST_CIPHER, &ctx, EVP_des_ede3_ecb(),
|
||||
tests3[n].key, NULL,
|
||||
tests3[n].plaintext, tests3[n].ciphertext, 8))
|
||||
ret = 0;
|
||||
goto err;
|
||||
}
|
||||
ret = 1;
|
||||
err:
|
||||
FIPS_cipher_ctx_cleanup(&ctx);
|
||||
if (ret == 0)
|
||||
FIPSerr(FIPS_F_FIPS_SELFTEST_DES,FIPS_R_SELFTEST_FAILED);
|
||||
|
@@ -553,11 +553,6 @@ static void keypair(FILE *in, FILE *out)
|
||||
int n=atoi(value);
|
||||
|
||||
dsa = FIPS_dsa_new();
|
||||
if (!dsa)
|
||||
{
|
||||
fprintf(stderr, "DSA allocation error\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!dsa2 && !dsa_builtin_paramgen(dsa, L, N, NULL, NULL, 0,
|
||||
NULL, NULL, NULL, NULL))
|
||||
{
|
||||
@@ -584,7 +579,8 @@ static void keypair(FILE *in, FILE *out)
|
||||
do_bn_print_name(out, "Y",dsa->pub_key);
|
||||
fputs(RESP_EOL, out);
|
||||
}
|
||||
FIPS_dsa_free(dsa);
|
||||
if (dsa)
|
||||
FIPS_dsa_free(dsa);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -143,7 +143,7 @@ int FIPS_selftest_ecdsa()
|
||||
EC_KEY *ec = NULL;
|
||||
BIGNUM *x = NULL, *y = NULL, *d = NULL;
|
||||
EVP_PKEY pk;
|
||||
int rv = 0, test_err = 0;
|
||||
int rv = 0;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < sizeof(test_ec_data)/sizeof(EC_SELFTEST_DATA); i++)
|
||||
@@ -173,12 +173,12 @@ int FIPS_selftest_ecdsa()
|
||||
if (!fips_pkey_signature_test(FIPS_TEST_SIGNATURE, &pk, NULL, 0,
|
||||
NULL, 0, EVP_sha512(), 0,
|
||||
ecd->name))
|
||||
test_err = 1;
|
||||
goto err;
|
||||
EC_KEY_free(ec);
|
||||
ec = NULL;
|
||||
}
|
||||
if (test_err == 0)
|
||||
rv = 1;
|
||||
|
||||
rv = 1;
|
||||
|
||||
err:
|
||||
|
||||
|
@@ -32,13 +32,17 @@ const void *FIPS_text_end(void);
|
||||
defined(__aarch64__) || \
|
||||
defined(__i386__)|| defined(__i386))) || \
|
||||
(defined(__vxworks) && (defined(__ppc__) || defined(__ppc) || \
|
||||
defined(__mips__)|| defined(__mips))) || \
|
||||
defined(__mips__)|| defined(__mips) || \
|
||||
defined(__i386__)|| defined(__i386))) || \
|
||||
(defined(__NetBSD__) && (defined(__powerpc__) || defined(__i386))) || \
|
||||
(defined(__linux) && ((defined(__PPC__) && !defined(__PPC64__)) || \
|
||||
defined(__arm__) || defined(__arm))) || \
|
||||
defined(__arm__) || defined(__arm)) || \
|
||||
defined(__mips__)) || \
|
||||
(defined(__APPLE__) /* verified on all MacOS X & iOS flavors */)|| \
|
||||
(defined(_TMS320C6X)) || \
|
||||
(defined(_WIN32) && defined(_MSC_VER))
|
||||
(defined(__ECOS__)) || \
|
||||
(defined(_WIN32) && defined(_MSC_VER)) || \
|
||||
(defined(__QNX__) && defined(__ARM__))
|
||||
# define FIPS_REF_POINT_IS_CROSS_COMPILER_AWARE
|
||||
# endif
|
||||
#endif
|
||||
|
@@ -40,46 +40,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/dsa.h>
|
||||
#include <openssl/ecdsa.h>
|
||||
#include <openssl/dh.h>
|
||||
|
||||
#include <openssl/fips.h>
|
||||
#include <openssl/fips_rand.h>
|
||||
#include "fips_utl.h"
|
||||
|
||||
static int verbose = 0;
|
||||
|
||||
static int fips_module_mode_set_verbose(int mode, const char *pass)
|
||||
{
|
||||
int rv;
|
||||
if (verbose)
|
||||
printf("Attempting to %s FIPS mode\n", mode ? "Enter" : "Leave");
|
||||
rv = FIPS_module_mode_set(mode, pass);
|
||||
if (verbose)
|
||||
printf("FIPS_module_mode() returned %d\n", FIPS_module_mode());
|
||||
return rv;
|
||||
}
|
||||
|
||||
static void do_print_rsa_key(RSA *rsa)
|
||||
{
|
||||
if (!verbose)
|
||||
return;
|
||||
do_bn_print_name(stdout, "RSA key modulus value", rsa->e);
|
||||
do_bn_print_name(stdout, "RSA key publicExponent value", rsa->n);
|
||||
do_bn_print_name(stdout, "RSA key pricateExponent value", rsa->d);
|
||||
do_bn_print_name(stdout, "RSA key prime1 value", rsa->p);
|
||||
do_bn_print_name(stdout, "RSA key prime2 value", rsa->q);
|
||||
do_bn_print_name(stdout, "RSA key exponent1 value", rsa->dmp1);
|
||||
do_bn_print_name(stdout, "RSA key exponent2 value", rsa->dmq1);
|
||||
do_bn_print_name(stdout, "RSA key coefficient value", rsa->iqmp);
|
||||
}
|
||||
|
||||
static void do_print_buf(char *name, unsigned char *buf, int buflen)
|
||||
{
|
||||
if (verbose)
|
||||
OutputValue(name, buf, buflen, stdout, 0);
|
||||
}
|
||||
|
||||
/* AES: encrypt and decrypt known plaintext, verify result matches original plaintext
|
||||
*/
|
||||
static int FIPS_aes_test(void)
|
||||
@@ -91,30 +57,14 @@ static int FIPS_aes_test(void)
|
||||
unsigned char plaintext[16] = "etaonrishdlcu";
|
||||
EVP_CIPHER_CTX ctx;
|
||||
FIPS_cipher_ctx_init(&ctx);
|
||||
if (verbose)
|
||||
{
|
||||
do_print_buf("Key", key, sizeof(key));
|
||||
do_print_buf("Plaintext", plaintext, sizeof(plaintext));
|
||||
}
|
||||
if (FIPS_cipherinit(&ctx, EVP_aes_128_ecb(), key, NULL, 1) <= 0)
|
||||
goto err;
|
||||
FIPS_cipher(&ctx, citmp, plaintext, 16);
|
||||
if (verbose)
|
||||
{
|
||||
do_print_buf("Ciphertext", citmp, sizeof(plaintext));
|
||||
printf("AES 128 bit ECB mode decryption started\n");
|
||||
}
|
||||
if (FIPS_cipherinit(&ctx, EVP_aes_128_ecb(), key, NULL, 0) <= 0)
|
||||
goto err;
|
||||
FIPS_cipher(&ctx, pltmp, citmp, 16);
|
||||
do_print_buf("Recovered Plaintext", pltmp, sizeof(plaintext));
|
||||
if (memcmp(pltmp, plaintext, 16))
|
||||
{
|
||||
printf("Comparison failure!!\n");
|
||||
goto err;
|
||||
}
|
||||
if (verbose)
|
||||
printf("Comparison success.\n");
|
||||
ret = 1;
|
||||
err:
|
||||
FIPS_cipher_ctx_cleanup(&ctx);
|
||||
@@ -133,13 +83,6 @@ static int FIPS_aes_gcm_test(void)
|
||||
unsigned char plaintext[16] = "etaonrishdlcu";
|
||||
EVP_CIPHER_CTX ctx;
|
||||
FIPS_cipher_ctx_init(&ctx);
|
||||
if (verbose)
|
||||
{
|
||||
do_print_buf("Key", key, sizeof(key));
|
||||
do_print_buf("IV", key, sizeof(iv));
|
||||
do_print_buf("Plaintext", plaintext, sizeof(plaintext));
|
||||
do_print_buf("AAD", aad, sizeof(aad));
|
||||
}
|
||||
if (FIPS_cipherinit(&ctx, EVP_aes_128_gcm(), key, iv, 1) <= 0)
|
||||
goto err;
|
||||
FIPS_cipher(&ctx, NULL, aad, sizeof(aad));
|
||||
@@ -148,12 +91,6 @@ static int FIPS_aes_gcm_test(void)
|
||||
if (!FIPS_cipher_ctx_ctrl(&ctx, EVP_CTRL_GCM_GET_TAG, 16, tagtmp))
|
||||
goto err;
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
do_print_buf("Ciphertext", citmp, sizeof(citmp));
|
||||
do_print_buf("Tag", tagtmp, sizeof(tagtmp));
|
||||
}
|
||||
|
||||
if (FIPS_cipherinit(&ctx, EVP_aes_128_gcm(), key, iv, 0) <= 0)
|
||||
goto err;
|
||||
if (!FIPS_cipher_ctx_ctrl(&ctx, EVP_CTRL_GCM_SET_TAG, 16, tagtmp))
|
||||
@@ -166,17 +103,8 @@ static int FIPS_aes_gcm_test(void)
|
||||
if (FIPS_cipher(&ctx, NULL, NULL, 0) < 0)
|
||||
goto err;
|
||||
|
||||
if (verbose)
|
||||
do_print_buf("Recovered Plaintext", pltmp, sizeof(plaintext));
|
||||
|
||||
if (memcmp(pltmp, plaintext, 16))
|
||||
{
|
||||
if (verbose)
|
||||
printf("Comparison failure!!\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
printf("Comparison sucess.\n");
|
||||
|
||||
ret = 1;
|
||||
err:
|
||||
@@ -194,110 +122,20 @@ static int FIPS_des3_test(void)
|
||||
unsigned char plaintext[] = { 'e', 't', 'a', 'o', 'n', 'r', 'i', 's' };
|
||||
EVP_CIPHER_CTX ctx;
|
||||
FIPS_cipher_ctx_init(&ctx);
|
||||
if (verbose)
|
||||
{
|
||||
do_print_buf("Key", key, sizeof(key));
|
||||
do_print_buf("Plaintext", plaintext, sizeof(plaintext));
|
||||
}
|
||||
if (FIPS_cipherinit(&ctx, EVP_des_ede3_ecb(), key, NULL, 1) <= 0)
|
||||
goto err;
|
||||
FIPS_cipher(&ctx, citmp, plaintext, 8);
|
||||
if (verbose)
|
||||
{
|
||||
do_print_buf("Ciphertext", citmp, sizeof(plaintext));
|
||||
printf("DES3 ECB mode decryption\n");
|
||||
}
|
||||
if (FIPS_cipherinit(&ctx, EVP_des_ede3_ecb(), key, NULL, 0) <= 0)
|
||||
goto err;
|
||||
FIPS_cipher(&ctx, pltmp, citmp, 8);
|
||||
if (verbose)
|
||||
do_print_buf("Recovered Plaintext", pltmp, sizeof(plaintext));
|
||||
if (memcmp(pltmp, plaintext, 8))
|
||||
{
|
||||
if (verbose)
|
||||
printf("Comparison failure!!\n");
|
||||
|
||||
goto err;
|
||||
}
|
||||
if (verbose)
|
||||
printf("Comparison success\n");
|
||||
ret = 1;
|
||||
err:
|
||||
FIPS_cipher_ctx_cleanup(&ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* ECDSA: generate keys and sign, verify input plaintext.
|
||||
*/
|
||||
static int FIPS_ecdsa_test(void)
|
||||
{
|
||||
EC_KEY *ec = NULL;
|
||||
unsigned char dgst[] = "etaonrishdlc";
|
||||
int r = 0;
|
||||
ECDSA_SIG *sig = NULL;
|
||||
|
||||
ERR_clear_error();
|
||||
ec = FIPS_ec_key_new_by_curve_name(NID_X9_62_prime256v1);
|
||||
if (!ec)
|
||||
goto end;
|
||||
if (!FIPS_ec_key_generate_key(ec))
|
||||
goto end;
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
BIGNUM *Qx, *Qy;
|
||||
BN_CTX *ctx;
|
||||
const EC_GROUP *grp;
|
||||
const EC_POINT *pt;
|
||||
const BIGNUM *priv;
|
||||
Qx = BN_new();
|
||||
Qy = BN_new();
|
||||
ctx = BN_CTX_new();
|
||||
grp = EC_KEY_get0_group(ec);
|
||||
pt = EC_KEY_get0_public_key(ec);
|
||||
priv = EC_KEY_get0_private_key(ec);
|
||||
printf("EC Key using P-256\n");
|
||||
if (!EC_POINT_get_affine_coordinates_GFp(grp, pt, Qx, Qy, ctx))
|
||||
goto end;
|
||||
|
||||
do_bn_print_name(stdout, "ECDSA key x coordinate", Qx);
|
||||
do_bn_print_name(stdout, "ECDSA key y coordinate", Qy);
|
||||
do_bn_print_name(stdout, "ECDSA key private value", priv);
|
||||
BN_free(Qx);
|
||||
BN_free(Qy);
|
||||
BN_CTX_free(ctx);
|
||||
printf("Signing string \"%s\" using SHA256\n", dgst);
|
||||
}
|
||||
|
||||
sig = FIPS_ecdsa_sign(ec, dgst, sizeof(dgst) -1, EVP_sha256());
|
||||
if (!sig)
|
||||
{
|
||||
if (verbose)
|
||||
printf("Signing Failed!!\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
printf("Signing successful\n");
|
||||
do_bn_print_name(stdout, "ECDSA signature r value", sig->r);
|
||||
do_bn_print_name(stdout, "ECDSA signature s value", sig->s);
|
||||
}
|
||||
|
||||
r = FIPS_ecdsa_verify(ec, dgst, sizeof(dgst) -1, EVP_sha256(), sig);
|
||||
if (verbose)
|
||||
printf("ECDSA verification %s\n", r ? "Successful." : "Failed!!");
|
||||
end:
|
||||
if (sig)
|
||||
FIPS_ecdsa_sig_free(sig);
|
||||
if (ec)
|
||||
FIPS_ec_key_free(ec);
|
||||
if (r != 1)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* DSA: generate keys and sign, verify input plaintext.
|
||||
*/
|
||||
@@ -319,34 +157,11 @@ static int FIPS_dsa_test(int bad)
|
||||
if (bad)
|
||||
BN_add_word(dsa->pub_key, 1);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
do_bn_print_name(stdout, "DSA key p value", dsa->p);
|
||||
do_bn_print_name(stdout, "DSA key q value", dsa->q);
|
||||
do_bn_print_name(stdout, "DSA key g value", dsa->g);
|
||||
do_bn_print_name(stdout, "DSA key public_key value", dsa->pub_key);
|
||||
do_bn_print_name(stdout, "DSA key private key value", dsa->priv_key);
|
||||
printf("Signing string \"%s\" using SHA256\n", dgst);
|
||||
}
|
||||
|
||||
sig = FIPS_dsa_sign(dsa, dgst, sizeof(dgst) -1, EVP_sha256());
|
||||
if (!sig)
|
||||
{
|
||||
if (verbose)
|
||||
printf("Signing Failed!!\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
printf("Signing successful\n");
|
||||
do_bn_print_name(stdout, "DSA signature r value", sig->r);
|
||||
do_bn_print_name(stdout, "DSA signature s value", sig->s);
|
||||
}
|
||||
|
||||
r = FIPS_dsa_verify(dsa, dgst, sizeof(dgst) -1, EVP_sha256(), sig);
|
||||
if (verbose)
|
||||
printf("DSA verification %s\n", r ? "Successful." : "Failed!!");
|
||||
end:
|
||||
if (sig)
|
||||
FIPS_dsa_sig_free(sig);
|
||||
@@ -381,30 +196,12 @@ static int FIPS_rsa_test(int bad)
|
||||
if (bad)
|
||||
BN_add_word(key->n, 1);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
do_print_rsa_key(key);
|
||||
printf("Signing string \"%s\" using SHA256\n", input_ptext);
|
||||
}
|
||||
|
||||
if (!FIPS_rsa_sign(key, input_ptext, sizeof(input_ptext) - 1, EVP_sha256(),
|
||||
RSA_PKCS1_PADDING, 0, NULL, buf, &slen))
|
||||
{
|
||||
if (verbose)
|
||||
printf("RSA Signing failed!!\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
printf("RSA signing successul\n");
|
||||
do_print_buf("RSA signature", buf, slen);
|
||||
}
|
||||
|
||||
r = FIPS_rsa_verify(key, input_ptext, sizeof(input_ptext) - 1, EVP_sha256(),
|
||||
RSA_PKCS1_PADDING, 0, NULL, buf, slen);
|
||||
if (verbose)
|
||||
printf("RSA Verification %s\n", r == 1 ? "Successful" : "Failed!!");
|
||||
end:
|
||||
if (key)
|
||||
FIPS_rsa_free(key);
|
||||
@@ -426,11 +223,6 @@ static int FIPS_sha1_test()
|
||||
|
||||
ERR_clear_error();
|
||||
if (!FIPS_digest(str,sizeof(str) - 1,md, NULL, EVP_sha1())) return 0;
|
||||
if (verbose)
|
||||
{
|
||||
printf("Digesting string %s\n", str);
|
||||
do_print_buf("Digest value", md, sizeof(md));
|
||||
}
|
||||
if (memcmp(md,digest,sizeof(md)))
|
||||
return 0;
|
||||
return 1;
|
||||
@@ -450,11 +242,6 @@ static int FIPS_sha256_test()
|
||||
|
||||
ERR_clear_error();
|
||||
if (!FIPS_digest(str,sizeof(str) - 1,md, NULL, EVP_sha256())) return 0;
|
||||
if (verbose)
|
||||
{
|
||||
printf("Digesting string %s\n", str);
|
||||
do_print_buf("Digest value", md, sizeof(md));
|
||||
}
|
||||
if (memcmp(md,digest,sizeof(md)))
|
||||
return 0;
|
||||
return 1;
|
||||
@@ -476,11 +263,6 @@ static int FIPS_sha512_test()
|
||||
|
||||
ERR_clear_error();
|
||||
if (!FIPS_digest(str,sizeof(str) - 1,md, NULL, EVP_sha512())) return 0;
|
||||
if (verbose)
|
||||
{
|
||||
printf("Digesting string %s\n", str);
|
||||
do_print_buf("Digest value", md, sizeof(md));
|
||||
}
|
||||
if (memcmp(md,digest,sizeof(md)))
|
||||
return 0;
|
||||
return 1;
|
||||
@@ -502,19 +284,8 @@ static int FIPS_hmac_sha1_test()
|
||||
|
||||
ERR_clear_error();
|
||||
if (!HMAC(EVP_sha1(),key,sizeof(key)-1,iv,sizeof(iv)-1,out,&outlen)) return 0;
|
||||
if (verbose)
|
||||
{
|
||||
do_print_buf("HMAC key", key, sizeof(key) -1);
|
||||
do_print_buf("HMAC input", iv, sizeof(iv) -1);
|
||||
do_print_buf("HMAC output", out, outlen);
|
||||
}
|
||||
if (memcmp(out,kaval,outlen))
|
||||
{
|
||||
if (verbose)
|
||||
printf("HMAC comparison failed!!\n");
|
||||
return 0;
|
||||
}
|
||||
printf("HMAC comparison successful.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -534,19 +305,6 @@ static int FIPS_hmac_sha224_test()
|
||||
|
||||
ERR_clear_error();
|
||||
if (!HMAC(EVP_sha224(),key,sizeof(key)-1,iv,sizeof(iv)-1,out,&outlen)) return 0;
|
||||
if (verbose)
|
||||
{
|
||||
do_print_buf("HMAC key", key, sizeof(key) -1);
|
||||
do_print_buf("HMAC input", iv, sizeof(iv) -1);
|
||||
do_print_buf("HMAC output", out, outlen);
|
||||
}
|
||||
if (memcmp(out,kaval,outlen))
|
||||
{
|
||||
if (verbose)
|
||||
printf("HMAC comparison failed!!\n");
|
||||
return 0;
|
||||
}
|
||||
printf("HMAC comparison successful.\n");
|
||||
if (memcmp(out,kaval,outlen))
|
||||
return 0;
|
||||
return 1;
|
||||
@@ -568,19 +326,8 @@ static int FIPS_hmac_sha256_test()
|
||||
|
||||
ERR_clear_error();
|
||||
if (!HMAC(EVP_sha256(),key,sizeof(key)-1,iv,sizeof(iv)-1,out,&outlen)) return 0;
|
||||
if (verbose)
|
||||
{
|
||||
do_print_buf("HMAC key", key, sizeof(key) -1);
|
||||
do_print_buf("HMAC input", iv, sizeof(iv) -1);
|
||||
do_print_buf("HMAC output", out, outlen);
|
||||
}
|
||||
if (memcmp(out,kaval,outlen))
|
||||
{
|
||||
if (verbose)
|
||||
printf("HMAC comparison failed!!\n");
|
||||
return 0;
|
||||
}
|
||||
printf("HMAC comparison successful.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -601,19 +348,8 @@ static int FIPS_hmac_sha384_test()
|
||||
|
||||
ERR_clear_error();
|
||||
if (!HMAC(EVP_sha384(),key,sizeof(key)-1,iv,sizeof(iv)-1,out,&outlen)) return 0;
|
||||
if (verbose)
|
||||
{
|
||||
do_print_buf("HMAC key", key, sizeof(key) -1);
|
||||
do_print_buf("HMAC input", iv, sizeof(iv) -1);
|
||||
do_print_buf("HMAC output", out, outlen);
|
||||
}
|
||||
if (memcmp(out,kaval,outlen))
|
||||
{
|
||||
if (verbose)
|
||||
printf("HMAC comparison failed!!\n");
|
||||
return 0;
|
||||
}
|
||||
printf("HMAC comparison successful.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -635,19 +371,8 @@ static int FIPS_hmac_sha512_test()
|
||||
|
||||
ERR_clear_error();
|
||||
if (!HMAC(EVP_sha512(),key,sizeof(key)-1,iv,sizeof(iv)-1,out,&outlen)) return 0;
|
||||
if (verbose)
|
||||
{
|
||||
do_print_buf("HMAC key", key, sizeof(key) -1);
|
||||
do_print_buf("HMAC input", iv, sizeof(iv) -1);
|
||||
do_print_buf("HMAC output", out, outlen);
|
||||
}
|
||||
if (memcmp(out,kaval,outlen))
|
||||
{
|
||||
if (verbose)
|
||||
printf("HMAC comparison failed!!\n");
|
||||
return 0;
|
||||
}
|
||||
printf("HMAC comparison successful.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -682,15 +407,18 @@ static int FIPS_cmac_aes128_test()
|
||||
out = OPENSSL_malloc(outlen);
|
||||
if (!CMAC_Final(ctx, out, &outlen))
|
||||
goto end;
|
||||
#if 0
|
||||
{
|
||||
char *hexout = OPENSSL_malloc(outlen * 2 + 1);
|
||||
bin2hex(out, outlen, hexout);
|
||||
printf("CMAC-AES128: res = %s\n", hexout);
|
||||
OPENSSL_free(hexout);
|
||||
}
|
||||
r = 1;
|
||||
#else
|
||||
if (!memcmp(out,kaval,outlen))
|
||||
r = 1;
|
||||
if (verbose)
|
||||
{
|
||||
do_print_buf("CMAC key", key, sizeof(key));
|
||||
do_print_buf("CMAC input", data, sizeof(data) -1);
|
||||
do_print_buf("CMAC output", out, outlen);
|
||||
printf("CMAC comparison %s\n", r == 1 ? "successful." : "Failed!!");
|
||||
}
|
||||
#endif
|
||||
end:
|
||||
CMAC_CTX_free(ctx);
|
||||
if (out)
|
||||
@@ -730,15 +458,18 @@ static int FIPS_cmac_aes192_test()
|
||||
out = OPENSSL_malloc(outlen);
|
||||
if (!CMAC_Final(ctx, out, &outlen))
|
||||
goto end;
|
||||
#if 0
|
||||
{
|
||||
char *hexout = OPENSSL_malloc(outlen * 2 + 1);
|
||||
bin2hex(out, outlen, hexout);
|
||||
printf("CMAC-AES192: res = %s\n", hexout);
|
||||
OPENSSL_free(hexout);
|
||||
}
|
||||
r = 1;
|
||||
#else
|
||||
if (!memcmp(out,kaval,outlen))
|
||||
r = 1;
|
||||
if (verbose)
|
||||
{
|
||||
do_print_buf("CMAC key", key, sizeof(key));
|
||||
do_print_buf("CMAC input", data, sizeof(data) -1);
|
||||
do_print_buf("CMAC output", out, outlen);
|
||||
printf("CMAC comparison %s\n", r == 1 ? "successful." : "Failed!!");
|
||||
}
|
||||
#endif
|
||||
end:
|
||||
CMAC_CTX_free(ctx);
|
||||
if (out)
|
||||
@@ -779,15 +510,18 @@ static int FIPS_cmac_aes256_test()
|
||||
out = OPENSSL_malloc(outlen);
|
||||
if (!CMAC_Final(ctx, out, &outlen))
|
||||
goto end;
|
||||
#if 0
|
||||
{
|
||||
char *hexout = OPENSSL_malloc(outlen * 2 + 1);
|
||||
bin2hex(out, outlen, hexout);
|
||||
printf("CMAC-AES256: res = %s\n", hexout);
|
||||
OPENSSL_free(hexout);
|
||||
}
|
||||
r = 1;
|
||||
#else
|
||||
if (!memcmp(out,kaval,outlen))
|
||||
r = 1;
|
||||
if (verbose)
|
||||
{
|
||||
do_print_buf("CMAC key", key, sizeof(key));
|
||||
do_print_buf("CMAC input", data, sizeof(data) -1);
|
||||
do_print_buf("CMAC output", out, outlen);
|
||||
printf("CMAC comparison %s\n", r == 1 ? "successful." : "Failed!!");
|
||||
}
|
||||
#endif
|
||||
end:
|
||||
CMAC_CTX_free(ctx);
|
||||
if (out)
|
||||
@@ -826,15 +560,18 @@ static int FIPS_cmac_tdea3_test()
|
||||
out = OPENSSL_malloc(outlen);
|
||||
if (!CMAC_Final(ctx, out, &outlen))
|
||||
goto end;
|
||||
#if 0
|
||||
{
|
||||
char *hexout = OPENSSL_malloc(outlen * 2 + 1);
|
||||
bin2hex(out, outlen, hexout);
|
||||
printf("CMAC-TDEA3: res = %s\n", hexout);
|
||||
OPENSSL_free(hexout);
|
||||
}
|
||||
r = 1;
|
||||
#else
|
||||
if (!memcmp(out,kaval,outlen))
|
||||
r = 1;
|
||||
if (verbose)
|
||||
{
|
||||
do_print_buf("CMAC key", key, sizeof(key));
|
||||
do_print_buf("CMAC input", data, sizeof(data) -1);
|
||||
do_print_buf("CMAC output", out, outlen);
|
||||
printf("CMAC comparison %s\n", r == 1 ? "successful." : "Failed!!");
|
||||
}
|
||||
#endif
|
||||
end:
|
||||
CMAC_CTX_free(ctx);
|
||||
if (out)
|
||||
@@ -890,11 +627,7 @@ static int Zeroize()
|
||||
for(i = 0; i < sizeof(userkey); i++) printf("%02x", userkey[i]);
|
||||
printf("\n");
|
||||
RAND_bytes(userkey, sizeof userkey);
|
||||
printf("\tchar buffer key after overwriting with random key: \n\t\t");
|
||||
for(i = 0; i < sizeof(userkey); i++) printf("%02x", userkey[i]);
|
||||
printf("\n");
|
||||
OPENSSL_cleanse(userkey, sizeof(userkey));
|
||||
printf("\tchar buffer key after zeroization: \n\t\t");
|
||||
printf("\tchar buffer key after overwriting: \n\t\t");
|
||||
for(i = 0; i < sizeof(userkey); i++) printf("%02x", userkey[i]);
|
||||
printf("\n");
|
||||
|
||||
@@ -981,18 +714,6 @@ static int do_drbg_all(void)
|
||||
{NID_aes_128_ctr, DRBG_FLAG_CTR_USE_DF},
|
||||
{NID_aes_192_ctr, DRBG_FLAG_CTR_USE_DF},
|
||||
{NID_aes_256_ctr, DRBG_FLAG_CTR_USE_DF},
|
||||
{(NID_X9_62_prime256v1 << 16)|NID_sha1, 0},
|
||||
{(NID_X9_62_prime256v1 << 16)|NID_sha224, 0},
|
||||
{(NID_X9_62_prime256v1 << 16)|NID_sha256, 0},
|
||||
{(NID_X9_62_prime256v1 << 16)|NID_sha384, 0},
|
||||
{(NID_X9_62_prime256v1 << 16)|NID_sha512, 0},
|
||||
{(NID_secp384r1 << 16)|NID_sha224, 0},
|
||||
{(NID_secp384r1 << 16)|NID_sha256, 0},
|
||||
{(NID_secp384r1 << 16)|NID_sha384, 0},
|
||||
{(NID_secp384r1 << 16)|NID_sha512, 0},
|
||||
{(NID_secp521r1 << 16)|NID_sha256, 0},
|
||||
{(NID_secp521r1 << 16)|NID_sha384, 0},
|
||||
{(NID_secp521r1 << 16)|NID_sha512, 0},
|
||||
{0, 0}
|
||||
};
|
||||
DRBG_LIST *lst;
|
||||
@@ -1014,13 +735,9 @@ static const char * Fail(const char *msg)
|
||||
return msg;
|
||||
}
|
||||
|
||||
#define test_msg(msg, rtest) \
|
||||
{ \
|
||||
int rv; \
|
||||
if (verbose) \
|
||||
printf("%s...started\n", msg); \
|
||||
rv = rtest; \
|
||||
printf("%s...%s\n", msg, rv ? "successful" : Fail("Failed!")); \
|
||||
static void test_msg(const char *msg, int result)
|
||||
{
|
||||
printf("%s...%s\n", msg, result ? "successful" : Fail("Failed!"));
|
||||
}
|
||||
|
||||
/* Table of IDs for POST translating between NIDs and names */
|
||||
@@ -1081,15 +798,13 @@ static const char *lookup_id(int id)
|
||||
static int fail_id = -1;
|
||||
static int fail_sub = -1;
|
||||
static int fail_key = -1;
|
||||
static int sub_num = -1, sub_count = -1;
|
||||
static int sub_fail_num = -1;
|
||||
|
||||
static int st_err, post_quiet = 0;
|
||||
|
||||
static int post_cb(int op, int id, int subid, void *ex)
|
||||
{
|
||||
const char *idstr, *exstr = "";
|
||||
char asctmp[20], teststr[80];
|
||||
char asctmp[20];
|
||||
int keytype = -1;
|
||||
int exp_fail = 0;
|
||||
#ifdef FIPS_POST_TIME
|
||||
@@ -1208,16 +923,6 @@ static int post_cb(int op, int id, int subid, void *ex)
|
||||
&& (fail_sub == -1 || fail_sub == subid))
|
||||
exp_fail = 1;
|
||||
|
||||
if (sub_num > 0)
|
||||
{
|
||||
if (sub_fail_num == sub_num)
|
||||
exp_fail = 1;
|
||||
sprintf(teststr, "\t\t%s %s (POST subtest #%d) test",
|
||||
idstr, exstr, sub_num);
|
||||
}
|
||||
else
|
||||
sprintf(teststr, "\t\t%s %s test", idstr, exstr);
|
||||
|
||||
switch(op)
|
||||
{
|
||||
case FIPS_POST_BEGIN:
|
||||
@@ -1228,16 +933,9 @@ static int post_cb(int op, int id, int subid, void *ex)
|
||||
clock_gettime(CLOCK_REALTIME, &tstart);
|
||||
#endif
|
||||
printf("\tPOST started\n");
|
||||
sub_num = 1;
|
||||
break;
|
||||
|
||||
case FIPS_POST_END:
|
||||
if (sub_count == -1)
|
||||
sub_count = sub_num;
|
||||
else if (sub_num != sub_count)
|
||||
printf("Inconsistent POST count %d != %d\n",
|
||||
sub_num, sub_count);
|
||||
sub_num = -1;
|
||||
printf("\tPOST %s\n", id ? "Success" : "Failed");
|
||||
#ifdef FIPS_POST_TIME
|
||||
clock_gettime(CLOCK_REALTIME, &tend);
|
||||
@@ -1249,22 +947,21 @@ static int post_cb(int op, int id, int subid, void *ex)
|
||||
|
||||
case FIPS_POST_STARTED:
|
||||
if (!post_quiet && !exp_fail)
|
||||
printf("%s started\n", teststr);
|
||||
printf("\t\t%s %s test started\n", idstr, exstr);
|
||||
#ifdef FIPS_POST_TIME
|
||||
clock_gettime(CLOCK_REALTIME, &start);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case FIPS_POST_SUCCESS:
|
||||
if (sub_num > 0)
|
||||
sub_num++;
|
||||
if (exp_fail)
|
||||
{
|
||||
printf("%s OK but should've failed\n", teststr);
|
||||
printf("\t\t%s %s test OK but should've failed\n",
|
||||
idstr, exstr);
|
||||
st_err++;
|
||||
}
|
||||
else if (!post_quiet)
|
||||
printf("%s OK\n", teststr);
|
||||
printf("\t\t%s %s test OK\n", idstr, exstr);
|
||||
#ifdef FIPS_POST_TIME
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
printf("\t\t\tTook %f seconds\n",
|
||||
@@ -1274,13 +971,15 @@ static int post_cb(int op, int id, int subid, void *ex)
|
||||
break;
|
||||
|
||||
case FIPS_POST_FAIL:
|
||||
if (sub_num > 0)
|
||||
sub_num++;
|
||||
if (exp_fail)
|
||||
printf("%s failed as expected\n", teststr);
|
||||
{
|
||||
printf("\t\t%s %s test failed as expected\n",
|
||||
idstr, exstr);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%s Failed Incorrectly!!\n", teststr);
|
||||
printf("\t\t%s %s test Failed Incorrectly!!\n",
|
||||
idstr, exstr);
|
||||
st_err++;
|
||||
}
|
||||
break;
|
||||
@@ -1288,7 +987,7 @@ static int post_cb(int op, int id, int subid, void *ex)
|
||||
case FIPS_POST_CORRUPT:
|
||||
if (exp_fail)
|
||||
{
|
||||
printf("%s failure induced\n", teststr);
|
||||
printf("\t\t%s %s test failure induced\n", idstr, exstr);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
@@ -1297,48 +996,63 @@ static int post_cb(int op, int id, int subid, void *ex)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Test POST induced failures */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *name;
|
||||
int id, subid, keyid;
|
||||
} fail_list;
|
||||
|
||||
static fail_list flist[] =
|
||||
{
|
||||
{"Integrity", FIPS_TEST_INTEGRITY, -1, -1},
|
||||
{"AES", FIPS_TEST_CIPHER, NID_aes_128_ecb, -1},
|
||||
{"DES3", FIPS_TEST_CIPHER, NID_des_ede3_ecb, -1},
|
||||
{"AES-GCM", FIPS_TEST_GCM, -1, -1},
|
||||
{"AES-CCM", FIPS_TEST_CCM, -1, -1},
|
||||
{"AES-XTS", FIPS_TEST_XTS, -1, -1},
|
||||
{"Digest", FIPS_TEST_DIGEST, -1, -1},
|
||||
{"HMAC", FIPS_TEST_HMAC, -1, -1},
|
||||
{"CMAC", FIPS_TEST_CMAC, -1, -1},
|
||||
{"DRBG", FIPS_TEST_DRBG, -1, -1},
|
||||
{"X9.31 PRNG", FIPS_TEST_X931, -1, -1},
|
||||
{"RSA", FIPS_TEST_SIGNATURE, -1, EVP_PKEY_RSA},
|
||||
{"DSA", FIPS_TEST_SIGNATURE, -1, EVP_PKEY_DSA},
|
||||
{"ECDSA", FIPS_TEST_SIGNATURE, -1, EVP_PKEY_EC},
|
||||
{"ECDH", FIPS_TEST_ECDH, -1, -1},
|
||||
{NULL, -1, -1, -1}
|
||||
};
|
||||
|
||||
static int do_fail_all(int fullpost, int fullerr)
|
||||
{
|
||||
fail_list *ftmp;
|
||||
int rv;
|
||||
size_t i;
|
||||
int sub_fail;
|
||||
RSA *rsa = NULL;
|
||||
DSA *dsa = NULL;
|
||||
DRBG_CTX *dctx = NULL, *defctx = NULL;
|
||||
EC_KEY *ec = NULL;
|
||||
BIGNUM *bn = NULL;
|
||||
unsigned char key[16] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
|
||||
EVP_CIPHER_CTX ctx;
|
||||
unsigned char out[10];
|
||||
if (!fullpost)
|
||||
post_quiet = 1;
|
||||
if (!fullerr)
|
||||
no_err = 1;
|
||||
fips_module_mode_set_verbose(0, NULL);
|
||||
for (sub_fail = 1; sub_fail < sub_count; sub_fail++)
|
||||
FIPS_module_mode_set(0, NULL);
|
||||
for (ftmp = flist; ftmp->name; ftmp++)
|
||||
{
|
||||
sub_fail_num = sub_fail;
|
||||
printf(" Testing induced failure of POST subtest %d\n",
|
||||
sub_fail);
|
||||
rv = fips_module_mode_set_verbose(1, FIPS_AUTH_USER_PASS);
|
||||
printf(" Testing induced failure of %s test\n", ftmp->name);
|
||||
fail_id = ftmp->id;
|
||||
fail_sub = ftmp->subid;
|
||||
fail_key = ftmp->keyid;
|
||||
rv = FIPS_module_mode_set(1, FIPS_AUTH_USER_PASS);
|
||||
if (rv)
|
||||
{
|
||||
printf("\tFIPS mode incorrectly successful!!\n");
|
||||
st_err++;
|
||||
}
|
||||
printf("\tAttempting crypto operation after failed POST... ");
|
||||
FIPS_cipher_ctx_init(&ctx);
|
||||
rv = FIPS_cipherinit(&ctx, EVP_aes_128_ecb(), key, NULL, 1);
|
||||
if (rv > 0)
|
||||
{
|
||||
printf("succeeded incorrectly!!\n");
|
||||
st_err++;
|
||||
}
|
||||
else
|
||||
printf("failed as expected.\n");
|
||||
FIPS_cipher_ctx_cleanup(&ctx);
|
||||
}
|
||||
sub_fail_num = -1;
|
||||
printf(" Testing induced failure of RSA keygen test\n");
|
||||
/* NB POST will succeed with a pairwise test failures as
|
||||
* it is not used during POST.
|
||||
@@ -1346,7 +1060,7 @@ static int do_fail_all(int fullpost, int fullerr)
|
||||
fail_id = FIPS_TEST_PAIRWISE;
|
||||
fail_key = EVP_PKEY_RSA;
|
||||
/* Now enter FIPS mode successfully */
|
||||
if (!fips_module_mode_set_verbose(1, FIPS_AUTH_USER_PASS))
|
||||
if (!FIPS_module_mode_set(1, FIPS_AUTH_USER_PASS))
|
||||
{
|
||||
printf("\tError entering FIPS mode\n");
|
||||
st_err++;
|
||||
@@ -1366,12 +1080,12 @@ static int do_fail_all(int fullpost, int fullerr)
|
||||
printf("\tRSA key generation failed as expected.\n");
|
||||
|
||||
/* Leave FIPS mode to clear error */
|
||||
fips_module_mode_set_verbose(0, NULL);
|
||||
FIPS_module_mode_set(0, NULL);
|
||||
|
||||
printf(" Testing induced failure of DSA keygen test\n");
|
||||
fail_key = EVP_PKEY_DSA;
|
||||
/* Enter FIPS mode successfully */
|
||||
if (!fips_module_mode_set_verbose(1, FIPS_AUTH_USER_PASS))
|
||||
if (!FIPS_module_mode_set(1, FIPS_AUTH_USER_PASS))
|
||||
{
|
||||
printf("\tError entering FIPS mode\n");
|
||||
st_err++;
|
||||
@@ -1390,9 +1104,9 @@ static int do_fail_all(int fullpost, int fullerr)
|
||||
printf("\tDSA key generation failed as expected.\n");
|
||||
|
||||
/* Leave FIPS mode to clear error */
|
||||
fips_module_mode_set_verbose(0, NULL);
|
||||
FIPS_module_mode_set(0, NULL);
|
||||
/* Enter FIPS mode successfully */
|
||||
if (!fips_module_mode_set_verbose(1, FIPS_AUTH_USER_PASS))
|
||||
if (!FIPS_module_mode_set(1, FIPS_AUTH_USER_PASS))
|
||||
{
|
||||
printf("\tError entering FIPS mode\n");
|
||||
st_err++;
|
||||
@@ -1421,9 +1135,9 @@ static int do_fail_all(int fullpost, int fullerr)
|
||||
fail_sub = -1;
|
||||
fail_key = -1;
|
||||
/* Leave FIPS mode to clear error */
|
||||
fips_module_mode_set_verbose(0, NULL);
|
||||
FIPS_module_mode_set(0, NULL);
|
||||
/* Enter FIPS mode successfully */
|
||||
if (!fips_module_mode_set_verbose(1, FIPS_AUTH_USER_PASS))
|
||||
if (!FIPS_module_mode_set(1, FIPS_AUTH_USER_PASS))
|
||||
{
|
||||
printf("\tError entering FIPS mode\n");
|
||||
st_err++;
|
||||
@@ -1456,9 +1170,9 @@ static int do_fail_all(int fullpost, int fullerr)
|
||||
FIPS_drbg_stick(0);
|
||||
|
||||
/* Leave FIPS mode to clear error */
|
||||
fips_module_mode_set_verbose(0, NULL);
|
||||
FIPS_module_mode_set(0, NULL);
|
||||
/* Enter FIPS mode successfully */
|
||||
if (!fips_module_mode_set_verbose(1, FIPS_AUTH_USER_PASS))
|
||||
if (!FIPS_module_mode_set(1, FIPS_AUTH_USER_PASS))
|
||||
{
|
||||
printf("\tError entering FIPS mode\n");
|
||||
st_err++;
|
||||
@@ -1486,9 +1200,9 @@ static int do_fail_all(int fullpost, int fullerr)
|
||||
else
|
||||
printf("\tDRBG continuous PRNG entropy failed as expected\n");
|
||||
/* Leave FIPS mode to clear error */
|
||||
fips_module_mode_set_verbose(0, NULL);
|
||||
FIPS_module_mode_set(0, NULL);
|
||||
/* Enter FIPS mode successfully */
|
||||
if (!fips_module_mode_set_verbose(1, FIPS_AUTH_USER_PASS))
|
||||
if (!FIPS_module_mode_set(1, FIPS_AUTH_USER_PASS))
|
||||
{
|
||||
printf("\tError entering FIPS mode\n");
|
||||
st_err++;
|
||||
@@ -1496,9 +1210,9 @@ static int do_fail_all(int fullpost, int fullerr)
|
||||
FIPS_drbg_free(dctx);
|
||||
|
||||
/* Leave FIPS mode to clear error */
|
||||
fips_module_mode_set_verbose(0, NULL);
|
||||
FIPS_module_mode_set(0, NULL);
|
||||
/* Enter FIPS mode successfully */
|
||||
if (!fips_module_mode_set_verbose(1, FIPS_AUTH_USER_PASS))
|
||||
if (!FIPS_module_mode_set(1, FIPS_AUTH_USER_PASS))
|
||||
{
|
||||
printf("\tError entering FIPS mode\n");
|
||||
st_err++;
|
||||
@@ -1526,9 +1240,9 @@ static int do_fail_all(int fullpost, int fullerr)
|
||||
FIPS_x931_stick(0);
|
||||
|
||||
/* Leave FIPS mode to clear error */
|
||||
fips_module_mode_set_verbose(0, NULL);
|
||||
FIPS_module_mode_set(0, NULL);
|
||||
/* Enter FIPS mode successfully */
|
||||
if (!fips_module_mode_set_verbose(1, FIPS_AUTH_USER_PASS))
|
||||
if (!FIPS_module_mode_set(1, FIPS_AUTH_USER_PASS))
|
||||
{
|
||||
printf("\tError entering FIPS mode\n");
|
||||
st_err++;
|
||||
@@ -1706,9 +1420,6 @@ int main(int argc, char **argv)
|
||||
} else if (!strcmp(*args, "fullerr")) {
|
||||
fullerr = 1;
|
||||
no_exit = 1;
|
||||
} else if (!strcmp(*args, "verbose")) {
|
||||
verbose = 1;
|
||||
no_exit = 1;
|
||||
} else {
|
||||
printf("Bad argument \"%s\"\n", *args);
|
||||
return 1;
|
||||
@@ -1718,7 +1429,7 @@ int main(int argc, char **argv)
|
||||
|
||||
if ((argc != 1) && !no_exit) {
|
||||
fips_algtest_init_nofips();
|
||||
if (!fips_module_mode_set_verbose(1, pass)) {
|
||||
if (!FIPS_module_mode_set(1, pass)) {
|
||||
printf("Power-up self test failed\n");
|
||||
return 1;
|
||||
}
|
||||
@@ -1739,7 +1450,7 @@ int main(int argc, char **argv)
|
||||
/* Power-up self test
|
||||
*/
|
||||
ERR_clear_error();
|
||||
test_msg("2a. Automatic power-up self test", fips_module_mode_set_verbose(1, pass));
|
||||
test_msg("2. Automatic power-up self test", FIPS_module_mode_set(1, pass));
|
||||
if (!FIPS_module_mode())
|
||||
return 1;
|
||||
if (do_drbg_stick)
|
||||
@@ -1747,8 +1458,6 @@ int main(int argc, char **argv)
|
||||
if (do_rng_stick)
|
||||
FIPS_x931_stick(1);
|
||||
|
||||
test_msg("2b. On demand self test", FIPS_selftest());
|
||||
|
||||
/* AES encryption/decryption
|
||||
*/
|
||||
test_msg("3a. AES encryption/decryption", FIPS_aes_test());
|
||||
@@ -1849,10 +1558,7 @@ int main(int argc, char **argv)
|
||||
printf("\t%s\n", do_drbg_all() ? "successful as expected"
|
||||
: Fail("failed INCORRECTLY!") );
|
||||
|
||||
test_msg("13. ECDSA key generation and signature validation",
|
||||
FIPS_ecdsa_test());
|
||||
|
||||
printf("14. Induced test failure check...\n");
|
||||
printf("13. Induced test failure check...\n");
|
||||
printf("\t%s\n", do_fail_all(fullpost, fullerr) ? "successful as expected"
|
||||
: Fail("failed INCORRECTLY!") );
|
||||
printf("\nAll tests completed with %d errors\n", Error);
|
||||
|
@@ -7,21 +7,10 @@
|
||||
# FIPS test definitions
|
||||
# List of all the unqualified file names we expect and command lines to run
|
||||
|
||||
# DSA tests
|
||||
my @fips_dsa_test_list = (
|
||||
|
||||
"DSA",
|
||||
|
||||
[ "PQGGen", "fips_dssvs pqg", "path:[^C]DSA/.*PQGGen" ],
|
||||
[ "KeyPair", "fips_dssvs keypair", "path:[^C]DSA/.*KeyPair" ],
|
||||
[ "SigGen", "fips_dssvs siggen", "path:[^C]DSA/.*SigGen" ],
|
||||
[ "SigVer", "fips_dssvs sigver", "path:[^C]DSA/.*SigVer" ]
|
||||
|
||||
);
|
||||
|
||||
my @fips_dsa_pqgver_test_list = (
|
||||
|
||||
[ "PQGVer", "fips_dssvs pqgver", "path:[^C]DSA/.*PQGVer" ]
|
||||
"DSA",
|
||||
[ "PQGVer", "fips_dssvs pqgver"]
|
||||
|
||||
);
|
||||
|
||||
@@ -34,20 +23,13 @@ my @fips_dsa2_test_list = (
|
||||
[ "KeyPair", "fips_dssvs keypair", "path:[^C]DSA2/.*KeyPair" ],
|
||||
[ "SigGen", "fips_dssvs siggen", "path:[^C]DSA2/.*SigGen" ],
|
||||
[ "SigVer", "fips_dssvs sigver", "path:[^C]DSA2/.*SigVer" ],
|
||||
[ "PQGVer", "fips_dssvs pqgver", "path:[^C]DSA2/.*PQGVer" ]
|
||||
[ "PQGVer", "fips_dssvs pqgver", "file:L\\s*=.*N\\s*=" ]
|
||||
|
||||
);
|
||||
|
||||
# ECDSA and ECDSA2 tests
|
||||
my @fips_ecdsa_test_list = (
|
||||
|
||||
"ECDSA",
|
||||
|
||||
[ "KeyPair", "fips_ecdsavs KeyPair", "path:/ECDSA/.*KeyPair" ],
|
||||
[ "PKV", "fips_ecdsavs PKV", "path:/ECDSA/.*PKV" ],
|
||||
[ "SigGen", "fips_ecdsavs SigGen", "path:/ECDSA/.*SigGen" ],
|
||||
[ "SigVer", "fips_ecdsavs SigVer", "path:/ECDSA/.*SigVer" ],
|
||||
# ECDSA2 tests
|
||||
|
||||
my @fips_ecdsa2_test_list = (
|
||||
"ECDSA2",
|
||||
|
||||
[ "KeyPair", "fips_ecdsavs KeyPair", "path:/ECDSA2/.*KeyPair" ],
|
||||
@@ -65,9 +47,9 @@ my @fips_rsa_test_list = (
|
||||
|
||||
[ "SigGen15", "fips_rsastest" ],
|
||||
[ "SigVer15", "fips_rsavtest" ],
|
||||
[ "SigVerRSA", "fips_rsavtest -x931" ],
|
||||
[ "SigVer(X9.31)", "fips_rsavtest -x931", 'file:9\.31' ],
|
||||
[ "KeyGenRSA", "fips_rsagtest" ],
|
||||
[ "SigGenRSA", "fips_rsastest -x931" ]
|
||||
[ "SigGen(X9.31)", "fips_rsastest -x931" , 'file:9\.31']
|
||||
|
||||
);
|
||||
|
||||
@@ -79,21 +61,22 @@ my @fips_rsa_test_list = (
|
||||
# RSA PSS salt length 0 tests
|
||||
|
||||
my @fips_rsa_pss0_test_list = (
|
||||
|
||||
"RSA",
|
||||
[ "SigGenPSS(0)", "fips_rsastest -saltlen 0",
|
||||
'file:^\s*#\s*salt\s+len:\s+0\s*$' ],
|
||||
'file:salt\s+len:\s+0' ],
|
||||
[ "SigVerPSS(0)", "fips_rsavtest -saltlen 0",
|
||||
'file:^\s*#\s*salt\s+len:\s+0\s*$' ],
|
||||
'file:salt\s+len:\s+0' ],
|
||||
|
||||
);
|
||||
|
||||
# RSA PSS salt length 62 tests
|
||||
|
||||
my @fips_rsa_pss62_test_list = (
|
||||
"RSA",
|
||||
[ "SigGenPSS(62)", "fips_rsastest -saltlen 62",
|
||||
'file:^\s*#\s*salt\s+len:\s+62\s*$' ],
|
||||
'file:salt\s+len:\s+62' ],
|
||||
[ "SigVerPSS(62)", "fips_rsavtest -saltlen 62",
|
||||
'file:^\s*#\s*salt\s+len:\s+62\s*$' ],
|
||||
'file:salt\s+len:\s+62' ],
|
||||
);
|
||||
|
||||
# SHA tests
|
||||
@@ -354,10 +337,8 @@ my @fips_des3_test_list = (
|
||||
"Triple DES",
|
||||
|
||||
[ "TCBCinvperm", "fips_desmovs -f" ],
|
||||
[ "TCBCMMT1", "fips_desmovs -f" ],
|
||||
[ "TCBCMMT2", "fips_desmovs -f" ],
|
||||
[ "TCBCMMT3", "fips_desmovs -f" ],
|
||||
[ "TCBCMonte1", "fips_desmovs -f" ],
|
||||
[ "TCBCMonte2", "fips_desmovs -f" ],
|
||||
[ "TCBCMonte3", "fips_desmovs -f" ],
|
||||
[ "TCBCpermop", "fips_desmovs -f" ],
|
||||
@@ -365,10 +346,8 @@ my @fips_des3_test_list = (
|
||||
[ "TCBCvarkey", "fips_desmovs -f" ],
|
||||
[ "TCBCvartext", "fips_desmovs -f" ],
|
||||
[ "TCFB64invperm", "fips_desmovs -f" ],
|
||||
[ "TCFB64MMT1", "fips_desmovs -f" ],
|
||||
[ "TCFB64MMT2", "fips_desmovs -f" ],
|
||||
[ "TCFB64MMT3", "fips_desmovs -f" ],
|
||||
[ "TCFB64Monte1", "fips_desmovs -f" ],
|
||||
[ "TCFB64Monte2", "fips_desmovs -f" ],
|
||||
[ "TCFB64Monte3", "fips_desmovs -f" ],
|
||||
[ "TCFB64permop", "fips_desmovs -f" ],
|
||||
@@ -376,10 +355,8 @@ my @fips_des3_test_list = (
|
||||
[ "TCFB64varkey", "fips_desmovs -f" ],
|
||||
[ "TCFB64vartext", "fips_desmovs -f" ],
|
||||
[ "TCFB8invperm", "fips_desmovs -f" ],
|
||||
[ "TCFB8MMT1", "fips_desmovs -f" ],
|
||||
[ "TCFB8MMT2", "fips_desmovs -f" ],
|
||||
[ "TCFB8MMT3", "fips_desmovs -f" ],
|
||||
[ "TCFB8Monte1", "fips_desmovs -f" ],
|
||||
[ "TCFB8Monte2", "fips_desmovs -f" ],
|
||||
[ "TCFB8Monte3", "fips_desmovs -f" ],
|
||||
[ "TCFB8permop", "fips_desmovs -f" ],
|
||||
@@ -387,10 +364,8 @@ my @fips_des3_test_list = (
|
||||
[ "TCFB8varkey", "fips_desmovs -f" ],
|
||||
[ "TCFB8vartext", "fips_desmovs -f" ],
|
||||
[ "TECBinvperm", "fips_desmovs -f" ],
|
||||
[ "TECBMMT1", "fips_desmovs -f" ],
|
||||
[ "TECBMMT2", "fips_desmovs -f" ],
|
||||
[ "TECBMMT3", "fips_desmovs -f" ],
|
||||
[ "TECBMonte1", "fips_desmovs -f" ],
|
||||
[ "TECBMonte2", "fips_desmovs -f" ],
|
||||
[ "TECBMonte3", "fips_desmovs -f" ],
|
||||
[ "TECBpermop", "fips_desmovs -f" ],
|
||||
@@ -398,10 +373,8 @@ my @fips_des3_test_list = (
|
||||
[ "TECBvarkey", "fips_desmovs -f" ],
|
||||
[ "TECBvartext", "fips_desmovs -f" ],
|
||||
[ "TOFBinvperm", "fips_desmovs -f" ],
|
||||
[ "TOFBMMT1", "fips_desmovs -f" ],
|
||||
[ "TOFBMMT2", "fips_desmovs -f" ],
|
||||
[ "TOFBMMT3", "fips_desmovs -f" ],
|
||||
[ "TOFBMonte1", "fips_desmovs -f" ],
|
||||
[ "TOFBMonte2", "fips_desmovs -f" ],
|
||||
[ "TOFBMonte3", "fips_desmovs -f" ],
|
||||
[ "TOFBpermop", "fips_desmovs -f" ],
|
||||
@@ -416,10 +389,8 @@ my @fips_des3_cfb1_test_list = (
|
||||
# DES3 CFB1 tests
|
||||
|
||||
[ "TCFB1invperm", "fips_desmovs -f" ],
|
||||
[ "TCFB1MMT1", "fips_desmovs -f" ],
|
||||
[ "TCFB1MMT2", "fips_desmovs -f" ],
|
||||
[ "TCFB1MMT3", "fips_desmovs -f" ],
|
||||
[ "TCFB1Monte1", "fips_desmovs -f" ],
|
||||
[ "TCFB1Monte2", "fips_desmovs -f" ],
|
||||
[ "TCFB1Monte3", "fips_desmovs -f" ],
|
||||
[ "TCFB1permop", "fips_desmovs -f" ],
|
||||
@@ -434,7 +405,6 @@ my @fips_drbg_test_list = (
|
||||
# SP800-90 DRBG tests
|
||||
"SP800-90 DRBG",
|
||||
[ "CTR_DRBG", "fips_drbgvs" ],
|
||||
[ "Dual_EC_DRBG", "fips_drbgvs" ],
|
||||
[ "Hash_DRBG", "fips_drbgvs" ],
|
||||
[ "HMAC_DRBG", "fips_drbgvs" ]
|
||||
|
||||
@@ -473,8 +443,6 @@ my @fips_ecdh_test_list = (
|
||||
#
|
||||
|
||||
my %verify_special = (
|
||||
"DSA:PQGGen" => "fips_dssvs pqgver",
|
||||
"DSA:KeyPair" => "fips_dssvs keyver",
|
||||
"DSA:SigGen" => "fips_dssvs sigver",
|
||||
"DSA2:PQGGen" => "fips_dssvs pqgver",
|
||||
"DSA2:KeyPair" => "fips_dssvs keyver",
|
||||
@@ -512,12 +480,14 @@ my $no_warn_bogus = 0;
|
||||
my $rmcmd = "rm -rf";
|
||||
my $mkcmd = "mkdir";
|
||||
my $cmpall = 0;
|
||||
my $info = 0;
|
||||
|
||||
my %fips_enabled = (
|
||||
"dsa" => 1,
|
||||
"dsa2" => 2,
|
||||
"dsa-pqgver" => 2,
|
||||
"ecdsa" => 2,
|
||||
"ecdsa2" => 2,
|
||||
"rsa" => 1,
|
||||
"rsa-pss0" => 2,
|
||||
"rsa-pss62" => 1,
|
||||
@@ -578,6 +548,12 @@ foreach (@ARGV) {
|
||||
elsif ( $_ eq "--notest" ) {
|
||||
$notest = 1;
|
||||
}
|
||||
elsif ( $_ eq "--debug-detect" ) {
|
||||
$notest = 1;
|
||||
$ignore_missing = 1;
|
||||
$ignore_bogus = 1;
|
||||
$info = 1;
|
||||
}
|
||||
elsif ( $_ eq "--quiet" ) {
|
||||
$quiet = 1;
|
||||
}
|
||||
@@ -640,14 +616,14 @@ if (!$fips_enabled{"v2"}) {
|
||||
}
|
||||
}
|
||||
|
||||
push @fips_test_list, @fips_dsa_test_list if $fips_enabled{"dsa"};
|
||||
push @fips_test_list, @fips_dsa_pqgver_test_list if $fips_enabled{"dsa-pqgver"};
|
||||
push @fips_test_list, @fips_dsa2_test_list if $fips_enabled{"dsa2"};
|
||||
push @fips_test_list, @fips_ecdsa_test_list if $fips_enabled{"ecdsa"};
|
||||
push @fips_test_list, @fips_dsa_pqgver_test_list if $fips_enabled{"dsa-pqgver"};
|
||||
push @fips_test_list, @fips_ecdsa2_test_list if $fips_enabled{"ecdsa2"};
|
||||
push @fips_test_list, @fips_rsa_test_list if $fips_enabled{"rsa"};
|
||||
push @fips_test_list, @fips_rsa_pss0_test_list if $fips_enabled{"rsa-pss0"};
|
||||
push @fips_test_list, @fips_rsa_pss62_test_list if $fips_enabled{"rsa-pss62"};
|
||||
push @fips_test_list, @fips_sha_test_list if $fips_enabled{"sha"};
|
||||
push @fips_test_list, @fips_drbg_test_list if $fips_enabled{"drbg"};
|
||||
push @fips_test_list, @fips_hmac_test_list if $fips_enabled{"hmac"};
|
||||
push @fips_test_list, @fips_cmac_test_list if $fips_enabled{"cmac"};
|
||||
push @fips_test_list, @fips_rand_aes_test_list if $fips_enabled{"rand-aes"};
|
||||
@@ -656,7 +632,6 @@ push @fips_test_list, @fips_aes_test_list if $fips_enabled{"aes"};
|
||||
push @fips_test_list, @fips_aes_cfb1_test_list if $fips_enabled{"aes-cfb1"};
|
||||
push @fips_test_list, @fips_des3_test_list if $fips_enabled{"des3"};
|
||||
push @fips_test_list, @fips_des3_cfb1_test_list if $fips_enabled{"des3-cfb1"};
|
||||
push @fips_test_list, @fips_drbg_test_list if $fips_enabled{"drbg"};
|
||||
push @fips_test_list, @fips_aes_ccm_test_list if $fips_enabled{"aes-ccm"};
|
||||
push @fips_test_list, @fips_aes_gcm_test_list if $fips_enabled{"aes-gcm"};
|
||||
push @fips_test_list, @fips_aes_xts_test_list if $fips_enabled{"aes-xts"};
|
||||
@@ -711,9 +686,9 @@ sanity_check_files();
|
||||
my ( $runerr, $cmperr, $cmpok, $scheckrunerr, $scheckerr, $scheckok, $skipcnt )
|
||||
= ( 0, 0, 0, 0, 0, 0, 0 );
|
||||
|
||||
exit(0) if $notest;
|
||||
print "Outputting commands to $outfile\n" if $outfile ne "";
|
||||
run_tests( $verify, $win32, $tprefix, $filter, $tvdir, $outfile );
|
||||
exit(0) if $notest;
|
||||
|
||||
if ($verify) {
|
||||
print "ALGORITHM TEST VERIFY SUMMARY REPORT:\n";
|
||||
@@ -779,7 +754,7 @@ EOF
|
||||
while (my ($key, $value) = each %fips_enabled)
|
||||
{
|
||||
printf "\t\t%-20s(%s by default)\n", $key ,
|
||||
$value == 1 ? "enabled" : "disabled";
|
||||
$value != 0 ? "enabled" : "disabled";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -818,13 +793,14 @@ sub sanity_check_exe {
|
||||
sub find_files {
|
||||
my ( $filter, $dir ) = @_;
|
||||
my ( $dirh, $testname, $tref );
|
||||
my $ttype;
|
||||
opendir( $dirh, $dir );
|
||||
while ( $_ = readdir($dirh) ) {
|
||||
next if ( $_ eq "." || $_ eq ".." );
|
||||
$_ = "$dir/$_";
|
||||
if ( -f "$_" ) {
|
||||
if (/\/([^\/]*)\.rsp$/) {
|
||||
$tref = find_test($1, $_);
|
||||
$tref = find_test($1, $_, \$ttype);
|
||||
if ( defined $tref ) {
|
||||
$testname = $$tref[0];
|
||||
if ( $$tref[4] eq "" ) {
|
||||
@@ -832,7 +808,7 @@ sub find_files {
|
||||
}
|
||||
else {
|
||||
print STDERR
|
||||
"WARNING: duplicate response file $_ for test $testname\n";
|
||||
"WARNING: duplicate response file $_ for $ttype test $testname\n";
|
||||
$nbogus++;
|
||||
}
|
||||
}
|
||||
@@ -843,21 +819,28 @@ sub find_files {
|
||||
}
|
||||
next unless /$filter.*\.req$/i;
|
||||
if (/\/([^\/]*)\.req$/) {
|
||||
$tref = find_test($1, $_);
|
||||
$tref = find_test($1, $_, \$ttype);
|
||||
if ( defined $tref ) {
|
||||
$testname = $$tref[0];
|
||||
if ( $$tref[3] eq "" ) {
|
||||
my $tfname = $$tref[3];
|
||||
if ( $tfname eq "" ) {
|
||||
$$tref[3] = $_;
|
||||
}
|
||||
else {
|
||||
print STDERR
|
||||
"WARNING: duplicate request file $_ for test $testname\n";
|
||||
"WARNING: duplicate request file $_ for $ttype test $testname\n";
|
||||
if ($info) {
|
||||
print_file_start($_, \*STDERR);
|
||||
print STDERR "Original filename $tfname\n";
|
||||
print_file_start($tfname, \*STDERR);
|
||||
}
|
||||
$nbogus++;
|
||||
}
|
||||
|
||||
}
|
||||
elsif ( !/SHAmix\.req$/ ) {
|
||||
print STDERR "WARNING: unrecognized filename $_\n" unless $no_warn_bogus;
|
||||
print_file_start($_, \*STDERR) if $info;
|
||||
$nbogus++;
|
||||
}
|
||||
}
|
||||
@@ -874,13 +857,15 @@ sub find_files {
|
||||
#
|
||||
|
||||
sub find_test {
|
||||
my ( $test, $path ) = @_;
|
||||
my ( $test, $path, $type ) = @_;
|
||||
foreach $tref (@fips_test_list) {
|
||||
next unless ref($tref);
|
||||
if (!ref($tref)) {
|
||||
$$type = $tref;
|
||||
next;
|
||||
}
|
||||
my ( $tst, $cmd, $excmd, $req, $resp ) = @$tref;
|
||||
my $regexp;
|
||||
$tst =~ s/\(.*$//;
|
||||
$test =~ s/_186-2//;
|
||||
if (defined $excmd) {
|
||||
if ($excmd =~ /^path:(.*)$/) {
|
||||
my $fmatch = $1;
|
||||
@@ -891,7 +876,7 @@ sub find_test {
|
||||
$regexp = $1;
|
||||
}
|
||||
}
|
||||
if ($test eq $tst) {
|
||||
if ($test =~ /^$tst/) {
|
||||
return $tref if (!defined $regexp);
|
||||
my $found = 0;
|
||||
my $line;
|
||||
@@ -911,22 +896,26 @@ sub find_test {
|
||||
|
||||
sub sanity_check_files {
|
||||
my $bad = 0;
|
||||
my $ttype;
|
||||
foreach (@fips_test_list) {
|
||||
next unless ref($_);
|
||||
if (!ref($_)) {
|
||||
$ttype = $_;
|
||||
next;
|
||||
}
|
||||
my ( $tst, $cmd, $regexp, $req, $resp ) = @$_;
|
||||
|
||||
#print STDERR "FILES $tst, $cmd, $req, $resp\n";
|
||||
if ( $req eq "" ) {
|
||||
print STDERR "WARNING: missing request file for $tst\n" unless $no_warn_missing;
|
||||
print STDERR "WARNING: missing request file for $ttype test $tst\n" unless $no_warn_missing;
|
||||
$bad = 1;
|
||||
next;
|
||||
}
|
||||
if ( $verify && $resp eq "" ) {
|
||||
print STDERR "WARNING: no response file for test $tst\n";
|
||||
print STDERR "WARNING: no response file for $ttype test test $tst\n";
|
||||
$bad = 1;
|
||||
}
|
||||
elsif ( !$verify && $resp ne "" ) {
|
||||
print STDERR "WARNING: response file $resp will be overwritten\n";
|
||||
print STDERR "WARNING: response file $resp for $ttype test $tst will be overwritten\n";
|
||||
}
|
||||
}
|
||||
if ($bad) {
|
||||
@@ -989,26 +978,37 @@ END
|
||||
if ($outfile ne "") {
|
||||
print "Generating script for $_ tests\n";
|
||||
print OUT "\n\n\necho \"Running $_ tests\"\n" unless $minimal_script;
|
||||
} else {
|
||||
} elsif ($notest) {
|
||||
print "Info for $_ tests:\n";
|
||||
} else {
|
||||
print "Running $_ tests\n" unless $quiet;
|
||||
}
|
||||
$ttype = $_;
|
||||
next;
|
||||
}
|
||||
my ( $tname, $tcmd, $regexp, $req, $rsp ) = @$_;
|
||||
if ($notest) {
|
||||
if ($req ne "") {
|
||||
print "Test $ttype, $tname: $req\n";
|
||||
print_file_start($req, \*STDOUT) if ($info);
|
||||
} else {
|
||||
print "$tname: not found\n";
|
||||
}
|
||||
next;
|
||||
}
|
||||
my $out = $rsp;
|
||||
if ($verify) {
|
||||
$out =~ s/\.rsp$/.tst/;
|
||||
}
|
||||
if ( $req eq "" ) {
|
||||
print STDERR
|
||||
"WARNING: Request file for $tname missing: test skipped\n" unless $no_warn_missing;
|
||||
"WARNING: Request file for $ttype test $tname missing: test skipped\n" unless $no_warn_missing;
|
||||
$skipcnt++;
|
||||
next;
|
||||
}
|
||||
if ( $verify && $rsp eq "" ) {
|
||||
print STDERR
|
||||
"WARNING: Response file for $tname missing: test skipped\n";
|
||||
"WARNING: Response file for $ttype test $tname missing: test skipped\n";
|
||||
$skipcnt++;
|
||||
next;
|
||||
}
|
||||
@@ -1212,3 +1212,22 @@ sub next_line {
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub print_file_start {
|
||||
my ($fname, $fh) = @_;
|
||||
print $fh "======\n";
|
||||
open IN, $fname;
|
||||
while (<IN>) {
|
||||
my $line = $_;
|
||||
s/#.*$//;
|
||||
last unless (/^\s*$/);
|
||||
print $fh $line;
|
||||
}
|
||||
my $lines = 0;
|
||||
while (<IN>) {
|
||||
print $fh $_;
|
||||
last if $lines++ > 10;
|
||||
}
|
||||
close IN;
|
||||
print $fh "======\n";
|
||||
}
|
||||
|
@@ -23,10 +23,10 @@ APPS=
|
||||
|
||||
LIB=$(TOP)/libcrypto.a
|
||||
LIBSRC= fips_rand.c fips_rand_selftest.c fips_drbg_lib.c \
|
||||
fips_drbg_hash.c fips_drbg_hmac.c fips_drbg_ctr.c fips_drbg_ec.c \
|
||||
fips_drbg_hash.c fips_drbg_hmac.c fips_drbg_ctr.c \
|
||||
fips_drbg_selftest.c fips_drbg_rand.c fips_rand_lib.c
|
||||
LIBOBJ= fips_rand.o fips_rand_selftest.o fips_drbg_lib.o \
|
||||
fips_drbg_hash.o fips_drbg_hmac.o fips_drbg_ctr.o fips_drbg_ec.o \
|
||||
fips_drbg_hash.o fips_drbg_hmac.o fips_drbg_ctr.o \
|
||||
fips_drbg_selftest.o fips_drbg_rand.o fips_rand_lib.o
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
@@ -105,18 +105,6 @@ fips_drbg_ctr.o: ../../include/openssl/ossl_typ.h
|
||||
fips_drbg_ctr.o: ../../include/openssl/safestack.h
|
||||
fips_drbg_ctr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
fips_drbg_ctr.o: fips_drbg_ctr.c fips_rand_lcl.h
|
||||
fips_drbg_ec.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
|
||||
fips_drbg_ec.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
fips_drbg_ec.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
fips_drbg_ec.o: ../../include/openssl/ec.h ../../include/openssl/evp.h
|
||||
fips_drbg_ec.o: ../../include/openssl/fips.h ../../include/openssl/fips_rand.h
|
||||
fips_drbg_ec.o: ../../include/openssl/hmac.h ../../include/openssl/obj_mac.h
|
||||
fips_drbg_ec.o: ../../include/openssl/objects.h
|
||||
fips_drbg_ec.o: ../../include/openssl/opensslconf.h
|
||||
fips_drbg_ec.o: ../../include/openssl/opensslv.h
|
||||
fips_drbg_ec.o: ../../include/openssl/ossl_typ.h
|
||||
fips_drbg_ec.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
fips_drbg_ec.o: ../../include/openssl/symhacks.h fips_drbg_ec.c fips_rand_lcl.h
|
||||
fips_drbg_hash.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
|
||||
fips_drbg_hash.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
|
||||
fips_drbg_hash.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
|
@@ -1,542 +0,0 @@
|
||||
/* fips/rand/fips_drbg_ec.c */
|
||||
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
|
||||
* project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2011 The OpenSSL Project. 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 acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED 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 OpenSSL PROJECT OR
|
||||
* ITS 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.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#define OPENSSL_FIPSAPI
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/fips.h>
|
||||
#include <openssl/fips_rand.h>
|
||||
#include <openssl/bn.h>
|
||||
#include "fips_rand_lcl.h"
|
||||
|
||||
/*#define EC_DRBG_TRACE*/
|
||||
|
||||
#ifdef EC_DRBG_TRACE
|
||||
static void hexprint(FILE *out, const unsigned char *buf, int buflen)
|
||||
{
|
||||
int i;
|
||||
fprintf(out, "\t");
|
||||
for (i = 0; i < buflen; i++)
|
||||
fprintf(out, "%02X", buf[i]);
|
||||
fprintf(out, "\n");
|
||||
}
|
||||
static void bnprint(FILE *out, const char *name, const BIGNUM *b)
|
||||
{
|
||||
unsigned char *tmp;
|
||||
int len;
|
||||
len = BN_num_bytes(b);
|
||||
tmp = OPENSSL_malloc(len);
|
||||
BN_bn2bin(b, tmp);
|
||||
fprintf(out, "%s\n", name);
|
||||
hexprint(out, tmp, len);
|
||||
OPENSSL_free(tmp);
|
||||
}
|
||||
#if 0
|
||||
static void ecprint(FILE *out, EC_GROUP *grp, EC_POINT *pt)
|
||||
{
|
||||
BIGNUM *x, *y;
|
||||
x = BN_new();
|
||||
y = BN_new();
|
||||
EC_POINT_get_affine_coordinates_GFp(grp, pt, x, y, NULL);
|
||||
bnprint(out, "\tPoint X: ", x);
|
||||
bnprint(out, "\tPoint Y: ", y);
|
||||
BN_free(x);
|
||||
BN_free(y);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* This is Hash_df from SP 800-90 10.4.1 */
|
||||
|
||||
static int hash_df(DRBG_CTX *dctx, unsigned char *out,
|
||||
const unsigned char *in1, size_t in1len,
|
||||
const unsigned char *in2, size_t in2len,
|
||||
const unsigned char *in3, size_t in3len)
|
||||
{
|
||||
DRBG_EC_CTX *ectx = &dctx->d.ec;
|
||||
EVP_MD_CTX *mctx = &ectx->mctx;
|
||||
unsigned char *vtmp = ectx->vtmp;
|
||||
unsigned char tmp[6];
|
||||
size_t mdlen = M_EVP_MD_size(ectx->md);
|
||||
/* Standard only ever needs seedlen bytes which is always less than
|
||||
* maximum permitted so no need to check length.
|
||||
*/
|
||||
size_t outlen = dctx->seedlen;
|
||||
size_t nbits = (outlen << 3) - ectx->exbits;
|
||||
tmp[0] = 1;
|
||||
tmp[1] = (nbits >> 24) & 0xff;
|
||||
tmp[2] = (nbits >> 16) & 0xff;
|
||||
tmp[3] = (nbits >> 8) & 0xff;
|
||||
tmp[4] = nbits & 0xff;
|
||||
if (!in1)
|
||||
{
|
||||
tmp[5] = (unsigned char)in1len;
|
||||
in1 = tmp + 5;
|
||||
in1len = 1;
|
||||
}
|
||||
for (;;)
|
||||
{
|
||||
if (!FIPS_digestinit(mctx, ectx->md))
|
||||
return 0;
|
||||
if (!FIPS_digestupdate(mctx, tmp, 5))
|
||||
return 0;
|
||||
if (in1 && !FIPS_digestupdate(mctx, in1, in1len))
|
||||
return 0;
|
||||
if (in2 && !FIPS_digestupdate(mctx, in2, in2len))
|
||||
return 0;
|
||||
if (in3 && !FIPS_digestupdate(mctx, in3, in3len))
|
||||
return 0;
|
||||
if (outlen < mdlen)
|
||||
{
|
||||
if (!FIPS_digestfinal(mctx, vtmp, NULL))
|
||||
return 0;
|
||||
memcpy(out, vtmp, outlen);
|
||||
OPENSSL_cleanse(vtmp, mdlen);
|
||||
return 1;
|
||||
}
|
||||
else if(!FIPS_digestfinal(mctx, out, NULL))
|
||||
return 0;
|
||||
|
||||
outlen -= mdlen;
|
||||
if (outlen == 0)
|
||||
return 1;
|
||||
tmp[0]++;
|
||||
out += mdlen;
|
||||
}
|
||||
}
|
||||
|
||||
static int bn2binpad(unsigned char *to, size_t tolen, BIGNUM *b)
|
||||
{
|
||||
size_t blen;
|
||||
blen = BN_num_bytes(b);
|
||||
/* If BIGNUM length greater than buffer, mask to get rightmost
|
||||
* bytes. NB: modifies b but this doesn't matter for our purposes.
|
||||
*/
|
||||
if (blen > tolen)
|
||||
{
|
||||
BN_mask_bits(b, tolen << 3);
|
||||
/* Update length because mask operation might create leading
|
||||
* zeroes.
|
||||
*/
|
||||
blen = BN_num_bytes(b);
|
||||
}
|
||||
/* If b length smaller than buffer pad with zeroes */
|
||||
if (blen < tolen)
|
||||
{
|
||||
memset(to, 0, tolen - blen);
|
||||
to += tolen - blen;
|
||||
}
|
||||
|
||||
/* This call cannot fail */
|
||||
BN_bn2bin(b, to);
|
||||
return 1;
|
||||
}
|
||||
/* Convert buffer to a BIGNUM discarding extra bits if necessary */
|
||||
static int bin2bnbits(DRBG_CTX *dctx, BIGNUM *r, const unsigned char *buf)
|
||||
{
|
||||
DRBG_EC_CTX *ectx = &dctx->d.ec;
|
||||
if (!BN_bin2bn(buf, dctx->seedlen, r))
|
||||
return 0;
|
||||
/* If we have extra bits right shift off the end of r */
|
||||
if (ectx->exbits)
|
||||
{
|
||||
if (!BN_rshift(r, r, ectx->exbits))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Calculate r = phi(s * P) or r= phi(s * Q) */
|
||||
|
||||
static int drbg_ec_mul(DRBG_EC_CTX *ectx, BIGNUM *r, const BIGNUM *s, int use_q)
|
||||
{
|
||||
if (use_q)
|
||||
{
|
||||
if (!EC_POINT_mul(ectx->curve, ectx->ptmp,
|
||||
NULL, ectx->Q, s, ectx->bctx))
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!EC_POINT_mul(ectx->curve, ectx->ptmp,
|
||||
s, NULL, NULL, ectx->bctx))
|
||||
return 0;
|
||||
}
|
||||
/* Get x coordinate of result */
|
||||
if (!EC_POINT_get_affine_coordinates_GFp(ectx->curve, ectx->ptmp, r,
|
||||
NULL, ectx->bctx))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int drbg_ec_instantiate(DRBG_CTX *dctx,
|
||||
const unsigned char *ent, size_t ent_len,
|
||||
const unsigned char *nonce, size_t nonce_len,
|
||||
const unsigned char *pstr, size_t pstr_len)
|
||||
{
|
||||
DRBG_EC_CTX *ectx = &dctx->d.ec;
|
||||
if (!hash_df(dctx, ectx->sbuf,
|
||||
ent, ent_len, nonce, nonce_len, pstr, pstr_len))
|
||||
return 0;
|
||||
if (!bin2bnbits(dctx, ectx->s, ectx->sbuf))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int drbg_ec_reseed(DRBG_CTX *dctx,
|
||||
const unsigned char *ent, size_t ent_len,
|
||||
const unsigned char *adin, size_t adin_len)
|
||||
{
|
||||
DRBG_EC_CTX *ectx = &dctx->d.ec;
|
||||
/* Convert s value to a binary buffer. Save it to tbuf as we are
|
||||
* about to overwrite it.
|
||||
*/
|
||||
if (ectx->exbits)
|
||||
BN_lshift(ectx->s, ectx->s, ectx->exbits);
|
||||
bn2binpad(ectx->tbuf, dctx->seedlen, ectx->s);
|
||||
if (!hash_df(dctx, ectx->sbuf, ectx->tbuf, dctx->seedlen,
|
||||
ent, ent_len, adin, adin_len))
|
||||
return 0;
|
||||
if (!bin2bnbits(dctx, ectx->s, ectx->sbuf))
|
||||
return 0;
|
||||
dctx->reseed_counter = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int drbg_ec_generate(DRBG_CTX *dctx,
|
||||
unsigned char *out, size_t outlen,
|
||||
const unsigned char *adin, size_t adin_len)
|
||||
{
|
||||
DRBG_EC_CTX *ectx = &dctx->d.ec;
|
||||
BIGNUM *t, *r;
|
||||
BIGNUM *s = ectx->s;
|
||||
/* special case: check reseed interval */
|
||||
if (out == NULL)
|
||||
{
|
||||
size_t nb = (outlen + dctx->blocklength - 1)/dctx->blocklength;
|
||||
if (dctx->reseed_counter + nb > dctx->reseed_interval)
|
||||
dctx->status = DRBG_STATUS_RESEED;
|
||||
return 1;
|
||||
}
|
||||
|
||||
BN_CTX_start(ectx->bctx);
|
||||
r = BN_CTX_get(ectx->bctx);
|
||||
if (!r)
|
||||
goto err;
|
||||
if (adin && adin_len)
|
||||
{
|
||||
size_t i;
|
||||
t = BN_CTX_get(ectx->bctx);
|
||||
if (!t)
|
||||
goto err;
|
||||
/* Convert s to buffer */
|
||||
if (ectx->exbits)
|
||||
BN_lshift(s, s, ectx->exbits);
|
||||
bn2binpad(ectx->sbuf, dctx->seedlen, s);
|
||||
/* Step 2 */
|
||||
if (!hash_df(dctx, ectx->tbuf, adin, adin_len,
|
||||
NULL, 0, NULL, 0))
|
||||
goto err;
|
||||
/* Step 5 */
|
||||
for (i = 0; i < dctx->seedlen; i++)
|
||||
ectx->tbuf[i] ^= ectx->sbuf[i];
|
||||
if (!bin2bnbits(dctx, t, ectx->tbuf))
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
/* Note if no additional input the algorithm never
|
||||
* needs separate values for t and s.
|
||||
*/
|
||||
t = s;
|
||||
|
||||
#ifdef EC_DRBG_TRACE
|
||||
bnprint(stderr, "s at start of generate: ", s);
|
||||
#endif
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* Step #6, calculate s = t * P */
|
||||
if (!drbg_ec_mul(ectx, s, t, 0))
|
||||
goto err;
|
||||
#ifdef EC_DRBG_TRACE
|
||||
bnprint(stderr, "s in generate: ", ectx->s);
|
||||
#endif
|
||||
/* Step #7, calculate r = s * Q */
|
||||
if (!drbg_ec_mul(ectx, r, s, 1))
|
||||
goto err;
|
||||
#ifdef EC_DRBG_TRACE
|
||||
bnprint(stderr, "r in generate is: ", r);
|
||||
#endif
|
||||
dctx->reseed_counter++;
|
||||
/* Get rightmost bits of r to output buffer */
|
||||
|
||||
if (!(dctx->xflags & DRBG_FLAG_TEST) && !dctx->lb_valid)
|
||||
{
|
||||
if (!bn2binpad(dctx->lb, dctx->blocklength, r))
|
||||
goto err;
|
||||
dctx->lb_valid = 1;
|
||||
continue;
|
||||
}
|
||||
if (outlen < dctx->blocklength)
|
||||
{
|
||||
if (!bn2binpad(ectx->vtmp, dctx->blocklength, r))
|
||||
goto err;
|
||||
if (!fips_drbg_cprng_test(dctx, ectx->vtmp))
|
||||
goto err;
|
||||
memcpy(out, ectx->vtmp, outlen);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!bn2binpad(out, dctx->blocklength, r))
|
||||
goto err;
|
||||
if (!fips_drbg_cprng_test(dctx, out))
|
||||
goto err;
|
||||
}
|
||||
outlen -= dctx->blocklength;
|
||||
if (!outlen)
|
||||
break;
|
||||
out += dctx->blocklength;
|
||||
/* Step #5 after first pass */
|
||||
t = s;
|
||||
#ifdef EC_DRBG_TRACE
|
||||
fprintf(stderr, "Random bits written:\n");
|
||||
hexprint(stderr, out, dctx->blocklength);
|
||||
#endif
|
||||
}
|
||||
if (!drbg_ec_mul(ectx, ectx->s, ectx->s, 0))
|
||||
return 0;
|
||||
#ifdef EC_DRBG_TRACE
|
||||
bnprint(stderr, "s after generate is: ", s);
|
||||
#endif
|
||||
BN_CTX_end(ectx->bctx);
|
||||
return 1;
|
||||
err:
|
||||
BN_CTX_end(ectx->bctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int drbg_ec_uninstantiate(DRBG_CTX *dctx)
|
||||
{
|
||||
DRBG_EC_CTX *ectx = &dctx->d.ec;
|
||||
EVP_MD_CTX_cleanup(&ectx->mctx);
|
||||
EC_GROUP_free(ectx->curve);
|
||||
EC_POINT_free(ectx->Q);
|
||||
EC_POINT_free(ectx->ptmp);
|
||||
BN_clear_free(ectx->s);
|
||||
BN_CTX_free(ectx->bctx);
|
||||
OPENSSL_cleanse(&dctx->d.ec, sizeof(DRBG_EC_CTX));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Q points from SP 800-90 A.1, P is generator */
|
||||
|
||||
__fips_constseg
|
||||
static const unsigned char p_256_qx[] = {
|
||||
0xc9,0x74,0x45,0xf4,0x5c,0xde,0xf9,0xf0,0xd3,0xe0,0x5e,0x1e,
|
||||
0x58,0x5f,0xc2,0x97,0x23,0x5b,0x82,0xb5,0xbe,0x8f,0xf3,0xef,
|
||||
0xca,0x67,0xc5,0x98,0x52,0x01,0x81,0x92
|
||||
};
|
||||
__fips_constseg
|
||||
static const unsigned char p_256_qy[] = {
|
||||
0xb2,0x8e,0xf5,0x57,0xba,0x31,0xdf,0xcb,0xdd,0x21,0xac,0x46,
|
||||
0xe2,0xa9,0x1e,0x3c,0x30,0x4f,0x44,0xcb,0x87,0x05,0x8a,0xda,
|
||||
0x2c,0xb8,0x15,0x15,0x1e,0x61,0x00,0x46
|
||||
};
|
||||
|
||||
__fips_constseg
|
||||
static const unsigned char p_384_qx[] = {
|
||||
0x8e,0x72,0x2d,0xe3,0x12,0x5b,0xdd,0xb0,0x55,0x80,0x16,0x4b,
|
||||
0xfe,0x20,0xb8,0xb4,0x32,0x21,0x6a,0x62,0x92,0x6c,0x57,0x50,
|
||||
0x2c,0xee,0xde,0x31,0xc4,0x78,0x16,0xed,0xd1,0xe8,0x97,0x69,
|
||||
0x12,0x41,0x79,0xd0,0xb6,0x95,0x10,0x64,0x28,0x81,0x50,0x65
|
||||
};
|
||||
__fips_constseg
|
||||
static const unsigned char p_384_qy[] = {
|
||||
0x02,0x3b,0x16,0x60,0xdd,0x70,0x1d,0x08,0x39,0xfd,0x45,0xee,
|
||||
0xc3,0x6f,0x9e,0xe7,0xb3,0x2e,0x13,0xb3,0x15,0xdc,0x02,0x61,
|
||||
0x0a,0xa1,0xb6,0x36,0xe3,0x46,0xdf,0x67,0x1f,0x79,0x0f,0x84,
|
||||
0xc5,0xe0,0x9b,0x05,0x67,0x4d,0xbb,0x7e,0x45,0xc8,0x03,0xdd
|
||||
};
|
||||
|
||||
__fips_constseg
|
||||
static const unsigned char p_521_qx[] = {
|
||||
0x01,0xb9,0xfa,0x3e,0x51,0x8d,0x68,0x3c,0x6b,0x65,0x76,0x36,
|
||||
0x94,0xac,0x8e,0xfb,0xae,0xc6,0xfa,0xb4,0x4f,0x22,0x76,0x17,
|
||||
0x1a,0x42,0x72,0x65,0x07,0xdd,0x08,0xad,0xd4,0xc3,0xb3,0xf4,
|
||||
0xc1,0xeb,0xc5,0xb1,0x22,0x2d,0xdb,0xa0,0x77,0xf7,0x22,0x94,
|
||||
0x3b,0x24,0xc3,0xed,0xfa,0x0f,0x85,0xfe,0x24,0xd0,0xc8,0xc0,
|
||||
0x15,0x91,0xf0,0xbe,0x6f,0x63
|
||||
};
|
||||
__fips_constseg
|
||||
static const unsigned char p_521_qy[] = {
|
||||
0x01,0xf3,0xbd,0xba,0x58,0x52,0x95,0xd9,0xa1,0x11,0x0d,0x1d,
|
||||
0xf1,0xf9,0x43,0x0e,0xf8,0x44,0x2c,0x50,0x18,0x97,0x6f,0xf3,
|
||||
0x43,0x7e,0xf9,0x1b,0x81,0xdc,0x0b,0x81,0x32,0xc8,0xd5,0xc3,
|
||||
0x9c,0x32,0xd0,0xe0,0x04,0xa3,0x09,0x2b,0x7d,0x32,0x7c,0x0e,
|
||||
0x7a,0x4d,0x26,0xd2,0xc7,0xb6,0x9b,0x58,0xf9,0x06,0x66,0x52,
|
||||
0x91,0x1e,0x45,0x77,0x79,0xde
|
||||
};
|
||||
|
||||
int fips_drbg_ec_init(DRBG_CTX *dctx)
|
||||
{
|
||||
const EVP_MD *md;
|
||||
const unsigned char *Q_x, *Q_y;
|
||||
BIGNUM *x, *y;
|
||||
size_t ptlen;
|
||||
int md_nid = dctx->type & 0xffff;
|
||||
int curve_nid = dctx->type >> 16;
|
||||
DRBG_EC_CTX *ectx = &dctx->d.ec;
|
||||
md = FIPS_get_digestbynid(md_nid);
|
||||
if (!md)
|
||||
return -2;
|
||||
|
||||
/* These are taken from SP 800-90 10.3.1 table 4 */
|
||||
switch (curve_nid)
|
||||
{
|
||||
case NID_X9_62_prime256v1:
|
||||
dctx->strength = 128;
|
||||
dctx->seedlen = 32;
|
||||
dctx->blocklength = 30;
|
||||
ectx->exbits = 0;
|
||||
Q_x = p_256_qx;
|
||||
Q_y = p_256_qy;
|
||||
ptlen = sizeof(p_256_qx);
|
||||
break;
|
||||
|
||||
case NID_secp384r1:
|
||||
if (md_nid == NID_sha1)
|
||||
return -2;
|
||||
dctx->strength = 192;
|
||||
dctx->seedlen = 48;
|
||||
dctx->blocklength = 46;
|
||||
ectx->exbits = 0;
|
||||
Q_x = p_384_qx;
|
||||
Q_y = p_384_qy;
|
||||
ptlen = sizeof(p_384_qx);
|
||||
break;
|
||||
|
||||
case NID_secp521r1:
|
||||
if (md_nid == NID_sha1 || md_nid == NID_sha224)
|
||||
return -2;
|
||||
dctx->strength = 256;
|
||||
dctx->seedlen = 66;
|
||||
dctx->blocklength = 63;
|
||||
ectx->exbits = 7;
|
||||
Q_x = p_521_qx;
|
||||
Q_y = p_521_qy;
|
||||
ptlen = sizeof(p_521_qx);
|
||||
break;
|
||||
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
|
||||
dctx->iflags |= DRBG_CUSTOM_RESEED;
|
||||
dctx->reseed_counter = 0;
|
||||
dctx->instantiate = drbg_ec_instantiate;
|
||||
dctx->reseed = drbg_ec_reseed;
|
||||
dctx->generate = drbg_ec_generate;
|
||||
dctx->uninstantiate = drbg_ec_uninstantiate;
|
||||
|
||||
ectx->md = md;
|
||||
EVP_MD_CTX_init(&ectx->mctx);
|
||||
|
||||
dctx->min_entropy = dctx->strength / 8;
|
||||
dctx->max_entropy = 2 << 10;
|
||||
|
||||
dctx->min_nonce = dctx->min_entropy / 2;
|
||||
dctx->max_nonce = 2 << 10;
|
||||
|
||||
dctx->max_pers = 2 << 10;
|
||||
dctx->max_adin = 2 << 10;
|
||||
|
||||
dctx->reseed_interval = 1<<24;
|
||||
dctx->max_request = dctx->reseed_interval * dctx->blocklength;
|
||||
|
||||
/* Setup internal structures */
|
||||
ectx->bctx = BN_CTX_new();
|
||||
if (!ectx->bctx)
|
||||
return 0;
|
||||
BN_CTX_start(ectx->bctx);
|
||||
|
||||
ectx->s = BN_new();
|
||||
|
||||
ectx->curve = EC_GROUP_new_by_curve_name(curve_nid);
|
||||
|
||||
ectx->Q = EC_POINT_new(ectx->curve);
|
||||
ectx->ptmp = EC_POINT_new(ectx->curve);
|
||||
|
||||
x = BN_CTX_get(ectx->bctx);
|
||||
y = BN_CTX_get(ectx->bctx);
|
||||
|
||||
if (!ectx->s || !ectx->curve || !ectx->Q || !y)
|
||||
goto err;
|
||||
|
||||
if (!BN_bin2bn(Q_x, ptlen, x) || !BN_bin2bn(Q_y, ptlen, y))
|
||||
goto err;
|
||||
if (!EC_POINT_set_affine_coordinates_GFp(ectx->curve, ectx->Q,
|
||||
x, y, ectx->bctx))
|
||||
goto err;
|
||||
|
||||
BN_CTX_end(ectx->bctx);
|
||||
|
||||
return 1;
|
||||
err:
|
||||
BN_CTX_end(ectx->bctx);
|
||||
drbg_ec_uninstantiate(dctx);
|
||||
return 0;
|
||||
}
|
@@ -79,8 +79,6 @@ int FIPS_drbg_init(DRBG_CTX *dctx, int type, unsigned int flags)
|
||||
rv = fips_drbg_ctr_init(dctx);
|
||||
if (rv == -2)
|
||||
rv = fips_drbg_hmac_init(dctx);
|
||||
if (rv == -2)
|
||||
rv = fips_drbg_ec_init(dctx);
|
||||
|
||||
if (rv <= 0)
|
||||
{
|
||||
|
@@ -133,9 +133,6 @@ typedef struct {
|
||||
#define make_drbg_test_data_df(nid, pr, p) \
|
||||
make_drbg_test_data(nid, DRBG_FLAG_CTR_USE_DF, pr, p)
|
||||
|
||||
#define make_drbg_test_data_ec(curve, md, pr, p) \
|
||||
make_drbg_test_data((curve << 16) | md , 0, pr, p)
|
||||
|
||||
static DRBG_SELFTEST_DATA drbg_test[] = {
|
||||
make_drbg_test_data_df(NID_aes_128_ctr, aes_128_use_df, 0),
|
||||
make_drbg_test_data_df(NID_aes_192_ctr, aes_192_use_df, 0),
|
||||
@@ -153,18 +150,6 @@ static DRBG_SELFTEST_DATA drbg_test[] = {
|
||||
make_drbg_test_data(NID_hmacWithSHA256, 0, hmac_sha256, 1),
|
||||
make_drbg_test_data(NID_hmacWithSHA384, 0, hmac_sha384, 0),
|
||||
make_drbg_test_data(NID_hmacWithSHA512, 0, hmac_sha512, 0),
|
||||
make_drbg_test_data_ec(NID_X9_62_prime256v1, NID_sha1, p_256_sha1, 0),
|
||||
make_drbg_test_data_ec(NID_X9_62_prime256v1, NID_sha224, p_256_sha224, 0),
|
||||
make_drbg_test_data_ec(NID_X9_62_prime256v1, NID_sha256, p_256_sha256, 1),
|
||||
make_drbg_test_data_ec(NID_X9_62_prime256v1, NID_sha384, p_256_sha384, 0),
|
||||
make_drbg_test_data_ec(NID_X9_62_prime256v1, NID_sha512, p_256_sha512, 0),
|
||||
make_drbg_test_data_ec(NID_secp384r1, NID_sha224, p_384_sha224, 0),
|
||||
make_drbg_test_data_ec(NID_secp384r1, NID_sha256, p_384_sha256, 0),
|
||||
make_drbg_test_data_ec(NID_secp384r1, NID_sha384, p_384_sha384, 0),
|
||||
make_drbg_test_data_ec(NID_secp384r1, NID_sha512, p_384_sha512, 0),
|
||||
make_drbg_test_data_ec(NID_secp521r1, NID_sha256, p_521_sha256, 0),
|
||||
make_drbg_test_data_ec(NID_secp521r1, NID_sha384, p_521_sha384, 0),
|
||||
make_drbg_test_data_ec(NID_secp521r1, NID_sha512, p_521_sha512, 0),
|
||||
{0,0,0}
|
||||
};
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -182,7 +182,7 @@ int main(int argc,char **argv)
|
||||
int r, nid = 0;
|
||||
int pr = 0;
|
||||
char buf[2048], lbuf[2048];
|
||||
unsigned char *randout = NULL;
|
||||
unsigned char randout[2048];
|
||||
char *keyword = NULL, *value = NULL;
|
||||
|
||||
unsigned char *ent = NULL, *nonce = NULL, *pers = NULL, *adin = NULL;
|
||||
@@ -298,8 +298,6 @@ int main(int argc,char **argv)
|
||||
else
|
||||
exit(1);
|
||||
}
|
||||
if (!strcmp(keyword, "[ReturnedBitsLen"))
|
||||
randoutlen = atoi(value) / 8;
|
||||
|
||||
if (!strcmp(keyword, "EntropyInput"))
|
||||
{
|
||||
@@ -329,11 +327,7 @@ int main(int argc,char **argv)
|
||||
FIPS_drbg_set_callbacks(dctx, test_entropy, 0, 0,
|
||||
test_nonce, 0);
|
||||
FIPS_drbg_set_app_data(dctx, &t);
|
||||
if (randoutlen == 0)
|
||||
randoutlen = (int)FIPS_drbg_get_blocklength(dctx);
|
||||
if (randout)
|
||||
OPENSSL_free(randout);
|
||||
randout = OPENSSL_malloc(randoutlen);
|
||||
randoutlen = (int)FIPS_drbg_get_blocklength(dctx);
|
||||
r = FIPS_drbg_instantiate(dctx, pers, perslen);
|
||||
if (!r)
|
||||
{
|
||||
@@ -412,8 +406,6 @@ int main(int argc,char **argv)
|
||||
}
|
||||
|
||||
}
|
||||
if (randout)
|
||||
OPENSSL_free(randout);
|
||||
if (in && in != stdin)
|
||||
fclose(in);
|
||||
if (out && out != stdout)
|
||||
|
@@ -236,6 +236,5 @@ struct drbg_ctx_st
|
||||
int fips_drbg_ctr_init(DRBG_CTX *dctx);
|
||||
int fips_drbg_hash_init(DRBG_CTX *dctx);
|
||||
int fips_drbg_hmac_init(DRBG_CTX *dctx);
|
||||
int fips_drbg_ec_init(DRBG_CTX *dctx);
|
||||
int fips_drbg_kat(DRBG_CTX *dctx, int nid, unsigned int flags);
|
||||
int fips_drbg_cprng_test(DRBG_CTX *dctx, const unsigned char *out);
|
||||
|
@@ -288,11 +288,8 @@ int FIPS_rsa_sign_digest(RSA *rsa, const unsigned char *md, int md_len,
|
||||
*siglen=j;
|
||||
}
|
||||
psserr:
|
||||
if (sbuf)
|
||||
{
|
||||
OPENSSL_cleanse(sbuf, i);
|
||||
OPENSSL_free(sbuf);
|
||||
}
|
||||
OPENSSL_cleanse(sbuf, i);
|
||||
OPENSSL_free(sbuf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@@ -30,8 +30,7 @@ LIB=$(TOP)/libcrypto.a
|
||||
LIBSRC=fips_sha1_selftest.c
|
||||
LIBOBJ=fips_sha1_selftest.o
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
PROGS= fips_standalone_sha1.c
|
||||
SRC= $(LIBSRC) fips_standalone_sha1.c
|
||||
|
||||
EXHEADER=
|
||||
HEADER=
|
||||
|
@@ -208,7 +208,6 @@ int FIPS_cipherinit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
|
||||
break;
|
||||
|
||||
case EVP_CIPH_CTR_MODE:
|
||||
ctx->num = 0;
|
||||
/* Don't reuse IV for CTR mode */
|
||||
if(iv)
|
||||
memcpy(ctx->iv, iv, M_EVP_CIPHER_CTX_iv_length(ctx));
|
||||
|
@@ -12,7 +12,6 @@ PERL= perl
|
||||
# KRB5 stuff
|
||||
KRB5_INCLUDES=
|
||||
LIBKRB5=
|
||||
TEST= fips_algvs.c
|
||||
|
||||
PEX_LIBS=
|
||||
EX_LIBS= #-lnsl -lsocket
|
||||
|
@@ -58,7 +58,7 @@ while (<STDIN>)
|
||||
}
|
||||
else
|
||||
{
|
||||
next unless (/^(fips\/|crypto|util|test|include|ms|c6x)/);
|
||||
next unless (/^(fips\/|crypto|util|test|include|ms|c6x|iOS)/);
|
||||
}
|
||||
if (/^crypto\/([^\/]+)/)
|
||||
{
|
||||
|
@@ -27,30 +27,33 @@ if (exists $ENV{"PREMAIN_DSO_EXE"})
|
||||
$fips_premain_dso = "";
|
||||
}
|
||||
|
||||
my $fips_sig = $ENV{"FIPS_SIG"};
|
||||
if (defined $fips_sig)
|
||||
{
|
||||
if ($fips_premain_dso ne "")
|
||||
{
|
||||
$fips_premain_dso = "$fips_sig -dso";
|
||||
}
|
||||
else
|
||||
{
|
||||
$fips_premain_dso = "$fips_sig -exe";
|
||||
}
|
||||
}
|
||||
|
||||
check_hash($sha1_exe, "fips_premain.c");
|
||||
check_hash($sha1_exe, "fipscanister.lib");
|
||||
|
||||
|
||||
print "Integrity check OK\n";
|
||||
|
||||
if (is_premain_linked(@ARGV)) {
|
||||
print "$fips_cc $fips_cc_args $fips_libdir/fips_premain.c\n";
|
||||
system "$fips_cc $fips_cc_args $fips_libdir/fips_premain.c";
|
||||
die "First stage Compile failure" if $? != 0;
|
||||
} elsif (!defined($ENV{FIPS_SIG})) {
|
||||
die "no fips_premain.obj linked";
|
||||
}
|
||||
print "$fips_cc $fips_cc_args $fips_libdir/fips_premain.c\n";
|
||||
system "$fips_cc $fips_cc_args $fips_libdir/fips_premain.c";
|
||||
die "First stage Compile failure" if $? != 0;
|
||||
|
||||
print "$fips_link @ARGV\n";
|
||||
system "$fips_link @ARGV";
|
||||
die "First stage Link failure" if $? != 0;
|
||||
|
||||
if (defined($ENV{FIPS_SIG})) {
|
||||
print "$ENV{FIPS_SIG} $fips_target\n";
|
||||
system "$ENV{FIPS_SIG} $fips_target";
|
||||
die "$ENV{FIPS_SIG} $fips_target failed" if $? != 0;
|
||||
exit;
|
||||
}
|
||||
|
||||
print "$fips_premain_dso $fips_target\n";
|
||||
system("$fips_premain_dso $fips_target >$fips_target.sha1");
|
||||
@@ -71,22 +74,6 @@ print "$fips_link @ARGV\n";
|
||||
system "$fips_link @ARGV";
|
||||
die "Second stage Link failure" if $? != 0;
|
||||
|
||||
sub is_premain_linked
|
||||
{
|
||||
return 1 if (grep /fips_premain\.obj/,@_);
|
||||
foreach (@_)
|
||||
{
|
||||
if (/^@(.*)/ && -f $1)
|
||||
{
|
||||
open FD,$1 or die "can't open $1";
|
||||
my $ret = (grep /fips_premain\.obj/,<FD>)?1:0;
|
||||
close FD;
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub check_hash
|
||||
{
|
||||
my ($sha1_exe, $filename) = @_;
|
||||
|
@@ -864,13 +864,13 @@ if ($fips)
|
||||
}
|
||||
$rules.=&cc_compile_target("\$(OBJ_D)${o}fips_standalone_sha1$obj",
|
||||
"fips${o}sha${o}fips_standalone_sha1.c",
|
||||
"\$(APP_CFLAGS)");
|
||||
"\$(SHLIB_CFLAGS)");
|
||||
$rules.=&cc_compile_target("\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj",
|
||||
"fips${o}fips_premain.c",
|
||||
"-DFINGERPRINT_PREMAIN_DSO_LOAD \$(APP_CFLAGS)");
|
||||
"-DFINGERPRINT_PREMAIN_DSO_LOAD \$(SHLIB_CFLAGS)");
|
||||
$rules.=&cc_compile_target("\$(OBJ_D)${o}fips_algvs$obj",
|
||||
"test${o}fips_algvs.c",
|
||||
"\$(APP_CFLAGS)");
|
||||
"\$(SHLIB_CFLAGS)");
|
||||
}
|
||||
|
||||
foreach (values %lib_nam)
|
||||
|
@@ -49,7 +49,8 @@ if ($FLAVOR =~ /WIN64/)
|
||||
# considered safe to ignore.
|
||||
#
|
||||
$base_cflags= " $mf_cflag";
|
||||
my $f = ($shlib and !$fipscanisterbuild)?' /MD':' /MT';
|
||||
my $f = $shlib?' /MD':' /MT';
|
||||
$lib_cflag='/Zl' if (!$shlib); # remove /DEFAULTLIBs from static lib
|
||||
$opt_cflags=$f.' /Ox';
|
||||
$dbg_cflags=$f.'d /Od -DDEBUG -D_DEBUG';
|
||||
$lflags="/nologo /subsystem:console /opt:ref";
|
||||
@@ -126,24 +127,25 @@ elsif ($FLAVOR =~ /CE/)
|
||||
$base_cflags.=" $wcecdefs";
|
||||
$base_cflags.=' -I$(WCECOMPAT)/include' if (defined($ENV{'WCECOMPAT'}));
|
||||
$base_cflags.=' -I$(PORTSDK_LIBPATH)/../../include' if (defined($ENV{'PORTSDK_LIBPATH'}));
|
||||
if (`cl 2>&1` =~ /Version 1[4-9]\./) {
|
||||
$base_cflags.=($shlib and !$fipscanisterbuild)?' /MD':' /MT';
|
||||
if ($ENV{PLATFORM} =~ /wce7/i) {
|
||||
$opt_cflags=' /MT /O1i'; # optimize for space, but with intrinsics...
|
||||
$dbg_cflags=' /MT /Od -DDEBUG -D_DEBUG';
|
||||
} else {
|
||||
$base_cflags.=' /MC';
|
||||
$opt_cflags=' /MC /O1i'; # optimize for space, but with intrinsics...
|
||||
$dbg_cflags=' /MC /Od -DDEBUG -D_DEBUG';
|
||||
}
|
||||
$opt_cflags=' /O1i'; # optimize for space, but with intrinsics...
|
||||
$dbg_cflags=' /Od -DDEBUG -D_DEBUG';
|
||||
|
||||
$lflags="/nologo /opt:ref $wcelflag";
|
||||
}
|
||||
else # Win32
|
||||
{
|
||||
$base_cflags= " $mf_cflag";
|
||||
my $f = ($shlib and !$fipscanisterbuild)?' /MD':' /MT';
|
||||
my $f = $shlib?' /MD':' /MT';
|
||||
$lib_cflag='/Zl' if (!$shlib); # remove /DEFAULTLIBs from static lib
|
||||
$opt_cflags=$f.' /Ox /O2 /Ob2';
|
||||
$dbg_cflags=$f.'d /Od -DDEBUG -D_DEBUG';
|
||||
$lflags="/nologo /subsystem:console /opt:ref";
|
||||
}
|
||||
$lib_cflag='/Zl' if (!$shlib or $fipscanisterbuild); # remove /DEFAULTLIBs
|
||||
$mlflags='';
|
||||
|
||||
$out_def ="out32"; $out_def.="dll" if ($shlib);
|
||||
@@ -288,8 +290,7 @@ elsif ($shlib && $FLAVOR =~ /CE/)
|
||||
{
|
||||
$mlflags.=" $lflags /dll";
|
||||
$lflags.=' /entry:mainCRTstartup' if(defined($ENV{'PORTSDK_LIBPATH'}));
|
||||
$lib_cflag.=" -D_WINDLL";
|
||||
$lib_cflag.=" -D_DLL" if (!$fipscanisterbuild);
|
||||
$lib_cflag.=" -D_WINDLL -D_DLL";
|
||||
}
|
||||
|
||||
sub do_lib_rule
|
||||
|
Reference in New Issue
Block a user