From 3642f632d3120ca512e11613cab14d69ca66fe73 Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Tue, 11 May 2004 12:46:24 +0000 Subject: [PATCH] Pull FIPS back into stable. --- .cvsignore | 3 +- Configure | 46 +- FAQ | 2 +- INSTALL | 4 +- INSTALL.W32 | 13 +- Makefile.org | 70 +- PROBLEMS | 4 +- apps/.cvsignore | 1 + apps/{Makefile.ssl => Makefile} | 77 +- apps/apps.c | 10 - apps/ca.c | 10 - apps/dgst.c | 50 +- apps/openssl.c | 19 + crypto/{Makefile.ssl => Makefile} | 13 +- crypto/aes/{Makefile.ssl => Makefile} | 9 +- crypto/aes/aes.h | 9 + crypto/aes/aes_cfb.c | 93 + crypto/aes/aes_core.c | 4 + crypto/asn1/{Makefile.ssl => Makefile} | 6 +- crypto/bf/{Makefile.ssl => Makefile} | 6 +- crypto/bio/{Makefile.ssl => Makefile} | 6 +- crypto/bio/bio.h | 1 + crypto/bn/{Makefile.ssl => Makefile} | 6 +- crypto/bn/bntest.c | 2 +- crypto/buffer/{Makefile.ssl => Makefile} | 6 +- crypto/cast/{Makefile.ssl => Makefile} | 6 +- crypto/cast/asm/.cvsignore | 1 + crypto/comp/{Makefile.ssl => Makefile} | 6 +- crypto/conf/{Makefile.ssl => Makefile} | 6 +- crypto/cryptlib.c | 5 + crypto/crypto-lib.com | 2 +- crypto/des/{Makefile.ssl => Makefile} | 8 +- crypto/des/cfb64ede.c | 111 + crypto/des/des.h | 6 +- crypto/des/des_enc.c | 8 + crypto/des/des_old.c | 2 +- crypto/des/destest.c | 4 +- crypto/des/ecb3_enc.c | 4 +- crypto/des/set_key.c | 4 + crypto/dh/{Makefile.ssl => Makefile} | 6 +- crypto/dsa/{Makefile.ssl => Makefile} | 22 +- crypto/dsa/dsa_gen.c | 5 +- crypto/dsa/dsa_key.c | 2 + crypto/dsa/dsa_ossl.c | 2 + crypto/dsa/dsa_sign.c | 12 + crypto/dsa/dsa_vrf.c | 8 + crypto/dso/{Makefile.ssl => Makefile} | 6 +- crypto/ec/{Makefile.ssl => Makefile} | 6 +- crypto/engine/{Makefile.ssl => Makefile} | 6 +- crypto/engine/hw_cryptodev.c | 8 +- crypto/err/{Makefile.ssl => Makefile} | 39 +- crypto/err/err.h | 2 + crypto/err/err_all.c | 4 + crypto/err/openssl.ec | 1 + crypto/evp/{Makefile.ssl => Makefile} | 6 +- crypto/evp/bio_md.c | 6 + crypto/evp/c_allc.c | 8 + crypto/evp/e_aes.c | 26 +- crypto/evp/e_des.c | 39 +- crypto/evp/e_des3.c | 47 +- crypto/evp/evp.h | 50 +- crypto/evp/evp_err.c | 4 +- crypto/evp/evp_lib.c | 24 + crypto/evp/evp_locl.h | 13 +- crypto/evp/evp_test.c | 25 +- crypto/evp/evptests.txt | 107 +- crypto/hmac/{Makefile.ssl => Makefile} | 6 +- crypto/idea/{Makefile.ssl => Makefile} | 6 +- crypto/krb5/{Makefile.ssl => Makefile} | 8 +- crypto/lhash/{Makefile.ssl => Makefile} | 6 +- crypto/md2/{Makefile.ssl => Makefile} | 6 +- crypto/md32_common.h | 12 + crypto/md4/{Makefile.ssl => Makefile} | 16 +- crypto/md5/{Makefile.ssl => Makefile} | 16 +- crypto/mdc2/{Makefile.ssl => Makefile} | 6 +- crypto/objects/{Makefile.ssl => Makefile} | 6 +- crypto/objects/obj_dat.h | 36 +- crypto/objects/obj_mac.h | 40 + crypto/objects/obj_mac.num | 10 + crypto/objects/objects.txt | 13 + crypto/ocsp/{Makefile.ssl => Makefile} | 8 +- crypto/pem/{Makefile.ssl => Makefile} | 6 +- crypto/pkcs12/{Makefile.ssl => Makefile} | 6 +- crypto/pkcs7/{Makefile.ssl => Makefile} | 6 +- crypto/rand/{Makefile.ssl => Makefile} | 38 +- crypto/rand/md_rand.c | 9 + crypto/rand/rand.h | 3 + crypto/rand/rand_err.c | 5 +- crypto/rand/rand_lib.c | 11 + crypto/rc2/{Makefile.ssl => Makefile} | 6 +- crypto/rc4/{Makefile.ssl => Makefile} | 6 +- crypto/rc5/{Makefile.ssl => Makefile} | 6 +- crypto/ripemd/{Makefile.ssl => Makefile} | 15 +- crypto/rsa/{Makefile.ssl => Makefile} | 6 +- crypto/rsa/rsa_eay.c | 2 +- crypto/rsa/rsa_gen.c | 3 + crypto/sha/{Makefile.ssl => Makefile} | 22 +- crypto/sha/sha1dgst.c | 8 + crypto/stack/{Makefile.ssl => Makefile} | 6 +- crypto/txt_db/{Makefile.ssl => Makefile} | 6 +- crypto/ui/{Makefile.ssl => Makefile} | 6 +- crypto/x509/{Makefile.ssl => Makefile} | 6 +- crypto/x509v3/{Makefile.ssl => Makefile} | 6 +- e_os.h | 21 +- fips/Makefile | 202 ++ fips/aes/Makefile | 131 + fips/aes/fingerprint.sha1 | 3 + fips/aes/fips_aes_core.c | 1263 ++++++++++ fips/aes/fips_aes_locl.h | 85 + fips/aes/fips_aes_selftest.c | 112 + fips/aes/fips_aesavs.c | 956 ++++++++ fips/des/Makefile | 155 ++ fips/des/asm/fips-dx86-elf.s | 2697 +++++++++++++++++++++ fips/des/fingerprint.sha1 | 5 + fips/des/fips_des_enc.c | 310 +++ fips/des/fips_des_locl.h | 428 ++++ fips/des/fips_des_selftest.c | 200 ++ fips/des/fips_desmovs.c | 784 ++++++ fips/des/fips_set_key.c | 415 ++++ fips/dsa/Makefile | 159 ++ fips/dsa/fingerprint.sha1 | 3 + fips/dsa/fips_dsa_gen.c | 373 +++ fips/dsa/fips_dsa_ossl.c | 387 +++ fips/dsa/fips_dsa_selftest.c | 168 ++ fips/dsa/fips_dsatest.c | 257 ++ fips/dsa/fips_dssvs.c | 306 +++ fips/fingerprint.sha1 | 4 + fips/fips.c | 189 ++ fips/fips.h | 125 + fips/fips_check_sha1 | 8 + fips/fips_err.h | 117 + fips/fips_err_wrapper.c | 7 + fips/fips_locl.h | 62 + fips/fips_make_sha1 | 27 + fips/fips_test_suite.c | 302 +++ fips/openssl_fips_fingerprint | 25 + fips/rand/Makefile | 104 + fips/rand/fingerprint.sha1 | 2 + fips/rand/fips_rand.c | 286 +++ fips/rand/fips_rand.h | 73 + fips/rand/fips_randtest.c | 369 +++ fips/rsa/Makefile | 112 + fips/rsa/fingerprint.sha1 | 3 + fips/rsa/fips_rsa_eay.c | 735 ++++++ fips/rsa/fips_rsa_gen.c | 249 ++ fips/rsa/fips_rsa_selftest.c | 207 ++ fips/sha1/.cvsignore | 2 + fips/sha1/Makefile | 158 ++ fips/sha1/asm/sx86-elf.s | 1568 ++++++++++++ fips/sha1/fingerprint.sha1 | 5 + fips/sha1/fips_md32_common.h | 637 +++++ fips/sha1/fips_sha1_selftest.c | 97 + fips/sha1/fips_sha1dgst.c | 80 + fips/sha1/fips_sha1test.c | 145 ++ fips/sha1/fips_sha_locl.h | 479 ++++ fips/sha1/fips_standalone_sha1.c | 156 ++ fips/sha1/sha1hashes.txt | 342 +++ fips/sha1/sha1vectors.txt | 2293 ++++++++++++++++++ fips/sha1/standalone.sha1 | 6 + ms/do_masm.bat | 22 +- ms/do_ms.bat | 22 +- ms/do_nasm.bat | 23 +- ms/do_nt.bat | 8 +- shlib/hpux10-cc.sh | 6 +- ssl/{Makefile.ssl => Makefile} | 188 +- ssl/s3_clnt.c | 10 + ssl/s3_srvr.c | 9 + ssl/ssl_cert.c | 9 + ssl/ssl_lib.c | 14 +- ssl/ssltest.c | 34 +- ssl/t1_enc.c | 20 +- test/.cvsignore | 4 + test/{Makefile.ssl => Makefile} | 221 +- test/bctest | 2 +- test/testenc | 2 +- test/testfipsssl | 113 + tools/{Makefile.ssl => Makefile} | 7 +- util/cygwin.sh | 6 +- util/domd | 10 +- util/fixNT.sh | 6 +- util/libeay.num | 66 +- util/mk1mf.pl | 10 +- util/mkdef.pl | 15 +- util/mkerr.pl | 3 +- util/mkfiles.pl | 9 +- util/pl/BC-16.pl | 2 +- util/pl/BC-32.pl | 2 +- util/pl/Mingw32.pl | 2 +- util/pl/OS2-EMX.pl | 2 +- util/pl/VC-16.pl | 4 +- util/pl/VC-32.pl | 4 +- util/pl/VC-CE.pl | 2 +- util/pl/ultrix.pl | 2 +- util/pod2mantest | 2 +- util/selftest.pl | 4 +- 195 files changed, 20155 insertions(+), 614 deletions(-) rename apps/{Makefile.ssl => Makefile} (96%) rename crypto/{Makefile.ssl => Makefile} (96%) rename crypto/aes/{Makefile.ssl => Makefile} (92%) rename crypto/asn1/{Makefile.ssl => Makefile} (99%) rename crypto/bf/{Makefile.ssl => Makefile} (94%) rename crypto/bio/{Makefile.ssl => Makefile} (98%) rename crypto/bn/{Makefile.ssl => Makefile} (98%) rename crypto/buffer/{Makefile.ssl => Makefile} (93%) rename crypto/cast/{Makefile.ssl => Makefile} (95%) rename crypto/comp/{Makefile.ssl => Makefile} (95%) rename crypto/conf/{Makefile.ssl => Makefile} (98%) rename crypto/des/{Makefile.ssl => Makefile} (98%) rename crypto/dh/{Makefile.ssl => Makefile} (97%) rename crypto/dsa/{Makefile.ssl => Makefile} (91%) rename crypto/dso/{Makefile.ssl => Makefile} (97%) rename crypto/ec/{Makefile.ssl => Makefile} (96%) rename crypto/engine/{Makefile.ssl => Makefile} (99%) rename crypto/err/{Makefile.ssl => Makefile} (69%) rename crypto/evp/{Makefile.ssl => Makefile} (99%) rename crypto/hmac/{Makefile.ssl => Makefile} (94%) rename crypto/idea/{Makefile.ssl => Makefile} (92%) rename crypto/krb5/{Makefile.ssl => Makefile} (91%) rename crypto/lhash/{Makefile.ssl => Makefile} (93%) rename crypto/md2/{Makefile.ssl => Makefile} (93%) rename crypto/md4/{Makefile.ssl => Makefile} (77%) rename crypto/md5/{Makefile.ssl => Makefile} (85%) rename crypto/mdc2/{Makefile.ssl => Makefile} (94%) rename crypto/objects/{Makefile.ssl => Makefile} (96%) rename crypto/ocsp/{Makefile.ssl => Makefile} (98%) rename crypto/pem/{Makefile.ssl => Makefile} (99%) rename crypto/pkcs12/{Makefile.ssl => Makefile} (99%) rename crypto/pkcs7/{Makefile.ssl => Makefile} (98%) rename crypto/rand/{Makefile.ssl => Makefile} (86%) rename crypto/rc2/{Makefile.ssl => Makefile} (92%) rename crypto/rc4/{Makefile.ssl => Makefile} (93%) rename crypto/rc5/{Makefile.ssl => Makefile} (93%) rename crypto/ripemd/{Makefile.ssl => Makefile} (82%) rename crypto/rsa/{Makefile.ssl => Makefile} (98%) rename crypto/sha/{Makefile.ssl => Makefile} (81%) rename crypto/stack/{Makefile.ssl => Makefile} (92%) rename crypto/txt_db/{Makefile.ssl => Makefile} (92%) rename crypto/ui/{Makefile.ssl => Makefile} (95%) rename crypto/x509/{Makefile.ssl => Makefile} (99%) rename crypto/x509v3/{Makefile.ssl => Makefile} (99%) create mode 100644 fips/Makefile create mode 100644 fips/aes/Makefile create mode 100644 fips/aes/fingerprint.sha1 create mode 100644 fips/aes/fips_aes_core.c create mode 100644 fips/aes/fips_aes_locl.h create mode 100644 fips/aes/fips_aes_selftest.c create mode 100644 fips/aes/fips_aesavs.c create mode 100644 fips/des/Makefile create mode 100644 fips/des/asm/fips-dx86-elf.s create mode 100644 fips/des/fingerprint.sha1 create mode 100644 fips/des/fips_des_enc.c create mode 100644 fips/des/fips_des_locl.h create mode 100644 fips/des/fips_des_selftest.c create mode 100644 fips/des/fips_desmovs.c create mode 100644 fips/des/fips_set_key.c create mode 100644 fips/dsa/Makefile create mode 100644 fips/dsa/fingerprint.sha1 create mode 100644 fips/dsa/fips_dsa_gen.c create mode 100644 fips/dsa/fips_dsa_ossl.c create mode 100644 fips/dsa/fips_dsa_selftest.c create mode 100644 fips/dsa/fips_dsatest.c create mode 100644 fips/dsa/fips_dssvs.c create mode 100644 fips/fingerprint.sha1 create mode 100644 fips/fips.c create mode 100644 fips/fips.h create mode 100755 fips/fips_check_sha1 create mode 100644 fips/fips_err.h create mode 100644 fips/fips_err_wrapper.c create mode 100644 fips/fips_locl.h create mode 100755 fips/fips_make_sha1 create mode 100644 fips/fips_test_suite.c create mode 100755 fips/openssl_fips_fingerprint create mode 100644 fips/rand/Makefile create mode 100644 fips/rand/fingerprint.sha1 create mode 100644 fips/rand/fips_rand.c create mode 100644 fips/rand/fips_rand.h create mode 100644 fips/rand/fips_randtest.c create mode 100644 fips/rsa/Makefile create mode 100644 fips/rsa/fingerprint.sha1 create mode 100644 fips/rsa/fips_rsa_eay.c create mode 100644 fips/rsa/fips_rsa_gen.c create mode 100644 fips/rsa/fips_rsa_selftest.c create mode 100644 fips/sha1/.cvsignore create mode 100644 fips/sha1/Makefile create mode 100644 fips/sha1/asm/sx86-elf.s create mode 100644 fips/sha1/fingerprint.sha1 create mode 100644 fips/sha1/fips_md32_common.h create mode 100644 fips/sha1/fips_sha1_selftest.c create mode 100644 fips/sha1/fips_sha1dgst.c create mode 100644 fips/sha1/fips_sha1test.c create mode 100644 fips/sha1/fips_sha_locl.h create mode 100644 fips/sha1/fips_standalone_sha1.c create mode 100644 fips/sha1/sha1hashes.txt create mode 100644 fips/sha1/sha1vectors.txt create mode 100644 fips/sha1/standalone.sha1 rename ssl/{Makefile.ssl => Makefile} (90%) rename test/{Makefile.ssl => Makefile} (75%) create mode 100644 test/testfipsssl rename tools/{Makefile.ssl => Makefile} (86%) diff --git a/.cvsignore b/.cvsignore index a01eb86196..bec4408ffc 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1,5 +1,5 @@ openssl.pc -Makefile.ssl +Makefile MINFO makefile.one tmp @@ -14,3 +14,4 @@ cctest.c cctest.a libcrypto.so.* libssl.so.* +libcrypto.sha1 diff --git a/Configure b/Configure index 4e7883c17a..6240962648 100755 --- a/Configure +++ b/Configure @@ -10,7 +10,7 @@ use strict; # see INSTALL for instructions. -my $usage="Usage: Configure [no- ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-engine] [no-hw-xxx|no-hw] [[no-]threads] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-dso] [no-krb5] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--test-sanity] os/compiler[:flags]\n"; +my $usage="Usage: Configure [no- ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-engine] [no-hw-xxx|no-hw] [[no-]threads] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-dso] [no-krb5] [386] [[no-]fips] [debug] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--test-sanity] os/compiler[:flags]\n"; # Options: # @@ -135,11 +135,12 @@ my %table=( # Our development configs "purify", "purify gcc:-g -DPURIFY -Wall::(unknown)::-lsocket -lnsl::::", "debug", "gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -ggdb -g2 -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror::(unknown)::-lefence::::", -"debug-ben", "gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::asm/bn86-elf.o asm/co86-elf.o", +"debug-ben", "gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -O2 -Wall -Wshadow -Werror -pipe::(unknown)::::asm/bn86-elf.o asm/co86-elf.o", "debug-ben-openbsd","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::", "debug-ben-openbsd-debug","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::", -"debug-ben-debug", "gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::::", +"debug-ben-debug", "gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -g3 -O2 -Wall -Wshadow -Werror -pipe::(unknown)::::::", "debug-ben-strict", "gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DCONST_STRICT -O2 -Wall -Wshadow -Werror -Wpointer-arith -Wcast-qual -Wwrite-strings -pipe::(unknown)::::::", +"debug-ben-fips-debug","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_FIPS -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::asm/bn86-elf.o asm/co86-elf.o", "debug-rse","cc:-DTERMIOS -DL_ENDIAN -pipe -O -g -ggdb3 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}", "debug-bodo", "gcc:-DL_ENDIAN -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DBIO_PAIR_DEBUG -DPEDANTIC -g -m486 -pedantic -Wshadow -Wall::-D_REENTRANT:::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}", "debug-ulf", "gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -g -O2 -m486 -Wall -Werror -Wshadow -pipe::-D_REENTRANT:::${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}", @@ -609,7 +610,7 @@ my $threads=0; my $no_asm=0; my $no_dso=0; my @skip=(); -my $Makefile="Makefile.ssl"; +my $Makefile="Makefile"; my $des_locl="crypto/des/des_locl.h"; my $des ="crypto/des/des.h"; my $bn ="crypto/bn/bn.h"; @@ -621,6 +622,7 @@ my $rc2 ="crypto/rc2/rc2.h"; my $bf ="crypto/bf/bf_locl.h"; my $bn_asm ="bn_asm.o"; my $des_enc="des_enc.o fcrypt_b.o"; +my $fips_des_enc="fips_des_enc.o"; my $bf_enc ="bf_enc.o"; my $cast_enc="c_enc.o"; my $rc4_enc="rc4_enc.o"; @@ -631,6 +633,8 @@ my $rmd160_obj=""; my $processor=""; my $default_ranlib; my $perl; +my $fips=0; +my $debug=0; my $no_ssl2=0; my $no_ssl3=0; @@ -739,6 +743,8 @@ PROCESS_ARGS: { $no_ssl3 = 1; } elsif (/^no-tls1?$/) { $no_tls1 = 1; } + elsif (/^no-fips$/) + { $fips = 0; } elsif (/^no-(.+)$/) { my $algo=$1; @@ -804,6 +810,14 @@ PROCESS_ARGS: } elsif (/^386$/) { $processor=386; } + elsif (/^fips$/) + { + $fips=1; + } + elsif (/^debug$/) + { + $debug=1; + } elsif (/^rsaref$/) { # No RSAref support any more since it's not needed. @@ -1139,12 +1153,20 @@ if ($ranlib eq "") $bn_obj = $bn_asm unless $bn_obj ne ""; -$des_obj=$des_enc unless ($des_obj =~ /\.o$/); +if ($fips) + { + $des_obj=$sha1_obj=""; + $openssl_other_defines.="#define OPENSSL_FIPS\n"; + } +$des_obj=$des_enc unless (!$fips && $des_obj =~ /\.o$/); +my $fips_des_obj='asm/fips-dx86-elf.o'; +$fips_des_obj=$fips_des_enc unless $processor eq '386'; +my $fips_sha1_obj='asm/sx86-elf.o' if $processor eq '386'; $bf_obj=$bf_enc unless ($bf_obj =~ /\.o$/); $cast_obj=$cast_enc unless ($cast_obj =~ /\.o$/); $rc4_obj=$rc4_enc unless ($rc4_obj =~ /\.o$/); $rc5_obj=$rc5_enc unless ($rc5_obj =~ /\.o$/); -if ($sha1_obj =~ /\.o$/) +if ($sha1_obj =~ /\.o$/ || $fips_sha1_obj =~ /\.o$/) { # $sha1_obj=$sha1_enc; $cflags.=" -DSHA1_ASM"; @@ -1160,6 +1182,12 @@ if ($rmd160_obj =~ /\.o$/) $cflags.=" -DRMD160_ASM"; } +if ($debug) + { + $cflags.=" -g"; + $cflags=~s/-fomit-frame-pointer//; + } + # "Stringify" the C flags string. This permits it to be made part of a string # and works as well on command lines. $cflags =~ s/([\\\"])/\\\1/g; @@ -1232,12 +1260,14 @@ while () s/^EXE_EXT=.*$/EXE_EXT= $exe_ext/; s/^BN_ASM=.*$/BN_ASM= $bn_obj/; s/^DES_ENC=.*$/DES_ENC= $des_obj/; + s/^FIPS_DES_ENC=.*$/FIPS_DES_ENC= $fips_des_obj/; s/^BF_ENC=.*$/BF_ENC= $bf_obj/; s/^CAST_ENC=.*$/CAST_ENC= $cast_obj/; s/^RC4_ENC=.*$/RC4_ENC= $rc4_obj/; s/^RC5_ENC=.*$/RC5_ENC= $rc5_obj/; s/^MD5_ASM_OBJ=.*$/MD5_ASM_OBJ= $md5_obj/; s/^SHA1_ASM_OBJ=.*$/SHA1_ASM_OBJ= $sha1_obj/; + s/^FIPS_SHA1_ASM_OBJ=.*$/FIPS_SHA1_ASM_OBJ= $fips_sha1_obj/; s/^RMD160_ASM_OBJ=.*$/RMD160_ASM_OBJ= $rmd160_obj/; s/^PROCESSOR=.*/PROCESSOR= $processor/; s/^RANLIB=.*/RANLIB= $ranlib/; @@ -1470,7 +1500,7 @@ if($IsWindows) { printf OUT <, including the output of "make report" in order to be added to the request tracker at http://www.openssl.org/support/rt2.html. diff --git a/INSTALL.W32 b/INSTALL.W32 index 0f6c302f0d..c277efa18b 100644 --- a/INSTALL.W32 +++ b/INSTALL.W32 @@ -46,12 +46,13 @@ http://www.kernel.org/pub/software/devel/nasm/binaries/win32/ The NASM binary nasmw.exe needs to be installed anywhere on your PATH. - Firstly you should run Configure: + Firstly you should run Configure (to build a FIPS-certified variant of + OpenSSL, add the option "fips"): > perl Configure VC-WIN32 Next you need to build the Makefiles and optionally the assembly language - files: + files (to build a FIPS-certified variant of OpenSSL, add the argument "fips"): - If you are using MASM then run: @@ -100,10 +101,12 @@ Borland C++ builder 5 --------------------- - * Configure for building with Borland Builder: + * Configure for building with Borland Builder (to build a FIPS-certified + variant of OpenSSL, add the option "fips"): > perl Configure BC-32 - * Create the appropriate makefile + * Create the appropriate makefile (to build a FIPS-certified variant of + OpenSSL, add the argument "fips") > ms\do_nasm * Build @@ -194,6 +197,8 @@ occur, try > ms\mingw32 no-asm instead. + If you want to build a FIPS-certified variant of OpenSSL, add the argument + "fips" libcrypto.a and libssl.a are the static libraries. To use the DLLs, link with libeay32.a and libssl32.a instead. diff --git a/Makefile.org b/Makefile.org index 955e385ae8..c22d57dbcf 100644 --- a/Makefile.org +++ b/Makefile.org @@ -101,6 +101,7 @@ PROCESSOR= # Set DES_ENC to des_enc.o if you want to use the C version #There are 4 x86 assember options. +FIPS_DES_ENC= des_enc.o fcrypt_b.o DES_ENC= asm/dx86-out.o asm/yx86-out.o #DES_ENC= des_enc.o fcrypt_b.o # C #DES_ENC= asm/dx86-elf.o asm/yx86-elf.o # elf @@ -153,6 +154,7 @@ MD5_ASM_OBJ= asm/mx86-out.o # Also need SHA1_ASM defined SHA1_ASM_OBJ= asm/sx86-out.o +FIPS_SHA1_ASM_OBJ= asm/sx86-out.o #SHA1_ASM_OBJ= asm/sx86-elf.o # elf #SHA1_ASM_OBJ= asm/sx86-sol.o # solaris #SHA1_ASM_OBJ= asm/sx86-out.o # a.out, FreeBSD @@ -173,23 +175,24 @@ LIBKRB5= # we might set SHLIB_MARK to '$(SHARED_LIBS)'. SHLIB_MARK= -DIRS= crypto ssl $(SHLIB_MARK) apps test tools -SHLIBDIRS= crypto ssl +DIRS= crypto fips ssl $(SHLIB_MARK) sigs apps test tools +SHLIBDIRS= fips crypto ssl # dirs in crypto to build -SDIRS= \ +SDIRS= objects \ md2 md4 md5 sha mdc2 hmac ripemd \ des rc2 rc4 rc5 idea bf cast \ bn ec rsa dsa dh dso engine aes \ - buffer bio stack lhash rand err objects \ + buffer bio stack lhash rand err \ evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 +FDIRS= sha1 rand des aes dsa rsa + # tests to perform. "alltests" is a special word indicating that all tests # should be performed. TESTS = alltests -MAKEFILE= Makefile.ssl -MAKE= make -f Makefile.ssl +MAKEFILE= Makefile MANDIR=$(OPENSSLDIR)/man MAN1=1 @@ -202,6 +205,7 @@ ONEDIRS=out tmp EDIRS= times doc bugs util include certs ms shlib mt demos perl sf dep VMS WDIRS= windows LIBS= libcrypto.a libssl.a +SIGS= libcrypto.sha1 SHARED_CRYPTO=libcrypto$(SHLIB_EXT) SHARED_SSL=libssl$(SHLIB_EXT) SHARED_LIBS= @@ -219,14 +223,32 @@ HEADER= e_os.h # When we're prepared to use shared libraries in the programs we link here # we might remove 'clean-shared' from the targets to perform at this stage -all: Makefile.ssl sub_all openssl.pc +all: Makefile sub_all openssl.pc + +sigs: $(SIGS) +libcrypto.sha1: libcrypto.a + if egrep 'define OPENSSL_FIPS' $(TOP)/include/openssl/opensslconf.h > /dev/null; then \ + $(RANLIB) libcrypto.a; \ + fips/sha1/fips_standalone_sha1 libcrypto.a > libcrypto.sha1; \ + fi sub_all: @for i in $(DIRS); \ do \ if [ -d "$$i" ]; then \ (cd $$i && echo "making all in $$i..." && \ - $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' AS='${AS}' ASFLAG='${ASFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' all ) || exit 1; \ + $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' AS='${AS}' ASFLAG='${ASFLAG}' SDIRS='$(SDIRS)' FDIRS='$(FDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' FIPS_DES_ENC='${FIPS_DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' FIPS_SHA1_ASM_OBJ='${FIPS_SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' all ) || exit 1; \ + else \ + $(MAKE) $$i; \ + fi; \ + done; + +sub_target: + @for i in $(DIRS); \ + do \ + if [ -d "$$i" ]; then \ + (cd $$i && echo "making $(TARGET) in $$i..." && \ + $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' AS='${AS}' ASFLAG='${ASFLAG}' SDIRS='$(SDIRS)' FDIRS='$(FDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' FIPS_DES_ENC='${FIPS_DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' FIPS_SHA1_ASM_OBJ='${FIPS_SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' TARGET='$(TARGET)' sub_target ) || exit 1; \ else \ $(MAKE) $$i; \ fi; \ @@ -483,7 +505,7 @@ do_hpux-shared: libs="$(LIBKRB5) $$libs"; \ fi; \ ( set -x; /usr/ccs/bin/ld ${SHARED_LDFLAGS} \ - +vnocompatwarnings \ + +vnocompatwarnings \ -b -z +s \ -o lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \ +h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \ @@ -506,7 +528,7 @@ do_hpux64-shared: libs="$(LIBKRB5) $$libs"; \ fi; \ ( set -x; /usr/ccs/bin/ld ${SHARED_LDFLAGS} \ - -b -z \ + -b -z \ -o lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \ +h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \ +forceload lib$$i.a -ldl -lc ) || exit 1; \ @@ -577,7 +599,7 @@ do_reliantunix-shared: libs="-l$$i $$libs"; \ done -openssl.pc: Makefile.ssl +openssl.pc: Makefile @ ( echo 'prefix=$(INSTALLTOP)'; \ echo 'exec_prefix=$${prefix}'; \ echo 'libdir=$${exec_prefix}/lib'; \ @@ -590,8 +612,8 @@ openssl.pc: Makefile.ssl echo 'Libs: -L$${libdir} -lssl -lcrypto $(LIBKRB5) $(EX_LIBS)'; \ echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > openssl.pc -Makefile.ssl: Makefile.org - @echo "Makefile.ssl is older than Makefile.org." +Makefile: Makefile.org + @echo "Makefile is older than Makefile.org." @echo "Reconfigure the source tree (via './config' or 'perl Configure'), please." @false @@ -621,7 +643,7 @@ makefile.one: files sh util/do_ms.sh files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl > $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile > $(TOP)/MINFO @for i in $(DIRS) ;\ do \ if [ -d "$$i" ]; then \ @@ -631,19 +653,18 @@ files: done; links: - @$(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mkdir-p.pl include/openssl @$(PERL) $(TOP)/util/mklink.pl include/openssl $(EXHEADER) @for i in $(DIRS); do \ if [ -d "$$i" ]; then \ (cd $$i && echo "making links in $$i..." && \ - $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PERL='${PERL}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' links ) || exit 1; \ + $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' FIPS_DES_ENC='${FIPS_DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' FIPS_SHA1_ASM_OBJ='${FIPS_SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PERL='${PERL}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' links ) || exit 1; \ fi; \ done; gentests: @(cd test && echo "generating dummy tests (if needed)..." && \ - $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' TESTS='${TESTS}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' TESTS='${TESTS}' OPENSSL_DEBUG_MEMORY=on generate ); + $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' FIPS_DES_ENC='${FIPS_DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' FIPS_SHA1_ASM_OBJ='${FIPS_SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' TESTS='${TESTS}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' TESTS='${TESTS}' OPENSSL_DEBUG_MEMORY=on generate ); dclean: rm -f *.bak @@ -672,7 +693,7 @@ test: tests tests: rehash @(cd test && echo "testing..." && \ - $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' TESTS='${TESTS}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' TESTS='${TESTS}' OPENSSL_DEBUG_MEMORY=on tests ); + $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' FIPS_DES_ENC='${FIPS_DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' FIPS_SHA1_ASM_OBJ='${FIPS_SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' TESTS='${TESTS}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' TESTS='${TESTS}' OPENSSL_DEBUG_MEMORY=on tests ); @LD_LIBRARY_PATH="`pwd`:$$LD_LIBRARY_PATH"; \ DYLD_LIBRARY_PATH="`pwd`:$$DYLD_LIBRARY_PATH"; \ SHLIB_PATH="`pwd`:$$SHLIB_PATH"; \ @@ -795,7 +816,9 @@ install: all install_docs if [ -f "$$i" ]; then \ ( echo installing $$i; \ cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \ - $(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \ + if ! egrep 'define OPENSSL_FIPS' $(TOP)/include/openssl/opensslconf.h > /dev/null; then \ + $(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \ + fi; \ chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \ mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i ); \ fi; \ @@ -832,6 +855,15 @@ install: all install_docs sed -e '1,/^$$/d' doc/openssl-shared.txt; \ fi; \ fi + @for i in $(SIGS) ;\ + do \ + if [ -f "$$i" ]; then \ + ( echo installing $$i; \ + cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \ + chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \ + mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i ); \ + fi; \ + done; cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig/openssl.pc diff --git a/PROBLEMS b/PROBLEMS index 85e96a5ebe..d6731b1b13 100644 --- a/PROBLEMS +++ b/PROBLEMS @@ -12,8 +12,8 @@ along the whole library path before it bothers looking for .a libraries. This means that -L switches won't matter unless OpenSSL is built with shared library support. -The workaround may be to change the following lines in apps/Makefile.ssl and -test/Makefile.ssl: +The workaround may be to change the following lines in apps/Makefile and +test/Makefile: LIBCRYPTO=-L.. -lcrypto LIBSSL=-L.. -lssl diff --git a/apps/.cvsignore b/apps/.cvsignore index cdd6c00dae..90083001b4 100644 --- a/apps/.cvsignore +++ b/apps/.cvsignore @@ -3,3 +3,4 @@ Makefile.save der_chop der_chop.bak CA.pl +openssl.sha1 diff --git a/apps/Makefile.ssl b/apps/Makefile similarity index 96% rename from apps/Makefile.ssl rename to apps/Makefile index 7068286204..03716f1124 100644 --- a/apps/Makefile.ssl +++ b/apps/Makefile @@ -1,5 +1,5 @@ # -# apps/Makefile.ssl +# apps/Makefile # DIR= apps @@ -10,10 +10,9 @@ CFLAG= -g -static INSTALL_PREFIX= INSTALLTOP= /usr/local/ssl OPENSSLDIR= /usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile PERL= perl RM= rm -f # KRB5 stuff @@ -94,7 +93,7 @@ sreq.o: req.c $(CC) -c $(INCLUDES) $(CFLAG) -o sreq.o req.c files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO install: @for i in $(EXE); \ @@ -121,7 +120,6 @@ tags: tests: links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile lint: lint -DLINT $(INCLUDES) $(SRC)>fluff @@ -151,6 +149,7 @@ $(PROGRAM): progs.h $(E_OBJ) $(PROGRAM).o $(DLIBCRYPTO) $(DLIBSSL) LD_LIBRARY_PATH=..:$$LD_LIBRARY_PATH \ $(CC) -o $(PROGRAM) $(CFLAGS) $(PROGRAM).o $(E_OBJ) $(PEX_LIBS) $(LIBSSL) $(LIBKRB5) $(LIBCRYPTO) $(EX_LIBS) ; \ fi + TOP=$(TOP) $(TOP)/fips/openssl_fips_fingerprint $(TOP)/libcrypto.a $(PROGRAM) -(cd ..; OPENSSL="`pwd`/apps/openssl"; export OPENSSL; \ LD_LIBRARY_PATH="`pwd`:$$LD_LIBRARY_PATH"; \ DYLD_LIBRARY_PATH="`pwd`:$$DYLD_LIBRARY_PATH"; \ @@ -344,21 +343,22 @@ dgst.o: ../include/openssl/crypto.h ../include/openssl/des.h dgst.o: ../include/openssl/des_old.h ../include/openssl/dh.h dgst.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h dgst.o: ../include/openssl/engine.h ../include/openssl/err.h -dgst.o: ../include/openssl/evp.h ../include/openssl/idea.h -dgst.o: ../include/openssl/lhash.h ../include/openssl/md2.h -dgst.o: ../include/openssl/md4.h ../include/openssl/md5.h -dgst.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h -dgst.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h -dgst.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h -dgst.o: ../include/openssl/pem.h ../include/openssl/pem2.h -dgst.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h -dgst.o: ../include/openssl/rc2.h ../include/openssl/rc4.h -dgst.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h -dgst.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -dgst.o: ../include/openssl/sha.h ../include/openssl/stack.h -dgst.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h -dgst.o: ../include/openssl/ui.h ../include/openssl/ui_compat.h -dgst.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h dgst.c +dgst.o: ../include/openssl/evp.h ../include/openssl/hmac.h +dgst.o: ../include/openssl/idea.h ../include/openssl/lhash.h +dgst.o: ../include/openssl/md2.h ../include/openssl/md4.h +dgst.o: ../include/openssl/md5.h ../include/openssl/mdc2.h +dgst.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h +dgst.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h +dgst.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h +dgst.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h +dgst.o: ../include/openssl/rand.h ../include/openssl/rc2.h +dgst.o: ../include/openssl/rc4.h ../include/openssl/rc5.h +dgst.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h +dgst.o: ../include/openssl/safestack.h ../include/openssl/sha.h +dgst.o: ../include/openssl/stack.h ../include/openssl/symhacks.h +dgst.o: ../include/openssl/txt_db.h ../include/openssl/ui.h +dgst.o: ../include/openssl/ui_compat.h ../include/openssl/x509.h +dgst.o: ../include/openssl/x509_vfy.h apps.h dgst.c dh.o: ../e_os.h ../include/openssl/aes.h ../include/openssl/asn1.h dh.o: ../include/openssl/bio.h ../include/openssl/blowfish.h dh.o: ../include/openssl/bn.h ../include/openssl/buffer.h @@ -637,24 +637,25 @@ openssl.o: ../include/openssl/des.h ../include/openssl/des_old.h openssl.o: ../include/openssl/dh.h ../include/openssl/dsa.h openssl.o: ../include/openssl/e_os2.h ../include/openssl/engine.h openssl.o: ../include/openssl/err.h ../include/openssl/evp.h -openssl.o: ../include/openssl/idea.h ../include/openssl/kssl.h -openssl.o: ../include/openssl/lhash.h ../include/openssl/md2.h -openssl.o: ../include/openssl/md4.h ../include/openssl/md5.h -openssl.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h -openssl.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h -openssl.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h -openssl.o: ../include/openssl/pem.h ../include/openssl/pem2.h -openssl.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h -openssl.o: ../include/openssl/rc2.h ../include/openssl/rc4.h -openssl.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h -openssl.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -openssl.o: ../include/openssl/sha.h ../include/openssl/ssl.h -openssl.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h -openssl.o: ../include/openssl/ssl3.h ../include/openssl/stack.h -openssl.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h -openssl.o: ../include/openssl/txt_db.h ../include/openssl/ui.h -openssl.o: ../include/openssl/ui_compat.h ../include/openssl/x509.h -openssl.o: ../include/openssl/x509_vfy.h apps.h openssl.c progs.h s_apps.h +openssl.o: ../include/openssl/fips.h ../include/openssl/idea.h +openssl.o: ../include/openssl/kssl.h ../include/openssl/lhash.h +openssl.o: ../include/openssl/md2.h ../include/openssl/md4.h +openssl.o: ../include/openssl/md5.h ../include/openssl/mdc2.h +openssl.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h +openssl.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h +openssl.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h +openssl.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h +openssl.o: ../include/openssl/rand.h ../include/openssl/rc2.h +openssl.o: ../include/openssl/rc4.h ../include/openssl/rc5.h +openssl.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h +openssl.o: ../include/openssl/safestack.h ../include/openssl/sha.h +openssl.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h +openssl.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h +openssl.o: ../include/openssl/stack.h ../include/openssl/symhacks.h +openssl.o: ../include/openssl/tls1.h ../include/openssl/txt_db.h +openssl.o: ../include/openssl/ui.h ../include/openssl/ui_compat.h +openssl.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h +openssl.o: openssl.c progs.h s_apps.h passwd.o: ../e_os.h ../include/openssl/aes.h ../include/openssl/asn1.h passwd.o: ../include/openssl/bio.h ../include/openssl/blowfish.h passwd.o: ../include/openssl/bn.h ../include/openssl/buffer.h diff --git a/apps/apps.c b/apps/apps.c index 4984e8e7cb..b747e2d3cf 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -126,16 +126,6 @@ #include #endif -#ifdef OPENSSL_SYS_WINDOWS -#define strcasecmp _stricmp -#else -# ifdef NO_STRINGS_H - int strcasecmp(); -# else -# include -# endif /* NO_STRINGS_H */ -#endif - #define NON_MAIN #include "apps.h" #undef NON_MAIN diff --git a/apps/ca.c b/apps/ca.c index 5328645bef..f7cc6a12a1 100644 --- a/apps/ca.c +++ b/apps/ca.c @@ -76,16 +76,6 @@ #include #include -#ifdef OPENSSL_SYS_WINDOWS -#define strcasecmp _stricmp -#else -# ifdef NO_STRINGS_H - int strcasecmp(); -# else -# include -# endif /* NO_STRINGS_H */ -#endif - #ifndef W_OK # ifdef OPENSSL_SYS_VMS # if defined(__DECC) diff --git a/apps/dgst.c b/apps/dgst.c index be25dafef7..8b4ec7f2e2 100644 --- a/apps/dgst.c +++ b/apps/dgst.c @@ -66,6 +66,7 @@ #include #include #include +#include #undef BUFSIZE #define BUFSIZE 1024*8 @@ -73,9 +74,11 @@ #undef PROG #define PROG dgst_main +static HMAC_CTX hmac_ctx; + int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout, EVP_PKEY *key, unsigned char *sigin, int siglen, const char *title, - const char *file); + const char *file,BIO *bmd,const char *hmac_key); int MAIN(int, char **); @@ -103,6 +106,7 @@ int MAIN(int argc, char **argv) #ifndef OPENSSL_NO_ENGINE char *engine=NULL; #endif + char *hmac_key=NULL; apps_startup(); @@ -181,6 +185,12 @@ int MAIN(int argc, char **argv) out_bin = 1; else if (strcmp(*argv,"-d") == 0) debug=1; + else if (!strcmp(*argv,"-hmac")) + { + if (--argc < 1) + break; + hmac_key=*++argv; + } else if ((m=EVP_get_digestbyname(&((*argv)[1]))) != NULL) md=m; else @@ -235,7 +245,7 @@ int MAIN(int argc, char **argv) } #ifndef OPENSSL_NO_ENGINE - e = setup_engine(bio_err, engine, 0); + e = setup_engine(bio_err, engine, 0); #endif in=BIO_new(BIO_s_file()); @@ -318,8 +328,6 @@ int MAIN(int argc, char **argv) goto end; } } - - /* we use md as a filter, reading from 'in' */ BIO_set_md(bmd,md); @@ -329,7 +337,7 @@ int MAIN(int argc, char **argv) { BIO_set_fp(in,stdin,BIO_NOCLOSE); err=do_fp(out, buf,inp,separator, out_bin, sigkey, sigbuf, - siglen,"","(stdin)"); + siglen,"","(stdin)",bmd,hmac_key); } else { @@ -347,14 +355,15 @@ int MAIN(int argc, char **argv) } if(!out_bin) { - size_t len = strlen(name)+strlen(argv[i])+5; + size_t len = strlen(name)+strlen(argv[i])+(hmac_key ? 5 : 0)+5; tmp=tofree=OPENSSL_malloc(len); - BIO_snprintf(tmp,len,"%s(%s)= ",name,argv[i]); + BIO_snprintf(tmp,len,"%s%s(%s)= ", + hmac_key ? "HMAC-" : "",name,argv[i]); } else tmp=""; r=do_fp(out,buf,inp,separator,out_bin,sigkey,sigbuf, - siglen,tmp,argv[i]); + siglen,tmp,argv[i],bmd,hmac_key); if(r) err=r; if(tofree) @@ -379,11 +388,21 @@ end: int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout, EVP_PKEY *key, unsigned char *sigin, int siglen, const char *title, - const char *file) + const char *file,BIO *bmd,const char *hmac_key) { - int len; + unsigned int len; int i; + EVP_MD_CTX *md_ctx; + + if (hmac_key) + { + EVP_MD *md; + BIO_get_md(bmd,&md); + HMAC_Init(&hmac_ctx,hmac_key,strlen(hmac_key),md); + BIO_get_md_ctx(bmd,&md_ctx); + BIO_set_md_ctx(bmd,&hmac_ctx.md_ctx); + } for (;;) { i=BIO_read(bp,(char *)buf,BUFSIZE); @@ -426,6 +445,11 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout, return 1; } } + else if(hmac_key) + { + HMAC_Final(&hmac_ctx,buf,&len); + HMAC_CTX_cleanup(&hmac_ctx); + } else len=BIO_gets(bp,(char *)buf,BUFSIZE); @@ -433,7 +457,7 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout, else { BIO_write(out,title,strlen(title)); - for (i=0; i +#include /* The LHASH callbacks ("hash" & "cmp") have been replaced by functions with the * base prototypes (we cast each variable inside the function to the required @@ -231,6 +232,24 @@ int main(int Argc, char *Argv[]) arg.data=NULL; arg.count=0; +#ifdef OPENSSL_FIPS + if(getenv("OPENSSL_FIPS")) { +#if defined(_WIN32) + char filename[MAX_PATH] = ""; + GetModuleFileName( NULL, filename, MAX_PATH) ; + p = filename; +#else + p = Argv[0]; +#endif + if (!FIPS_mode_set(1,p)) { + ERR_load_crypto_strings(); + ERR_print_errors(BIO_new_fp(stderr,BIO_NOCLOSE)); + exit(1); + } + if (getenv("OPENSSL_FIPS_MD5")) + FIPS_allow_md5(1); + } +#endif if (bio_err == NULL) if ((bio_err=BIO_new(BIO_s_file())) != NULL) BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); diff --git a/crypto/Makefile.ssl b/crypto/Makefile similarity index 96% rename from crypto/Makefile.ssl rename to crypto/Makefile index b9951a4600..a349537e72 100644 --- a/crypto/Makefile.ssl +++ b/crypto/Makefile @@ -11,10 +11,9 @@ CFLAG= -g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP= /usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile RM= rm -f AR= ar r @@ -52,9 +51,9 @@ top: all: shared -buildinf.h: ../Makefile.ssl +buildinf.h: ../Makefile ( echo "#ifndef MK1MF_BUILD"; \ - echo ' /* auto-generated by crypto/Makefile.ssl for crypto/cversion.c */'; \ + echo ' /* auto-generated by crypto/Makefile for crypto/cversion.c */'; \ echo ' #define CFLAGS "$(CC) $(CFLAG)"'; \ echo ' #define PLATFORM "$(PLATFORM)"'; \ echo " #define DATE \"`LC_ALL=C LC_TIME=C date`\""; \ @@ -73,7 +72,7 @@ subdirs: done; files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO @for i in $(SDIRS) ;\ do \ (cd $$i && echo "making 'files' in crypto/$$i..." && \ @@ -81,11 +80,9 @@ files: done; links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../apps $(APPS) - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @for i in $(SDIRS); do \ (cd $$i && echo "making links in crypto/$$i..." && \ $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' PERL='${PERL}' links ); \ @@ -203,6 +200,8 @@ mem_dbg.o: ../include/openssl/err.h ../include/openssl/lhash.h mem_dbg.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h mem_dbg.o: ../include/openssl/safestack.h ../include/openssl/stack.h mem_dbg.o: ../include/openssl/symhacks.h cryptlib.h mem_dbg.c +o_str.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h o_str.c +o_str.o: o_str.h o_time.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h o_time.c o_time.o: o_time.h tmdiff.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h diff --git a/crypto/aes/Makefile.ssl b/crypto/aes/Makefile similarity index 92% rename from crypto/aes/Makefile.ssl rename to crypto/aes/Makefile index f353aeb697..71087bc18f 100644 --- a/crypto/aes/Makefile.ssl +++ b/crypto/aes/Makefile @@ -11,10 +11,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP= /usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r # CFLAGS= -mpentiumpro $(INCLUDES) $(CFLAG) -O3 -fexpensive-optimizations -funroll-loops -fforce-addr @@ -49,10 +48,9 @@ lib: $(LIBOBJ) $(LIBOBJ): $(LIBSRC) files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @@ -91,7 +89,8 @@ aes_cbc.o: ../../include/openssl/opensslconf.h aes_cbc.c aes_locl.h aes_cfb.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h aes_cfb.o: ../../include/openssl/opensslconf.h aes_cfb.c aes_locl.h aes_core.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h -aes_core.o: ../../include/openssl/opensslconf.h aes_core.c aes_locl.h +aes_core.o: ../../include/openssl/fips.h ../../include/openssl/opensslconf.h +aes_core.o: aes_core.c aes_locl.h aes_ctr.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h aes_ctr.o: ../../include/openssl/opensslconf.h aes_ctr.c aes_locl.h aes_ecb.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h diff --git a/crypto/aes/aes.h b/crypto/aes/aes.h index da067f4a8f..5e177a3dd8 100644 --- a/crypto/aes/aes.h +++ b/crypto/aes/aes.h @@ -95,6 +95,15 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, const unsigned long length, const AES_KEY *key, unsigned char *ivec, int *num, const int enc); +void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc); +void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc); +void AES_cfbr_encrypt_block(const unsigned char *in,unsigned char *out, + const int nbits,const AES_KEY *key, + unsigned char *ivec,const int enc); void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, const unsigned long length, const AES_KEY *key, unsigned char *ivec, int *num); diff --git a/crypto/aes/aes_cfb.c b/crypto/aes/aes_cfb.c index 9b569dda90..2e0c41ec2b 100644 --- a/crypto/aes/aes_cfb.c +++ b/crypto/aes/aes_cfb.c @@ -155,3 +155,96 @@ void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, *num=n; } +/* This expects a single block of size nbits for both in and out. Note that + it corrupts any extra bits in the last byte of out */ +/* Untested, once it is working, it will be optimised */ +void AES_cfbr_encrypt_block(const unsigned char *in,unsigned char *out, + const int nbits,const AES_KEY *key, + unsigned char *ivec,const int enc) + { + int n; + unsigned char ovec[AES_BLOCK_SIZE*2]; + + assert(in && out && key && ivec); + if(enc) + { + /* construct the new IV */ + AES_encrypt(ivec,ovec,key); + /* encrypt the input */ + for(n=0 ; n < (nbits+7)/8 ; ++n) + out[n]=in[n]^ovec[n]; + /* fill in the first half of the new IV with the current IV */ + memcpy(ovec,ivec,AES_BLOCK_SIZE); + /* and put the ciphertext in the second half */ + memcpy(ovec+AES_BLOCK_SIZE,out,(nbits+7)/8); + /* shift ovec left most of the bits... */ + memmove(ovec,ovec+nbits/8,AES_BLOCK_SIZE+(nbits%8 ? 1 : 0)); + /* now the remaining bits */ + if(nbits%8 != 0) + for(n=0 ; n < AES_BLOCK_SIZE ; ++n) + { + ovec[n]<<=nbits%8; + ovec[n]|=ovec[n+1]>>(8-nbits%8); + } + /* finally, move it back into place */ + memcpy(ivec,ovec,AES_BLOCK_SIZE); + } + else + { + /* construct the new IV in the first half of ovec */ + AES_encrypt(ivec,ovec,key); + /* decrypt the input */ + for(n=0 ; n < (nbits+7)/8 ; ++n) + out[n]=in[n]^ovec[n]; + /* fill in the first half of the new IV with the current IV */ + memcpy(ovec,ivec,AES_BLOCK_SIZE); + /* append the ciphertext */ + memcpy(ovec+AES_BLOCK_SIZE,in,(nbits+7)/8); + /* shift ovec left most of the bits... */ + memmove(ovec,ovec+nbits/8,AES_BLOCK_SIZE+(nbits%8 ? 1 : 0)); + /* now the remaining bits */ + if(nbits%8 != 0) + for(n=0 ; n < AES_BLOCK_SIZE ; ++n) + { + ovec[n]<<=nbits%8; + ovec[n]|=ovec[n+1]>>(8-nbits%8); + } + /* finally, move it back into place */ + memcpy(ivec,ovec,AES_BLOCK_SIZE); + } + /* it is not necessary to cleanse ovec, since the IV is not secret */ + } + +/* N.B. This expects the input to be packed, MS bit first */ +void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc) + { + unsigned int n; + unsigned char c[1],d[1]; + + assert(in && out && key && ivec && num); + assert(*num == 0); + + memset(out,0,(length+7)/8); + for(n=0 ; n < length ; ++n) + { + c[0]=(in[n/8]&(1 << (7-n%8))) ? 0x80 : 0; + AES_cfbr_encrypt_block(c,d,1,key,ivec,enc); + out[n/8]=(out[n/8]&~(1 << (7-n%8)))|((d[0]&0x80) >> (n%8)); + } + } + +void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc) + { + unsigned int n; + + assert(in && out && key && ivec && num); + assert(*num == 0); + + for(n=0 ; n < length ; ++n) + AES_cfbr_encrypt_block(&in[n],&out[n],8,key,ivec,enc); + } + diff --git a/crypto/aes/aes_core.c b/crypto/aes/aes_core.c index 2f41a825f8..ed566a8123 100644 --- a/crypto/aes/aes_core.c +++ b/crypto/aes/aes_core.c @@ -37,8 +37,11 @@ #include #include +#include #include "aes_locl.h" +#ifndef OPENSSL_FIPS + /* Te0[x] = S [x].[02, 01, 01, 03]; Te1[x] = S [x].[03, 02, 01, 01]; @@ -1255,3 +1258,4 @@ void AES_decrypt(const unsigned char *in, unsigned char *out, PUTU32(out + 12, s3); } +#endif /* ndef OPENSSL_FIPS */ diff --git a/crypto/asn1/Makefile.ssl b/crypto/asn1/Makefile similarity index 99% rename from crypto/asn1/Makefile.ssl rename to crypto/asn1/Makefile index cb45194d48..61145cba5a 100644 --- a/crypto/asn1/Makefile.ssl +++ b/crypto/asn1/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -74,10 +73,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/bf/Makefile.ssl b/crypto/bf/Makefile similarity index 94% rename from crypto/bf/Makefile.ssl rename to crypto/bf/Makefile index be3ad77a05..0a2a4439dc 100644 --- a/crypto/bf/Makefile.ssl +++ b/crypto/bf/Makefile @@ -11,10 +11,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r BF_ENC= bf_enc.o @@ -65,10 +64,9 @@ asm/bx86unix.cpp: asm/bf-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl (cd asm; $(PERL) bf-586.pl cpp $(PROCESSOR) >bx86unix.cpp) files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/bio/Makefile.ssl b/crypto/bio/Makefile similarity index 98% rename from crypto/bio/Makefile.ssl rename to crypto/bio/Makefile index d0b9e297b0..7da953202d 100644 --- a/crypto/bio/Makefile.ssl +++ b/crypto/bio/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -54,10 +53,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/bio/bio.h b/crypto/bio/bio.h index fbbc16d00c..2eb703830f 100644 --- a/crypto/bio/bio.h +++ b/crypto/bio/bio.h @@ -347,6 +347,7 @@ typedef struct bio_f_buffer_ctx_struct #define BIO_C_NWRITE0 145 #define BIO_C_NWRITE 146 #define BIO_C_RESET_READ_REQUEST 147 +#define BIO_C_SET_MD_CTX 148 #define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg) diff --git a/crypto/bn/Makefile.ssl b/crypto/bn/Makefile similarity index 98% rename from crypto/bn/Makefile.ssl rename to crypto/bn/Makefile index 4e3aa0f141..76ced9f37c 100644 --- a/crypto/bn/Makefile.ssl +++ b/crypto/bn/Makefile @@ -11,10 +11,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r BN_ASM= bn_asm.o @@ -124,10 +123,9 @@ asm/pa-risc2W.o: asm/pa-risc2W.s /usr/ccs/bin/as -o asm/pa-risc2W.o asm/pa-risc2W.s files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/bn/bntest.c b/crypto/bn/bntest.c index 3c8c540387..28cd3339da 100644 --- a/crypto/bn/bntest.c +++ b/crypto/bn/bntest.c @@ -232,7 +232,7 @@ int main(int argc, char *argv[]) EXIT(0); err: BIO_puts(out,"1\n"); /* make sure the Perl script fed by bc notices - * the failure, see test_bn in test/Makefile.ssl*/ + * the failure, see test_bn in test/Makefile */ BIO_flush(out); ERR_load_crypto_strings(); ERR_print_errors_fp(stderr); diff --git a/crypto/buffer/Makefile.ssl b/crypto/buffer/Makefile similarity index 93% rename from crypto/buffer/Makefile.ssl rename to crypto/buffer/Makefile index b131ca3078..8593dce0e4 100644 --- a/crypto/buffer/Makefile.ssl +++ b/crypto/buffer/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -44,10 +43,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/cast/Makefile.ssl b/crypto/cast/Makefile similarity index 95% rename from crypto/cast/Makefile.ssl rename to crypto/cast/Makefile index 98393a37ba..f338e88ad5 100644 --- a/crypto/cast/Makefile.ssl +++ b/crypto/cast/Makefile @@ -11,10 +11,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CAST_ENC=c_enc.o @@ -68,10 +67,9 @@ asm/cx86unix.cpp: asm/cast-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl (cd asm; $(PERL) cast-586.pl cpp $(PROCESSOR) >cx86unix.cpp) files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/cast/asm/.cvsignore b/crypto/cast/asm/.cvsignore index ed39ad9fc6..d6bf08ba1b 100644 --- a/crypto/cast/asm/.cvsignore +++ b/crypto/cast/asm/.cvsignore @@ -1 +1,2 @@ cx86unix.cpp +cx86-elf.s diff --git a/crypto/comp/Makefile.ssl b/crypto/comp/Makefile similarity index 95% rename from crypto/comp/Makefile.ssl rename to crypto/comp/Makefile index f70ba1b285..1f0fcb7842 100644 --- a/crypto/comp/Makefile.ssl +++ b/crypto/comp/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -47,10 +46,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/conf/Makefile.ssl b/crypto/conf/Makefile similarity index 98% rename from crypto/conf/Makefile.ssl rename to crypto/conf/Makefile index c5873bc6e7..155cc6c8fb 100644 --- a/crypto/conf/Makefile.ssl +++ b/crypto/conf/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -47,10 +46,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c index 2924def2bb..84c1e6853f 100644 --- a/crypto/cryptlib.c +++ b/crypto/cryptlib.c @@ -66,6 +66,11 @@ static double SSLeay_MSVC5_hack=0.0; /* and for VC1.5 */ #endif +#ifdef OPENSSL_FIPS +int FIPS_mode; +void *FIPS_rand_check; +#endif /* def OPENSSL_FIPS */ + DECLARE_STACK_OF(CRYPTO_dynlock) IMPLEMENT_STACK_OF(CRYPTO_dynlock) diff --git a/crypto/crypto-lib.com b/crypto/crypto-lib.com index 39e78c69e5..a2bae06c5f 100644 --- a/crypto/crypto-lib.com +++ b/crypto/crypto-lib.com @@ -158,7 +158,7 @@ $! $ APPS_DES = "DES/DES,CBC3_ENC" $ APPS_PKCS7 = "ENC/ENC;DEC/DEC;SIGN/SIGN;VERIFY/VERIFY,EXAMPLE" $ -$ LIB_ = "cryptlib,mem,mem_clr,mem_dbg,cversion,ex_data,tmdiff,cpt_err,ebcdic,uid,o_time" +$ LIB_ = "cryptlib,mem,mem_clr,mem_dbg,cversion,ex_data,tmdiff,cpt_err,ebcdic,uid,o_time,o_str" $ LIB_MD2 = "md2_dgst,md2_one" $ LIB_MD4 = "md4_dgst,md4_one" $ LIB_MD5 = "md5_dgst,md5_one" diff --git a/crypto/des/Makefile.ssl b/crypto/des/Makefile similarity index 98% rename from crypto/des/Makefile.ssl rename to crypto/des/Makefile index 0d9ba2b42f..2d0ceda07f 100644 --- a/crypto/des/Makefile.ssl +++ b/crypto/des/Makefile @@ -11,10 +11,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r RANLIB= ranlib DES_ENC= des_enc.o fcrypt_b.o @@ -94,10 +93,9 @@ asm/yx86unix.cpp: asm/crypt586.pl ../perlasm/x86asm.pl (cd asm; $(PERL) crypt586.pl cpp >yx86unix.cpp) files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @@ -170,7 +168,7 @@ des_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h des_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h des_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h des_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h -des_enc.o: ../../include/openssl/ui_compat.h des_enc.c des_locl.h ncbc_enc.c +des_enc.o: ../../include/openssl/ui_compat.h des_enc.c des_locl.h des_old.o: ../../include/openssl/crypto.h ../../include/openssl/des.h des_old.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h des_old.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h diff --git a/crypto/des/cfb64ede.c b/crypto/des/cfb64ede.c index 60c1aa08db..f422fef1d6 100644 --- a/crypto/des/cfb64ede.c +++ b/crypto/des/cfb64ede.c @@ -140,3 +140,114 @@ void DES_ede2_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, DES_ede3_cfb64_encrypt(in,out,length,ks1,ks2,ks1,ivec,num,enc); } #endif + +/* This is compatible with the single key CFB-r for DES, even thought that's + * not what EVP needs. + */ + +void DES_ede3_cfb_encrypt(const unsigned char *in,unsigned char *out, + int numbits,long length,DES_key_schedule *ks1, + DES_key_schedule *ks2,DES_key_schedule *ks3, + DES_cblock *ivec,int enc) + { + register DES_LONG d0,d1,v0,v1; + register long l=length; + register int num=numbits,n=(numbits+7)/8,i; + DES_LONG ti[2]; + unsigned char *iv; + unsigned char ovec[16]; + + if (num > 64) return; + iv = &(*ivec)[0]; + c2l(iv,v0); + c2l(iv,v1); + if (enc) + { + while (l >= n) + { + l-=n; + ti[0]=v0; + ti[1]=v1; + DES_encrypt3(ti,ks1,ks2,ks3); + c2ln(in,d0,d1,n); + in+=n; + d0^=ti[0]; + d1^=ti[1]; + l2cn(d0,d1,out,n); + out+=n; + /* 30-08-94 - eay - changed because l>>32 and + * l<<32 are bad under gcc :-( */ + if (num == 32) + { v0=v1; v1=d0; } + else if (num == 64) + { v0=d0; v1=d1; } + else + { + iv=&ovec[0]; + l2c(v0,iv); + l2c(v1,iv); + l2c(d0,iv); + l2c(d1,iv); + /* shift ovec left most of the bits... */ + memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0)); + /* now the remaining bits */ + if(num%8 != 0) + for(i=0 ; i < 8 ; ++i) + { + ovec[i]<<=num%8; + ovec[i]|=ovec[i+1]>>(8-num%8); + } + iv=&ovec[0]; + c2l(iv,v0); + c2l(iv,v1); + } + } + } + else + { + while (l >= n) + { + l-=n; + ti[0]=v0; + ti[1]=v1; + DES_encrypt3(ti,ks1,ks2,ks3); + c2ln(in,d0,d1,n); + in+=n; + /* 30-08-94 - eay - changed because l>>32 and + * l<<32 are bad under gcc :-( */ + if (num == 32) + { v0=v1; v1=d0; } + else if (num == 64) + { v0=d0; v1=d1; } + else + { + iv=&ovec[0]; + l2c(v0,iv); + l2c(v1,iv); + l2c(d0,iv); + l2c(d1,iv); + /* shift ovec left most of the bits... */ + memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0)); + /* now the remaining bits */ + if(num%8 != 0) + for(i=0 ; i < 8 ; ++i) + { + ovec[i]<<=num%8; + ovec[i]|=ovec[i+1]>>(8-num%8); + } + iv=&ovec[0]; + c2l(iv,v0); + c2l(iv,v1); + } + d0^=ti[0]; + d1^=ti[1]; + l2cn(d0,d1,out,n); + out+=n; + } + } + iv = &(*ivec)[0]; + l2c(v0,iv); + l2c(v1,iv); + v0=v1=d0=d1=ti[0]=ti[1]=0; + } + diff --git a/crypto/des/des.h b/crypto/des/des.h index daaf239dbe..c5df1c9c7b 100644 --- a/crypto/des/des.h +++ b/crypto/des/des.h @@ -128,7 +128,7 @@ OPENSSL_DECLARE_GLOBAL(int,DES_rw_mode); /* defaults to DES_PCBC_MODE */ #define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode) const char *DES_options(void); -void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, +void DES_ecb3_encrypt(const unsigned char *input, unsigned char *output, DES_key_schedule *ks1,DES_key_schedule *ks2, DES_key_schedule *ks3, int enc); DES_LONG DES_cbc_cksum(const unsigned char *input,DES_cblock *output, @@ -187,6 +187,10 @@ void DES_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out, long length,DES_key_schedule *ks1, DES_key_schedule *ks2,DES_key_schedule *ks3, DES_cblock *ivec,int *num,int enc); +void DES_ede3_cfb_encrypt(const unsigned char *in,unsigned char *out, + int numbits,long length,DES_key_schedule *ks1, + DES_key_schedule *ks2,DES_key_schedule *ks3, + DES_cblock *ivec,int enc); void DES_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out, long length,DES_key_schedule *ks1, DES_key_schedule *ks2,DES_key_schedule *ks3, diff --git a/crypto/des/des_enc.c b/crypto/des/des_enc.c index 1c37ab96d3..8dd30e2cb7 100644 --- a/crypto/des/des_enc.c +++ b/crypto/des/des_enc.c @@ -58,6 +58,8 @@ #include "des_locl.h" +#ifndef OPENSSL_FIPS + void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) { register DES_LONG l,r,t,u; @@ -287,8 +289,12 @@ void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, data[1]=r; } +#endif /* ndef OPENSSL_FIPS */ + #ifndef DES_DEFAULT_OPTIONS +#if !defined(OPENSSL_FIPS) || !defined(I386_ONLY) + #undef CBC_ENC_C__DONT_UPDATE_IV #include "ncbc_enc.c" /* DES_ncbc_encrypt */ @@ -404,4 +410,6 @@ void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, tin[0]=tin[1]=0; } +#endif /* !defined(OPENSSL_FIPS) || !defined(I386_ONLY) */ + #endif /* DES_DEFAULT_OPTIONS */ diff --git a/crypto/des/des_old.c b/crypto/des/des_old.c index 7e4cd7180d..88e9802aad 100644 --- a/crypto/des/des_old.c +++ b/crypto/des/des_old.c @@ -84,7 +84,7 @@ void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock des_key_schedule ks1,des_key_schedule ks2, des_key_schedule ks3, int enc) { - DES_ecb3_encrypt((const_DES_cblock *)input, output, + DES_ecb3_encrypt((const unsigned char *)input, (unsigned char *)output, (DES_key_schedule *)ks1, (DES_key_schedule *)ks2, (DES_key_schedule *)ks3, enc); } diff --git a/crypto/des/destest.c b/crypto/des/destest.c index 3983ac8e5f..e3e9d77f14 100644 --- a/crypto/des/destest.c +++ b/crypto/des/destest.c @@ -439,8 +439,8 @@ int main(int argc, char *argv[]) memcpy(in,plain_data[i],8); memset(out,0,8); memset(outin,0,8); - des_ecb2_encrypt(&in,&out,ks,ks2,DES_ENCRYPT); - des_ecb2_encrypt(&out,&outin,ks,ks2,DES_DECRYPT); + des_ecb2_encrypt(in,out,ks,ks2,DES_ENCRYPT); + des_ecb2_encrypt(out,outin,ks,ks2,DES_DECRYPT); if (memcmp(out,cipher_ecb2[i],8) != 0) { diff --git a/crypto/des/ecb3_enc.c b/crypto/des/ecb3_enc.c index c3437bc606..fa0c9c4d4f 100644 --- a/crypto/des/ecb3_enc.c +++ b/crypto/des/ecb3_enc.c @@ -58,15 +58,13 @@ #include "des_locl.h" -void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, +void DES_ecb3_encrypt(const unsigned char *in, unsigned char *out, DES_key_schedule *ks1, DES_key_schedule *ks2, DES_key_schedule *ks3, int enc) { register DES_LONG l0,l1; DES_LONG ll[2]; - const unsigned char *in = &(*input)[0]; - unsigned char *out = &(*output)[0]; c2l(in,l0); c2l(in,l1); diff --git a/crypto/des/set_key.c b/crypto/des/set_key.c index 143008ed9c..8881d46a7a 100644 --- a/crypto/des/set_key.c +++ b/crypto/des/set_key.c @@ -65,6 +65,8 @@ */ #include "des_locl.h" +#ifndef OPENSSL_FIPS + OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key); /* defaults to false */ static const unsigned char odd_parity[256]={ @@ -405,3 +407,5 @@ void des_fixup_key_parity(des_cblock *key) des_set_odd_parity(key); } */ + +#endif /* ndef OPENSSL_FIPS */ diff --git a/crypto/dh/Makefile.ssl b/crypto/dh/Makefile similarity index 97% rename from crypto/dh/Makefile.ssl rename to crypto/dh/Makefile index e05fc01a12..a0e8217fa8 100644 --- a/crypto/dh/Makefile.ssl +++ b/crypto/dh/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -44,10 +43,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/dsa/Makefile.ssl b/crypto/dsa/Makefile similarity index 91% rename from crypto/dsa/Makefile.ssl rename to crypto/dsa/Makefile index e5f8a8cf51..418db981d3 100644 --- a/crypto/dsa/Makefile.ssl +++ b/crypto/dsa/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -46,10 +45,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @@ -153,19 +151,23 @@ dsa_sign.o: ../../e_os.h ../../include/openssl/asn1.h dsa_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h dsa_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h -dsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +dsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h +dsa_sign.o: ../../include/openssl/err.h ../../include/openssl/fips.h dsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h -dsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h -dsa_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +dsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h +dsa_sign.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +dsa_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h dsa_sign.o: ../cryptlib.h dsa_sign.c dsa_vrf.o: ../../e_os.h ../../include/openssl/asn1.h dsa_vrf.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h dsa_vrf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h dsa_vrf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h dsa_vrf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h -dsa_vrf.o: ../../include/openssl/err.h ../../include/openssl/lhash.h +dsa_vrf.o: ../../include/openssl/engine.h ../../include/openssl/err.h +dsa_vrf.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h dsa_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h dsa_vrf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h -dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -dsa_vrf.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_vrf.c +dsa_vrf.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h +dsa_vrf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +dsa_vrf.o: ../../include/openssl/ui.h ../cryptlib.h dsa_vrf.c diff --git a/crypto/dsa/dsa_gen.c b/crypto/dsa/dsa_gen.c index dc9c249310..e307beb3da 100644 --- a/crypto/dsa/dsa_gen.c +++ b/crypto/dsa/dsa_gen.c @@ -80,6 +80,7 @@ #include #include +#ifndef OPENSSL_FIPS DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len, int *counter_ret, unsigned long *h_ret, @@ -293,4 +294,6 @@ err: if (mont != NULL) BN_MONT_CTX_free(mont); return(ok?ret:NULL); } -#endif +#endif /* ndef OPENSSL_FIPS */ +#endif /* ndef OPENSSL_NO_SHA */ + diff --git a/crypto/dsa/dsa_key.c b/crypto/dsa/dsa_key.c index ef87c3e637..30607ca579 100644 --- a/crypto/dsa/dsa_key.c +++ b/crypto/dsa/dsa_key.c @@ -64,6 +64,7 @@ #include #include +#ifndef OPENSSL_FIPS int DSA_generate_key(DSA *dsa) { int ok=0; @@ -103,3 +104,4 @@ err: return(ok); } #endif +#endif diff --git a/crypto/dsa/dsa_ossl.c b/crypto/dsa/dsa_ossl.c index b9e7f3ea5c..f1a85afcde 100644 --- a/crypto/dsa/dsa_ossl.c +++ b/crypto/dsa/dsa_ossl.c @@ -65,6 +65,7 @@ #include #include +#ifndef OPENSSL_FIPS static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, @@ -346,3 +347,4 @@ static int dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p, { return BN_mod_exp_mont(r, a, p, m, ctx, m_ctx); } +#endif diff --git a/crypto/dsa/dsa_sign.c b/crypto/dsa/dsa_sign.c index 89205026f0..1821adf3d6 100644 --- a/crypto/dsa/dsa_sign.c +++ b/crypto/dsa/dsa_sign.c @@ -64,9 +64,17 @@ #include #include #include +#ifndef OPENSSL_NO_ENGINE +#include +#endif +#include DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) { +#ifdef OPENSSL_FIPS + if(FIPS_mode && !FIPS_dsa_check(dsa)) + return NULL; +#endif return dsa->meth->dsa_do_sign(dgst, dlen, dsa); } @@ -87,6 +95,10 @@ int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) { +#ifdef OPENSSL_FIPS + if(FIPS_mode && !FIPS_dsa_check(dsa)) + return 0; +#endif return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp); } diff --git a/crypto/dsa/dsa_vrf.c b/crypto/dsa/dsa_vrf.c index c4aeddd056..493bdd07cd 100644 --- a/crypto/dsa/dsa_vrf.c +++ b/crypto/dsa/dsa_vrf.c @@ -65,10 +65,18 @@ #include #include #include +#ifndef OPENSSL_NO_ENGINE +#include +#endif +#include int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa) { +#ifdef OPENSSL_FIPS + if(FIPS_mode && !FIPS_dsa_check(dsa)) + return -1; +#endif return dsa->meth->dsa_do_verify(dgst, dgst_len, sig, dsa); } diff --git a/crypto/dso/Makefile.ssl b/crypto/dso/Makefile similarity index 97% rename from crypto/dso/Makefile.ssl rename to crypto/dso/Makefile index c0449d184e..dd8d243485 100644 --- a/crypto/dso/Makefile.ssl +++ b/crypto/dso/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -46,10 +45,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/ec/Makefile.ssl b/crypto/ec/Makefile similarity index 96% rename from crypto/ec/Makefile.ssl rename to crypto/ec/Makefile index a2805c47a2..92272f2881 100644 --- a/crypto/ec/Makefile.ssl +++ b/crypto/ec/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -47,10 +46,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/engine/Makefile.ssl b/crypto/engine/Makefile similarity index 99% rename from crypto/engine/Makefile.ssl rename to crypto/engine/Makefile index 30a4446ff9..61942acf6d 100644 --- a/crypto/engine/Makefile.ssl +++ b/crypto/engine/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -54,10 +53,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/engine/hw_cryptodev.c b/crypto/engine/hw_cryptodev.c index 467c0daa1b..d4832310ea 100644 --- a/crypto/engine/hw_cryptodev.c +++ b/crypto/engine/hw_cryptodev.c @@ -77,7 +77,7 @@ static int cryptodev_max_iv(int cipher); static int cryptodev_key_length_valid(int cipher, int len); static int cipher_nid_to_cryptodev(int nid); static int get_cryptodev_ciphers(const int **cnids); -static int get_cryptodev_digests(const int **cnids); +/*static int get_cryptodev_digests(const int **cnids);*/ static int cryptodev_usable_ciphers(const int **nids); static int cryptodev_usable_digests(const int **nids); static int cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, @@ -137,6 +137,7 @@ static struct { { 0, NID_undef, 0, 0, }, }; +#if 0 /* UNUSED */ static struct { int id; int nid; @@ -149,6 +150,7 @@ static struct { { CRYPTO_SHA1, NID_undef, }, { 0, NID_undef, }, }; +#endif /* * Return a fd if /dev/crypto seems usable, 0 otherwise. @@ -289,6 +291,7 @@ get_cryptodev_ciphers(const int **cnids) * returning them here is harmless, as long as we return NULL * when asked for a handler in the cryptodev_engine_digests routine */ +#if 0 /* UNUSED */ static int get_cryptodev_digests(const int **cnids) { @@ -318,6 +321,7 @@ get_cryptodev_digests(const int **cnids) *cnids = NULL; return (count); } +#endif /* * Find the useable ciphers|digests from dev/crypto - this is the first @@ -623,7 +627,7 @@ static int bn2crparam(const BIGNUM *a, struct crparam *crp) { int i, j, k; - ssize_t words, bytes, bits; + ssize_t bytes, bits; u_char *b; crp->crp_p = NULL; diff --git a/crypto/err/Makefile.ssl b/crypto/err/Makefile similarity index 69% rename from crypto/err/Makefile.ssl rename to crypto/err/Makefile index b253061d07..10a69fcbe8 100644 --- a/crypto/err/Makefile.ssl +++ b/crypto/err/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -44,10 +43,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @@ -94,22 +92,23 @@ err_all.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h err_all.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h err_all.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h err_all.o: ../../include/openssl/engine.h ../../include/openssl/err.h -err_all.o: ../../include/openssl/evp.h ../../include/openssl/idea.h -err_all.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h -err_all.o: ../../include/openssl/md4.h ../../include/openssl/md5.h -err_all.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h -err_all.o: ../../include/openssl/objects.h ../../include/openssl/ocsp.h -err_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h -err_all.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem2.h -err_all.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h -err_all.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h -err_all.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h -err_all.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h -err_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h -err_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -err_all.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -err_all.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h -err_all.o: ../../include/openssl/x509v3.h err_all.c +err_all.o: ../../include/openssl/evp.h ../../include/openssl/fips.h +err_all.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h +err_all.o: ../../include/openssl/md2.h ../../include/openssl/md4.h +err_all.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h +err_all.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h +err_all.o: ../../include/openssl/ocsp.h ../../include/openssl/opensslconf.h +err_all.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h +err_all.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs12.h +err_all.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h +err_all.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h +err_all.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h +err_all.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h +err_all.o: ../../include/openssl/sha.h ../../include/openssl/stack.h +err_all.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h +err_all.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h +err_all.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h +err_all.o: err_all.c err_prn.o: ../../e_os.h ../../include/openssl/bio.h err_prn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h err_prn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h diff --git a/crypto/err/err.h b/crypto/err/err.h index 8faa3a7b4f..723c1f5314 100644 --- a/crypto/err/err.h +++ b/crypto/err/err.h @@ -131,6 +131,7 @@ typedef struct err_state_st #define ERR_LIB_OCSP 39 #define ERR_LIB_UI 40 #define ERR_LIB_COMP 41 +#define ERR_LIB_FIPS 42 #define ERR_LIB_USER 128 @@ -159,6 +160,7 @@ typedef struct err_state_st #define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__) #define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__) #define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__) +#define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),__FILE__,__LINE__) /* Borland C seems too stupid to be able to shift and do longs in * the pre-processor :-( */ diff --git a/crypto/err/err_all.c b/crypto/err/err_all.c index dc505d9d9d..4dc9300892 100644 --- a/crypto/err/err_all.c +++ b/crypto/err/err_all.c @@ -87,6 +87,7 @@ #endif #include #include +#include void ERR_load_crypto_strings(void) { @@ -129,5 +130,8 @@ void ERR_load_crypto_strings(void) #endif ERR_load_OCSP_strings(); ERR_load_UI_strings(); +#endif +#ifdef OPENSSL_FIPS + ERR_load_FIPS_strings(); #endif } diff --git a/crypto/err/openssl.ec b/crypto/err/openssl.ec index 29a69dfdd4..447a7f87ed 100644 --- a/crypto/err/openssl.ec +++ b/crypto/err/openssl.ec @@ -27,6 +27,7 @@ L DSO crypto/dso/dso.h crypto/dso/dso_err.c L ENGINE crypto/engine/engine.h crypto/engine/eng_err.c L OCSP crypto/ocsp/ocsp.h crypto/ocsp/ocsp_err.c L UI crypto/ui/ui.h crypto/ui/ui_err.c +L FIPS fips/fips.h fips/fips_err.h # additional header files to be scanned for function names L NONE crypto/x509/x509_vfy.h NONE diff --git a/crypto/evp/Makefile.ssl b/crypto/evp/Makefile similarity index 99% rename from crypto/evp/Makefile.ssl rename to crypto/evp/Makefile index f33aebd33a..af5e139f0d 100644 --- a/crypto/evp/Makefile.ssl +++ b/crypto/evp/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -64,10 +63,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) cp $(TESTDATA) ../../test diff --git a/crypto/evp/bio_md.c b/crypto/evp/bio_md.c index c632dfb202..53f1f56cad 100644 --- a/crypto/evp/bio_md.c +++ b/crypto/evp/bio_md.c @@ -199,6 +199,12 @@ static long md_ctrl(BIO *b, int cmd, long num, void *ptr) else ret=0; break; + case BIO_C_SET_MD_CTX: + if (b->init) + b->ptr=ptr; + else + ret=0; + break; case BIO_C_DO_STATE_MACHINE: BIO_clear_retry_flags(b); ret=BIO_ctrl(b->next_bio,cmd,num,ptr); diff --git a/crypto/evp/c_allc.c b/crypto/evp/c_allc.c index 341a958fd4..fc96812365 100644 --- a/crypto/evp/c_allc.c +++ b/crypto/evp/c_allc.c @@ -67,6 +67,8 @@ void OpenSSL_add_all_ciphers(void) #ifndef OPENSSL_NO_DES EVP_add_cipher(EVP_des_cfb()); + EVP_add_cipher(EVP_des_cfb1()); + EVP_add_cipher(EVP_des_cfb8()); EVP_add_cipher(EVP_des_ede_cfb()); EVP_add_cipher(EVP_des_ede3_cfb()); @@ -150,6 +152,8 @@ void OpenSSL_add_all_ciphers(void) EVP_add_cipher(EVP_aes_128_ecb()); EVP_add_cipher(EVP_aes_128_cbc()); EVP_add_cipher(EVP_aes_128_cfb()); + EVP_add_cipher(EVP_aes_128_cfb1()); + EVP_add_cipher(EVP_aes_128_cfb8()); EVP_add_cipher(EVP_aes_128_ofb()); #if 0 EVP_add_cipher(EVP_aes_128_ctr()); @@ -159,6 +163,8 @@ void OpenSSL_add_all_ciphers(void) EVP_add_cipher(EVP_aes_192_ecb()); EVP_add_cipher(EVP_aes_192_cbc()); EVP_add_cipher(EVP_aes_192_cfb()); + EVP_add_cipher(EVP_aes_192_cfb1()); + EVP_add_cipher(EVP_aes_192_cfb8()); EVP_add_cipher(EVP_aes_192_ofb()); #if 0 EVP_add_cipher(EVP_aes_192_ctr()); @@ -168,6 +174,8 @@ void OpenSSL_add_all_ciphers(void) EVP_add_cipher(EVP_aes_256_ecb()); EVP_add_cipher(EVP_aes_256_cbc()); EVP_add_cipher(EVP_aes_256_cfb()); + EVP_add_cipher(EVP_aes_256_cfb1()); + EVP_add_cipher(EVP_aes_256_cfb8()); EVP_add_cipher(EVP_aes_256_ofb()); #if 0 EVP_add_cipher(EVP_aes_256_ctr()); diff --git a/crypto/evp/e_aes.c b/crypto/evp/e_aes.c index fe8bcda631..9844d7f9bc 100644 --- a/crypto/evp/e_aes.c +++ b/crypto/evp/e_aes.c @@ -84,17 +84,35 @@ IMPLEMENT_BLOCK_CIPHER(aes_256, ks, AES, EVP_AES_KEY, EVP_CIPHER_get_asn1_iv, NULL) +#define IMPLEMENT_AES_CFBR(ksize,cbits) IMPLEMENT_CFBR(aes,AES,EVP_AES_KEY,ks,ksize,cbits,16) + +IMPLEMENT_AES_CFBR(128,1) +IMPLEMENT_AES_CFBR(192,1) +IMPLEMENT_AES_CFBR(256,1) + +IMPLEMENT_AES_CFBR(128,8) +IMPLEMENT_AES_CFBR(192,8) +IMPLEMENT_AES_CFBR(256,8) + static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, - const unsigned char *iv, int enc) { + const unsigned char *iv, int enc) + { + int ret; if ((ctx->cipher->flags & EVP_CIPH_MODE) == EVP_CIPH_CFB_MODE || (ctx->cipher->flags & EVP_CIPH_MODE) == EVP_CIPH_OFB_MODE || enc) - AES_set_encrypt_key(key, ctx->key_len * 8, ctx->cipher_data); + ret=AES_set_encrypt_key(key, ctx->key_len * 8, ctx->cipher_data); else - AES_set_decrypt_key(key, ctx->key_len * 8, ctx->cipher_data); + ret=AES_set_decrypt_key(key, ctx->key_len * 8, ctx->cipher_data); + + if(ret < 0) + { + EVPerr(EVP_F_AES_INIT_KEY,EVP_R_AES_KEY_SETUP_FAILED); + return 0; + } return 1; -} + } #endif diff --git a/crypto/evp/e_des.c b/crypto/evp/e_des.c index 105266a4b3..f2554ecc6a 100644 --- a/crypto/evp/e_des.c +++ b/crypto/evp/e_des.c @@ -56,9 +56,9 @@ * [including the GNU Public Licence.] */ -#ifndef OPENSSL_NO_DES #include #include "cryptlib.h" +#ifndef OPENSSL_NO_DES #include #include #include "evp_locl.h" @@ -92,20 +92,53 @@ static int des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, return 1; } -static int des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, unsigned int inl) +static int des_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + const unsigned char *in, unsigned int inl) { DES_cfb64_encrypt(in, out, (long)inl, ctx->cipher_data, (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt); return 1; } +/* Although we have a CFB-r implementation for DES, it doesn't pack the right + way, so wrap it here */ +static int des_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + const unsigned char *in, unsigned int inl) + { + unsigned int n; + unsigned char c[1],d[1]; + + for(n=0 ; n < inl ; ++n) + { + c[0]=(in[n/8]&(1 << (7-n%8))) ? 0x80 : 0; + DES_cfb_encrypt(c,d,1,1,ctx->cipher_data,(DES_cblock *)ctx->iv, + ctx->encrypt); + out[n/8]=(out[n/8]&~(0x80 >> (n%8)))|((d[0]&0x80) >> (n%8)); + } + return 1; + } + +static int des_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + const unsigned char *in, unsigned int inl) + { + DES_cfb_encrypt(in,out,8,inl,ctx->cipher_data,(DES_cblock *)ctx->iv, + ctx->encrypt); + return 1; + } + BLOCK_CIPHER_defs(des, DES_key_schedule, NID_des, 8, 8, 8, 64, 0, des_init_key, NULL, EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL) +BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,1,0,des_init_key,NULL, + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv,NULL) + +BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,8,0,des_init_key,NULL, + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv,NULL) static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) diff --git a/crypto/evp/e_des3.c b/crypto/evp/e_des3.c index 077860e7b6..b462d7c6af 100644 --- a/crypto/evp/e_des3.c +++ b/crypto/evp/e_des3.c @@ -56,9 +56,9 @@ * [including the GNU Public Licence.] */ -#ifndef OPENSSL_NO_DES #include #include "cryptlib.h" +#ifndef OPENSSL_NO_DES #include #include #include "evp_locl.h" @@ -85,7 +85,7 @@ static int des_ede_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) { BLOCK_CIPHER_ecb_loop() - DES_ecb3_encrypt((DES_cblock *)(in + i), (DES_cblock *)(out + i), + DES_ecb3_encrypt(in + i,out + i, &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, ctx->encrypt); @@ -121,7 +121,7 @@ static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, return 1; } -static int des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, +static int des_ede_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) { DES_ede3_cfb64_encrypt(in, out, (long)inl, @@ -130,13 +130,42 @@ static int des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, return 1; } +/* Although we have a CFB-r implementation for 3-DES, it doesn't pack the right + way, so wrap it here */ +static int des_ede3_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + const unsigned char *in, unsigned int inl) + { + unsigned int n; + unsigned char c[1],d[1]; + + for(n=0 ; n < inl ; ++n) + { + c[0]=(in[n/8]&(1 << (7-n%8))) ? 0x80 : 0; + DES_ede3_cfb_encrypt(c,d,1,1, + &data(ctx)->ks1,&data(ctx)->ks2,&data(ctx)->ks3, + (DES_cblock *)ctx->iv,ctx->encrypt); + out[n/8]=(out[n/8]&~(0x80 >> (n%8)))|((d[0]&0x80) >> (n%8)); + } + + return 1; + } + +static int des_ede3_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + const unsigned char *in, unsigned int inl) + { + DES_ede3_cfb_encrypt(in,out,8,inl, + &data(ctx)->ks1,&data(ctx)->ks2,&data(ctx)->ks3, + (DES_cblock *)ctx->iv,ctx->encrypt); + return 1; + } + BLOCK_CIPHER_defs(des_ede, DES_EDE_KEY, NID_des_ede, 8, 16, 8, 64, 0, des_ede_init_key, NULL, EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL) -#define des_ede3_cfb_cipher des_ede_cfb_cipher +#define des_ede3_cfb64_cipher des_ede_cfb64_cipher #define des_ede3_ofb_cipher des_ede_ofb_cipher #define des_ede3_cbc_cipher des_ede_cbc_cipher #define des_ede3_ecb_cipher des_ede_ecb_cipher @@ -147,6 +176,16 @@ BLOCK_CIPHER_defs(des_ede3, DES_EDE_KEY, NID_des_ede3, 8, 24, 8, 64, EVP_CIPHER_get_asn1_iv, NULL) +BLOCK_CIPHER_def_cfb(des_ede3,DES_EDE_KEY,NID_des_ede3,24,8,1,0, + des_ede3_init_key,NULL, + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv,NULL) + +BLOCK_CIPHER_def_cfb(des_ede3,DES_EDE_KEY,NID_des_ede3,24,8,8,0, + des_ede3_init_key,NULL, + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv,NULL) + static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { diff --git a/crypto/evp/evp.h b/crypto/evp/evp.h index 4801d8eaa3..115878ff17 100644 --- a/crypto/evp/evp.h +++ b/crypto/evp/evp.h @@ -499,6 +499,7 @@ void BIO_set_md(BIO *,const EVP_MD *md); #endif #define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp) #define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp) +#define BIO_set_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_SET_MD_CTX,0,(char *)mdcp) #define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL) #define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp) @@ -640,9 +641,20 @@ const EVP_CIPHER *EVP_des_ede(void); const EVP_CIPHER *EVP_des_ede3(void); const EVP_CIPHER *EVP_des_ede_ecb(void); const EVP_CIPHER *EVP_des_ede3_ecb(void); -const EVP_CIPHER *EVP_des_cfb(void); -const EVP_CIPHER *EVP_des_ede_cfb(void); -const EVP_CIPHER *EVP_des_ede3_cfb(void); +const EVP_CIPHER *EVP_des_cfb64(void); +# define EVP_des_cfb EVP_des_cfb64 +const EVP_CIPHER *EVP_des_cfb1(void); +const EVP_CIPHER *EVP_des_cfb8(void); +const EVP_CIPHER *EVP_des_ede_cfb64(void); +# define EVP_des_ede_cfb EVP_des_ede_cfb64 +#if 0 +const EVP_CIPHER *EVP_des_ede_cfb1(void); +const EVP_CIPHER *EVP_des_ede_cfb8(void); +#endif +const EVP_CIPHER *EVP_des_ede3_cfb64(void); +# define EVP_des_ede3_cfb EVP_des_ede3_cfb64 +const EVP_CIPHER *EVP_des_ede3_cfb1(void); +const EVP_CIPHER *EVP_des_ede3_cfb8(void); const EVP_CIPHER *EVP_des_ofb(void); const EVP_CIPHER *EVP_des_ede_ofb(void); const EVP_CIPHER *EVP_des_ede3_ofb(void); @@ -666,7 +678,8 @@ const EVP_CIPHER *EVP_rc4_40(void); #endif #ifndef OPENSSL_NO_IDEA const EVP_CIPHER *EVP_idea_ecb(void); -const EVP_CIPHER *EVP_idea_cfb(void); +const EVP_CIPHER *EVP_idea_cfb64(void); +# define EVP_idea_cfb EVP_idea_cfb64 const EVP_CIPHER *EVP_idea_ofb(void); const EVP_CIPHER *EVP_idea_cbc(void); #endif @@ -675,45 +688,58 @@ const EVP_CIPHER *EVP_rc2_ecb(void); const EVP_CIPHER *EVP_rc2_cbc(void); const EVP_CIPHER *EVP_rc2_40_cbc(void); const EVP_CIPHER *EVP_rc2_64_cbc(void); -const EVP_CIPHER *EVP_rc2_cfb(void); +const EVP_CIPHER *EVP_rc2_cfb64(void); +# define EVP_rc2_cfb EVP_rc2_cfb64 const EVP_CIPHER *EVP_rc2_ofb(void); #endif #ifndef OPENSSL_NO_BF const EVP_CIPHER *EVP_bf_ecb(void); const EVP_CIPHER *EVP_bf_cbc(void); -const EVP_CIPHER *EVP_bf_cfb(void); +const EVP_CIPHER *EVP_bf_cfb64(void); +# define EVP_bf_cfb EVP_bf_cfb64 const EVP_CIPHER *EVP_bf_ofb(void); #endif #ifndef OPENSSL_NO_CAST const EVP_CIPHER *EVP_cast5_ecb(void); const EVP_CIPHER *EVP_cast5_cbc(void); -const EVP_CIPHER *EVP_cast5_cfb(void); +const EVP_CIPHER *EVP_cast5_cfb64(void); +# define EVP_cast5_cfb EVP_cast5_cfb64 const EVP_CIPHER *EVP_cast5_ofb(void); #endif #ifndef OPENSSL_NO_RC5 const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void); const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void); -const EVP_CIPHER *EVP_rc5_32_12_16_cfb(void); +const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void); +# define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64 const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void); #endif #ifndef OPENSSL_NO_AES const EVP_CIPHER *EVP_aes_128_ecb(void); const EVP_CIPHER *EVP_aes_128_cbc(void); -const EVP_CIPHER *EVP_aes_128_cfb(void); +const EVP_CIPHER *EVP_aes_128_cfb1(void); +const EVP_CIPHER *EVP_aes_128_cfb8(void); +const EVP_CIPHER *EVP_aes_128_cfb128(void); +# define EVP_aes_128_cfb EVP_aes_128_cfb128 const EVP_CIPHER *EVP_aes_128_ofb(void); #if 0 const EVP_CIPHER *EVP_aes_128_ctr(void); #endif const EVP_CIPHER *EVP_aes_192_ecb(void); const EVP_CIPHER *EVP_aes_192_cbc(void); -const EVP_CIPHER *EVP_aes_192_cfb(void); +const EVP_CIPHER *EVP_aes_192_cfb1(void); +const EVP_CIPHER *EVP_aes_192_cfb8(void); +const EVP_CIPHER *EVP_aes_192_cfb128(void); +# define EVP_aes_192_cfb EVP_aes_192_cfb128 const EVP_CIPHER *EVP_aes_192_ofb(void); #if 0 const EVP_CIPHER *EVP_aes_192_ctr(void); #endif const EVP_CIPHER *EVP_aes_256_ecb(void); const EVP_CIPHER *EVP_aes_256_cbc(void); -const EVP_CIPHER *EVP_aes_256_cfb(void); +const EVP_CIPHER *EVP_aes_256_cfb1(void); +const EVP_CIPHER *EVP_aes_256_cfb8(void); +const EVP_CIPHER *EVP_aes_256_cfb128(void); +# define EVP_aes_256_cfb EVP_aes_256_cfb128 const EVP_CIPHER *EVP_aes_256_ofb(void); #if 0 const EVP_CIPHER *EVP_aes_256_ctr(void); @@ -825,6 +851,7 @@ void ERR_load_EVP_strings(void); /* Error codes for the EVP functions. */ /* Function codes. */ +#define EVP_F_AES_INIT_KEY 129 #define EVP_F_D2I_PKEY 100 #define EVP_F_EVP_CIPHERINIT 123 #define EVP_F_EVP_CIPHER_CTX_CTRL 124 @@ -855,6 +882,7 @@ void ERR_load_EVP_strings(void); #define EVP_F_RC5_CTRL 125 /* Reason codes. */ +#define EVP_R_AES_KEY_SETUP_FAILED 140 #define EVP_R_BAD_BLOCK_LENGTH 136 #define EVP_R_BAD_DECRYPT 100 #define EVP_R_BAD_KEY_LENGTH 137 diff --git a/crypto/evp/evp_err.c b/crypto/evp/evp_err.c index 3a23d21c21..be6d442521 100644 --- a/crypto/evp/evp_err.c +++ b/crypto/evp/evp_err.c @@ -1,6 +1,6 @@ /* crypto/evp/evp_err.c */ /* ==================================================================== - * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * Copyright (c) 1999-2002 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 @@ -66,6 +66,7 @@ #ifndef OPENSSL_NO_ERR static ERR_STRING_DATA EVP_str_functs[]= { +{ERR_PACK(0,EVP_F_AES_INIT_KEY,0), "AES_INIT_KEY"}, {ERR_PACK(0,EVP_F_D2I_PKEY,0), "D2I_PKEY"}, {ERR_PACK(0,EVP_F_EVP_CIPHERINIT,0), "EVP_CipherInit"}, {ERR_PACK(0,EVP_F_EVP_CIPHER_CTX_CTRL,0), "EVP_CIPHER_CTX_ctrl"}, @@ -99,6 +100,7 @@ static ERR_STRING_DATA EVP_str_functs[]= static ERR_STRING_DATA EVP_str_reasons[]= { +{EVP_R_AES_KEY_SETUP_FAILED ,"aes key setup failed"}, {EVP_R_BAD_BLOCK_LENGTH ,"bad block length"}, {EVP_R_BAD_DECRYPT ,"bad decrypt"}, {EVP_R_BAD_KEY_LENGTH ,"bad key length"}, diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c index 52a3b287be..f14028dc31 100644 --- a/crypto/evp/evp_lib.c +++ b/crypto/evp/evp_lib.c @@ -133,6 +133,30 @@ int EVP_CIPHER_type(const EVP_CIPHER *ctx) return NID_rc4; + case NID_aes_128_cfb128: + case NID_aes_128_cfb8: + case NID_aes_128_cfb1: + + return NID_aes_128_cfb128; + + case NID_aes_192_cfb128: + case NID_aes_192_cfb8: + case NID_aes_192_cfb1: + + return NID_aes_192_cfb128; + + case NID_aes_256_cfb128: + case NID_aes_256_cfb8: + case NID_aes_256_cfb1: + + return NID_aes_256_cfb128; + + case NID_des_cfb64: + case NID_des_cfb8: + case NID_des_cfb1: + + return NID_des_cfb64; + default: /* Check it has an OID and it is valid */ otmp = OBJ_nid2obj(nid); diff --git a/crypto/evp/evp_locl.h b/crypto/evp/evp_locl.h index 4d81a3bf4c..2204e345ad 100644 --- a/crypto/evp/evp_locl.h +++ b/crypto/evp/evp_locl.h @@ -90,7 +90,7 @@ static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const uns } #define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ -static int cname##_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ +static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ {\ cprefix##_cfb##cbits##_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num, ctx->encrypt);\ return 1;\ @@ -127,7 +127,7 @@ BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \ #define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, \ iv_len, cbits, flags, init_key, cleanup, \ set_asn1, get_asn1, ctrl) \ -BLOCK_CIPHER_def1(cname, cfb##cbits, cfb, CFB, kstruct, nid, 1, \ +BLOCK_CIPHER_def1(cname, cfb##cbits, cfb##cbits, CFB, kstruct, nid, 1, \ key_len, iv_len, flags, init_key, cleanup, set_asn1, \ get_asn1, ctrl) @@ -225,3 +225,12 @@ const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; } get_asn1, ctrl) #define EVP_C_DATA(kstruct, ctx) ((kstruct *)(ctx)->cipher_data) + +#define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len) \ + BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \ + BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \ + NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \ + 0, cipher##_init_key, NULL, \ + EVP_CIPHER_set_asn1_iv, \ + EVP_CIPHER_get_asn1_iv, \ + NULL) diff --git a/crypto/evp/evp_test.c b/crypto/evp/evp_test.c index 28460173f7..7d256e695b 100644 --- a/crypto/evp/evp_test.c +++ b/crypto/evp/evp_test.c @@ -136,7 +136,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, const unsigned char *iv,int in, const unsigned char *plaintext,int pn, const unsigned char *ciphertext,int cn, - int encdec) + int encdec,int multiplier) { EVP_CIPHER_CTX ctx; unsigned char out[4096]; @@ -166,7 +166,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, } EVP_CIPHER_CTX_set_padding(&ctx,0); - if(!EVP_EncryptUpdate(&ctx,out,&outl,plaintext,pn)) + if(!EVP_EncryptUpdate(&ctx,out,&outl,plaintext,pn*multiplier)) { fprintf(stderr,"Encrypt failed\n"); test1_exit(6); @@ -177,7 +177,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, test1_exit(7); } - if(outl+outl2 != cn) + if(outl+outl2 != cn*multiplier) { fprintf(stderr,"Ciphertext length mismatch got %d expected %d\n", outl+outl2,cn); @@ -202,7 +202,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, } EVP_CIPHER_CTX_set_padding(&ctx,0); - if(!EVP_DecryptUpdate(&ctx,out,&outl,ciphertext,cn)) + if(!EVP_DecryptUpdate(&ctx,out,&outl,ciphertext,cn*multiplier)) { fprintf(stderr,"Decrypt failed\n"); test1_exit(6); @@ -213,7 +213,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, test1_exit(7); } - if(outl+outl2 != cn) + if(outl+outl2 != cn*multiplier) { fprintf(stderr,"Plaintext length mismatch got %d expected %d\n", outl+outl2,cn); @@ -238,7 +238,7 @@ static int test_cipher(const char *cipher,const unsigned char *key,int kn, const unsigned char *iv,int in, const unsigned char *plaintext,int pn, const unsigned char *ciphertext,int cn, - int encdec) + int encdec,int multiplier) { const EVP_CIPHER *c; @@ -246,7 +246,7 @@ static int test_cipher(const char *cipher,const unsigned char *key,int kn, if(!c) return 0; - test1(c,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec); + test1(c,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec,multiplier); return 1; } @@ -359,6 +359,7 @@ int main(int argc,char **argv) unsigned char *iv,*key,*plaintext,*ciphertext; int encdec; int kn,in,pn,cn; + int multiplier=1; if(!fgets((char *)line,sizeof line,f)) break; @@ -383,7 +384,15 @@ int main(int argc,char **argv) pn=convert(plaintext); cn=convert(ciphertext); - if(!test_cipher(cipher,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec) + if(strchr(cipher,'*')) + { + p=cipher; + sstrsep(&p,"*"); + multiplier=atoi(sstrsep(&p,"*")); + } + + if(!test_cipher(cipher,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec, + multiplier) && !test_digest(cipher,plaintext,pn,ciphertext,cn)) { fprintf(stderr,"Can't find %s\n",cipher); diff --git a/crypto/evp/evptests.txt b/crypto/evp/evptests.txt index 80bd9c7765..dfe91a5bc0 100644 --- a/crypto/evp/evptests.txt +++ b/crypto/evp/evptests.txt @@ -92,7 +92,102 @@ AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000 AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:F58C4C04D6E5F1BA779EABFB5F7BFBD6:AE2D8A571E03AC9C9EB76FAC45AF8E51:9CFC4E967EDB808D679F777BC6702C7D AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:9CFC4E967EDB808D679F777BC6702C7D:30C81C46A35CE411E5FBC1191A0A52EF:39F23369A9D9BACFA530E26304231461 AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:39F23369A9D9BACFA530E26304231461:F69F2445DF4F9B17AD2B417BE66C3710:B2EB05E2C39BE9FCDA6C19078C6A9D1B -# We don't support CFB{1,8}-AESxxx.{En,De}crypt + +# CFB1-AES128.Encrypt + +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:00:00:1 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:00020406080a0c0e10121416181a1c1e:80:80:1 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:0004080c1014181c2024282c3034383d:80:80:1 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:0008101820283038404850586068707b:00:00:1 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:00102030405060708090a0b0c0d0e0f6:80:80:1 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:0020406080a0c0e10121416181a1c1ed:00:00:1 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:004080c1014181c2024282c3034383da:80:00:1 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:008101820283038404850586068707b4:80:00:1 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:0102030405060708090a0b0c0d0e0f68:80:80:1 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:020406080a0c0e10121416181a1c1ed1:80:00:1 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:04080c1014181c2024282c3034383da2:00:80:1 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:08101820283038404850586068707b45:00:80:1 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:102030405060708090a0b0c0d0e0f68b:00:00:1 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:20406080a0c0e10121416181a1c1ed16:00:00:1 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:4080c1014181c2024282c3034383da2c:00:80:1 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:8101820283038404850586068707b459:80:80:1 +# all of the above packed into one... +# in: 0110 1011 1100 0001 = 6bc1 +# out: 0110 1000 1011 0011 = 68b3 +AES-128-CFB1*8:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:6bc1:68b3:1 + +# CFB1-AES128.Decrypt +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:00:00:0 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:00020406080a0c0e10121416181a1c1e:80:80:0 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:0004080c1014181c2024282c3034383d:80:80:0 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:0008101820283038404850586068707b:00:00:0 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:00102030405060708090a0b0c0d0e0f6:80:80:0 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:0020406080a0c0e10121416181a1c1ed:00:00:0 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:004080c1014181c2024282c3034383da:80:00:0 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:008101820283038404850586068707b4:80:00:0 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:0102030405060708090a0b0c0d0e0f68:80:80:0 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:020406080a0c0e10121416181a1c1ed1:80:00:0 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:04080c1014181c2024282c3034383da2:00:80:0 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:08101820283038404850586068707b45:00:80:0 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:102030405060708090a0b0c0d0e0f68b:00:00:0 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:20406080a0c0e10121416181a1c1ed16:00:00:0 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:4080c1014181c2024282c3034383da2c:00:80:0 +AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:8101820283038404850586068707b459:80:80:0 +# all of the above packed into one... +# in: 0110 1000 1011 0011 = 68b3 +# out: 0110 1011 1100 0001 = 6bc1 +AES-128-CFB1*8:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:6bc1:68b3:0 + +# TODO: CFB1-AES192 and 256 + +# CFB8-AES128.Encrypt + +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:6b:3b:1 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0102030405060708090a0b0c0d0e0f3b:c1:79:1 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:02030405060708090a0b0c0d0e0f3b79:be:42:1 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:030405060708090a0b0c0d0e0f3b7942:e2:4c:1 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0405060708090a0b0c0d0e0f3b79424c:2e:9c:1 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:05060708090a0b0c0d0e0f3b79424c9c:40:0d:1 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:060708090a0b0c0d0e0f3b79424c9c0d:9f:d4:1 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0708090a0b0c0d0e0f3b79424c9c0dd4:96:36:1 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:08090a0b0c0d0e0f3b79424c9c0dd436:e9:ba:1 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:090a0b0c0d0e0f3b79424c9c0dd436ba:3d:ce:1 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0a0b0c0d0e0f3b79424c9c0dd436bace:7e:9e:1 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0b0c0d0e0f3b79424c9c0dd436bace9e:11:0e:1 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0c0d0e0f3b79424c9c0dd436bace9e0e:73:d4:1 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0d0e0f3b79424c9c0dd436bace9e0ed4:93:58:1 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0e0f3b79424c9c0dd436bace9e0ed458:17:6a:1 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0f3b79424c9c0dd436bace9e0ed4586a:2a:4f:1 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:3b79424c9c0dd436bace9e0ed4586a4f:ae:32:1 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:79424c9c0dd436bace9e0ed4586a4f32:2d:b9:1 +# all of the above packed into one +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:6bc1bee22e409f96e93d7e117393172aae2d:3b79424c9c0dd436bace9e0ed4586a4f32b9:1 + +# CFB8-AES128.Decrypt + +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:6b:3b:0 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0102030405060708090a0b0c0d0e0f3b:c1:79:0 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:02030405060708090a0b0c0d0e0f3b79:be:42:0 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:030405060708090a0b0c0d0e0f3b7942:e2:4c:0 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0405060708090a0b0c0d0e0f3b79424c:2e:9c:0 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:05060708090a0b0c0d0e0f3b79424c9c:40:0d:0 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:060708090a0b0c0d0e0f3b79424c9c0d:9f:d4:0 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0708090a0b0c0d0e0f3b79424c9c0dd4:96:36:0 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:08090a0b0c0d0e0f3b79424c9c0dd436:e9:ba:0 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:090a0b0c0d0e0f3b79424c9c0dd436ba:3d:ce:0 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0a0b0c0d0e0f3b79424c9c0dd436bace:7e:9e:0 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0b0c0d0e0f3b79424c9c0dd436bace9e:11:0e:0 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0c0d0e0f3b79424c9c0dd436bace9e0e:73:d4:0 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0d0e0f3b79424c9c0dd436bace9e0ed4:93:58:0 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0e0f3b79424c9c0dd436bace9e0ed458:17:6a:0 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0f3b79424c9c0dd436bace9e0ed4586a:2a:4f:0 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:3b79424c9c0dd436bace9e0ed4586a4f:ae:32:0 +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:79424c9c0dd436bace9e0ed4586a4f32:2d:b9:0 +# all of the above packed into one +AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:6bc1bee22e409f96e93d7e117393172aae2d:3b79424c9c0dd436bace9e0ed4586a4f32b9:0 + +# TODO: 192 and 256 bit keys + # For all CFB128 encrypts and decrypts, the transformed sequence is # AES-bits-CFB:key:IV/ciphertext':plaintext:ciphertext:encdec # CFB128-AES128.Encrypt @@ -174,6 +269,16 @@ DESX-CBC:0123456789abcdeff1e0d3c2b5a49786fedcba9876543210:fedcba9876543210:37363 # DES EDE3 CBC tests (from destest) DES-EDE3-CBC:0123456789abcdeff1e0d3c2b5a49786fedcba9876543210:fedcba9876543210:37363534333231204E6F77206973207468652074696D6520666F722000000000:3FE301C962AC01D02213763C1CBD4CDC799657C064ECF5D41C673812CFDE9675 +# DES CFB1 from FIPS 81 +# plaintext: 0100 1110 0110 1111 0111 0111 = 4e6f77 +# ciphertext: 1100 1101 0001 1110 1100 1001 = cd1ec9 + +DES-CFB1*8:0123456789abcdef:1234567890abcdef:4e6f77:cd1ec9 + +# DES CFB8 from FIPS 81 + +DES-CFB8:0123456789abcdef:1234567890abcdef:4e6f7720697320746865:f31fda07011462ee187f + # RC4 tests (from rc4test) RC4:0123456789abcdef0123456789abcdef::0123456789abcdef:75b7878099e0c596 RC4:0123456789abcdef0123456789abcdef::0000000000000000:7494c2e7104b0879 diff --git a/crypto/hmac/Makefile.ssl b/crypto/hmac/Makefile similarity index 94% rename from crypto/hmac/Makefile.ssl rename to crypto/hmac/Makefile index f1c07322c4..6033f0ae18 100644 --- a/crypto/hmac/Makefile.ssl +++ b/crypto/hmac/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -44,10 +43,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/idea/Makefile.ssl b/crypto/idea/Makefile similarity index 92% rename from crypto/idea/Makefile.ssl rename to crypto/idea/Makefile index fa016ea399..fbf8a162e8 100644 --- a/crypto/idea/Makefile.ssl +++ b/crypto/idea/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -44,10 +43,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/krb5/Makefile.ssl b/crypto/krb5/Makefile similarity index 91% rename from crypto/krb5/Makefile.ssl rename to crypto/krb5/Makefile index d9224c0f09..b931505abe 100644 --- a/crypto/krb5/Makefile.ssl +++ b/crypto/krb5/Makefile @@ -1,5 +1,5 @@ # -# OpenSSL/krb5/Makefile.ssl +# OpenSSL/krb5/Makefile # DIR= krb5 @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -45,10 +44,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile ; @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/lhash/Makefile.ssl b/crypto/lhash/Makefile similarity index 93% rename from crypto/lhash/Makefile.ssl rename to crypto/lhash/Makefile index 60e7ee3393..a38423a540 100644 --- a/crypto/lhash/Makefile.ssl +++ b/crypto/lhash/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -44,10 +43,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/md2/Makefile.ssl b/crypto/md2/Makefile similarity index 93% rename from crypto/md2/Makefile.ssl rename to crypto/md2/Makefile index 3206924c90..975eda2367 100644 --- a/crypto/md2/Makefile.ssl +++ b/crypto/md2/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -44,10 +43,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/md32_common.h b/crypto/md32_common.h index 573850b122..6fc4467a67 100644 --- a/crypto/md32_common.h +++ b/crypto/md32_common.h @@ -128,6 +128,10 @@ * */ +#include +#include +#include "../fips/fips_locl.h" + #if !defined(DATA_ORDER_IS_BIG_ENDIAN) && !defined(DATA_ORDER_IS_LITTLE_ENDIAN) #error "DATA_ORDER must be defined!" #endif @@ -555,6 +559,14 @@ int HASH_FINAL (unsigned char *md, HASH_CTX *c) static const unsigned char end[4]={0x80,0x00,0x00,0x00}; const unsigned char *cp=end; +#ifdef OPENSSL_FIPS + if(FIPS_mode && !FIPS_md5_allowed) + { + FIPSerr(FIPS_F_HASH_FINAL,FIPS_R_NON_FIPS_METHOD); + return 0; + } +#endif + /* c->num should definitly have room for at least one more byte. */ p=c->data; i=c->num>>2; diff --git a/crypto/md4/Makefile.ssl b/crypto/md4/Makefile similarity index 77% rename from crypto/md4/Makefile.ssl rename to crypto/md4/Makefile index 7d2e8d8d3b..ac99dc5d95 100644 --- a/crypto/md4/Makefile.ssl +++ b/crypto/md4/Makefile @@ -11,10 +11,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -45,10 +44,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @@ -80,10 +78,14 @@ clean: # DO NOT DELETE THIS LINE -- make depend depends on it. -md4_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/md4.h +md4_dgst.o: ../../fips/fips_locl.h ../../include/openssl/bio.h +md4_dgst.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h +md4_dgst.o: ../../include/openssl/err.h ../../include/openssl/fips.h +md4_dgst.o: ../../include/openssl/lhash.h ../../include/openssl/md4.h md4_dgst.o: ../../include/openssl/opensslconf.h -md4_dgst.o: ../../include/openssl/opensslv.h ../md32_common.h md4_dgst.c -md4_dgst.o: md4_locl.h +md4_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +md4_dgst.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +md4_dgst.o: ../md32_common.h md4_dgst.c md4_locl.h md4_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h md4_one.o: ../../include/openssl/md4.h ../../include/openssl/opensslconf.h md4_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h diff --git a/crypto/md5/Makefile.ssl b/crypto/md5/Makefile similarity index 85% rename from crypto/md5/Makefile.ssl rename to crypto/md5/Makefile index 2361775a2d..9edec1a226 100644 --- a/crypto/md5/Makefile.ssl +++ b/crypto/md5/Makefile @@ -11,10 +11,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r MD5_ASM_OBJ= @@ -81,10 +80,9 @@ asm/md5-sparcv9.o: asm/md5-sparcv9.S -o asm/md5-sparcv9.o asm/md5-sparcv9.S files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @@ -116,10 +114,14 @@ clean: # DO NOT DELETE THIS LINE -- make depend depends on it. -md5_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/md5.h +md5_dgst.o: ../../fips/fips_locl.h ../../include/openssl/bio.h +md5_dgst.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h +md5_dgst.o: ../../include/openssl/err.h ../../include/openssl/fips.h +md5_dgst.o: ../../include/openssl/lhash.h ../../include/openssl/md5.h md5_dgst.o: ../../include/openssl/opensslconf.h -md5_dgst.o: ../../include/openssl/opensslv.h ../md32_common.h md5_dgst.c -md5_dgst.o: md5_locl.h +md5_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +md5_dgst.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +md5_dgst.o: ../md32_common.h md5_dgst.c md5_locl.h md5_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h md5_one.o: ../../include/openssl/md5.h ../../include/openssl/opensslconf.h md5_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h diff --git a/crypto/mdc2/Makefile.ssl b/crypto/mdc2/Makefile similarity index 94% rename from crypto/mdc2/Makefile.ssl rename to crypto/mdc2/Makefile index 33f366fb08..7b70164423 100644 --- a/crypto/mdc2/Makefile.ssl +++ b/crypto/mdc2/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -44,10 +43,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/objects/Makefile.ssl b/crypto/objects/Makefile similarity index 96% rename from crypto/objects/Makefile.ssl rename to crypto/objects/Makefile index 3e7a194cf9..48a912846f 100644 --- a/crypto/objects/Makefile.ssl +++ b/crypto/objects/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r PERL= perl @@ -52,10 +51,9 @@ obj_mac.h: objects.pl objects.txt obj_mac.num $(PERL) objects.pl objects.txt obj_mac.num obj_mac.h files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/objects/obj_dat.h b/crypto/objects/obj_dat.h index 969b18a341..9de7b1217e 100644 --- a/crypto/objects/obj_dat.h +++ b/crypto/objects/obj_dat.h @@ -62,9 +62,9 @@ * [including the GNU Public Licence.] */ -#define NUM_NID 650 -#define NUM_SN 643 -#define NUM_LN 643 +#define NUM_NID 660 +#define NUM_SN 653 +#define NUM_LN 653 #define NUM_OBJ 617 static unsigned char lvalues[4455]={ @@ -1728,20 +1728,36 @@ static ASN1_OBJECT nid_objs[NUM_NID]={ 10,&(lvalues[4434]),0}, {"msUPN","Microsoft Universal Principal Name",NID_ms_upn,10, &(lvalues[4444]),0}, +{"AES-128-CFB1","aes-128-cfb1",NID_aes_128_cfb1,0,NULL}, +{"AES-192-CFB1","aes-192-cfb1",NID_aes_192_cfb1,0,NULL}, +{"AES-256-CFB1","aes-256-cfb1",NID_aes_256_cfb1,0,NULL}, +{"AES-128-CFB8","aes-128-cfb8",NID_aes_128_cfb8,0,NULL}, +{"AES-192-CFB8","aes-192-cfb8",NID_aes_192_cfb8,0,NULL}, +{"AES-256-CFB8","aes-256-cfb8",NID_aes_256_cfb8,0,NULL}, +{"DES-CFB1","des-cfb1",NID_des_cfb1,0,NULL}, +{"DES-CFB8","des-cfb8",NID_des_cfb8,0,NULL}, +{"DES-EDE3-CFB1","des-ede3-cfb1",NID_des_ede3_cfb1,0,NULL}, +{"DES-EDE3-CFB8","des-ede3-cfb8",NID_des_ede3_cfb8,0,NULL}, }; static ASN1_OBJECT *sn_objs[NUM_SN]={ &(nid_objs[364]),/* "AD_DVCS" */ &(nid_objs[419]),/* "AES-128-CBC" */ &(nid_objs[421]),/* "AES-128-CFB" */ +&(nid_objs[650]),/* "AES-128-CFB1" */ +&(nid_objs[653]),/* "AES-128-CFB8" */ &(nid_objs[418]),/* "AES-128-ECB" */ &(nid_objs[420]),/* "AES-128-OFB" */ &(nid_objs[423]),/* "AES-192-CBC" */ &(nid_objs[425]),/* "AES-192-CFB" */ +&(nid_objs[651]),/* "AES-192-CFB1" */ +&(nid_objs[654]),/* "AES-192-CFB8" */ &(nid_objs[422]),/* "AES-192-ECB" */ &(nid_objs[424]),/* "AES-192-OFB" */ &(nid_objs[427]),/* "AES-256-CBC" */ &(nid_objs[429]),/* "AES-256-CFB" */ +&(nid_objs[652]),/* "AES-256-CFB1" */ +&(nid_objs[655]),/* "AES-256-CFB8" */ &(nid_objs[426]),/* "AES-256-ECB" */ &(nid_objs[428]),/* "AES-256-OFB" */ &(nid_objs[91]),/* "BF-CBC" */ @@ -1762,6 +1778,8 @@ static ASN1_OBJECT *sn_objs[NUM_SN]={ &(nid_objs[31]),/* "DES-CBC" */ &(nid_objs[643]),/* "DES-CDMF" */ &(nid_objs[30]),/* "DES-CFB" */ +&(nid_objs[656]),/* "DES-CFB1" */ +&(nid_objs[657]),/* "DES-CFB8" */ &(nid_objs[29]),/* "DES-ECB" */ &(nid_objs[32]),/* "DES-EDE" */ &(nid_objs[43]),/* "DES-EDE-CBC" */ @@ -1770,6 +1788,8 @@ static ASN1_OBJECT *sn_objs[NUM_SN]={ &(nid_objs[33]),/* "DES-EDE3" */ &(nid_objs[44]),/* "DES-EDE3-CBC" */ &(nid_objs[61]),/* "DES-EDE3-CFB" */ +&(nid_objs[658]),/* "DES-EDE3-CFB1" */ +&(nid_objs[659]),/* "DES-EDE3-CFB8" */ &(nid_objs[63]),/* "DES-EDE3-OFB" */ &(nid_objs[45]),/* "DES-OFB" */ &(nid_objs[80]),/* "DESX-CBC" */ @@ -2485,14 +2505,20 @@ static ASN1_OBJECT *ln_objs[NUM_LN]={ &(nid_objs[606]),/* "additional verification" */ &(nid_objs[419]),/* "aes-128-cbc" */ &(nid_objs[421]),/* "aes-128-cfb" */ +&(nid_objs[650]),/* "aes-128-cfb1" */ +&(nid_objs[653]),/* "aes-128-cfb8" */ &(nid_objs[418]),/* "aes-128-ecb" */ &(nid_objs[420]),/* "aes-128-ofb" */ &(nid_objs[423]),/* "aes-192-cbc" */ &(nid_objs[425]),/* "aes-192-cfb" */ +&(nid_objs[651]),/* "aes-192-cfb1" */ +&(nid_objs[654]),/* "aes-192-cfb8" */ &(nid_objs[422]),/* "aes-192-ecb" */ &(nid_objs[424]),/* "aes-192-ofb" */ &(nid_objs[427]),/* "aes-256-cbc" */ &(nid_objs[429]),/* "aes-256-cfb" */ +&(nid_objs[652]),/* "aes-256-cfb1" */ +&(nid_objs[655]),/* "aes-256-cfb8" */ &(nid_objs[426]),/* "aes-256-ecb" */ &(nid_objs[428]),/* "aes-256-ofb" */ &(nid_objs[376]),/* "algorithm" */ @@ -2531,6 +2557,8 @@ static ASN1_OBJECT *ln_objs[NUM_LN]={ &(nid_objs[31]),/* "des-cbc" */ &(nid_objs[643]),/* "des-cdmf" */ &(nid_objs[30]),/* "des-cfb" */ +&(nid_objs[656]),/* "des-cfb1" */ +&(nid_objs[657]),/* "des-cfb8" */ &(nid_objs[29]),/* "des-ecb" */ &(nid_objs[32]),/* "des-ede" */ &(nid_objs[43]),/* "des-ede-cbc" */ @@ -2539,6 +2567,8 @@ static ASN1_OBJECT *ln_objs[NUM_LN]={ &(nid_objs[33]),/* "des-ede3" */ &(nid_objs[44]),/* "des-ede3-cbc" */ &(nid_objs[61]),/* "des-ede3-cfb" */ +&(nid_objs[658]),/* "des-ede3-cfb1" */ +&(nid_objs[659]),/* "des-ede3-cfb8" */ &(nid_objs[63]),/* "des-ede3-ofb" */ &(nid_objs[45]),/* "des-ofb" */ &(nid_objs[107]),/* "description" */ diff --git a/crypto/objects/obj_mac.h b/crypto/objects/obj_mac.h index 7645012298..ceeaaa391d 100644 --- a/crypto/objects/obj_mac.h +++ b/crypto/objects/obj_mac.h @@ -2009,6 +2009,46 @@ #define NID_aes_256_cfb128 429 #define OBJ_aes_256_cfb128 OBJ_aes,44L +#define SN_aes_128_cfb1 "AES-128-CFB1" +#define LN_aes_128_cfb1 "aes-128-cfb1" +#define NID_aes_128_cfb1 650 + +#define SN_aes_192_cfb1 "AES-192-CFB1" +#define LN_aes_192_cfb1 "aes-192-cfb1" +#define NID_aes_192_cfb1 651 + +#define SN_aes_256_cfb1 "AES-256-CFB1" +#define LN_aes_256_cfb1 "aes-256-cfb1" +#define NID_aes_256_cfb1 652 + +#define SN_aes_128_cfb8 "AES-128-CFB8" +#define LN_aes_128_cfb8 "aes-128-cfb8" +#define NID_aes_128_cfb8 653 + +#define SN_aes_192_cfb8 "AES-192-CFB8" +#define LN_aes_192_cfb8 "aes-192-cfb8" +#define NID_aes_192_cfb8 654 + +#define SN_aes_256_cfb8 "AES-256-CFB8" +#define LN_aes_256_cfb8 "aes-256-cfb8" +#define NID_aes_256_cfb8 655 + +#define SN_des_cfb1 "DES-CFB1" +#define LN_des_cfb1 "des-cfb1" +#define NID_des_cfb1 656 + +#define SN_des_cfb8 "DES-CFB8" +#define LN_des_cfb8 "des-cfb8" +#define NID_des_cfb8 657 + +#define SN_des_ede3_cfb1 "DES-EDE3-CFB1" +#define LN_des_ede3_cfb1 "des-ede3-cfb1" +#define NID_des_ede3_cfb1 658 + +#define SN_des_ede3_cfb8 "DES-EDE3-CFB8" +#define LN_des_ede3_cfb8 "des-ede3-cfb8" +#define NID_des_ede3_cfb8 659 + #define SN_hold_instruction_code "holdInstructionCode" #define LN_hold_instruction_code "Hold Instruction Code" #define NID_hold_instruction_code 430 diff --git a/crypto/objects/obj_mac.num b/crypto/objects/obj_mac.num index 9838072b65..4dffeaed22 100644 --- a/crypto/objects/obj_mac.num +++ b/crypto/objects/obj_mac.num @@ -647,3 +647,13 @@ joint_iso_itu_t 646 international_organizations 647 ms_smartcard_login 648 ms_upn 649 +aes_128_cfb1 650 +aes_192_cfb1 651 +aes_256_cfb1 652 +aes_128_cfb8 653 +aes_192_cfb8 654 +aes_256_cfb8 655 +des_cfb1 656 +des_cfb8 657 +des_ede3_cfb1 658 +des_ede3_cfb8 659 diff --git a/crypto/objects/objects.txt b/crypto/objects/objects.txt index 3ba11f65cc..cd315d0cc0 100644 --- a/crypto/objects/objects.txt +++ b/crypto/objects/objects.txt @@ -681,6 +681,19 @@ aes 43 : AES-256-OFB : aes-256-ofb !Cname aes-256-cfb128 aes 44 : AES-256-CFB : aes-256-cfb +# There are no OIDs for these modes... + + : AES-128-CFB1 : aes-128-cfb1 + : AES-192-CFB1 : aes-192-cfb1 + : AES-256-CFB1 : aes-256-cfb1 + : AES-128-CFB8 : aes-128-cfb8 + : AES-192-CFB8 : aes-192-cfb8 + : AES-256-CFB8 : aes-256-cfb8 + : DES-CFB1 : des-cfb1 + : DES-CFB8 : des-cfb8 + : DES-EDE3-CFB1 : des-ede3-cfb1 + : DES-EDE3-CFB8 : des-ede3-cfb8 + # Hold instruction CRL entry extension !Cname hold-instruction-code id-ce 23 : holdInstructionCode : Hold Instruction Code diff --git a/crypto/ocsp/Makefile.ssl b/crypto/ocsp/Makefile similarity index 98% rename from crypto/ocsp/Makefile.ssl rename to crypto/ocsp/Makefile index 02477be538..7135ba6b94 100644 --- a/crypto/ocsp/Makefile.ssl +++ b/crypto/ocsp/Makefile @@ -1,5 +1,5 @@ # -# OpenSSL/ocsp/Makefile.ssl +# OpenSSL/ocsp/Makefile # DIR= ocsp @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -47,10 +46,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile ; @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/pem/Makefile.ssl b/crypto/pem/Makefile similarity index 99% rename from crypto/pem/Makefile.ssl rename to crypto/pem/Makefile index d3043eb401..55a6fa69f2 100644 --- a/crypto/pem/Makefile.ssl +++ b/crypto/pem/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -47,10 +46,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: $(EXHEADER) - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/pkcs12/Makefile.ssl b/crypto/pkcs12/Makefile similarity index 99% rename from crypto/pkcs12/Makefile.ssl rename to crypto/pkcs12/Makefile index a6e47b4085..0bd0b7a977 100644 --- a/crypto/pkcs12/Makefile.ssl +++ b/crypto/pkcs12/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -50,10 +49,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/pkcs7/Makefile.ssl b/crypto/pkcs7/Makefile similarity index 98% rename from crypto/pkcs7/Makefile.ssl rename to crypto/pkcs7/Makefile index c3bfc7d560..7eda4e8a6a 100644 --- a/crypto/pkcs7/Makefile.ssl +++ b/crypto/pkcs7/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r PEX_LIBS= @@ -65,10 +64,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/rand/Makefile.ssl b/crypto/rand/Makefile similarity index 86% rename from crypto/rand/Makefile.ssl rename to crypto/rand/Makefile index e5cbe5319c..4ab4b9c7b0 100644 --- a/crypto/rand/Makefile.ssl +++ b/crypto/rand/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -46,10 +45,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @@ -88,19 +86,19 @@ md_rand.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h md_rand.o: ../../include/openssl/des.h ../../include/openssl/des_old.h md_rand.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h md_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h -md_rand.o: ../../include/openssl/evp.h ../../include/openssl/idea.h -md_rand.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h -md_rand.o: ../../include/openssl/md4.h ../../include/openssl/md5.h -md_rand.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h -md_rand.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h -md_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h -md_rand.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h -md_rand.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h -md_rand.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h -md_rand.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h -md_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -md_rand.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -md_rand.o: md_rand.c rand_lcl.h +md_rand.o: ../../include/openssl/evp.h ../../include/openssl/fips.h +md_rand.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h +md_rand.o: ../../include/openssl/md2.h ../../include/openssl/md4.h +md_rand.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h +md_rand.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h +md_rand.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +md_rand.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h +md_rand.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h +md_rand.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h +md_rand.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h +md_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h +md_rand.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h +md_rand.o: ../../include/openssl/ui_compat.h md_rand.c rand_lcl.h rand_egd.o: ../../include/openssl/buffer.h ../../include/openssl/e_os2.h rand_egd.o: ../../include/openssl/opensslconf.h rand_egd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h @@ -115,15 +113,17 @@ rand_err.o: rand_err.c rand_lib.o: ../../e_os.h ../../include/openssl/asn1.h rand_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h rand_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h +rand_lib.o: ../../include/openssl/des.h ../../include/openssl/des_old.h rand_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h rand_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h -rand_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h +rand_lib.o: ../../include/openssl/err.h ../../include/openssl/fips.h +rand_lib.o: ../../include/openssl/fips_rand.h ../../include/openssl/lhash.h rand_lib.o: ../../include/openssl/opensslconf.h rand_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h rand_lib.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h rand_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h rand_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h -rand_lib.o: ../cryptlib.h rand_lib.c +rand_lib.o: ../../include/openssl/ui_compat.h ../cryptlib.h rand_lib.c rand_os2.o: ../../e_os.h ../../include/openssl/aes.h rand_os2.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h rand_os2.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h diff --git a/crypto/rand/md_rand.c b/crypto/rand/md_rand.c index eeffc0df4c..24e590ab64 100644 --- a/crypto/rand/md_rand.c +++ b/crypto/rand/md_rand.c @@ -126,6 +126,7 @@ #include #include +#include #ifdef BN_DEBUG # define PREDICT @@ -332,6 +333,14 @@ static int ssleay_rand_bytes(unsigned char *buf, int num) #endif int do_stir_pool = 0; +#ifdef OPENSSL_FIPS + if(FIPS_mode) + { + FIPSerr(FIPS_F_SSLEAY_RAND_BYTES,FIPS_R_NON_FIPS_METHOD); + return 0; + } +#endif + #ifdef PREDICT if (rand_predictable) { diff --git a/crypto/rand/rand.h b/crypto/rand/rand.h index 606382dd21..b22dd613fb 100644 --- a/crypto/rand/rand.h +++ b/crypto/rand/rand.h @@ -121,11 +121,14 @@ void ERR_load_RAND_strings(void); /* Error codes for the RAND functions. */ /* Function codes. */ +#define RAND_F_FIPS_RAND_BYTES 102 #define RAND_F_RAND_GET_RAND_METHOD 101 #define RAND_F_SSLEAY_RAND_BYTES 100 /* Reason codes. */ +#define RAND_R_NON_FIPS_METHOD 101 #define RAND_R_PRNG_NOT_SEEDED 100 +#define RAND_R_PRNG_STUCK 102 #ifdef __cplusplus } diff --git a/crypto/rand/rand_err.c b/crypto/rand/rand_err.c index b77267e213..b808309496 100644 --- a/crypto/rand/rand_err.c +++ b/crypto/rand/rand_err.c @@ -1,6 +1,6 @@ /* crypto/rand/rand_err.c */ /* ==================================================================== - * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * Copyright (c) 1999-2003 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 @@ -66,6 +66,7 @@ #ifndef OPENSSL_NO_ERR static ERR_STRING_DATA RAND_str_functs[]= { +{ERR_PACK(0,RAND_F_FIPS_RAND_BYTES,0), "FIPS_RAND_BYTES"}, {ERR_PACK(0,RAND_F_RAND_GET_RAND_METHOD,0), "RAND_get_rand_method"}, {ERR_PACK(0,RAND_F_SSLEAY_RAND_BYTES,0), "SSLEAY_RAND_BYTES"}, {0,NULL} @@ -73,7 +74,9 @@ static ERR_STRING_DATA RAND_str_functs[]= static ERR_STRING_DATA RAND_str_reasons[]= { +{RAND_R_NON_FIPS_METHOD ,"non fips method"}, {RAND_R_PRNG_NOT_SEEDED ,"PRNG not seeded"}, +{RAND_R_PRNG_STUCK ,"prng stuck"}, {0,NULL} }; diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c index 513e338985..869d11cab6 100644 --- a/crypto/rand/rand_lib.c +++ b/crypto/rand/rand_lib.c @@ -63,6 +63,8 @@ #ifndef OPENSSL_NO_ENGINE #include #endif +#include +#include #ifndef OPENSSL_NO_ENGINE /* non-NULL if default_RAND_meth is ENGINE-provided */ @@ -85,6 +87,15 @@ int RAND_set_rand_method(const RAND_METHOD *meth) const RAND_METHOD *RAND_get_rand_method(void) { +#ifdef OPENSSL_FIPS + if(FIPS_mode && default_RAND_meth != FIPS_rand_check) + { + RANDerr(RAND_F_RAND_GET_RAND_METHOD,RAND_R_NON_FIPS_METHOD); + return 0; + } +#endif + + if (!default_RAND_meth) { #ifndef OPENSSL_NO_ENGINE diff --git a/crypto/rc2/Makefile.ssl b/crypto/rc2/Makefile similarity index 92% rename from crypto/rc2/Makefile.ssl rename to crypto/rc2/Makefile index 98d5960d5d..982b9c911d 100644 --- a/crypto/rc2/Makefile.ssl +++ b/crypto/rc2/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -44,10 +43,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/rc4/Makefile.ssl b/crypto/rc4/Makefile similarity index 93% rename from crypto/rc4/Makefile.ssl rename to crypto/rc4/Makefile index 3e602662be..15da280838 100644 --- a/crypto/rc4/Makefile.ssl +++ b/crypto/rc4/Makefile @@ -11,10 +11,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r RC4_ENC=rc4_enc.o @@ -68,10 +67,9 @@ asm/rx86unix.cpp: asm/rc4-586.pl ../perlasm/x86asm.pl (cd asm; $(PERL) rc4-586.pl cpp >rx86unix.cpp) files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/rc5/Makefile.ssl b/crypto/rc5/Makefile similarity index 93% rename from crypto/rc5/Makefile.ssl rename to crypto/rc5/Makefile index 3f9632f8f7..09133f0287 100644 --- a/crypto/rc5/Makefile.ssl +++ b/crypto/rc5/Makefile @@ -11,10 +11,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r RC5_ENC= rc5_enc.o @@ -65,10 +64,9 @@ asm/r586unix.cpp: asm/rc5-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl (cd asm; $(PERL) rc5-586.pl cpp >r586unix.cpp) files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/ripemd/Makefile.ssl b/crypto/ripemd/Makefile similarity index 82% rename from crypto/ripemd/Makefile.ssl rename to crypto/ripemd/Makefile index f22ac790ae..d727cd3c9e 100644 --- a/crypto/ripemd/Makefile.ssl +++ b/crypto/ripemd/Makefile @@ -11,10 +11,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r RIP_ASM_OBJ= @@ -63,10 +62,9 @@ asm/rm86unix.cpp: asm/rmd-586.pl ../perlasm/x86asm.pl (cd asm; $(PERL) rmd-586.pl cpp >rm86unix.cpp) files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @@ -98,9 +96,14 @@ clean: # DO NOT DELETE THIS LINE -- make depend depends on it. -rmd_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h +rmd_dgst.o: ../../fips/fips_locl.h ../../include/openssl/bio.h +rmd_dgst.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h +rmd_dgst.o: ../../include/openssl/err.h ../../include/openssl/fips.h +rmd_dgst.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h rmd_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/ripemd.h -rmd_dgst.o: ../md32_common.h rmd_dgst.c rmd_locl.h rmdconst.h +rmd_dgst.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +rmd_dgst.o: ../../include/openssl/symhacks.h ../md32_common.h rmd_dgst.c +rmd_dgst.o: rmd_locl.h rmdconst.h rmd_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h rmd_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h rmd_one.o: ../../include/openssl/ripemd.h ../../include/openssl/safestack.h diff --git a/crypto/rsa/Makefile.ssl b/crypto/rsa/Makefile similarity index 98% rename from crypto/rsa/Makefile.ssl rename to crypto/rsa/Makefile index 8089344a04..7e666a072f 100644 --- a/crypto/rsa/Makefile.ssl +++ b/crypto/rsa/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -48,10 +47,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/rsa/rsa_eay.c b/crypto/rsa/rsa_eay.c index e0d286266e..d4caab3f95 100644 --- a/crypto/rsa/rsa_eay.c +++ b/crypto/rsa/rsa_eay.c @@ -62,7 +62,7 @@ #include #include -#ifndef RSA_NULL +#if !defined(RSA_NULL) && !defined(OPENSSL_FIPS) static int RSA_eay_public_encrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa,int padding); diff --git a/crypto/rsa/rsa_gen.c b/crypto/rsa/rsa_gen.c index 00c25adbc5..adb5e34da5 100644 --- a/crypto/rsa/rsa_gen.c +++ b/crypto/rsa/rsa_gen.c @@ -62,6 +62,8 @@ #include #include +#ifndef OPENSSL_FIPS + RSA *RSA_generate_key(int bits, unsigned long e_value, void (*callback)(int,int,void *), void *cb_arg) { @@ -195,3 +197,4 @@ err: return(rsa); } +#endif diff --git a/crypto/sha/Makefile.ssl b/crypto/sha/Makefile similarity index 81% rename from crypto/sha/Makefile.ssl rename to crypto/sha/Makefile index 4ba201c787..1e63885925 100644 --- a/crypto/sha/Makefile.ssl +++ b/crypto/sha/Makefile @@ -11,10 +11,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r SHA1_ASM_OBJ= @@ -63,10 +62,9 @@ asm/sx86unix.cpp: asm/sha1-586.pl ../perlasm/x86asm.pl (cd asm; $(PERL) sha1-586.pl cpp $(PROCESSOR) >sx86unix.cpp) files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @@ -103,12 +101,16 @@ sha1_one.o: ../../include/openssl/opensslconf.h sha1_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h sha1_one.o: ../../include/openssl/sha.h ../../include/openssl/stack.h sha1_one.o: ../../include/openssl/symhacks.h sha1_one.c -sha1dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -sha1dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h -sha1dgst.o: ../md32_common.h sha1dgst.c sha_locl.h -sha_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -sha_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h -sha_dgst.o: ../md32_common.h sha_dgst.c sha_locl.h +sha1dgst.o: ../../include/openssl/opensslconf.h +sha1dgst.o: ../../include/openssl/opensslv.h sha1dgst.c +sha_dgst.o: ../../fips/fips_locl.h ../../include/openssl/bio.h +sha_dgst.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h +sha_dgst.o: ../../include/openssl/err.h ../../include/openssl/fips.h +sha_dgst.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h +sha_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +sha_dgst.o: ../../include/openssl/sha.h ../../include/openssl/stack.h +sha_dgst.o: ../../include/openssl/symhacks.h ../md32_common.h sha_dgst.c +sha_dgst.o: sha_locl.h sha_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h sha_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h sha_one.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h diff --git a/crypto/sha/sha1dgst.c b/crypto/sha/sha1dgst.c index 182f65982a..1e2009b760 100644 --- a/crypto/sha/sha1dgst.c +++ b/crypto/sha/sha1dgst.c @@ -62,12 +62,20 @@ #define SHA_1 #include +#include +#ifndef OPENSSL_FIPS const char *SHA1_version="SHA1" OPENSSL_VERSION_PTEXT; /* The implementation is in ../md32_common.h */ #include "sha_locl.h" +#else /* ndef OPENSSL_FIPS */ + +static void *dummy=&dummy; + +#endif /* ndef OPENSSL_FIPS */ + #endif diff --git a/crypto/stack/Makefile.ssl b/crypto/stack/Makefile similarity index 92% rename from crypto/stack/Makefile.ssl rename to crypto/stack/Makefile index 7120fb804a..1f258148d4 100644 --- a/crypto/stack/Makefile.ssl +++ b/crypto/stack/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -44,10 +43,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/txt_db/Makefile.ssl b/crypto/txt_db/Makefile similarity index 92% rename from crypto/txt_db/Makefile.ssl rename to crypto/txt_db/Makefile index 6221dfae4d..15ae6ceda8 100644 --- a/crypto/txt_db/Makefile.ssl +++ b/crypto/txt_db/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -44,10 +43,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/ui/Makefile.ssl b/crypto/ui/Makefile similarity index 95% rename from crypto/ui/Makefile.ssl rename to crypto/ui/Makefile index ba46951d1c..0045931218 100644 --- a/crypto/ui/Makefile.ssl +++ b/crypto/ui/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -48,10 +47,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/x509/Makefile.ssl b/crypto/x509/Makefile similarity index 99% rename from crypto/x509/Makefile.ssl rename to crypto/x509/Makefile index 3a3452536c..be61a48214 100644 --- a/crypto/x509/Makefile.ssl +++ b/crypto/x509/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -54,10 +53,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/crypto/x509v3/Makefile.ssl b/crypto/x509v3/Makefile similarity index 99% rename from crypto/x509v3/Makefile.ssl rename to crypto/x509v3/Makefile index 66df90c346..7b0d03ac61 100644 --- a/crypto/x509v3/Makefile.ssl +++ b/crypto/x509v3/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r CFLAGS= $(INCLUDES) $(CFLAG) @@ -50,10 +49,9 @@ lib: $(LIBOBJ) @touch lib files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) diff --git a/e_os.h b/e_os.h index 096eabe09a..51b516209d 100644 --- a/e_os.h +++ b/e_os.h @@ -510,11 +510,30 @@ extern char *sys_errlist[]; extern int sys_nerr; #define IRIX_CC_BUG /* CDS++ up to V2.0Bsomething suffered from the same bug.*/ #endif +#if defined(OPENSSL_SYS_WINDOWS) +# define strcasecmp _stricmp +# define strncasecmp _strnicmp +#elif defined(OPENSSL_SYS_VMS) +/* VMS below version 7.0 doesn't have strcasecmp() */ +# include +# define strcasecmp OPENSSL_strcasecmp +# define strncasecmp OPENSSL_strncasecmp +#elif defined(OPENSSL_SYS_OS2) && defined(__EMX__) +# define strcasecmp stricmp +# define strncasecmp strnicmp +#else +# ifdef NO_STRINGS_H + int strcasecmp(); + int strncasecmp(); +# else +# include +# endif /* NO_STRINGS_H */ +#endif + #if defined(OPENSSL_SYS_OS2) && defined(__EMX__) # include # include # define NO_SYSLOG -# define strcasecmp stricmp #endif /* vxworks */ diff --git a/fips/Makefile b/fips/Makefile new file mode 100644 index 0000000000..351e1443e2 --- /dev/null +++ b/fips/Makefile @@ -0,0 +1,202 @@ +# +# SSLeay/fips/Makefile +# + +DIR= fips +TOP= .. +CC= cc +INCLUDE= -I. -I$(TOP) -I../include +INCLUDES= -I.. -I../.. -I../../include +CFLAG= -g +INSTALL_PREFIX= +OPENSSLDIR= /usr/local/ssl +INSTALLTOP= /usr/local/ssl +MAKEDEPPROG= makedepend +MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) +MAKEFILE= Makefile +RM= rm -f +AR= ar r + +PEX_LIBS= +EX_LIBS= + +CFLAGS= $(INCLUDE) $(CFLAG) + + +LIBS= + +FDIRS=sha1 rand des aes dsa rsa + +GENERAL=Makefile README fips-lib.com install.com + +LIB= $(TOP)/libcrypto.a +SHARED_LIB= libcrypto$(SHLIB_EXT) +LIBSRC=fips.c fips_err_wrapper.c +LIBOBJ=fips.o fips_err_wrapper.o + +SRC= $(LIBSRC) + +EXHEADER=fips.h +HEADER=$(EXHEADER) fips_err.h +EXE=openssl_fips_fingerprint + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + @(cd ..; $(MAKE) DIRS=$(DIR) all) + +all: subdirs lib check shared + +check: + TOP=`pwd`/$(TOP) ./fips_check_sha1 fingerprint.sha1 $(SRC) $(HEADER) + +subdirs: + @for i in $(FDIRS) ;\ + do \ + (cd $$i && echo "making all in fips/$$i..." && \ + $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' FIPS_DES_ENC='${FIPS_DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' FIPS_SHA1_ASM_OBJ='${FIPS_SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' all ) || exit 1; \ + done; + +sub_target: + @for i in $(FDIRS) ;\ + do \ + (cd $$i && echo "making $(TARGET) in fips/$$i..." && \ + $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' FIPS_DES_ENC='${FIPS_DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' FIPS_SHA1_ASM_OBJ='${FIPS_SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' $(TARGET) ) || exit 1; \ + done; + +files: + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO + @for i in $(FDIRS) ;\ + do \ + (cd $$i && echo "making 'files' in fips/$$i..." && \ + $(MAKE) PERL='${PERL}' files ); \ + done; + +links: + @$(PERL) $(TOP)/util/mklink.pl ../include/openssl $(EXHEADER) + @for i in $(FDIRS); do \ + (cd $$i && echo "making links in fips/$$i..." && \ + $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' FIPS_DES_ENC='${FIPS_DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' FIPS_SHA1_ASM_OBJ='${FIPS_SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' PERL='${PERL}' links ); \ + done; + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + $(RANLIB) $(LIB) || echo Never mind. + @touch lib + +shared: + if [ -n "$(SHARED_LIBS)" ]; then \ + (cd ..; $(MAKE) $(SHARED_LIB)); \ + fi + +libs: + @for i in $(FDIRS) ;\ + do \ + (cd $$i && echo "making libs in fips/$$i..." && \ + $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALL_PREFIX='${INSTALL_PREFIX}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' AR='${AR}' lib ); \ + done; + +tests: + @for i in $(FDIRS) ;\ + do \ + (cd $$i && echo "making tests in fips/$$i..." && \ + $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' AR='${AR}' tests ); \ + done; + +top_fips_test_suite: + (cd $(TOP); $(MAKE) DIRS=fips FDIRS=. TARGET=fips_test_suite sub_target) + +fips_test_suite: fips_test_suite.o $(TOP)/libcrypto.a + $(CC) $(CFLAGS) -o fips_test_suite fips_test_suite.o $(PEX_LIBS) $(TOP)/libcrypto.a $(EX_LIBS) + TOP=$(TOP) $(TOP)/fips/openssl_fips_fingerprint $(TOP)/libcrypto.a fips_test_suite || { rm fips_test_suite; false; } + +fips_test: top top_fips_test_suite + cd testvectors && perl -p -i -e 's/COUNT=/COUNT = /' des[23]/req/*.req + @for i in dsa sha1 aes des ; \ + do \ + (cd $$i && echo "making fips_test in fips/$$i..." && $(MAKE) fips_test) \ + done; + +install: + @for i in $(EXHEADER) ;\ + do \ + (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ + chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ + done; + @for i in $(FDIRS) ;\ + do \ + (cd $$i && echo "making install in fips/$$i..." && \ + $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALL_PREFIX='${INSTALL_PREFIX}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' install ); \ + done; + @for i in $(EXE) ; \ + do \ + echo "installing $$i"; \ + cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \ + chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \ + mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i; \ + done + +lint: + @for i in $(FDIRS) ;\ + do \ + (cd $$i && echo "making lint in fips/$$i..." && \ + $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' lint ); \ + done; + +depend: + if [ ! -f buildinf.h ]; then touch buildinf.h; fi # fake buildinf.h if it does not exist + $(MAKEDEPEND) -- $(CFLAG) $(INCLUDE) $(DEPFLAG) -- $(SRC) + if [ ! -s buildinf.h ]; then rm buildinf.h; fi + @for i in $(FDIRS) ;\ + do \ + (cd $$i && echo "making depend in fips/$$i..." && \ + $(MAKE) MAKEFILE='${MAKEFILE}' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' DEPFLAG='${DEPFLAG}' MAKEDEPPROG='${MAKEDEPPROG}' KRB5_INCLUDES='${KRB5_INCLUDES}' PERL='${PERL}' depend ); \ + done; + +clean: + rm -f buildinf.h *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + @for i in $(FDIRS) ;\ + do \ + (cd $$i && echo "making clean in fips/$$i..." && \ + $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' clean ); \ + done; + +dclean: + $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + @for i in $(FDIRS) ;\ + do \ + (cd $$i && echo "making dclean in fips/$$i..." && \ + $(MAKE) PERL='${PERL}' CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' dclean ); \ + done; + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +fips.o: ../include/openssl/aes.h ../include/openssl/asn1.h +fips.o: ../include/openssl/bio.h ../include/openssl/blowfish.h +fips.o: ../include/openssl/bn.h ../include/openssl/cast.h +fips.o: ../include/openssl/crypto.h ../include/openssl/des.h +fips.o: ../include/openssl/des_old.h ../include/openssl/dh.h +fips.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h +fips.o: ../include/openssl/err.h ../include/openssl/evp.h +fips.o: ../include/openssl/fips.h ../include/openssl/fips_rand.h +fips.o: ../include/openssl/hmac.h ../include/openssl/idea.h +fips.o: ../include/openssl/lhash.h ../include/openssl/md2.h +fips.o: ../include/openssl/md4.h ../include/openssl/md5.h +fips.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h +fips.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h +fips.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h +fips.o: ../include/openssl/rand.h ../include/openssl/rc2.h +fips.o: ../include/openssl/rc4.h ../include/openssl/rc5.h +fips.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h +fips.o: ../include/openssl/safestack.h ../include/openssl/sha.h +fips.o: ../include/openssl/stack.h ../include/openssl/symhacks.h +fips.o: ../include/openssl/ui.h ../include/openssl/ui_compat.h fips.c +fips.o: fips_locl.h +fips_err_wrapper.o: ../include/openssl/bio.h ../include/openssl/crypto.h +fips_err_wrapper.o: ../include/openssl/e_os2.h ../include/openssl/err.h +fips_err_wrapper.o: ../include/openssl/fips.h ../include/openssl/lhash.h +fips_err_wrapper.o: ../include/openssl/opensslconf.h +fips_err_wrapper.o: ../include/openssl/opensslv.h +fips_err_wrapper.o: ../include/openssl/safestack.h ../include/openssl/stack.h +fips_err_wrapper.o: ../include/openssl/symhacks.h fips_err.h fips_err_wrapper.c diff --git a/fips/aes/Makefile b/fips/aes/Makefile new file mode 100644 index 0000000000..b085d43122 --- /dev/null +++ b/fips/aes/Makefile @@ -0,0 +1,131 @@ +# +# SSLeay/fips/aes/Makefile +# + +DIR= aes +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALL_PREFIX= +OPENSSLDIR= /usr/local/ssl +INSTALLTOP=/usr/local/ssl +MAKEDEPPROG= makedepend +MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) +MAKEFILE= Makefile +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=fips_aesavs.c +TESTDATA=fips_aes_data +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=fips_aes_core.c fips_aes_selftest.c +LIBOBJ=fips_aes_core.o fips_aes_selftest.o + +SRC= $(LIBSRC) + +EXHEADER= +HEADER= $(EXHEADER) fips_aes_locl.h + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd $(TOP); $(MAKE) DIRS=fips FDIRS=$(DIR) sub_all) + +all: check lib + +check: + TOP=`pwd`/$(TOP) ../fips_check_sha1 fingerprint.sha1 $(SRC) $(HEADER) + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + $(RANLIB) $(LIB) || echo Never mind. + @sleep 2; touch lib + +files: + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO + +links: + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/include/openssl $(EXHEADER) + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/test $(TEST) + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/test $(TESTDATA) + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ + chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +top_fips_aesavs: + (cd $(TOP); $(MAKE) DIRS=fips FDIRS=$(DIR) TARGET=fips_aesavs sub_target) + +fips_aesavs: fips_aesavs.o $(TOP)/libcrypto.a + $(CC) $(CFLAGS) -o fips_aesavs fips_aesavs.o $(PEX_LIBS) $(TOP)/libcrypto.a $(EX_LIBS) + TOP=$(TOP) $(TOP)/fips/openssl_fips_fingerprint $(TOP)/libcrypto.a fips_aesavs + +fips_test: top top_fips_aesavs + find ../testvectors/aes/req -name '*.req' > testlist + -rm -rf ../testvectors/aes/rsp + mkdir ../testvectors/aes/rsp + ./fips_aesavs -d testlist + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) \ + $(SRC) $(TEST) + +dclean: + $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff +# DO NOT DELETE THIS LINE -- make depend depends on it. + +fips_aes_core.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h +fips_aes_core.o: ../../include/openssl/fips.h +fips_aes_core.o: ../../include/openssl/opensslconf.h fips_aes_core.c +fips_aes_core.o: fips_aes_locl.h +fips_aes_selftest.o: ../../include/openssl/aes.h ../../include/openssl/bio.h +fips_aes_selftest.o: ../../include/openssl/crypto.h +fips_aes_selftest.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +fips_aes_selftest.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h +fips_aes_selftest.o: ../../include/openssl/opensslconf.h +fips_aes_selftest.o: ../../include/openssl/opensslv.h +fips_aes_selftest.o: ../../include/openssl/safestack.h +fips_aes_selftest.o: ../../include/openssl/stack.h +fips_aes_selftest.o: ../../include/openssl/symhacks.h fips_aes_selftest.c +fips_aesavs.o: ../../e_os.h ../../include/openssl/aes.h +fips_aesavs.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h +fips_aesavs.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h +fips_aesavs.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h +fips_aesavs.o: ../../include/openssl/des.h ../../include/openssl/des_old.h +fips_aesavs.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h +fips_aesavs.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +fips_aesavs.o: ../../include/openssl/evp.h ../../include/openssl/fips.h +fips_aesavs.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h +fips_aesavs.o: ../../include/openssl/md2.h ../../include/openssl/md4.h +fips_aesavs.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h +fips_aesavs.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h +fips_aesavs.o: ../../include/openssl/opensslconf.h +fips_aesavs.o: ../../include/openssl/opensslv.h +fips_aesavs.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h +fips_aesavs.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h +fips_aesavs.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h +fips_aesavs.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h +fips_aesavs.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +fips_aesavs.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +fips_aesavs.o: fips_aesavs.c diff --git a/fips/aes/fingerprint.sha1 b/fips/aes/fingerprint.sha1 new file mode 100644 index 0000000000..295b552cb1 --- /dev/null +++ b/fips/aes/fingerprint.sha1 @@ -0,0 +1,3 @@ +HMAC-SHA1(fips_aes_core.c)= 979e9a3084dc8e15d9f222bf721e6faccf6bcd18 +HMAC-SHA1(fips_aes_selftest.c)= 98b01502221e7fe529fd981222f2cbb52eb4cbe0 +HMAC-SHA1(fips_aes_locl.h)= ded58f0cda8cb967dc5f5f3a860601c0b8744623 diff --git a/fips/aes/fips_aes_core.c b/fips/aes/fips_aes_core.c new file mode 100644 index 0000000000..371a7f9e49 --- /dev/null +++ b/fips/aes/fips_aes_core.c @@ -0,0 +1,1263 @@ +/* crypto/aes/aes_core.c -*- mode:C; c-file-style: "eay" -*- */ +/** + * rijndael-alg-fst.c + * + * @version 3.0 (December 2000) + * + * Optimised ANSI C code for the Rijndael cipher (now AES) + * + * @author Vincent Rijmen + * @author Antoon Bosselaers + * @author Paulo Barreto + * + * This code is hereby placed in the public domain. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* Note: rewritten a little bit to provide error control and an OpenSSL- + compatible API */ + +#ifndef AES_DEBUG +# ifndef NDEBUG +# define NDEBUG +# endif +#endif +#include + +#include +#include +#include "fips_aes_locl.h" +#include + +#ifdef OPENSSL_FIPS + +/* +Te0[x] = S [x].[02, 01, 01, 03]; +Te1[x] = S [x].[03, 02, 01, 01]; +Te2[x] = S [x].[01, 03, 02, 01]; +Te3[x] = S [x].[01, 01, 03, 02]; +Te4[x] = S [x].[01, 01, 01, 01]; + +Td0[x] = Si[x].[0e, 09, 0d, 0b]; +Td1[x] = Si[x].[0b, 0e, 09, 0d]; +Td2[x] = Si[x].[0d, 0b, 0e, 09]; +Td3[x] = Si[x].[09, 0d, 0b, 0e]; +Td4[x] = Si[x].[01, 01, 01, 01]; +*/ + +static const u32 Te0[256] = { + 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU, + 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U, + 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU, + 0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU, + 0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U, + 0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU, + 0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU, + 0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU, + 0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU, + 0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU, + 0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U, + 0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU, + 0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU, + 0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U, + 0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU, + 0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU, + 0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU, + 0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU, + 0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU, + 0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U, + 0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU, + 0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU, + 0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU, + 0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU, + 0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U, + 0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U, + 0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U, + 0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U, + 0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU, + 0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U, + 0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U, + 0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU, + 0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU, + 0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U, + 0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U, + 0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U, + 0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU, + 0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U, + 0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU, + 0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U, + 0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU, + 0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U, + 0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U, + 0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU, + 0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U, + 0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U, + 0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U, + 0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U, + 0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U, + 0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U, + 0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U, + 0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U, + 0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU, + 0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U, + 0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U, + 0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U, + 0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U, + 0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U, + 0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U, + 0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU, + 0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U, + 0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U, + 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U, + 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU, +}; +static const u32 Te1[256] = { + 0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU, + 0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U, + 0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU, + 0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U, + 0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU, + 0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U, + 0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU, + 0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U, + 0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U, + 0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU, + 0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U, + 0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U, + 0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U, + 0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU, + 0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U, + 0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U, + 0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU, + 0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U, + 0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U, + 0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U, + 0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU, + 0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU, + 0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U, + 0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU, + 0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU, + 0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U, + 0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU, + 0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U, + 0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU, + 0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U, + 0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U, + 0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U, + 0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU, + 0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U, + 0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU, + 0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U, + 0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU, + 0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U, + 0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U, + 0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU, + 0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU, + 0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU, + 0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U, + 0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U, + 0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU, + 0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U, + 0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU, + 0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U, + 0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU, + 0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U, + 0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU, + 0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU, + 0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U, + 0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU, + 0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U, + 0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU, + 0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U, + 0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U, + 0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U, + 0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU, + 0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU, + 0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U, + 0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU, + 0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U, +}; +static const u32 Te2[256] = { + 0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU, + 0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U, + 0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU, + 0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U, + 0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU, + 0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U, + 0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU, + 0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U, + 0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U, + 0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU, + 0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U, + 0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U, + 0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U, + 0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU, + 0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U, + 0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U, + 0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU, + 0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U, + 0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U, + 0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U, + 0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU, + 0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU, + 0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U, + 0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU, + 0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU, + 0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U, + 0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU, + 0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U, + 0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU, + 0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U, + 0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U, + 0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U, + 0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU, + 0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U, + 0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU, + 0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U, + 0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU, + 0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U, + 0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U, + 0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU, + 0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU, + 0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU, + 0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U, + 0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U, + 0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU, + 0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U, + 0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU, + 0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U, + 0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU, + 0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U, + 0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU, + 0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU, + 0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U, + 0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU, + 0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U, + 0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU, + 0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U, + 0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U, + 0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U, + 0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU, + 0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU, + 0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U, + 0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU, + 0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U, +}; +static const u32 Te3[256] = { + + 0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U, + 0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U, + 0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U, + 0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU, + 0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU, + 0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU, + 0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U, + 0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU, + 0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU, + 0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U, + 0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U, + 0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU, + 0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU, + 0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU, + 0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU, + 0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU, + 0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U, + 0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU, + 0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU, + 0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U, + 0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U, + 0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U, + 0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U, + 0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U, + 0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU, + 0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U, + 0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU, + 0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU, + 0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U, + 0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U, + 0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U, + 0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU, + 0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U, + 0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU, + 0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU, + 0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U, + 0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U, + 0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU, + 0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U, + 0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU, + 0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U, + 0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U, + 0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U, + 0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U, + 0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU, + 0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U, + 0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU, + 0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U, + 0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU, + 0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U, + 0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU, + 0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU, + 0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU, + 0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU, + 0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U, + 0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U, + 0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U, + 0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U, + 0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U, + 0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U, + 0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU, + 0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U, + 0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU, + 0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU, +}; +static const u32 Te4[256] = { + 0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU, + 0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U, + 0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU, + 0xfefefefeU, 0xd7d7d7d7U, 0xababababU, 0x76767676U, + 0xcacacacaU, 0x82828282U, 0xc9c9c9c9U, 0x7d7d7d7dU, + 0xfafafafaU, 0x59595959U, 0x47474747U, 0xf0f0f0f0U, + 0xadadadadU, 0xd4d4d4d4U, 0xa2a2a2a2U, 0xafafafafU, + 0x9c9c9c9cU, 0xa4a4a4a4U, 0x72727272U, 0xc0c0c0c0U, + 0xb7b7b7b7U, 0xfdfdfdfdU, 0x93939393U, 0x26262626U, + 0x36363636U, 0x3f3f3f3fU, 0xf7f7f7f7U, 0xccccccccU, + 0x34343434U, 0xa5a5a5a5U, 0xe5e5e5e5U, 0xf1f1f1f1U, + 0x71717171U, 0xd8d8d8d8U, 0x31313131U, 0x15151515U, + 0x04040404U, 0xc7c7c7c7U, 0x23232323U, 0xc3c3c3c3U, + 0x18181818U, 0x96969696U, 0x05050505U, 0x9a9a9a9aU, + 0x07070707U, 0x12121212U, 0x80808080U, 0xe2e2e2e2U, + 0xebebebebU, 0x27272727U, 0xb2b2b2b2U, 0x75757575U, + 0x09090909U, 0x83838383U, 0x2c2c2c2cU, 0x1a1a1a1aU, + 0x1b1b1b1bU, 0x6e6e6e6eU, 0x5a5a5a5aU, 0xa0a0a0a0U, + 0x52525252U, 0x3b3b3b3bU, 0xd6d6d6d6U, 0xb3b3b3b3U, + 0x29292929U, 0xe3e3e3e3U, 0x2f2f2f2fU, 0x84848484U, + 0x53535353U, 0xd1d1d1d1U, 0x00000000U, 0xededededU, + 0x20202020U, 0xfcfcfcfcU, 0xb1b1b1b1U, 0x5b5b5b5bU, + 0x6a6a6a6aU, 0xcbcbcbcbU, 0xbebebebeU, 0x39393939U, + 0x4a4a4a4aU, 0x4c4c4c4cU, 0x58585858U, 0xcfcfcfcfU, + 0xd0d0d0d0U, 0xefefefefU, 0xaaaaaaaaU, 0xfbfbfbfbU, + 0x43434343U, 0x4d4d4d4dU, 0x33333333U, 0x85858585U, + 0x45454545U, 0xf9f9f9f9U, 0x02020202U, 0x7f7f7f7fU, + 0x50505050U, 0x3c3c3c3cU, 0x9f9f9f9fU, 0xa8a8a8a8U, + 0x51515151U, 0xa3a3a3a3U, 0x40404040U, 0x8f8f8f8fU, + 0x92929292U, 0x9d9d9d9dU, 0x38383838U, 0xf5f5f5f5U, + 0xbcbcbcbcU, 0xb6b6b6b6U, 0xdadadadaU, 0x21212121U, + 0x10101010U, 0xffffffffU, 0xf3f3f3f3U, 0xd2d2d2d2U, + 0xcdcdcdcdU, 0x0c0c0c0cU, 0x13131313U, 0xececececU, + 0x5f5f5f5fU, 0x97979797U, 0x44444444U, 0x17171717U, + 0xc4c4c4c4U, 0xa7a7a7a7U, 0x7e7e7e7eU, 0x3d3d3d3dU, + 0x64646464U, 0x5d5d5d5dU, 0x19191919U, 0x73737373U, + 0x60606060U, 0x81818181U, 0x4f4f4f4fU, 0xdcdcdcdcU, + 0x22222222U, 0x2a2a2a2aU, 0x90909090U, 0x88888888U, + 0x46464646U, 0xeeeeeeeeU, 0xb8b8b8b8U, 0x14141414U, + 0xdedededeU, 0x5e5e5e5eU, 0x0b0b0b0bU, 0xdbdbdbdbU, + 0xe0e0e0e0U, 0x32323232U, 0x3a3a3a3aU, 0x0a0a0a0aU, + 0x49494949U, 0x06060606U, 0x24242424U, 0x5c5c5c5cU, + 0xc2c2c2c2U, 0xd3d3d3d3U, 0xacacacacU, 0x62626262U, + 0x91919191U, 0x95959595U, 0xe4e4e4e4U, 0x79797979U, + 0xe7e7e7e7U, 0xc8c8c8c8U, 0x37373737U, 0x6d6d6d6dU, + 0x8d8d8d8dU, 0xd5d5d5d5U, 0x4e4e4e4eU, 0xa9a9a9a9U, + 0x6c6c6c6cU, 0x56565656U, 0xf4f4f4f4U, 0xeaeaeaeaU, + 0x65656565U, 0x7a7a7a7aU, 0xaeaeaeaeU, 0x08080808U, + 0xbabababaU, 0x78787878U, 0x25252525U, 0x2e2e2e2eU, + 0x1c1c1c1cU, 0xa6a6a6a6U, 0xb4b4b4b4U, 0xc6c6c6c6U, + 0xe8e8e8e8U, 0xddddddddU, 0x74747474U, 0x1f1f1f1fU, + 0x4b4b4b4bU, 0xbdbdbdbdU, 0x8b8b8b8bU, 0x8a8a8a8aU, + 0x70707070U, 0x3e3e3e3eU, 0xb5b5b5b5U, 0x66666666U, + 0x48484848U, 0x03030303U, 0xf6f6f6f6U, 0x0e0e0e0eU, + 0x61616161U, 0x35353535U, 0x57575757U, 0xb9b9b9b9U, + 0x86868686U, 0xc1c1c1c1U, 0x1d1d1d1dU, 0x9e9e9e9eU, + 0xe1e1e1e1U, 0xf8f8f8f8U, 0x98989898U, 0x11111111U, + 0x69696969U, 0xd9d9d9d9U, 0x8e8e8e8eU, 0x94949494U, + 0x9b9b9b9bU, 0x1e1e1e1eU, 0x87878787U, 0xe9e9e9e9U, + 0xcecececeU, 0x55555555U, 0x28282828U, 0xdfdfdfdfU, + 0x8c8c8c8cU, 0xa1a1a1a1U, 0x89898989U, 0x0d0d0d0dU, + 0xbfbfbfbfU, 0xe6e6e6e6U, 0x42424242U, 0x68686868U, + 0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU, + 0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U, +}; +static const u32 Td0[256] = { + 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U, + 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U, + 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U, + 0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU, + 0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U, + 0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U, + 0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU, + 0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U, + 0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU, + 0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U, + 0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U, + 0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U, + 0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U, + 0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU, + 0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U, + 0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU, + 0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U, + 0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU, + 0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U, + 0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U, + 0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U, + 0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU, + 0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U, + 0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU, + 0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U, + 0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU, + 0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U, + 0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU, + 0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU, + 0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U, + 0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU, + 0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U, + 0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU, + 0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U, + 0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U, + 0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U, + 0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU, + 0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U, + 0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U, + 0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU, + 0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U, + 0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U, + 0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U, + 0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U, + 0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U, + 0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU, + 0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U, + 0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U, + 0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U, + 0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U, + 0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U, + 0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU, + 0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU, + 0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU, + 0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU, + 0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U, + 0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U, + 0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU, + 0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU, + 0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U, + 0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU, + 0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U, + 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U, + 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U, +}; +static const u32 Td1[256] = { + 0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU, + 0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U, + 0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU, + 0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U, + 0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U, + 0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U, + 0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U, + 0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U, + 0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U, + 0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU, + 0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU, + 0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU, + 0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U, + 0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU, + 0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U, + 0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U, + 0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U, + 0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU, + 0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU, + 0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U, + 0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU, + 0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U, + 0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU, + 0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU, + 0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U, + 0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U, + 0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U, + 0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU, + 0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U, + 0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU, + 0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U, + 0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U, + 0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U, + 0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU, + 0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U, + 0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U, + 0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U, + 0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U, + 0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U, + 0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U, + 0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU, + 0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU, + 0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U, + 0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU, + 0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U, + 0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU, + 0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU, + 0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U, + 0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU, + 0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U, + 0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U, + 0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U, + 0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U, + 0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U, + 0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U, + 0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U, + 0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU, + 0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U, + 0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U, + 0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU, + 0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U, + 0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U, + 0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U, + 0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U, +}; +static const u32 Td2[256] = { + 0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U, + 0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U, + 0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U, + 0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U, + 0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU, + 0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U, + 0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U, + 0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U, + 0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U, + 0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU, + 0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U, + 0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U, + 0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU, + 0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U, + 0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U, + 0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U, + 0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U, + 0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U, + 0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U, + 0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU, + + 0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U, + 0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U, + 0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U, + 0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U, + 0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U, + 0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU, + 0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU, + 0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U, + 0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU, + 0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U, + 0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU, + 0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU, + 0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU, + 0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU, + 0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U, + 0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U, + 0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U, + 0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U, + 0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U, + 0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U, + 0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U, + 0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU, + 0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU, + 0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U, + 0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U, + 0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU, + 0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU, + 0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U, + 0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U, + 0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U, + 0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U, + 0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U, + 0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U, + 0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U, + 0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU, + 0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U, + 0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U, + 0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U, + 0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U, + 0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U, + 0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U, + 0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU, + 0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U, + 0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U, +}; +static const u32 Td3[256] = { + 0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU, + 0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU, + 0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U, + 0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U, + 0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU, + 0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU, + 0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U, + 0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU, + 0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U, + 0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU, + 0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U, + 0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U, + 0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U, + 0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U, + 0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U, + 0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU, + 0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU, + 0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U, + 0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U, + 0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU, + 0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU, + 0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U, + 0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U, + 0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U, + 0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U, + 0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU, + 0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U, + 0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U, + 0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU, + 0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU, + 0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U, + 0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U, + 0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U, + 0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU, + 0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U, + 0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U, + 0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U, + 0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U, + 0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U, + 0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U, + 0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U, + 0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU, + 0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U, + 0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U, + 0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU, + 0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU, + 0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U, + 0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU, + 0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U, + 0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U, + 0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U, + 0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U, + 0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U, + 0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U, + 0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU, + 0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU, + 0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU, + 0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU, + 0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U, + 0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U, + 0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U, + 0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU, + 0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U, + 0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U, +}; +static const u32 Td4[256] = { + 0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U, + 0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U, + 0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU, + 0x81818181U, 0xf3f3f3f3U, 0xd7d7d7d7U, 0xfbfbfbfbU, + 0x7c7c7c7cU, 0xe3e3e3e3U, 0x39393939U, 0x82828282U, + 0x9b9b9b9bU, 0x2f2f2f2fU, 0xffffffffU, 0x87878787U, + 0x34343434U, 0x8e8e8e8eU, 0x43434343U, 0x44444444U, + 0xc4c4c4c4U, 0xdedededeU, 0xe9e9e9e9U, 0xcbcbcbcbU, + 0x54545454U, 0x7b7b7b7bU, 0x94949494U, 0x32323232U, + 0xa6a6a6a6U, 0xc2c2c2c2U, 0x23232323U, 0x3d3d3d3dU, + 0xeeeeeeeeU, 0x4c4c4c4cU, 0x95959595U, 0x0b0b0b0bU, + 0x42424242U, 0xfafafafaU, 0xc3c3c3c3U, 0x4e4e4e4eU, + 0x08080808U, 0x2e2e2e2eU, 0xa1a1a1a1U, 0x66666666U, + 0x28282828U, 0xd9d9d9d9U, 0x24242424U, 0xb2b2b2b2U, + 0x76767676U, 0x5b5b5b5bU, 0xa2a2a2a2U, 0x49494949U, + 0x6d6d6d6dU, 0x8b8b8b8bU, 0xd1d1d1d1U, 0x25252525U, + 0x72727272U, 0xf8f8f8f8U, 0xf6f6f6f6U, 0x64646464U, + 0x86868686U, 0x68686868U, 0x98989898U, 0x16161616U, + 0xd4d4d4d4U, 0xa4a4a4a4U, 0x5c5c5c5cU, 0xccccccccU, + 0x5d5d5d5dU, 0x65656565U, 0xb6b6b6b6U, 0x92929292U, + 0x6c6c6c6cU, 0x70707070U, 0x48484848U, 0x50505050U, + 0xfdfdfdfdU, 0xededededU, 0xb9b9b9b9U, 0xdadadadaU, + 0x5e5e5e5eU, 0x15151515U, 0x46464646U, 0x57575757U, + 0xa7a7a7a7U, 0x8d8d8d8dU, 0x9d9d9d9dU, 0x84848484U, + 0x90909090U, 0xd8d8d8d8U, 0xababababU, 0x00000000U, + 0x8c8c8c8cU, 0xbcbcbcbcU, 0xd3d3d3d3U, 0x0a0a0a0aU, + 0xf7f7f7f7U, 0xe4e4e4e4U, 0x58585858U, 0x05050505U, + 0xb8b8b8b8U, 0xb3b3b3b3U, 0x45454545U, 0x06060606U, + 0xd0d0d0d0U, 0x2c2c2c2cU, 0x1e1e1e1eU, 0x8f8f8f8fU, + 0xcacacacaU, 0x3f3f3f3fU, 0x0f0f0f0fU, 0x02020202U, + 0xc1c1c1c1U, 0xafafafafU, 0xbdbdbdbdU, 0x03030303U, + 0x01010101U, 0x13131313U, 0x8a8a8a8aU, 0x6b6b6b6bU, + 0x3a3a3a3aU, 0x91919191U, 0x11111111U, 0x41414141U, + 0x4f4f4f4fU, 0x67676767U, 0xdcdcdcdcU, 0xeaeaeaeaU, + 0x97979797U, 0xf2f2f2f2U, 0xcfcfcfcfU, 0xcecececeU, + 0xf0f0f0f0U, 0xb4b4b4b4U, 0xe6e6e6e6U, 0x73737373U, + 0x96969696U, 0xacacacacU, 0x74747474U, 0x22222222U, + 0xe7e7e7e7U, 0xadadadadU, 0x35353535U, 0x85858585U, + 0xe2e2e2e2U, 0xf9f9f9f9U, 0x37373737U, 0xe8e8e8e8U, + 0x1c1c1c1cU, 0x75757575U, 0xdfdfdfdfU, 0x6e6e6e6eU, + 0x47474747U, 0xf1f1f1f1U, 0x1a1a1a1aU, 0x71717171U, + 0x1d1d1d1dU, 0x29292929U, 0xc5c5c5c5U, 0x89898989U, + 0x6f6f6f6fU, 0xb7b7b7b7U, 0x62626262U, 0x0e0e0e0eU, + 0xaaaaaaaaU, 0x18181818U, 0xbebebebeU, 0x1b1b1b1bU, + 0xfcfcfcfcU, 0x56565656U, 0x3e3e3e3eU, 0x4b4b4b4bU, + 0xc6c6c6c6U, 0xd2d2d2d2U, 0x79797979U, 0x20202020U, + 0x9a9a9a9aU, 0xdbdbdbdbU, 0xc0c0c0c0U, 0xfefefefeU, + 0x78787878U, 0xcdcdcdcdU, 0x5a5a5a5aU, 0xf4f4f4f4U, + 0x1f1f1f1fU, 0xddddddddU, 0xa8a8a8a8U, 0x33333333U, + 0x88888888U, 0x07070707U, 0xc7c7c7c7U, 0x31313131U, + 0xb1b1b1b1U, 0x12121212U, 0x10101010U, 0x59595959U, + 0x27272727U, 0x80808080U, 0xececececU, 0x5f5f5f5fU, + 0x60606060U, 0x51515151U, 0x7f7f7f7fU, 0xa9a9a9a9U, + 0x19191919U, 0xb5b5b5b5U, 0x4a4a4a4aU, 0x0d0d0d0dU, + 0x2d2d2d2dU, 0xe5e5e5e5U, 0x7a7a7a7aU, 0x9f9f9f9fU, + 0x93939393U, 0xc9c9c9c9U, 0x9c9c9c9cU, 0xefefefefU, + 0xa0a0a0a0U, 0xe0e0e0e0U, 0x3b3b3b3bU, 0x4d4d4d4dU, + 0xaeaeaeaeU, 0x2a2a2a2aU, 0xf5f5f5f5U, 0xb0b0b0b0U, + 0xc8c8c8c8U, 0xebebebebU, 0xbbbbbbbbU, 0x3c3c3c3cU, + 0x83838383U, 0x53535353U, 0x99999999U, 0x61616161U, + 0x17171717U, 0x2b2b2b2bU, 0x04040404U, 0x7e7e7e7eU, + 0xbabababaU, 0x77777777U, 0xd6d6d6d6U, 0x26262626U, + 0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U, + 0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU, +}; +static const u32 rcon[] = { + 0x01000000, 0x02000000, 0x04000000, 0x08000000, + 0x10000000, 0x20000000, 0x40000000, 0x80000000, + 0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */ +}; + +/** + * Expand the cipher key into the encryption key schedule. + */ +int AES_set_encrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key) { + + u32 *rk; + int i = 0; + u32 temp; + + if (!userKey || !key) + return -1; + if (bits != 128 && bits != 192 && bits != 256) + return -2; + if(FIPS_selftest_fail) + return -3; + + rk = key->rd_key; + + if (bits==128) + key->rounds = 10; + else if (bits==192) + key->rounds = 12; + else + key->rounds = 14; + + rk[0] = GETU32(userKey ); + rk[1] = GETU32(userKey + 4); + rk[2] = GETU32(userKey + 8); + rk[3] = GETU32(userKey + 12); + if (bits == 128) { + while (1) { + temp = rk[3]; + rk[4] = rk[0] ^ + (Te4[(temp >> 16) & 0xff] & 0xff000000) ^ + (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^ + (Te4[(temp ) & 0xff] & 0x0000ff00) ^ + (Te4[(temp >> 24) ] & 0x000000ff) ^ + rcon[i]; + rk[5] = rk[1] ^ rk[4]; + rk[6] = rk[2] ^ rk[5]; + rk[7] = rk[3] ^ rk[6]; + if (++i == 10) { + return 0; + } + rk += 4; + } + } + rk[4] = GETU32(userKey + 16); + rk[5] = GETU32(userKey + 20); + if (bits == 192) { + while (1) { + temp = rk[ 5]; + rk[ 6] = rk[ 0] ^ + (Te4[(temp >> 16) & 0xff] & 0xff000000) ^ + (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^ + (Te4[(temp ) & 0xff] & 0x0000ff00) ^ + (Te4[(temp >> 24) ] & 0x000000ff) ^ + rcon[i]; + rk[ 7] = rk[ 1] ^ rk[ 6]; + rk[ 8] = rk[ 2] ^ rk[ 7]; + rk[ 9] = rk[ 3] ^ rk[ 8]; + if (++i == 8) { + return 0; + } + rk[10] = rk[ 4] ^ rk[ 9]; + rk[11] = rk[ 5] ^ rk[10]; + rk += 6; + } + } + rk[6] = GETU32(userKey + 24); + rk[7] = GETU32(userKey + 28); + if (bits == 256) { + while (1) { + temp = rk[ 7]; + rk[ 8] = rk[ 0] ^ + (Te4[(temp >> 16) & 0xff] & 0xff000000) ^ + (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^ + (Te4[(temp ) & 0xff] & 0x0000ff00) ^ + (Te4[(temp >> 24) ] & 0x000000ff) ^ + rcon[i]; + rk[ 9] = rk[ 1] ^ rk[ 8]; + rk[10] = rk[ 2] ^ rk[ 9]; + rk[11] = rk[ 3] ^ rk[10]; + if (++i == 7) { + return 0; + } + temp = rk[11]; + rk[12] = rk[ 4] ^ + (Te4[(temp >> 24) ] & 0xff000000) ^ + (Te4[(temp >> 16) & 0xff] & 0x00ff0000) ^ + (Te4[(temp >> 8) & 0xff] & 0x0000ff00) ^ + (Te4[(temp ) & 0xff] & 0x000000ff); + rk[13] = rk[ 5] ^ rk[12]; + rk[14] = rk[ 6] ^ rk[13]; + rk[15] = rk[ 7] ^ rk[14]; + + rk += 8; + } + } + return 0; +} + +/** + * Expand the cipher key into the decryption key schedule. + */ +int AES_set_decrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key) { + + u32 *rk; + int i, j, status; + u32 temp; + + /* first, start with an encryption schedule */ + status = AES_set_encrypt_key(userKey, bits, key); + if (status < 0) + return status; + + rk = key->rd_key; + + /* invert the order of the round keys: */ + for (i = 0, j = 4*(key->rounds); i < j; i += 4, j -= 4) { + temp = rk[i ]; rk[i ] = rk[j ]; rk[j ] = temp; + temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp; + temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp; + temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp; + } + /* apply the inverse MixColumn transform to all round keys but the first and the last: */ + for (i = 1; i < (key->rounds); i++) { + rk += 4; + rk[0] = + Td0[Te4[(rk[0] >> 24) ] & 0xff] ^ + Td1[Te4[(rk[0] >> 16) & 0xff] & 0xff] ^ + Td2[Te4[(rk[0] >> 8) & 0xff] & 0xff] ^ + Td3[Te4[(rk[0] ) & 0xff] & 0xff]; + rk[1] = + Td0[Te4[(rk[1] >> 24) ] & 0xff] ^ + Td1[Te4[(rk[1] >> 16) & 0xff] & 0xff] ^ + Td2[Te4[(rk[1] >> 8) & 0xff] & 0xff] ^ + Td3[Te4[(rk[1] ) & 0xff] & 0xff]; + rk[2] = + Td0[Te4[(rk[2] >> 24) ] & 0xff] ^ + Td1[Te4[(rk[2] >> 16) & 0xff] & 0xff] ^ + Td2[Te4[(rk[2] >> 8) & 0xff] & 0xff] ^ + Td3[Te4[(rk[2] ) & 0xff] & 0xff]; + rk[3] = + Td0[Te4[(rk[3] >> 24) ] & 0xff] ^ + Td1[Te4[(rk[3] >> 16) & 0xff] & 0xff] ^ + Td2[Te4[(rk[3] >> 8) & 0xff] & 0xff] ^ + Td3[Te4[(rk[3] ) & 0xff] & 0xff]; + } + return 0; +} + +/* + * Encrypt a single block + * in and out can overlap + */ +void AES_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key) { + + const u32 *rk; + u32 s0, s1, s2, s3, t0, t1, t2, t3; +#ifndef FULL_UNROLL + int r; +#endif /* ?FULL_UNROLL */ + + assert(in && out && key); + rk = key->rd_key; + + /* + * map byte array block to cipher state + * and add initial round key: + */ + s0 = GETU32(in ) ^ rk[0]; + s1 = GETU32(in + 4) ^ rk[1]; + s2 = GETU32(in + 8) ^ rk[2]; + s3 = GETU32(in + 12) ^ rk[3]; +#ifdef FULL_UNROLL + /* round 1: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[ 4]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[ 5]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[ 6]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[ 7]; + /* round 2: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[ 8]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[ 9]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[10]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[11]; + /* round 3: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[12]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[13]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[14]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[15]; + /* round 4: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[16]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[17]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[18]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[19]; + /* round 5: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[20]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[21]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[22]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[23]; + /* round 6: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[24]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[25]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[26]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[27]; + /* round 7: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[28]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[29]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[30]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[31]; + /* round 8: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[32]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[33]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[34]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[35]; + /* round 9: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[36]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[37]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[38]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[39]; + if (key->rounds > 10) { + /* round 10: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[40]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[41]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[42]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[43]; + /* round 11: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[44]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[45]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[46]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[47]; + if (key->rounds > 12) { + /* round 12: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[48]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[49]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[50]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[51]; + /* round 13: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[52]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[53]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[54]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[55]; + } + } + rk += key->rounds << 2; +#else /* !FULL_UNROLL */ + /* + * Nr - 1 full rounds: + */ + r = key->rounds >> 1; + for (;;) { + t0 = + Te0[(s0 >> 24) ] ^ + Te1[(s1 >> 16) & 0xff] ^ + Te2[(s2 >> 8) & 0xff] ^ + Te3[(s3 ) & 0xff] ^ + rk[4]; + t1 = + Te0[(s1 >> 24) ] ^ + Te1[(s2 >> 16) & 0xff] ^ + Te2[(s3 >> 8) & 0xff] ^ + Te3[(s0 ) & 0xff] ^ + rk[5]; + t2 = + Te0[(s2 >> 24) ] ^ + Te1[(s3 >> 16) & 0xff] ^ + Te2[(s0 >> 8) & 0xff] ^ + Te3[(s1 ) & 0xff] ^ + rk[6]; + t3 = + Te0[(s3 >> 24) ] ^ + Te1[(s0 >> 16) & 0xff] ^ + Te2[(s1 >> 8) & 0xff] ^ + Te3[(s2 ) & 0xff] ^ + rk[7]; + + rk += 8; + if (--r == 0) { + break; + } + + s0 = + Te0[(t0 >> 24) ] ^ + Te1[(t1 >> 16) & 0xff] ^ + Te2[(t2 >> 8) & 0xff] ^ + Te3[(t3 ) & 0xff] ^ + rk[0]; + s1 = + Te0[(t1 >> 24) ] ^ + Te1[(t2 >> 16) & 0xff] ^ + Te2[(t3 >> 8) & 0xff] ^ + Te3[(t0 ) & 0xff] ^ + rk[1]; + s2 = + Te0[(t2 >> 24) ] ^ + Te1[(t3 >> 16) & 0xff] ^ + Te2[(t0 >> 8) & 0xff] ^ + Te3[(t1 ) & 0xff] ^ + rk[2]; + s3 = + Te0[(t3 >> 24) ] ^ + Te1[(t0 >> 16) & 0xff] ^ + Te2[(t1 >> 8) & 0xff] ^ + Te3[(t2 ) & 0xff] ^ + rk[3]; + } +#endif /* ?FULL_UNROLL */ + /* + * apply last round and + * map cipher state to byte array block: + */ + s0 = + (Te4[(t0 >> 24) ] & 0xff000000) ^ + (Te4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ + (Te4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ + (Te4[(t3 ) & 0xff] & 0x000000ff) ^ + rk[0]; + PUTU32(out , s0); + s1 = + (Te4[(t1 >> 24) ] & 0xff000000) ^ + (Te4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ + (Te4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ + (Te4[(t0 ) & 0xff] & 0x000000ff) ^ + rk[1]; + PUTU32(out + 4, s1); + s2 = + (Te4[(t2 >> 24) ] & 0xff000000) ^ + (Te4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ + (Te4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ + (Te4[(t1 ) & 0xff] & 0x000000ff) ^ + rk[2]; + PUTU32(out + 8, s2); + s3 = + (Te4[(t3 >> 24) ] & 0xff000000) ^ + (Te4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ + (Te4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ + (Te4[(t2 ) & 0xff] & 0x000000ff) ^ + rk[3]; + PUTU32(out + 12, s3); +} + +/* + * Decrypt a single block + * in and out can overlap + */ +void AES_decrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key) { + + const u32 *rk; + u32 s0, s1, s2, s3, t0, t1, t2, t3; +#ifndef FULL_UNROLL + int r; +#endif /* ?FULL_UNROLL */ + + assert(in && out && key); + rk = key->rd_key; + + /* + * map byte array block to cipher state + * and add initial round key: + */ + s0 = GETU32(in ) ^ rk[0]; + s1 = GETU32(in + 4) ^ rk[1]; + s2 = GETU32(in + 8) ^ rk[2]; + s3 = GETU32(in + 12) ^ rk[3]; +#ifdef FULL_UNROLL + /* round 1: */ + t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[ 4]; + t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[ 5]; + t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[ 6]; + t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[ 7]; + /* round 2: */ + s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[ 8]; + s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[ 9]; + s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[10]; + s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[11]; + /* round 3: */ + t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[12]; + t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[13]; + t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[14]; + t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[15]; + /* round 4: */ + s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[16]; + s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[17]; + s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[18]; + s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[19]; + /* round 5: */ + t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[20]; + t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[21]; + t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[22]; + t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[23]; + /* round 6: */ + s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[24]; + s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[25]; + s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[26]; + s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[27]; + /* round 7: */ + t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[28]; + t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[29]; + t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[30]; + t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[31]; + /* round 8: */ + s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[32]; + s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[33]; + s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[34]; + s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[35]; + /* round 9: */ + t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[36]; + t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[37]; + t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[38]; + t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[39]; + if (key->rounds > 10) { + /* round 10: */ + s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[40]; + s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[41]; + s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[42]; + s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[43]; + /* round 11: */ + t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[44]; + t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[45]; + t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[46]; + t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[47]; + if (key->rounds > 12) { + /* round 12: */ + s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[48]; + s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[49]; + s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[50]; + s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[51]; + /* round 13: */ + t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[52]; + t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[53]; + t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[54]; + t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[55]; + } + } + rk += key->rounds << 2; +#else /* !FULL_UNROLL */ + /* + * Nr - 1 full rounds: + */ + r = key->rounds >> 1; + for (;;) { + t0 = + Td0[(s0 >> 24) ] ^ + Td1[(s3 >> 16) & 0xff] ^ + Td2[(s2 >> 8) & 0xff] ^ + Td3[(s1 ) & 0xff] ^ + rk[4]; + t1 = + Td0[(s1 >> 24) ] ^ + Td1[(s0 >> 16) & 0xff] ^ + Td2[(s3 >> 8) & 0xff] ^ + Td3[(s2 ) & 0xff] ^ + rk[5]; + t2 = + Td0[(s2 >> 24) ] ^ + Td1[(s1 >> 16) & 0xff] ^ + Td2[(s0 >> 8) & 0xff] ^ + Td3[(s3 ) & 0xff] ^ + rk[6]; + t3 = + Td0[(s3 >> 24) ] ^ + Td1[(s2 >> 16) & 0xff] ^ + Td2[(s1 >> 8) & 0xff] ^ + Td3[(s0 ) & 0xff] ^ + rk[7]; + + rk += 8; + if (--r == 0) { + break; + } + + s0 = + Td0[(t0 >> 24) ] ^ + Td1[(t3 >> 16) & 0xff] ^ + Td2[(t2 >> 8) & 0xff] ^ + Td3[(t1 ) & 0xff] ^ + rk[0]; + s1 = + Td0[(t1 >> 24) ] ^ + Td1[(t0 >> 16) & 0xff] ^ + Td2[(t3 >> 8) & 0xff] ^ + Td3[(t2 ) & 0xff] ^ + rk[1]; + s2 = + Td0[(t2 >> 24) ] ^ + Td1[(t1 >> 16) & 0xff] ^ + Td2[(t0 >> 8) & 0xff] ^ + Td3[(t3 ) & 0xff] ^ + rk[2]; + s3 = + Td0[(t3 >> 24) ] ^ + Td1[(t2 >> 16) & 0xff] ^ + Td2[(t1 >> 8) & 0xff] ^ + Td3[(t0 ) & 0xff] ^ + rk[3]; + } +#endif /* ?FULL_UNROLL */ + /* + * apply last round and + * map cipher state to byte array block: + */ + s0 = + (Td4[(t0 >> 24) ] & 0xff000000) ^ + (Td4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ + (Td4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ + (Td4[(t1 ) & 0xff] & 0x000000ff) ^ + rk[0]; + PUTU32(out , s0); + s1 = + (Td4[(t1 >> 24) ] & 0xff000000) ^ + (Td4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ + (Td4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ + (Td4[(t2 ) & 0xff] & 0x000000ff) ^ + rk[1]; + PUTU32(out + 4, s1); + s2 = + (Td4[(t2 >> 24) ] & 0xff000000) ^ + (Td4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ + (Td4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ + (Td4[(t3 ) & 0xff] & 0x000000ff) ^ + rk[2]; + PUTU32(out + 8, s2); + s3 = + (Td4[(t3 >> 24) ] & 0xff000000) ^ + (Td4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ + (Td4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ + (Td4[(t0 ) & 0xff] & 0x000000ff) ^ + rk[3]; + PUTU32(out + 12, s3); +} + +#endif /* def OPENSSL_FIPS */ diff --git a/fips/aes/fips_aes_locl.h b/fips/aes/fips_aes_locl.h new file mode 100644 index 0000000000..f290946058 --- /dev/null +++ b/fips/aes/fips_aes_locl.h @@ -0,0 +1,85 @@ +/* crypto/aes/aes.h -*- mode:C; c-file-style: "eay" -*- */ +/* ==================================================================== + * Copyright (c) 1998-2002 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 + * openssl-core@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. + * ==================================================================== + * + */ + +#ifndef HEADER_AES_LOCL_H +#define HEADER_AES_LOCL_H + +#include + +#ifdef OPENSSL_NO_AES +#error AES is disabled. +#endif + +#include +#include +#include + +#if defined(_MSC_VER) && !defined(OPENSSL_SYS_WINCE) +# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00) +# define GETU32(p) SWAP(*((u32 *)(p))) +# define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); } +#else +# define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3])) +# define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); } +#endif + +typedef unsigned long u32; +typedef unsigned short u16; +typedef unsigned char u8; + +#define MAXKC (256/32) +#define MAXKB (256/8) +#define MAXNR 14 + +/* This controls loop-unrolling in aes_core.c */ +#undef FULL_UNROLL + +#endif /* !HEADER_AES_LOCL_H */ diff --git a/fips/aes/fips_aes_selftest.c b/fips/aes/fips_aes_selftest.c new file mode 100644 index 0000000000..0e53d21bd0 --- /dev/null +++ b/fips/aes/fips_aes_selftest.c @@ -0,0 +1,112 @@ +/* ==================================================================== + * Copyright (c) 2003 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 + * openssl-core@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. + * + */ + +#include +#include +#include +#include + +#ifdef OPENSSL_FIPS +static struct + { + unsigned char key[16]; + unsigned char plaintext[16]; + unsigned char ciphertext[16]; + } tests[]= + { + { + { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F }, + { 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77, + 0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF }, + { 0x69,0xC4,0xE0,0xD8,0x6A,0x7B,0x04,0x30, + 0xD8,0xCD,0xB7,0x80,0x70,0xB4,0xC5,0x5A }, + }, + }; + +void FIPS_corrupt_aes() + { + tests[0].key[0]++; + } + +int FIPS_selftest_aes() + { + int n; + + /* Encrypt and check against known ciphertext */ + for(n=0 ; n < 1 ; ++n) + { + AES_KEY key; + unsigned char buf[16]; + + AES_set_encrypt_key(tests[n].key,128,&key); + AES_encrypt(tests[n].plaintext,buf,&key); + if(memcmp(buf,tests[n].ciphertext,sizeof buf)) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_AES,FIPS_R_SELFTEST_FAILED); + return 0; + } + } + /* Decrypt and check against known plaintext */ + for(n=0 ; n < 1 ; ++n) + { + AES_KEY key; + unsigned char buf[16]; + + AES_set_decrypt_key(tests[n].key,128,&key); + AES_decrypt(tests[n].ciphertext,buf,&key); + if(memcmp(buf,tests[n].plaintext,sizeof buf)) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_AES,FIPS_R_SELFTEST_FAILED); + return 0; + } + } + return 1; + } +#endif diff --git a/fips/aes/fips_aesavs.c b/fips/aes/fips_aesavs.c new file mode 100644 index 0000000000..29e97b0cf7 --- /dev/null +++ b/fips/aes/fips_aesavs.c @@ -0,0 +1,956 @@ +/*--------------------------------------------- + NIST AES Algorithm Validation Suite + Test Program + + Copyright + V-ONE Corporation + 20250 Century Blvd, Suite 300 + Germantown, MD 20874 + U.S.A. + ----------------------------------------------*/ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include "e_os.h" + +#define AES_BLOCK_SIZE 16 + +#define VERBOSE 1 + +/*-----------------------------------------------*/ + +int AESTest(EVP_CIPHER_CTX *ctx, + char *amode, int akeysz, unsigned char *aKey, + unsigned char *iVec, + int dir, /* 0 = decrypt, 1 = encrypt */ + unsigned char *plaintext, unsigned char *ciphertext, int len) + { + const EVP_CIPHER *cipher = NULL; + int ret = 1; + int kt = 0; + + if (ctx) + memset(ctx, 0, sizeof(EVP_CIPHER_CTX)); + + if (strcasecmp(amode, "CBC") == 0) + kt = 1000; + else if (strcasecmp(amode, "ECB") == 0) + kt = 2000; + else if (strcasecmp(amode, "CFB128") == 0) + kt = 3000; + else if (strncasecmp(amode, "OFB", 3) == 0) + kt = 4000; + else if(!strcasecmp(amode,"CFB1")) + kt=5000; + else if(!strcasecmp(amode,"CFB8")) + kt=6000; + else + { + printf("Unknown mode: %s\n", amode); + exit(1); + } + if (ret) + { + if ((akeysz != 128) && (akeysz != 192) && (akeysz != 256)) + { + printf("Invalid key size: %d\n", akeysz); + ret = 0; + } + else + { + kt += akeysz; + switch (kt) + { + case 1128: /* CBC 128 */ + cipher = EVP_aes_128_cbc(); + break; + case 1192: /* CBC 192 */ + cipher = EVP_aes_192_cbc(); + break; + case 1256: /* CBC 256 */ + cipher = EVP_aes_256_cbc(); + break; + case 2128: /* ECB 128 */ + cipher = EVP_aes_128_ecb(); + break; + case 2192: /* ECB 192 */ + cipher = EVP_aes_192_ecb(); + break; + case 2256: /* ECB 256 */ + cipher = EVP_aes_256_ecb(); + break; + case 3128: /* CFB 128 */ + cipher = EVP_aes_128_cfb(); + break; + case 3192: /* CFB 192 */ + cipher = EVP_aes_192_cfb(); + break; + case 3256: /* CFB 256 */ + cipher = EVP_aes_256_cfb(); + break; + case 4128: /* OFB 128 */ + cipher = EVP_aes_128_ofb(); + break; + case 4192: /* OFB 192 */ + cipher = EVP_aes_192_ofb(); + break; + case 4256: /* OFB 256 */ + cipher = EVP_aes_256_ofb(); + break; + case 5128: + cipher=EVP_aes_128_cfb1(); + break; + case 5192: + cipher=EVP_aes_192_cfb1(); + break; + case 5256: + cipher=EVP_aes_256_cfb1(); + break; + case 6128: + cipher=EVP_aes_128_cfb8(); + break; + case 6192: + cipher=EVP_aes_192_cfb8(); + break; + case 6256: + cipher=EVP_aes_256_cfb8(); + break; + default: + printf("Didn't handle mode %d\n",kt); + exit(1); + } + if (dir) + { /* encrypt */ + if(!EVP_CipherInit(ctx, cipher, aKey, iVec, AES_ENCRYPT)) + { + ERR_print_errors_fp(stderr); + exit(1); + } + + EVP_Cipher(ctx, ciphertext, (unsigned char*)plaintext, len); + } + else + { /* decrypt */ + if(!EVP_CipherInit(ctx, cipher, aKey, iVec, AES_DECRYPT)) + { + ERR_print_errors_fp(stderr); + exit(1); + } + EVP_Cipher(ctx, (unsigned char*)plaintext, ciphertext, len); + } + } + } + return ret; + } + +/*-----------------------------------------------*/ + +int hex2bin(char *in, int len, unsigned char *out) +{ + int n1, n2; + unsigned char ch; + + for (n1 = 0, n2 = 0; n1 < len; ) + { /* first byte */ + if ((in[n1] >= '0') && (in[n1] <= '9')) + ch = in[n1++] - '0'; + else if ((in[n1] >= 'A') && (in[n1] <= 'F')) + ch = in[n1++] - 'A' + 10; + else if ((in[n1] >= 'a') && (in[n1] <= 'f')) + ch = in[n1++] - 'a' + 10; + else + return -1; + if(len == 1) + { + out[n2++]=ch; + break; + } + out[n2] = ch << 4; + /* second byte */ + if ((in[n1] >= '0') && (in[n1] <= '9')) + ch = in[n1++] - '0'; + else if ((in[n1] >= 'A') && (in[n1] <= 'F')) + ch = in[n1++] - 'A' + 10; + else if ((in[n1] >= 'a') && (in[n1] <= 'f')) + ch = in[n1++] - 'a' + 10; + else + return -1; + out[n2++] |= ch; + } + return n2; +} + +/*-----------------------------------------------*/ + +int bin2hex(unsigned char *in, int len, char *out) +{ + int n1, n2; + unsigned char ch; + + for (n1 = 0, n2 = 0; n1 < len; ++n1) + { + /* first nibble */ + ch = in[n1] >> 4; + if (ch <= 0x09) + out[n2++] = ch + '0'; + else + out[n2++] = ch - 10 + 'a'; + /* second nibble */ + ch = in[n1] & 0x0f; + if (ch <= 0x09) + out[n2++] = ch + '0'; + else + out[n2++] = ch - 10 + 'a'; + } + return n2; +} + +/* NB: this return the number of _bits_ read */ +int bint2bin(const char *in, int len, unsigned char *out) + { + int n; + + memset(out,0,len); + for(n=0 ; n < len ; ++n) + if(in[n] == '1') + out[n/8]|=(0x80 >> (n%8)); + return len; + } + +int bin2bint(const unsigned char *in,int len,char *out) + { + int n; + + for(n=0 ; n < len ; ++n) + out[n]=(in[n/8]&(0x80 >> (n%8))) ? '1' : '0'; + return n; + } + +/*-----------------------------------------------*/ + +void PrintValue(char *tag, unsigned char *val, int len) +{ +#if VERBOSE + char obuf[2048]; + int olen; + olen = bin2hex(val, len, obuf); + printf("%s = %.*s\n", tag, olen, obuf); +#endif +} + +void OutputValue(char *tag, unsigned char *val, int len, FILE *rfp,int bitmode) + { + char obuf[2048]; + int olen; + + if(bitmode) + olen=bin2bint(val,len,obuf); + else + olen=bin2hex(val,len,obuf); + + fprintf(rfp, "%s = %.*s\n", tag, olen, obuf); +#if VERBOSE + printf("%s = %.*s\n", tag, olen, obuf); +#endif + } + +/*-----------------------------------------------*/ +char *t_tag[2] = {"PLAINTEXT", "CIPHERTEXT"}; +char *t_mode[6] = {"CBC","ECB","OFB","CFB1","CFB8","CFB128"}; +enum Mode {CBC, ECB, OFB, CFB1, CFB8, CFB128}; +enum XCrypt {XDECRYPT, XENCRYPT}; + +/*=============================*/ +/* Monte Carlo Tests */ +/*-----------------------------*/ + +/*#define gb(a,b) (((a)[(b)/8] >> ((b)%8))&1)*/ +/*#define sb(a,b,v) ((a)[(b)/8]=((a)[(b)/8]&~(1 << ((b)%8)))|(!!(v) << ((b)%8)))*/ + +#define gb(a,b) (((a)[(b)/8] >> (7-(b)%8))&1) +#define sb(a,b,v) ((a)[(b)/8]=((a)[(b)/8]&~(1 << (7-(b)%8)))|(!!(v) << (7-(b)%8))) + +int do_mct(char *amode, + int akeysz, unsigned char *aKey,unsigned char *iVec, + int dir, unsigned char *text, int len, + FILE *rfp) + { + int ret = 0; + unsigned char key[101][32]; + unsigned char iv[101][AES_BLOCK_SIZE]; + unsigned char ptext[1001][32]; + unsigned char ctext[1001][32]; + unsigned char ciphertext[64+4]; + int i, j, n, n1, n2; + int imode = 0, nkeysz = akeysz/8; + EVP_CIPHER_CTX ctx; + + if (len > 32) + { + printf("\n>>>> Length exceeds 32 for %s %d <<<<\n\n", + amode, akeysz); + return -1; + } + for (imode = 0; imode < 6; ++imode) + if (strcmp(amode, t_mode[imode]) == 0) + break; + if (imode == 6) + { + printf("Unrecognized mode: %s\n", amode); + return -1; + } + + memcpy(key[0], aKey, nkeysz); + if (iVec) + memcpy(iv[0], iVec, AES_BLOCK_SIZE); + if (dir == XENCRYPT) + memcpy(ptext[0], text, len); + else + memcpy(ctext[0], text, len); + for (i = 0; i < 100; ++i) + { + /* printf("Iteration %d\n", i); */ + if (i > 0) + { + fprintf(rfp,"COUNT = %d\n",i); + OutputValue("KEY",key[i],nkeysz,rfp,0); + if (imode != ECB) /* ECB */ + OutputValue("IV",iv[i],AES_BLOCK_SIZE,rfp,0); + /* Output Ciphertext | Plaintext */ + OutputValue(t_tag[dir^1],dir ? ptext[0] : ctext[0],len,rfp, + imode == CFB1); + } + for (j = 0; j < 1000; ++j) + { + switch (imode) + { + case ECB: + if (j == 0) + { /* set up encryption */ + ret = AESTest(&ctx, amode, akeysz, key[i], NULL, + dir, /* 0 = decrypt, 1 = encrypt */ + ptext[j], ctext[j], len); + if (dir == XENCRYPT) + memcpy(ptext[j+1], ctext[j], len); + else + memcpy(ctext[j+1], ptext[j], len); + } + else + { + if (dir == XENCRYPT) + { + EVP_Cipher(&ctx, ctext[j], ptext[j], len); + memcpy(ptext[j+1], ctext[j], len); + } + else + { + EVP_Cipher(&ctx, ptext[j], ctext[j], len); + memcpy(ctext[j+1], ptext[j], len); + } + } + break; + + case CBC: + case OFB: + case CFB128: + if (j == 0) + { + ret = AESTest(&ctx, amode, akeysz, key[i], iv[i], + dir, /* 0 = decrypt, 1 = encrypt */ + ptext[j], ctext[j], len); + if (dir == XENCRYPT) + memcpy(ptext[j+1], iv[i], len); + else + memcpy(ctext[j+1], iv[i], len); + } + else + { + if (dir == XENCRYPT) + { + EVP_Cipher(&ctx, ctext[j], ptext[j], len); + memcpy(ptext[j+1], ctext[j-1], len); + } + else + { + EVP_Cipher(&ctx, ptext[j], ctext[j], len); + memcpy(ctext[j+1], ptext[j-1], len); + } + } + break; + + case CFB8: + if (j == 0) + { + ret = AESTest(&ctx, amode, akeysz, key[i], iv[i], + dir, /* 0 = decrypt, 1 = encrypt */ + ptext[j], ctext[j], len); + } + else + { + if (dir == XENCRYPT) + EVP_Cipher(&ctx, ctext[j], ptext[j], len); + else + EVP_Cipher(&ctx, ptext[j], ctext[j], len); + } + if (dir == XENCRYPT) + { + if (j < 16) + memcpy(ptext[j+1], &iv[i][j], len); + else + memcpy(ptext[j+1], ctext[j-16], len); + } + else + { + if (j < 16) + memcpy(ctext[j+1], &iv[i][j], len); + else + memcpy(ctext[j+1], ptext[j-16], len); + } + break; + + case CFB1: + if(j == 0) + { + /* compensate for wrong endianness of input file */ + if(i == 0) + ptext[0][0]<<=7; + ret=AESTest(&ctx,amode,akeysz,key[i],iv[i],dir, + ptext[j], ctext[j], len); + } + else + { + if (dir == XENCRYPT) + EVP_Cipher(&ctx, ctext[j], ptext[j], len); + else + EVP_Cipher(&ctx, ptext[j], ctext[j], len); + + } + if(dir == XENCRYPT) + { + if(j < 128) + sb(ptext[j+1],0,gb(iv[i],j)); + else + sb(ptext[j+1],0,gb(ctext[j-128],0)); + } + else + { + if(j < 128) + sb(ctext[j+1],0,gb(iv[i],j)); + else + sb(ctext[j+1],0,gb(ptext[j-128],0)); + } + break; + } + } + --j; /* reset to last of range */ + /* Output Ciphertext | Plaintext */ + OutputValue(t_tag[dir],dir ? ctext[j] : ptext[j],len,rfp, + imode == CFB1); + fprintf(rfp, "\n"); /* add separator */ + + /* Compute next KEY */ + if (dir == XENCRYPT) + { + if (imode == CFB8) + { /* ct = CT[j-15] || CT[j-14] || ... || CT[j] */ + for (n1 = 0, n2 = nkeysz-1; n1 < nkeysz; ++n1, --n2) + ciphertext[n1] = ctext[j-n2][0]; + } + else if(imode == CFB1) + { + for(n1=0,n2=akeysz-1 ; n1 < akeysz ; ++n1,--n2) + sb(ciphertext,n1,gb(ctext[j-n2],0)); + } + else + switch (akeysz) + { + case 128: + memcpy(ciphertext, ctext[j], 16); + break; + case 192: + memcpy(ciphertext, ctext[j-1]+8, 8); + memcpy(ciphertext+8, ctext[j], 16); + break; + case 256: + memcpy(ciphertext, ctext[j-1], 16); + memcpy(ciphertext+16, ctext[j], 16); + break; + } + } + else + { + if (imode == CFB8) + { /* ct = CT[j-15] || CT[j-14] || ... || CT[j] */ + for (n1 = 0, n2 = nkeysz-1; n1 < nkeysz; ++n1, --n2) + ciphertext[n1] = ptext[j-n2][0]; + } + else if(imode == CFB1) + { + for(n1=0,n2=akeysz-1 ; n1 < akeysz ; ++n1,--n2) + sb(ciphertext,n1,gb(ptext[j-n2],0)); + } + else + switch (akeysz) + { + case 128: + memcpy(ciphertext, ptext[j], 16); + break; + case 192: + memcpy(ciphertext, ptext[j-1]+8, 8); + memcpy(ciphertext+8, ptext[j], 16); + break; + case 256: + memcpy(ciphertext, ptext[j-1], 16); + memcpy(ciphertext+16, ptext[j], 16); + break; + } + } + /* Compute next key: Key[i+1] = Key[i] xor ct */ + for (n = 0; n < nkeysz; ++n) + key[i+1][n] = key[i][n] ^ ciphertext[n]; + + /* Compute next IV and text */ + if (dir == XENCRYPT) + { + switch (imode) + { + case ECB: + memcpy(ptext[0], ctext[j], AES_BLOCK_SIZE); + break; + case CBC: + case OFB: + case CFB128: + memcpy(iv[i+1], ctext[j], AES_BLOCK_SIZE); + memcpy(ptext[0], ctext[j-1], AES_BLOCK_SIZE); + break; + case CFB8: + /* IV[i+1] = ct */ + for (n1 = 0, n2 = 15; n1 < 16; ++n1, --n2) + iv[i+1][n1] = ctext[j-n2][0]; + ptext[0][0] = ctext[j-16][0]; + break; + case CFB1: + for(n1=0,n2=127 ; n1 < 128 ; ++n1,--n2) + sb(iv[i+1],n1,gb(ctext[j-n2],0)); + ptext[0][0]=ctext[j-128][0]&0x80; + break; + } + } + else + { + switch (imode) + { + case ECB: + memcpy(ctext[0], ptext[j], AES_BLOCK_SIZE); + break; + case CBC: + case OFB: + case CFB128: + memcpy(iv[i+1], ptext[j], AES_BLOCK_SIZE); + memcpy(ctext[0], ptext[j-1], AES_BLOCK_SIZE); + break; + case CFB8: + for (n1 = 0, n2 = 15; n1 < 16; ++n1, --n2) + iv[i+1][n1] = ptext[j-n2][0]; + ctext[0][0] = ptext[j-16][0]; + break; + case CFB1: + for(n1=0,n2=127 ; n1 < 128 ; ++n1,--n2) + sb(iv[i+1],n1,gb(ptext[j-n2],0)); + ctext[0][0]=ptext[j-128][0]&0x80; + break; + } + } + } + + return ret; + } + +/*================================================*/ +/*---------------------------- + # Config info for v-one + # AESVS MMT test data for ECB + # State : Encrypt and Decrypt + # Key Length : 256 + # Fri Aug 30 04:07:22 PM + ----------------------------*/ + +int proc_file(char *rqfile) + { + char afn[256], rfn[256]; + FILE *afp = NULL, *rfp = NULL; + char ibuf[2048]; + int ilen, len, ret = 0; + char algo[8] = ""; + char amode[8] = ""; + char atest[8] = ""; + int akeysz = 0; + unsigned char iVec[20], aKey[40]; + int dir = -1, err = 0, step = 0; + unsigned char plaintext[2048]; + unsigned char ciphertext[2048]; + char *rp; + EVP_CIPHER_CTX ctx; + + if (!rqfile || !(*rqfile)) + { + printf("No req file\n"); + return -1; + } + strcpy(afn, rqfile); + + if ((afp = fopen(afn, "r")) == NULL) + { + printf("Cannot open file: %s, %s\n", + afn, strerror(errno)); + return -1; + } + strcpy(rfn,afn); + rp=strstr(rfn,"req/"); + assert(rp); + memcpy(rp,"rsp",3); + rp = strstr(rfn, ".req"); + memcpy(rp, ".rsp", 4); + if ((rfp = fopen(rfn, "w")) == NULL) + { + printf("Cannot open file: %s, %s\n", + rfn, strerror(errno)); + fclose(afp); + afp = NULL; + return -1; + } + while (!err && (fgets(ibuf, sizeof(ibuf), afp)) != NULL) + { + ilen = strlen(ibuf); + /* printf("step=%d ibuf=%s",step,ibuf); */ + switch (step) + { + case 0: /* read preamble */ + if (ibuf[0] == '\n') + { /* end of preamble */ + if ((*algo == '\0') || + (*amode == '\0') || + (akeysz == 0)) + { + printf("Missing Algorithm, Mode or KeySize (%s/%s/%d)\n", + algo,amode,akeysz); + err = 1; + } + else + { + fputs(ibuf, rfp); + ++ step; + } + } + else if (ibuf[0] != '#') + { + printf("Invalid preamble item: %s\n", ibuf); + err = 1; + } + else + { /* process preamble */ + char *xp, *pp = ibuf+2; + int n; + if (akeysz) + { /* insert current time & date */ + time_t rtim = time(0); + fprintf(rfp, "# %s", ctime(&rtim)); + } + else + { + fputs(ibuf, rfp); + if (strncmp(pp, "AESVS ", 6) == 0) + { + strcpy(algo, "AES"); + /* get test type */ + pp += 6; + xp = strchr(pp, ' '); + n = xp-pp; + strncpy(atest, pp, n); + atest[n] = '\0'; + /* get mode */ + xp = strrchr(pp, ' '); /* get mode" */ + n = strlen(xp+1)-1; + strncpy(amode, xp+1, n); + amode[n] = '\0'; + /* amode[3] = '\0'; */ + printf("Test = %s, Mode = %s\n", atest, amode); + } + else if (strncasecmp(pp, "Key Length : ", 13) == 0) + { + akeysz = atoi(pp+13); + printf("Key size = %d\n", akeysz); + } + } + } + break; + + case 1: /* [ENCRYPT] | [DECRYPT] */ + if (ibuf[0] == '[') + { + fputs(ibuf, rfp); + ++step; + if (strncasecmp(ibuf, "[ENCRYPT]", 9) == 0) + dir = 1; + else if (strncasecmp(ibuf, "[DECRYPT]", 9) == 0) + dir = 0; + else + { + printf("Invalid keyword: %s\n", ibuf); + err = 1; + } + break; + } + else if (dir == -1) + { + err = 1; + printf("Missing ENCRYPT/DECRYPT keyword\n"); + break; + } + else + step = 2; + + case 2: /* KEY = xxxx */ + fputs(ibuf, rfp); + if(*ibuf == '\n') + break; + if(!strncasecmp(ibuf,"COUNT = ",8)) + break; + + if (strncasecmp(ibuf, "KEY = ", 6) != 0) + { + printf("Missing KEY\n"); + err = 1; + } + else + { + len = hex2bin((char*)ibuf+6, strlen(ibuf+6)-1, aKey); + if (len < 0) + { + printf("Invalid KEY\n"); + err =1; + break; + } + PrintValue("KEY", aKey, len); + if (strcmp(amode, "ECB") == 0) + { + memset(iVec, 0, sizeof(iVec)); + step = (dir)? 4: 5; /* no ivec for ECB */ + } + else + ++step; + } + break; + + case 3: /* IV = xxxx */ + fputs(ibuf, rfp); + if (strncasecmp(ibuf, "IV = ", 5) != 0) + { + printf("Missing IV\n"); + err = 1; + } + else + { + len = hex2bin((char*)ibuf+5, strlen(ibuf+5)-1, iVec); + if (len < 0) + { + printf("Invalid IV\n"); + err =1; + break; + } + PrintValue("IV", iVec, len); + step = (dir)? 4: 5; + } + break; + + case 4: /* PLAINTEXT = xxxx */ + fputs(ibuf, rfp); + if (strncasecmp(ibuf, "PLAINTEXT = ", 12) != 0) + { + printf("Missing PLAINTEXT\n"); + err = 1; + } + else + { + int nn = strlen(ibuf+12); + if(!strcmp(amode,"CFB1")) + len=bint2bin(ibuf+12,nn-1,plaintext); + else + len=hex2bin(ibuf+12, nn-1,plaintext); + if (len < 0) + { + printf("Invalid PLAINTEXT: %s", ibuf+12); + err =1; + break; + } + if (len >= sizeof(plaintext)) + { + printf("Buffer overflow\n"); + } + PrintValue("PLAINTEXT", (unsigned char*)plaintext, len); + if (strcmp(atest, "MCT") == 0) /* Monte Carlo Test */ + { + if(do_mct(amode, akeysz, aKey, iVec, + dir, (unsigned char*)plaintext, len, + rfp) < 0) + exit(1); + } + else + { + ret = AESTest(&ctx, amode, akeysz, aKey, iVec, + dir, /* 0 = decrypt, 1 = encrypt */ + plaintext, ciphertext, len); + OutputValue("CIPHERTEXT",ciphertext,len,rfp, + !strcmp(amode,"CFB1")); + } + step = 6; + } + break; + + case 5: /* CIPHERTEXT = xxxx */ + fputs(ibuf, rfp); + if (strncasecmp(ibuf, "CIPHERTEXT = ", 13) != 0) + { + printf("Missing KEY\n"); + err = 1; + } + else + { + if(!strcmp(amode,"CFB1")) + len=bint2bin(ibuf+13,strlen(ibuf+13)-1,ciphertext); + else + len = hex2bin(ibuf+13,strlen(ibuf+13)-1,ciphertext); + if (len < 0) + { + printf("Invalid CIPHERTEXT\n"); + err =1; + break; + } + + PrintValue("CIPHERTEXT", ciphertext, len); + if (strcmp(atest, "MCT") == 0) /* Monte Carlo Test */ + { + do_mct(amode, akeysz, aKey, iVec, + dir, ciphertext, len, rfp); + } + else + { + ret = AESTest(&ctx, amode, akeysz, aKey, iVec, + dir, /* 0 = decrypt, 1 = encrypt */ + plaintext, ciphertext, len); + OutputValue("PLAINTEXT",(unsigned char *)plaintext,len,rfp, + !strcmp(amode,"CFB1")); + } + step = 6; + } + break; + + case 6: + if (ibuf[0] != '\n') + { + err = 1; + printf("Missing terminator\n"); + } + else if (strcmp(atest, "MCT") != 0) + { /* MCT already added terminating nl */ + fputs(ibuf, rfp); + } + step = 1; + break; + } + } + if (rfp) + fclose(rfp); + if (afp) + fclose(afp); + return err; + } + +/*-------------------------------------------------- + Processes either a single file or + a set of files whose names are passed in a file. + A single file is specified as: + aes_test -f xxx.req + A set of files is specified as: + aes_test -d xxxxx.xxx + The default is: -d req.txt +--------------------------------------------------*/ +int main(int argc, char **argv) + { + char *rqlist = "req.txt"; + FILE *fp = NULL; + char fn[250] = "", rfn[256] = ""; + int f_opt = 0, d_opt = 1; + +#ifdef OPENSSL_FIPS + if(!FIPS_mode_set(1,argv[0])) + { + ERR_print_errors(BIO_new_fp(stderr,BIO_NOCLOSE)); + exit(1); + } +#endif + ERR_load_crypto_strings(); + if (argc > 1) + { + if (strcasecmp(argv[1], "-d") == 0) + { + d_opt = 1; + } + else if (strcasecmp(argv[1], "-f") == 0) + { + f_opt = 1; + d_opt = 0; + } + else + { + printf("Invalid parameter: %s\n", argv[1]); + return 0; + } + if (argc < 3) + { + printf("Missing parameter\n"); + return 0; + } + if (d_opt) + rqlist = argv[2]; + else + strcpy(fn, argv[2]); + } + if (d_opt) + { /* list of files (directory) */ + if (!(fp = fopen(rqlist, "r"))) + { + printf("Cannot open req list file\n"); + return -1; + } + while (fgets(fn, sizeof(fn), fp)) + { + strtok(fn, "\r\n"); + strcpy(rfn, fn); + printf("Processing: %s\n", rfn); + if (proc_file(rfn)) + { + printf(">>> Processing failed for: %s <<<\n", rfn); + exit(1); + } + } + fclose(fp); + } + else /* single file */ + { + printf("Processing: %s\n", fn); + if (proc_file(fn)) + { + printf(">>> Processing failed for: %s <<<\n", fn); + } + } + return 0; + } diff --git a/fips/des/Makefile b/fips/des/Makefile new file mode 100644 index 0000000000..7d38bc7ed5 --- /dev/null +++ b/fips/des/Makefile @@ -0,0 +1,155 @@ +# +# SSLeay/fips/des/Makefile +# + +DIR= des +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALL_PREFIX= +OPENSSLDIR= /usr/local/ssl +INSTALLTOP=/usr/local/ssl +MAKEDEPPROG= makedepend +MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) +MAKEFILE= Makefile +AR= ar r + +FIPS_DES_ENC=fips_des_enc.o + +CFLAGS= $(INCLUDES) $(CFLAG) -g + +GENERAL=Makefile +TEST= fips_desmovs.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=fips_des_enc.c asm/fips-dx86-elf.s fips_des_selftest.c fips_set_key.c +LIBOBJ=$(FIPS_DES_ENC) fips_des_selftest.o fips_set_key.o + +SRC= $(LIBSRC) + +EXHEADER= +HEADER= $(EXHEADER) fips_des_locl.h + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd $(TOP); $(MAKE) DIRS=fips FDIRS=$(DIR) sub_all) + +all: check lib + +check: + TOP=`pwd`/$(TOP) ../fips_check_sha1 fingerprint.sha1 $(SRC) $(HEADER) + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + $(RANLIB) $(LIB) || echo Never mind. + @sleep 2; touch lib + +files: + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO + +links: + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/include/openssl $(EXHEADER) + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/test $(TEST) + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ + chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +top_fips_desmovs: + (cd $(TOP); $(MAKE) DIRS=fips FDIRS=$(DIR) TARGET=fips_desmovs sub_target) + +fips_desmovs: fips_desmovs.o $(TOP)/libcrypto.a + $(CC) $(CFLAGS) -o fips_desmovs fips_desmovs.o $(PEX_LIBS) $(TOP)/libcrypto.a $(EX_LIBS) + TOP=$(TOP) $(TOP)/fips/openssl_fips_fingerprint $(TOP)/libcrypto.a fips_desmovs + +fips_test: top_fips_desmovs + find ../testvectors/des/req -name '*.req' > testlist + -rm -rf ../testvectors/des/rsp + mkdir ../testvectors/des/rsp + ./fips_desmovs -d testlist + find ../testvectors/des2/req -name '*.req' > testlist + -rm -rf ../testvectors/des2/rsp + mkdir ../testvectors/des2/rsp + ./fips_desmovs -d testlist + find ../testvectors/des3/req -name '*.req' > testlist + -rm -rf ../testvectors/des3/rsp + mkdir ../testvectors/des3/rsp + ./fips_desmovs -d testlist + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) \ + $(SRC) $(TEST) +dclean: + $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff +# DO NOT DELETE THIS LINE -- make depend depends on it. + +fips_des_enc.o: ../../e_os.h ../../include/openssl/crypto.h +fips_des_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h +fips_des_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/fips.h +fips_des_enc.o: ../../include/openssl/opensslconf.h +fips_des_enc.o: ../../include/openssl/opensslv.h +fips_des_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +fips_des_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h +fips_des_enc.o: ../../include/openssl/ui_compat.h fips_des_enc.c +fips_des_enc.o: fips_des_locl.h +fips_des_selftest.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h +fips_des_selftest.o: ../../include/openssl/des.h +fips_des_selftest.o: ../../include/openssl/des_old.h +fips_des_selftest.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +fips_des_selftest.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h +fips_des_selftest.o: ../../include/openssl/opensslconf.h +fips_des_selftest.o: ../../include/openssl/opensslv.h +fips_des_selftest.o: ../../include/openssl/safestack.h +fips_des_selftest.o: ../../include/openssl/stack.h +fips_des_selftest.o: ../../include/openssl/symhacks.h +fips_des_selftest.o: ../../include/openssl/ui.h +fips_des_selftest.o: ../../include/openssl/ui_compat.h fips_des_selftest.c +fips_desmovs.o: ../../e_os.h ../../include/openssl/aes.h +fips_desmovs.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h +fips_desmovs.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h +fips_desmovs.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h +fips_desmovs.o: ../../include/openssl/des.h ../../include/openssl/des_old.h +fips_desmovs.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h +fips_desmovs.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +fips_desmovs.o: ../../include/openssl/evp.h ../../include/openssl/fips.h +fips_desmovs.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h +fips_desmovs.o: ../../include/openssl/md2.h ../../include/openssl/md4.h +fips_desmovs.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h +fips_desmovs.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h +fips_desmovs.o: ../../include/openssl/opensslconf.h +fips_desmovs.o: ../../include/openssl/opensslv.h +fips_desmovs.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h +fips_desmovs.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h +fips_desmovs.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h +fips_desmovs.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h +fips_desmovs.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +fips_desmovs.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +fips_desmovs.o: fips_desmovs.c +fips_set_key.o: ../../e_os.h ../../include/openssl/crypto.h +fips_set_key.o: ../../include/openssl/des.h ../../include/openssl/des_old.h +fips_set_key.o: ../../include/openssl/e_os2.h +fips_set_key.o: ../../include/openssl/opensslconf.h +fips_set_key.o: ../../include/openssl/opensslv.h +fips_set_key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +fips_set_key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h +fips_set_key.o: ../../include/openssl/ui_compat.h ../fips.h fips_des_locl.h +fips_set_key.o: fips_set_key.c diff --git a/fips/des/asm/fips-dx86-elf.s b/fips/des/asm/fips-dx86-elf.s new file mode 100644 index 0000000000..c9939221e4 --- /dev/null +++ b/fips/des/asm/fips-dx86-elf.s @@ -0,0 +1,2697 @@ + + + + + + + .file "des-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align 16 +.globl DES_encrypt1 + .type DES_encrypt1,@function +DES_encrypt1: + pushl %esi + pushl %edi + + + movl 12(%esp), %esi + xorl %ecx, %ecx + pushl %ebx + pushl %ebp + movl (%esi), %eax + movl 28(%esp), %ebx + movl 4(%esi), %edi + + + roll $4, %eax + movl %eax, %esi + xorl %edi, %eax + andl $0xf0f0f0f0, %eax + xorl %eax, %esi + xorl %eax, %edi + + roll $20, %edi + movl %edi, %eax + xorl %esi, %edi + andl $0xfff0000f, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $14, %eax + movl %eax, %edi + xorl %esi, %eax + andl $0x33333333, %eax + xorl %eax, %edi + xorl %eax, %esi + + roll $22, %esi + movl %esi, %eax + xorl %edi, %esi + andl $0x03fc03fc, %esi + xorl %esi, %eax + xorl %esi, %edi + + roll $9, %eax + movl %eax, %esi + xorl %edi, %eax + andl $0xaaaaaaaa, %eax + xorl %eax, %esi + xorl %eax, %edi + +.byte 209 +.byte 199 + leal DES_SPtrans, %ebp + movl 24(%esp), %ecx + cmpl $0, %ebx + je .L000start_decrypt + + + movl (%ecx), %eax + xorl %ebx, %ebx + movl 4(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 8(%ecx), %eax + xorl %ebx, %ebx + movl 12(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 16(%ecx), %eax + xorl %ebx, %ebx + movl 20(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 24(%ecx), %eax + xorl %ebx, %ebx + movl 28(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 32(%ecx), %eax + xorl %ebx, %ebx + movl 36(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 40(%ecx), %eax + xorl %ebx, %ebx + movl 44(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 48(%ecx), %eax + xorl %ebx, %ebx + movl 52(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 56(%ecx), %eax + xorl %ebx, %ebx + movl 60(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 64(%ecx), %eax + xorl %ebx, %ebx + movl 68(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 72(%ecx), %eax + xorl %ebx, %ebx + movl 76(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 80(%ecx), %eax + xorl %ebx, %ebx + movl 84(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 88(%ecx), %eax + xorl %ebx, %ebx + movl 92(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 96(%ecx), %eax + xorl %ebx, %ebx + movl 100(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 104(%ecx), %eax + xorl %ebx, %ebx + movl 108(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 112(%ecx), %eax + xorl %ebx, %ebx + movl 116(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 120(%ecx), %eax + xorl %ebx, %ebx + movl 124(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + jmp .L001end +.L000start_decrypt: + + + movl 120(%ecx), %eax + xorl %ebx, %ebx + movl 124(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 112(%ecx), %eax + xorl %ebx, %ebx + movl 116(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 104(%ecx), %eax + xorl %ebx, %ebx + movl 108(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 96(%ecx), %eax + xorl %ebx, %ebx + movl 100(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 88(%ecx), %eax + xorl %ebx, %ebx + movl 92(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 80(%ecx), %eax + xorl %ebx, %ebx + movl 84(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 72(%ecx), %eax + xorl %ebx, %ebx + movl 76(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 64(%ecx), %eax + xorl %ebx, %ebx + movl 68(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 56(%ecx), %eax + xorl %ebx, %ebx + movl 60(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 48(%ecx), %eax + xorl %ebx, %ebx + movl 52(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 40(%ecx), %eax + xorl %ebx, %ebx + movl 44(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 32(%ecx), %eax + xorl %ebx, %ebx + movl 36(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 24(%ecx), %eax + xorl %ebx, %ebx + movl 28(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 16(%ecx), %eax + xorl %ebx, %ebx + movl 20(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 8(%ecx), %eax + xorl %ebx, %ebx + movl 12(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl (%ecx), %eax + xorl %ebx, %ebx + movl 4(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi +.L001end: + + + movl 20(%esp), %edx +.byte 209 +.byte 206 + movl %edi, %eax + xorl %esi, %edi + andl $0xaaaaaaaa, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $23, %eax + movl %eax, %edi + xorl %esi, %eax + andl $0x03fc03fc, %eax + xorl %eax, %edi + xorl %eax, %esi + + roll $10, %edi + movl %edi, %eax + xorl %esi, %edi + andl $0x33333333, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $18, %esi + movl %esi, %edi + xorl %eax, %esi + andl $0xfff0000f, %esi + xorl %esi, %edi + xorl %esi, %eax + + roll $12, %edi + movl %edi, %esi + xorl %eax, %edi + andl $0xf0f0f0f0, %edi + xorl %edi, %esi + xorl %edi, %eax + + rorl $4, %eax + movl %eax, (%edx) + movl %esi, 4(%edx) + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +.L_DES_encrypt1_end: + .size DES_encrypt1,.L_DES_encrypt1_end-DES_encrypt1 +.ident "desasm.pl" +.text + .align 16 +.globl DES_encrypt2 + .type DES_encrypt2,@function +DES_encrypt2: + pushl %esi + pushl %edi + + + movl 12(%esp), %eax + xorl %ecx, %ecx + pushl %ebx + pushl %ebp + movl (%eax), %esi + movl 28(%esp), %ebx + roll $3, %esi + movl 4(%eax), %edi + roll $3, %edi + leal DES_SPtrans, %ebp + movl 24(%esp), %ecx + cmpl $0, %ebx + je .L002start_decrypt + + + movl (%ecx), %eax + xorl %ebx, %ebx + movl 4(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 8(%ecx), %eax + xorl %ebx, %ebx + movl 12(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 16(%ecx), %eax + xorl %ebx, %ebx + movl 20(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 24(%ecx), %eax + xorl %ebx, %ebx + movl 28(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 32(%ecx), %eax + xorl %ebx, %ebx + movl 36(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 40(%ecx), %eax + xorl %ebx, %ebx + movl 44(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 48(%ecx), %eax + xorl %ebx, %ebx + movl 52(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 56(%ecx), %eax + xorl %ebx, %ebx + movl 60(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 64(%ecx), %eax + xorl %ebx, %ebx + movl 68(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 72(%ecx), %eax + xorl %ebx, %ebx + movl 76(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 80(%ecx), %eax + xorl %ebx, %ebx + movl 84(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 88(%ecx), %eax + xorl %ebx, %ebx + movl 92(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 96(%ecx), %eax + xorl %ebx, %ebx + movl 100(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 104(%ecx), %eax + xorl %ebx, %ebx + movl 108(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 112(%ecx), %eax + xorl %ebx, %ebx + movl 116(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 120(%ecx), %eax + xorl %ebx, %ebx + movl 124(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + jmp .L003end +.L002start_decrypt: + + + movl 120(%ecx), %eax + xorl %ebx, %ebx + movl 124(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 112(%ecx), %eax + xorl %ebx, %ebx + movl 116(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 104(%ecx), %eax + xorl %ebx, %ebx + movl 108(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 96(%ecx), %eax + xorl %ebx, %ebx + movl 100(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 88(%ecx), %eax + xorl %ebx, %ebx + movl 92(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 80(%ecx), %eax + xorl %ebx, %ebx + movl 84(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 72(%ecx), %eax + xorl %ebx, %ebx + movl 76(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 64(%ecx), %eax + xorl %ebx, %ebx + movl 68(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 56(%ecx), %eax + xorl %ebx, %ebx + movl 60(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 48(%ecx), %eax + xorl %ebx, %ebx + movl 52(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 40(%ecx), %eax + xorl %ebx, %ebx + movl 44(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 32(%ecx), %eax + xorl %ebx, %ebx + movl 36(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 24(%ecx), %eax + xorl %ebx, %ebx + movl 28(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl 16(%ecx), %eax + xorl %ebx, %ebx + movl 20(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi + + + movl 8(%ecx), %eax + xorl %ebx, %ebx + movl 12(%ecx), %edx + xorl %esi, %eax + xorl %ecx, %ecx + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%edi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%edi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%edi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%edi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%edi + xorl 0x700(%ebp,%ecx),%edi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%edi + xorl 0x500(%ebp,%edx),%edi + + + movl (%ecx), %eax + xorl %ebx, %ebx + movl 4(%ecx), %edx + xorl %edi, %eax + xorl %ecx, %ecx + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + xorl (%ebp,%ebx),%esi + movb %dl, %bl + xorl 0x200(%ebp,%ecx),%esi + movb %dh, %cl + shrl $16, %eax + xorl 0x100(%ebp,%ebx),%esi + movb %ah, %bl + shrl $16, %edx + xorl 0x300(%ebp,%ecx),%esi + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + xorl 0x600(%ebp,%ebx),%esi + xorl 0x700(%ebp,%ecx),%esi + movl 24(%esp), %ecx + xorl 0x400(%ebp,%eax),%esi + xorl 0x500(%ebp,%edx),%esi +.L003end: + + + rorl $3, %edi + movl 20(%esp), %eax + rorl $3, %esi + movl %edi, (%eax) + movl %esi, 4(%eax) + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +.L_DES_encrypt2_end: + .size DES_encrypt2,.L_DES_encrypt2_end-DES_encrypt2 +.ident "desasm.pl" +.text + .align 16 +.globl DES_encrypt3 + .type DES_encrypt3,@function +DES_encrypt3: + pushl %ebx + movl 8(%esp), %ebx + pushl %ebp + pushl %esi + pushl %edi + + + movl (%ebx), %edi + movl 4(%ebx), %esi + subl $12, %esp + + + roll $4, %edi + movl %edi, %edx + xorl %esi, %edi + andl $0xf0f0f0f0, %edi + xorl %edi, %edx + xorl %edi, %esi + + roll $20, %esi + movl %esi, %edi + xorl %edx, %esi + andl $0xfff0000f, %esi + xorl %esi, %edi + xorl %esi, %edx + + roll $14, %edi + movl %edi, %esi + xorl %edx, %edi + andl $0x33333333, %edi + xorl %edi, %esi + xorl %edi, %edx + + roll $22, %edx + movl %edx, %edi + xorl %esi, %edx + andl $0x03fc03fc, %edx + xorl %edx, %edi + xorl %edx, %esi + + roll $9, %edi + movl %edi, %edx + xorl %esi, %edi + andl $0xaaaaaaaa, %edi + xorl %edi, %edx + xorl %edi, %esi + + rorl $3, %edx + rorl $2, %esi + movl %esi, 4(%ebx) + movl 36(%esp), %eax + movl %edx, (%ebx) + movl 40(%esp), %edi + movl 44(%esp), %esi + movl $1, 8(%esp) + movl %eax, 4(%esp) + movl %ebx, (%esp) + call DES_encrypt2 + movl $0, 8(%esp) + movl %edi, 4(%esp) + movl %ebx, (%esp) + call DES_encrypt2 + movl $1, 8(%esp) + movl %esi, 4(%esp) + movl %ebx, (%esp) + call DES_encrypt2 + addl $12, %esp + movl (%ebx), %edi + movl 4(%ebx), %esi + + + roll $2, %esi + roll $3, %edi + movl %edi, %eax + xorl %esi, %edi + andl $0xaaaaaaaa, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $23, %eax + movl %eax, %edi + xorl %esi, %eax + andl $0x03fc03fc, %eax + xorl %eax, %edi + xorl %eax, %esi + + roll $10, %edi + movl %edi, %eax + xorl %esi, %edi + andl $0x33333333, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $18, %esi + movl %esi, %edi + xorl %eax, %esi + andl $0xfff0000f, %esi + xorl %esi, %edi + xorl %esi, %eax + + roll $12, %edi + movl %edi, %esi + xorl %eax, %edi + andl $0xf0f0f0f0, %edi + xorl %edi, %esi + xorl %edi, %eax + + rorl $4, %eax + movl %eax, (%ebx) + movl %esi, 4(%ebx) + popl %edi + popl %esi + popl %ebp + popl %ebx + ret +.L_DES_encrypt3_end: + .size DES_encrypt3,.L_DES_encrypt3_end-DES_encrypt3 +.ident "desasm.pl" +.text + .align 16 +.globl DES_decrypt3 + .type DES_decrypt3,@function +DES_decrypt3: + pushl %ebx + movl 8(%esp), %ebx + pushl %ebp + pushl %esi + pushl %edi + + + movl (%ebx), %edi + movl 4(%ebx), %esi + subl $12, %esp + + + roll $4, %edi + movl %edi, %edx + xorl %esi, %edi + andl $0xf0f0f0f0, %edi + xorl %edi, %edx + xorl %edi, %esi + + roll $20, %esi + movl %esi, %edi + xorl %edx, %esi + andl $0xfff0000f, %esi + xorl %esi, %edi + xorl %esi, %edx + + roll $14, %edi + movl %edi, %esi + xorl %edx, %edi + andl $0x33333333, %edi + xorl %edi, %esi + xorl %edi, %edx + + roll $22, %edx + movl %edx, %edi + xorl %esi, %edx + andl $0x03fc03fc, %edx + xorl %edx, %edi + xorl %edx, %esi + + roll $9, %edi + movl %edi, %edx + xorl %esi, %edi + andl $0xaaaaaaaa, %edi + xorl %edi, %edx + xorl %edi, %esi + + rorl $3, %edx + rorl $2, %esi + movl %esi, 4(%ebx) + movl 36(%esp), %esi + movl %edx, (%ebx) + movl 40(%esp), %edi + movl 44(%esp), %eax + movl $0, 8(%esp) + movl %eax, 4(%esp) + movl %ebx, (%esp) + call DES_encrypt2 + movl $1, 8(%esp) + movl %edi, 4(%esp) + movl %ebx, (%esp) + call DES_encrypt2 + movl $0, 8(%esp) + movl %esi, 4(%esp) + movl %ebx, (%esp) + call DES_encrypt2 + addl $12, %esp + movl (%ebx), %edi + movl 4(%ebx), %esi + + + roll $2, %esi + roll $3, %edi + movl %edi, %eax + xorl %esi, %edi + andl $0xaaaaaaaa, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $23, %eax + movl %eax, %edi + xorl %esi, %eax + andl $0x03fc03fc, %eax + xorl %eax, %edi + xorl %eax, %esi + + roll $10, %edi + movl %edi, %eax + xorl %esi, %edi + andl $0x33333333, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $18, %esi + movl %esi, %edi + xorl %eax, %esi + andl $0xfff0000f, %esi + xorl %esi, %edi + xorl %esi, %eax + + roll $12, %edi + movl %edi, %esi + xorl %eax, %edi + andl $0xf0f0f0f0, %edi + xorl %edi, %esi + xorl %edi, %eax + + rorl $4, %eax + movl %eax, (%ebx) + movl %esi, 4(%ebx) + popl %edi + popl %esi + popl %ebp + popl %ebx + ret +.L_DES_decrypt3_end: + .size DES_decrypt3,.L_DES_decrypt3_end-DES_decrypt3 +.ident "desasm.pl" +.text + .align 16 +.globl DES_ncbc_encrypt + .type DES_ncbc_encrypt,@function +DES_ncbc_encrypt: + + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + movl 28(%esp), %ebp + + movl 36(%esp), %ebx + movl (%ebx), %esi + movl 4(%ebx), %edi + pushl %edi + pushl %esi + pushl %edi + pushl %esi + movl %esp, %ebx + movl 36(%esp), %esi + movl 40(%esp), %edi + + movl 56(%esp), %ecx + + pushl %ecx + + movl 52(%esp), %eax + pushl %eax + pushl %ebx + cmpl $0, %ecx + jz .L004decrypt + andl $4294967288, %ebp + movl 12(%esp), %eax + movl 16(%esp), %ebx + jz .L005encrypt_finish +.L006encrypt_loop: + movl (%esi), %ecx + movl 4(%esi), %edx + xorl %ecx, %eax + xorl %edx, %ebx + movl %eax, 12(%esp) + movl %ebx, 16(%esp) + call DES_encrypt1 + movl 12(%esp), %eax + movl 16(%esp), %ebx + movl %eax, (%edi) + movl %ebx, 4(%edi) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L006encrypt_loop +.L005encrypt_finish: + movl 56(%esp), %ebp + andl $7, %ebp + jz .L007finish + call .L008PIC_point +.L008PIC_point: + popl %edx + leal .L009cbc_enc_jmp_table-.L008PIC_point(%edx),%ecx + movl (%ecx,%ebp,4), %ebp + addl %edx, %ebp + xorl %ecx, %ecx + xorl %edx, %edx + jmp *%ebp +.L010ej7: + movb 6(%esi), %dh + sall $8, %edx +.L011ej6: + movb 5(%esi), %dh +.L012ej5: + movb 4(%esi), %dl +.L013ej4: + movl (%esi), %ecx + jmp .L014ejend +.L015ej3: + movb 2(%esi), %ch + sall $8, %ecx +.L016ej2: + movb 1(%esi), %ch +.L017ej1: + movb (%esi), %cl +.L014ejend: + xorl %ecx, %eax + xorl %edx, %ebx + movl %eax, 12(%esp) + movl %ebx, 16(%esp) + call DES_encrypt1 + movl 12(%esp), %eax + movl 16(%esp), %ebx + movl %eax, (%edi) + movl %ebx, 4(%edi) + jmp .L007finish +.align 16 +.L004decrypt: + andl $4294967288, %ebp + movl 20(%esp), %eax + movl 24(%esp), %ebx + jz .L018decrypt_finish +.L019decrypt_loop: + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 12(%esp) + movl %ebx, 16(%esp) + call DES_encrypt1 + movl 12(%esp), %eax + movl 16(%esp), %ebx + movl 20(%esp), %ecx + movl 24(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx + movl %ecx, (%edi) + movl %edx, 4(%edi) + movl %eax, 20(%esp) + movl %ebx, 24(%esp) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L019decrypt_loop +.L018decrypt_finish: + movl 56(%esp), %ebp + andl $7, %ebp + jz .L007finish + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 12(%esp) + movl %ebx, 16(%esp) + call DES_encrypt1 + movl 12(%esp), %eax + movl 16(%esp), %ebx + movl 20(%esp), %ecx + movl 24(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx +.L020dj7: + rorl $16, %edx + movb %dl, 6(%edi) + shrl $16, %edx +.L021dj6: + movb %dh, 5(%edi) +.L022dj5: + movb %dl, 4(%edi) +.L023dj4: + movl %ecx, (%edi) + jmp .L024djend +.L025dj3: + rorl $16, %ecx + movb %cl, 2(%edi) + sall $16, %ecx +.L026dj2: + movb %ch, 1(%esi) +.L027dj1: + movb %cl, (%esi) +.L024djend: + jmp .L007finish +.align 16 +.L007finish: + movl 64(%esp), %ecx + addl $28, %esp + movl %eax, (%ecx) + movl %ebx, 4(%ecx) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.align 16 +.L009cbc_enc_jmp_table: + .long 0 + .long .L017ej1-.L008PIC_point + .long .L016ej2-.L008PIC_point + .long .L015ej3-.L008PIC_point + .long .L013ej4-.L008PIC_point + .long .L012ej5-.L008PIC_point + .long .L011ej6-.L008PIC_point + .long .L010ej7-.L008PIC_point +.L_DES_ncbc_encrypt_end: + .size DES_ncbc_encrypt,.L_DES_ncbc_encrypt_end-DES_ncbc_encrypt +.ident "desasm.pl" +.text + .align 16 +.globl DES_ede3_cbc_encrypt + .type DES_ede3_cbc_encrypt,@function +DES_ede3_cbc_encrypt: + + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + movl 28(%esp), %ebp + + movl 44(%esp), %ebx + movl (%ebx), %esi + movl 4(%ebx), %edi + pushl %edi + pushl %esi + pushl %edi + pushl %esi + movl %esp, %ebx + movl 36(%esp), %esi + movl 40(%esp), %edi + + movl 64(%esp), %ecx + + movl 56(%esp), %eax + pushl %eax + + movl 56(%esp), %eax + pushl %eax + + movl 56(%esp), %eax + pushl %eax + pushl %ebx + cmpl $0, %ecx + jz .L028decrypt + andl $4294967288, %ebp + movl 16(%esp), %eax + movl 20(%esp), %ebx + jz .L029encrypt_finish +.L030encrypt_loop: + movl (%esi), %ecx + movl 4(%esi), %edx + xorl %ecx, %eax + xorl %edx, %ebx + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + call DES_encrypt3 + movl 16(%esp), %eax + movl 20(%esp), %ebx + movl %eax, (%edi) + movl %ebx, 4(%edi) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L030encrypt_loop +.L029encrypt_finish: + movl 60(%esp), %ebp + andl $7, %ebp + jz .L031finish + call .L032PIC_point +.L032PIC_point: + popl %edx + leal .L033cbc_enc_jmp_table-.L032PIC_point(%edx),%ecx + movl (%ecx,%ebp,4), %ebp + addl %edx, %ebp + xorl %ecx, %ecx + xorl %edx, %edx + jmp *%ebp +.L034ej7: + movb 6(%esi), %dh + sall $8, %edx +.L035ej6: + movb 5(%esi), %dh +.L036ej5: + movb 4(%esi), %dl +.L037ej4: + movl (%esi), %ecx + jmp .L038ejend +.L039ej3: + movb 2(%esi), %ch + sall $8, %ecx +.L040ej2: + movb 1(%esi), %ch +.L041ej1: + movb (%esi), %cl +.L038ejend: + xorl %ecx, %eax + xorl %edx, %ebx + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + call DES_encrypt3 + movl 16(%esp), %eax + movl 20(%esp), %ebx + movl %eax, (%edi) + movl %ebx, 4(%edi) + jmp .L031finish +.align 16 +.L028decrypt: + andl $4294967288, %ebp + movl 24(%esp), %eax + movl 28(%esp), %ebx + jz .L042decrypt_finish +.L043decrypt_loop: + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + call DES_decrypt3 + movl 16(%esp), %eax + movl 20(%esp), %ebx + movl 24(%esp), %ecx + movl 28(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx + movl %ecx, (%edi) + movl %edx, 4(%edi) + movl %eax, 24(%esp) + movl %ebx, 28(%esp) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L043decrypt_loop +.L042decrypt_finish: + movl 60(%esp), %ebp + andl $7, %ebp + jz .L031finish + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + call DES_decrypt3 + movl 16(%esp), %eax + movl 20(%esp), %ebx + movl 24(%esp), %ecx + movl 28(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx +.L044dj7: + rorl $16, %edx + movb %dl, 6(%edi) + shrl $16, %edx +.L045dj6: + movb %dh, 5(%edi) +.L046dj5: + movb %dl, 4(%edi) +.L047dj4: + movl %ecx, (%edi) + jmp .L048djend +.L049dj3: + rorl $16, %ecx + movb %cl, 2(%edi) + sall $16, %ecx +.L050dj2: + movb %ch, 1(%esi) +.L051dj1: + movb %cl, (%esi) +.L048djend: + jmp .L031finish +.align 16 +.L031finish: + movl 76(%esp), %ecx + addl $32, %esp + movl %eax, (%ecx) + movl %ebx, 4(%ecx) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.align 16 +.L033cbc_enc_jmp_table: + .long 0 + .long .L041ej1-.L032PIC_point + .long .L040ej2-.L032PIC_point + .long .L039ej3-.L032PIC_point + .long .L037ej4-.L032PIC_point + .long .L036ej5-.L032PIC_point + .long .L035ej6-.L032PIC_point + .long .L034ej7-.L032PIC_point +.L_DES_ede3_cbc_encrypt_end: + .size DES_ede3_cbc_encrypt,.L_DES_ede3_cbc_encrypt_end-DES_ede3_cbc_encrypt +.ident "desasm.pl" diff --git a/fips/des/fingerprint.sha1 b/fips/des/fingerprint.sha1 new file mode 100644 index 0000000000..76caf96fb4 --- /dev/null +++ b/fips/des/fingerprint.sha1 @@ -0,0 +1,5 @@ +HMAC-SHA1(fips_des_enc.c)= ea89417ba58c148c3d72d29438cd0bedc2315f7f +HMAC-SHA1(asm/fips-dx86-elf.s)= 2f85e8e86806c92ee4c12cf5354e19eccf6ed47d +HMAC-SHA1(fips_des_selftest.c)= 3bc574e51647c5f5ab45d1007b2cf461d67764a9 +HMAC-SHA1(fips_set_key.c)= e55cabd0cbe5cd17710e11270d9594c0d7237064 +HMAC-SHA1(fips_des_locl.h)= 7053848e884df47f06de9f2248380b92e58ef4e5 diff --git a/fips/des/fips_des_enc.c b/fips/des/fips_des_enc.c new file mode 100644 index 0000000000..8d364fe28b --- /dev/null +++ b/fips/des/fips_des_enc.c @@ -0,0 +1,310 @@ +/* crypto/des/des_enc.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include "fips_des_locl.h" +#include + +#ifdef OPENSSL_FIPS + +void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) + { + register DES_LONG l,r,t,u; +#ifdef DES_PTR + register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans; +#endif +#ifndef DES_UNROLL + register int i; +#endif + register DES_LONG *s; + + if(FIPS_selftest_fail) + { + data[0]=data[1]=0; + return; + } + + r=data[0]; + l=data[1]; + + IP(r,l); + /* Things have been modified so that the initial rotate is + * done outside the loop. This required the + * DES_SPtrans values in sp.h to be rotated 1 bit to the right. + * One perl script later and things have a 5% speed up on a sparc2. + * Thanks to Richard Outerbridge <71755.204@CompuServe.COM> + * for pointing this out. */ + /* clear the top bits on machines with 8byte longs */ + /* shift left by 2 */ + r=ROTATE(r,29)&0xffffffffL; + l=ROTATE(l,29)&0xffffffffL; + + s=ks->ks->deslong; + /* I don't know if it is worth the effort of loop unrolling the + * inner loop */ + if (enc) + { +#ifdef DES_UNROLL + D_ENCRYPT(l,r, 0); /* 1 */ + D_ENCRYPT(r,l, 2); /* 2 */ + D_ENCRYPT(l,r, 4); /* 3 */ + D_ENCRYPT(r,l, 6); /* 4 */ + D_ENCRYPT(l,r, 8); /* 5 */ + D_ENCRYPT(r,l,10); /* 6 */ + D_ENCRYPT(l,r,12); /* 7 */ + D_ENCRYPT(r,l,14); /* 8 */ + D_ENCRYPT(l,r,16); /* 9 */ + D_ENCRYPT(r,l,18); /* 10 */ + D_ENCRYPT(l,r,20); /* 11 */ + D_ENCRYPT(r,l,22); /* 12 */ + D_ENCRYPT(l,r,24); /* 13 */ + D_ENCRYPT(r,l,26); /* 14 */ + D_ENCRYPT(l,r,28); /* 15 */ + D_ENCRYPT(r,l,30); /* 16 */ +#else + for (i=0; i<32; i+=8) + { + D_ENCRYPT(l,r,i+0); /* 1 */ + D_ENCRYPT(r,l,i+2); /* 2 */ + D_ENCRYPT(l,r,i+4); /* 3 */ + D_ENCRYPT(r,l,i+6); /* 4 */ + } +#endif + } + else + { +#ifdef DES_UNROLL + D_ENCRYPT(l,r,30); /* 16 */ + D_ENCRYPT(r,l,28); /* 15 */ + D_ENCRYPT(l,r,26); /* 14 */ + D_ENCRYPT(r,l,24); /* 13 */ + D_ENCRYPT(l,r,22); /* 12 */ + D_ENCRYPT(r,l,20); /* 11 */ + D_ENCRYPT(l,r,18); /* 10 */ + D_ENCRYPT(r,l,16); /* 9 */ + D_ENCRYPT(l,r,14); /* 8 */ + D_ENCRYPT(r,l,12); /* 7 */ + D_ENCRYPT(l,r,10); /* 6 */ + D_ENCRYPT(r,l, 8); /* 5 */ + D_ENCRYPT(l,r, 6); /* 4 */ + D_ENCRYPT(r,l, 4); /* 3 */ + D_ENCRYPT(l,r, 2); /* 2 */ + D_ENCRYPT(r,l, 0); /* 1 */ +#else + for (i=30; i>0; i-=8) + { + D_ENCRYPT(l,r,i-0); /* 16 */ + D_ENCRYPT(r,l,i-2); /* 15 */ + D_ENCRYPT(l,r,i-4); /* 14 */ + D_ENCRYPT(r,l,i-6); /* 13 */ + } +#endif + } + + /* rotate and clear the top bits on machines with 8byte longs */ + l=ROTATE(l,3)&0xffffffffL; + r=ROTATE(r,3)&0xffffffffL; + + FP(r,l); + data[0]=l; + data[1]=r; + l=r=t=u=0; + } + +void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) + { + register DES_LONG l,r,t,u; +#ifdef DES_PTR + register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans; +#endif +#ifndef DES_UNROLL + register int i; +#endif + register DES_LONG *s; + + if(FIPS_selftest_fail) + { + data[0]=data[1]=0; + return; + } + + r=data[0]; + l=data[1]; + + /* Things have been modified so that the initial rotate is + * done outside the loop. This required the + * DES_SPtrans values in sp.h to be rotated 1 bit to the right. + * One perl script later and things have a 5% speed up on a sparc2. + * Thanks to Richard Outerbridge <71755.204@CompuServe.COM> + * for pointing this out. */ + /* clear the top bits on machines with 8byte longs */ + r=ROTATE(r,29)&0xffffffffL; + l=ROTATE(l,29)&0xffffffffL; + + s=ks->ks->deslong; + /* I don't know if it is worth the effort of loop unrolling the + * inner loop */ + if (enc) + { +#ifdef DES_UNROLL + D_ENCRYPT(l,r, 0); /* 1 */ + D_ENCRYPT(r,l, 2); /* 2 */ + D_ENCRYPT(l,r, 4); /* 3 */ + D_ENCRYPT(r,l, 6); /* 4 */ + D_ENCRYPT(l,r, 8); /* 5 */ + D_ENCRYPT(r,l,10); /* 6 */ + D_ENCRYPT(l,r,12); /* 7 */ + D_ENCRYPT(r,l,14); /* 8 */ + D_ENCRYPT(l,r,16); /* 9 */ + D_ENCRYPT(r,l,18); /* 10 */ + D_ENCRYPT(l,r,20); /* 11 */ + D_ENCRYPT(r,l,22); /* 12 */ + D_ENCRYPT(l,r,24); /* 13 */ + D_ENCRYPT(r,l,26); /* 14 */ + D_ENCRYPT(l,r,28); /* 15 */ + D_ENCRYPT(r,l,30); /* 16 */ +#else + for (i=0; i<32; i+=8) + { + D_ENCRYPT(l,r,i+0); /* 1 */ + D_ENCRYPT(r,l,i+2); /* 2 */ + D_ENCRYPT(l,r,i+4); /* 3 */ + D_ENCRYPT(r,l,i+6); /* 4 */ + } +#endif + } + else + { +#ifdef DES_UNROLL + D_ENCRYPT(l,r,30); /* 16 */ + D_ENCRYPT(r,l,28); /* 15 */ + D_ENCRYPT(l,r,26); /* 14 */ + D_ENCRYPT(r,l,24); /* 13 */ + D_ENCRYPT(l,r,22); /* 12 */ + D_ENCRYPT(r,l,20); /* 11 */ + D_ENCRYPT(l,r,18); /* 10 */ + D_ENCRYPT(r,l,16); /* 9 */ + D_ENCRYPT(l,r,14); /* 8 */ + D_ENCRYPT(r,l,12); /* 7 */ + D_ENCRYPT(l,r,10); /* 6 */ + D_ENCRYPT(r,l, 8); /* 5 */ + D_ENCRYPT(l,r, 6); /* 4 */ + D_ENCRYPT(r,l, 4); /* 3 */ + D_ENCRYPT(l,r, 2); /* 2 */ + D_ENCRYPT(r,l, 0); /* 1 */ +#else + for (i=30; i>0; i-=8) + { + D_ENCRYPT(l,r,i-0); /* 16 */ + D_ENCRYPT(r,l,i-2); /* 15 */ + D_ENCRYPT(l,r,i-4); /* 14 */ + D_ENCRYPT(r,l,i-6); /* 13 */ + } +#endif + } + /* rotate and clear the top bits on machines with 8byte longs */ + data[0]=ROTATE(l,3)&0xffffffffL; + data[1]=ROTATE(r,3)&0xffffffffL; + l=r=t=u=0; + } + +void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3) + { + register DES_LONG l,r; + + l=data[0]; + r=data[1]; + IP(l,r); + data[0]=l; + data[1]=r; + DES_encrypt2((DES_LONG *)data,ks1,DES_ENCRYPT); + DES_encrypt2((DES_LONG *)data,ks2,DES_DECRYPT); + DES_encrypt2((DES_LONG *)data,ks3,DES_ENCRYPT); + l=data[0]; + r=data[1]; + FP(r,l); + data[0]=l; + data[1]=r; + } + +void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3) + { + register DES_LONG l,r; + + l=data[0]; + r=data[1]; + IP(l,r); + data[0]=l; + data[1]=r; + DES_encrypt2((DES_LONG *)data,ks3,DES_DECRYPT); + DES_encrypt2((DES_LONG *)data,ks2,DES_ENCRYPT); + DES_encrypt2((DES_LONG *)data,ks1,DES_DECRYPT); + l=data[0]; + r=data[1]; + FP(r,l); + data[0]=l; + data[1]=r; + } + +#else /* ndef OPENSSL_FIPS */ + +static void *dummy=&dummy; + +#endif /* ndef OPENSSL_FIPS */ + diff --git a/fips/des/fips_des_locl.h b/fips/des/fips_des_locl.h new file mode 100644 index 0000000000..ef9323a6d6 --- /dev/null +++ b/fips/des/fips_des_locl.h @@ -0,0 +1,428 @@ +/* crypto/des/des_locl.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_DES_LOCL_H +#define HEADER_DES_LOCL_H + +#include "e_os.h" + +#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16) +#ifndef OPENSSL_SYS_MSDOS +#define OPENSSL_SYS_MSDOS +#endif +#endif + +#include +#include + +#ifndef OPENSSL_SYS_MSDOS +#if !defined(OPENSSL_SYS_VMS) || defined(__DECC) +#ifdef OPENSSL_UNISTD +# include OPENSSL_UNISTD +#else +# include +#endif +#include +#endif +#endif +#include + +#ifdef OPENSSL_SYS_MSDOS /* Visual C++ 2.1 (Windows NT/95) */ +#include +#include +#include +#include +#endif + +#if defined(__STDC__) || defined(OPENSSL_SYS_VMS) || defined(M_XENIX) || defined(OPENSSL_SYS_MSDOS) +#include +#endif + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +#define ITERATIONS 16 +#define HALF_ITERATIONS 8 + +/* used in des_read and des_write */ +#define MAXWRITE (1024*16) +#define BSIZE (MAXWRITE+4) + +#define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \ + l|=((DES_LONG)(*((c)++)))<< 8L, \ + l|=((DES_LONG)(*((c)++)))<<16L, \ + l|=((DES_LONG)(*((c)++)))<<24L) + +/* NOTE - c is not incremented as per c2l */ +#define c2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((DES_LONG)(*(--(c))))<<24L; \ + case 7: l2|=((DES_LONG)(*(--(c))))<<16L; \ + case 6: l2|=((DES_LONG)(*(--(c))))<< 8L; \ + case 5: l2|=((DES_LONG)(*(--(c)))); \ + case 4: l1 =((DES_LONG)(*(--(c))))<<24L; \ + case 3: l1|=((DES_LONG)(*(--(c))))<<16L; \ + case 2: l1|=((DES_LONG)(*(--(c))))<< 8L; \ + case 1: l1|=((DES_LONG)(*(--(c)))); \ + } \ + } + +#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24L)&0xff)) + +/* replacements for htonl and ntohl since I have no idea what to do + * when faced with machines with 8 byte longs. */ +#define HDRSIZE 4 + +#define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \ + l|=((DES_LONG)(*((c)++)))<<16L, \ + l|=((DES_LONG)(*((c)++)))<< 8L, \ + l|=((DES_LONG)(*((c)++)))) + +#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +/* NOTE - c is not incremented as per l2c */ +#define l2cn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ + case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ + case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ + case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ + case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ + case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ + case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ + case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ + } \ + } + +#if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER) +#define ROTATE(a,n) (_lrotr(a,n)) +#elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) +# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) +# define ROTATE(a,n) ({ register unsigned int ret; \ + asm ("rorl %1,%0" \ + : "=r"(ret) \ + : "I"(n),"0"(a) \ + : "cc"); \ + ret; \ + }) +# endif +#endif +#ifndef ROTATE +#define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n)))) +#endif + +/* Don't worry about the LOAD_DATA() stuff, that is used by + * fcrypt() to add it's little bit to the front */ + +#ifdef DES_FCRYPT + +#define LOAD_DATA_tmp(R,S,u,t,E0,E1) \ + { DES_LONG tmp; LOAD_DATA(R,S,u,t,E0,E1,tmp); } + +#define LOAD_DATA(R,S,u,t,E0,E1,tmp) \ + t=R^(R>>16L); \ + u=t&E0; t&=E1; \ + tmp=(u<<16); u^=R^s[S ]; u^=tmp; \ + tmp=(t<<16); t^=R^s[S+1]; t^=tmp +#else +#define LOAD_DATA_tmp(a,b,c,d,e,f) LOAD_DATA(a,b,c,d,e,f,g) +#define LOAD_DATA(R,S,u,t,E0,E1,tmp) \ + u=R^s[S ]; \ + t=R^s[S+1] +#endif + +/* The changes to this macro may help or hinder, depending on the + * compiler and the architecture. gcc2 always seems to do well :-). + * Inspired by Dana How + * DO NOT use the alternative version on machines with 8 byte longs. + * It does not seem to work on the Alpha, even when DES_LONG is 4 + * bytes, probably an issue of accessing non-word aligned objects :-( */ +#ifdef DES_PTR + +/* It recently occurred to me that 0^0^0^0^0^0^0 == 0, so there + * is no reason to not xor all the sub items together. This potentially + * saves a register since things can be xored directly into L */ + +#if defined(DES_RISC1) || defined(DES_RISC2) +#ifdef DES_RISC1 +#define D_ENCRYPT(LL,R,S) { \ + unsigned int u1,u2,u3; \ + LOAD_DATA(R,S,u,t,E0,E1,u1); \ + u2=(int)u>>8L; \ + u1=(int)u&0xfc; \ + u2&=0xfc; \ + t=ROTATE(t,4); \ + u>>=16L; \ + LL^= *(const DES_LONG *)(des_SP +u1); \ + LL^= *(const DES_LONG *)(des_SP+0x200+u2); \ + u3=(int)(u>>8L); \ + u1=(int)u&0xfc; \ + u3&=0xfc; \ + LL^= *(const DES_LONG *)(des_SP+0x400+u1); \ + LL^= *(const DES_LONG *)(des_SP+0x600+u3); \ + u2=(int)t>>8L; \ + u1=(int)t&0xfc; \ + u2&=0xfc; \ + t>>=16L; \ + LL^= *(const DES_LONG *)(des_SP+0x100+u1); \ + LL^= *(const DES_LONG *)(des_SP+0x300+u2); \ + u3=(int)t>>8L; \ + u1=(int)t&0xfc; \ + u3&=0xfc; \ + LL^= *(const DES_LONG *)(des_SP+0x500+u1); \ + LL^= *(const DES_LONG *)(des_SP+0x700+u3); } +#endif +#ifdef DES_RISC2 +#define D_ENCRYPT(LL,R,S) { \ + unsigned int u1,u2,s1,s2; \ + LOAD_DATA(R,S,u,t,E0,E1,u1); \ + u2=(int)u>>8L; \ + u1=(int)u&0xfc; \ + u2&=0xfc; \ + t=ROTATE(t,4); \ + LL^= *(const DES_LONG *)(des_SP +u1); \ + LL^= *(const DES_LONG *)(des_SP+0x200+u2); \ + s1=(int)(u>>16L); \ + s2=(int)(u>>24L); \ + s1&=0xfc; \ + s2&=0xfc; \ + LL^= *(const DES_LONG *)(des_SP+0x400+s1); \ + LL^= *(const DES_LONG *)(des_SP+0x600+s2); \ + u2=(int)t>>8L; \ + u1=(int)t&0xfc; \ + u2&=0xfc; \ + LL^= *(const DES_LONG *)(des_SP+0x100+u1); \ + LL^= *(const DES_LONG *)(des_SP+0x300+u2); \ + s1=(int)(t>>16L); \ + s2=(int)(t>>24L); \ + s1&=0xfc; \ + s2&=0xfc; \ + LL^= *(const DES_LONG *)(des_SP+0x500+s1); \ + LL^= *(const DES_LONG *)(des_SP+0x700+s2); } +#endif +#else +#define D_ENCRYPT(LL,R,S) { \ + LOAD_DATA_tmp(R,S,u,t,E0,E1); \ + t=ROTATE(t,4); \ + LL^= \ + *(const DES_LONG *)(des_SP +((u )&0xfc))^ \ + *(const DES_LONG *)(des_SP+0x200+((u>> 8L)&0xfc))^ \ + *(const DES_LONG *)(des_SP+0x400+((u>>16L)&0xfc))^ \ + *(const DES_LONG *)(des_SP+0x600+((u>>24L)&0xfc))^ \ + *(const DES_LONG *)(des_SP+0x100+((t )&0xfc))^ \ + *(const DES_LONG *)(des_SP+0x300+((t>> 8L)&0xfc))^ \ + *(const DES_LONG *)(des_SP+0x500+((t>>16L)&0xfc))^ \ + *(const DES_LONG *)(des_SP+0x700+((t>>24L)&0xfc)); } +#endif + +#else /* original version */ + +#if defined(DES_RISC1) || defined(DES_RISC2) +#ifdef DES_RISC1 +#define D_ENCRYPT(LL,R,S) {\ + unsigned int u1,u2,u3; \ + LOAD_DATA(R,S,u,t,E0,E1,u1); \ + u>>=2L; \ + t=ROTATE(t,6); \ + u2=(int)u>>8L; \ + u1=(int)u&0x3f; \ + u2&=0x3f; \ + u>>=16L; \ + LL^=DES_SPtrans[0][u1]; \ + LL^=DES_SPtrans[2][u2]; \ + u3=(int)u>>8L; \ + u1=(int)u&0x3f; \ + u3&=0x3f; \ + LL^=DES_SPtrans[4][u1]; \ + LL^=DES_SPtrans[6][u3]; \ + u2=(int)t>>8L; \ + u1=(int)t&0x3f; \ + u2&=0x3f; \ + t>>=16L; \ + LL^=DES_SPtrans[1][u1]; \ + LL^=DES_SPtrans[3][u2]; \ + u3=(int)t>>8L; \ + u1=(int)t&0x3f; \ + u3&=0x3f; \ + LL^=DES_SPtrans[5][u1]; \ + LL^=DES_SPtrans[7][u3]; } +#endif +#ifdef DES_RISC2 +#define D_ENCRYPT(LL,R,S) {\ + unsigned int u1,u2,s1,s2; \ + LOAD_DATA(R,S,u,t,E0,E1,u1); \ + u>>=2L; \ + t=ROTATE(t,6); \ + u2=(int)u>>8L; \ + u1=(int)u&0x3f; \ + u2&=0x3f; \ + LL^=DES_SPtrans[0][u1]; \ + LL^=DES_SPtrans[2][u2]; \ + s1=(int)u>>16L; \ + s2=(int)u>>24L; \ + s1&=0x3f; \ + s2&=0x3f; \ + LL^=DES_SPtrans[4][s1]; \ + LL^=DES_SPtrans[6][s2]; \ + u2=(int)t>>8L; \ + u1=(int)t&0x3f; \ + u2&=0x3f; \ + LL^=DES_SPtrans[1][u1]; \ + LL^=DES_SPtrans[3][u2]; \ + s1=(int)t>>16; \ + s2=(int)t>>24L; \ + s1&=0x3f; \ + s2&=0x3f; \ + LL^=DES_SPtrans[5][s1]; \ + LL^=DES_SPtrans[7][s2]; } +#endif + +#else + +#define D_ENCRYPT(LL,R,S) {\ + LOAD_DATA_tmp(R,S,u,t,E0,E1); \ + t=ROTATE(t,4); \ + LL^=\ + DES_SPtrans[0][(u>> 2L)&0x3f]^ \ + DES_SPtrans[2][(u>>10L)&0x3f]^ \ + DES_SPtrans[4][(u>>18L)&0x3f]^ \ + DES_SPtrans[6][(u>>26L)&0x3f]^ \ + DES_SPtrans[1][(t>> 2L)&0x3f]^ \ + DES_SPtrans[3][(t>>10L)&0x3f]^ \ + DES_SPtrans[5][(t>>18L)&0x3f]^ \ + DES_SPtrans[7][(t>>26L)&0x3f]; } +#endif +#endif + + /* IP and FP + * The problem is more of a geometric problem that random bit fiddling. + 0 1 2 3 4 5 6 7 62 54 46 38 30 22 14 6 + 8 9 10 11 12 13 14 15 60 52 44 36 28 20 12 4 + 16 17 18 19 20 21 22 23 58 50 42 34 26 18 10 2 + 24 25 26 27 28 29 30 31 to 56 48 40 32 24 16 8 0 + + 32 33 34 35 36 37 38 39 63 55 47 39 31 23 15 7 + 40 41 42 43 44 45 46 47 61 53 45 37 29 21 13 5 + 48 49 50 51 52 53 54 55 59 51 43 35 27 19 11 3 + 56 57 58 59 60 61 62 63 57 49 41 33 25 17 9 1 + + The output has been subject to swaps of the form + 0 1 -> 3 1 but the odd and even bits have been put into + 2 3 2 0 + different words. The main trick is to remember that + t=((l>>size)^r)&(mask); + r^=t; + l^=(t<>(n))^(b))&(m)),\ + (b)^=(t),\ + (a)^=((t)<<(n))) + +#define IP(l,r) \ + { \ + register DES_LONG tt; \ + PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \ + PERM_OP(l,r,tt,16,0x0000ffffL); \ + PERM_OP(r,l,tt, 2,0x33333333L); \ + PERM_OP(l,r,tt, 8,0x00ff00ffL); \ + PERM_OP(r,l,tt, 1,0x55555555L); \ + } + +#define FP(l,r) \ + { \ + register DES_LONG tt; \ + PERM_OP(l,r,tt, 1,0x55555555L); \ + PERM_OP(r,l,tt, 8,0x00ff00ffL); \ + PERM_OP(l,r,tt, 2,0x33333333L); \ + PERM_OP(r,l,tt,16,0x0000ffffL); \ + PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \ + } + +OPENSSL_EXTERN const DES_LONG DES_SPtrans[8][64]; + +void fcrypt_body(DES_LONG *out,DES_key_schedule *ks, + DES_LONG Eswap0, DES_LONG Eswap1); +#endif diff --git a/fips/des/fips_des_selftest.c b/fips/des/fips_des_selftest.c new file mode 100644 index 0000000000..3e0778eb5e --- /dev/null +++ b/fips/des/fips_des_selftest.c @@ -0,0 +1,200 @@ +/* ==================================================================== + * Copyright (c) 2003 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 + * openssl-core@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. + * + */ + +#include +#include +#include +#include +#include + +#ifdef OPENSSL_FIPS +static struct + { + DES_cblock key; + unsigned char plaintext[8]; + unsigned char ciphertext[8]; + } tests[]= + { + { + { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, + { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, + { 0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7 } + }, + { + { 0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10 }, + { 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF }, + { 0xED,0x39,0xD9,0x50,0xFA,0x74,0xBC,0xC4 }, + }, + }; + +static struct + { + DES_cblock key1; + DES_cblock key2; + unsigned char plaintext[8]; + unsigned char ciphertext[8]; + } tests2[]= + { + { + { 0x7c,0x4f,0x6e,0xf7,0xa2,0x04,0x16,0xec }, + { 0x0b,0x6b,0x7c,0x9e,0x5e,0x19,0xa7,0xc4 }, + { 0x06,0xa7,0xd8,0x79,0xaa,0xce,0x69,0xef }, + { 0x4c,0x11,0x17,0x55,0xbf,0xc4,0x4e,0xfd } + }, + { + { 0x5d,0x9e,0x01,0xd3,0x25,0xc7,0x3e,0x34 }, + { 0x01,0x16,0x7c,0x85,0x23,0xdf,0xe0,0x68 }, + { 0x9c,0x50,0x09,0x0f,0x5e,0x7d,0x69,0x7e }, + { 0xd2,0x0b,0x18,0xdf,0xd9,0x0d,0x9e,0xff }, + } + }; + +static struct + { + DES_cblock key1; + DES_cblock key2; + DES_cblock key3; + unsigned char plaintext[8]; + unsigned char ciphertext[8]; + } tests3[]= + { + { + { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, + { 0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10 }, + { 0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0 }, + { 0x8f,0x8f,0xbf,0x9b,0x5d,0x48,0xb4,0x1c}, + { 0x59,0x8c,0xe5,0xd3,0x6c,0xa2,0xea,0x1b}, + }, + { + { 0xDC,0xBA,0x98,0x76,0x54,0x32,0x10,0xFE }, + { 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF }, + { 0xED,0x39,0xD9,0x50,0xFA,0x74,0xBC,0xC4 }, + { 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF }, + { 0x11,0x25,0xb0,0x35,0xbe,0xa0,0x82,0x86 }, + }, + }; + +void FIPS_corrupt_des() + { + tests[0].plaintext[0]++; + } + +int FIPS_selftest_des() + { + int n; + + /* Encrypt/decrypt with DES and compare to known answers */ + for(n=0 ; n < 2 ; ++n) + { + DES_key_schedule key; + DES_cblock buf; + + DES_set_key(&tests[n].key,&key); + DES_ecb_encrypt(&tests[n].plaintext,&buf,&key,1); + if(memcmp(buf,tests[n].ciphertext,sizeof buf)) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_DES,FIPS_R_SELFTEST_FAILED); + return 0; + } + DES_ecb_encrypt(&tests[n].ciphertext,&buf,&key,0); + if(memcmp(buf,tests[n].plaintext,sizeof buf)) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_DES,FIPS_R_SELFTEST_FAILED); + return 0; + } + } + + /* Encrypt/decrypt with 2-key 3DES and compare to known answers */ + for(n=0 ; n < 2 ; ++n) + { + DES_key_schedule key1, key2; + unsigned char buf[8]; + + DES_set_key(&tests2[n].key1,&key1); + DES_set_key(&tests2[n].key2,&key2); + DES_ecb2_encrypt(tests2[n].plaintext,buf,&key1,&key2,1); + if(memcmp(buf,tests2[n].ciphertext,sizeof buf)) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_DES,FIPS_R_SELFTEST_FAILED); + return 0; + } + DES_ecb2_encrypt(tests2[n].ciphertext,buf,&key1,&key2,0); + if(memcmp(buf,tests2[n].plaintext,sizeof buf)) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_DES,FIPS_R_SELFTEST_FAILED); + return 0; + } + } + + /* Encrypt/decrypt with 3DES and compare to known answers */ + for(n=0 ; n < 2 ; ++n) + { + DES_key_schedule key1, key2, key3; + unsigned char buf[8]; + + DES_set_key(&tests3[n].key1,&key1); + DES_set_key(&tests3[n].key2,&key2); + DES_set_key(&tests3[n].key3,&key3); + DES_ecb3_encrypt(tests3[n].plaintext,buf,&key1,&key2,&key3,1); + if(memcmp(buf,tests3[n].ciphertext,sizeof buf)) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_DES,FIPS_R_SELFTEST_FAILED); + return 0; + } + DES_ecb3_encrypt(tests3[n].ciphertext,buf,&key1,&key2,&key3,0); + if(memcmp(buf,tests3[n].plaintext,sizeof buf)) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_DES,FIPS_R_SELFTEST_FAILED); + return 0; + } + } + + return 1; + } +#endif diff --git a/fips/des/fips_desmovs.c b/fips/des/fips_desmovs.c new file mode 100644 index 0000000000..3128a752be --- /dev/null +++ b/fips/des/fips_desmovs.c @@ -0,0 +1,784 @@ +/*--------------------------------------------- + NIST DES Modes of Operation Validation System + Test Program + + Based on the AES Validation Suite, which was: + Copyright + V-ONE Corporation + 20250 Century Blvd, Suite 300 + Germantown, MD 20874 + U.S.A. + ----------------------------------------------*/ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include "e_os.h" + +/*#define AES_BLOCK_SIZE 16*/ + +#define VERBOSE 0 + +/*-----------------------------------------------*/ + +int DESTest(EVP_CIPHER_CTX *ctx, + char *amode, int akeysz, unsigned char *aKey, + unsigned char *iVec, + int dir, /* 0 = decrypt, 1 = encrypt */ + unsigned char *out, unsigned char *in, int len) + { + const EVP_CIPHER *cipher = NULL; + int kt = 0; + + if (ctx) + memset(ctx, 0, sizeof(EVP_CIPHER_CTX)); + + if (strcasecmp(amode, "CBC") == 0) + kt = 1000; + else if (strcasecmp(amode, "ECB") == 0) + kt = 2000; + else if (strcasecmp(amode, "CFB64") == 0) + kt = 3000; + else if (strncasecmp(amode, "OFB", 3) == 0) + kt = 4000; + else if(!strcasecmp(amode,"CFB1")) + kt=5000; + else if(!strcasecmp(amode,"CFB8")) + kt=6000; + else + { + printf("Unknown mode: %s\n", amode); + exit(1); + } + if (akeysz != 64 && akeysz != 192) + { + printf("Invalid key size: %d\n", akeysz); + exit(1); + } + else + { + kt += akeysz; + switch (kt) + { + case 1064: + cipher=EVP_des_cbc(); + break; + case 1192: + cipher=EVP_des_ede3_cbc(); + break; + case 2064: + cipher=EVP_des_ecb(); + break; + case 2192: + cipher=EVP_des_ede3_ecb(); + break; + case 3064: + cipher=EVP_des_cfb64(); + break; + case 3192: + cipher=EVP_des_ede3_cfb64(); + break; + case 4064: + cipher=EVP_des_ofb(); + break; + case 4192: + cipher=EVP_des_ede3_ofb(); + break; + case 5064: + cipher=EVP_des_cfb1(); + break; + case 5192: + cipher=EVP_des_ede3_cfb1(); + break; + case 6064: + cipher=EVP_des_cfb8(); + break; + case 6192: + cipher=EVP_des_ede3_cfb8(); + break; + default: + printf("Didn't handle mode %d\n",kt); + exit(1); + } + if(!EVP_CipherInit(ctx, cipher, aKey, iVec, dir)) + { + ERR_print_errors_fp(stderr); + exit(1); + } + EVP_Cipher(ctx, out, in, len); + } + return 1; + } + +/*-----------------------------------------------*/ + +int hex2bin(char *in, int len, unsigned char *out) + { + int n1, n2; + unsigned char ch; + + for (n1 = 0, n2 = 0; n1 < len; ) + { /* first byte */ + if ((in[n1] >= '0') && (in[n1] <= '9')) + ch = in[n1++] - '0'; + else if ((in[n1] >= 'A') && (in[n1] <= 'F')) + ch = in[n1++] - 'A' + 10; + else if ((in[n1] >= 'a') && (in[n1] <= 'f')) + ch = in[n1++] - 'a' + 10; + else + return -1; + if(len == 1) + { + out[n2++]=ch; + break; + } + out[n2] = ch << 4; + /* second byte */ + if ((in[n1] >= '0') && (in[n1] <= '9')) + ch = in[n1++] - '0'; + else if ((in[n1] >= 'A') && (in[n1] <= 'F')) + ch = in[n1++] - 'A' + 10; + else if ((in[n1] >= 'a') && (in[n1] <= 'f')) + ch = in[n1++] - 'a' + 10; + else + return -1; + out[n2++] |= ch; + } + return n2; + } + +/*-----------------------------------------------*/ + +int bin2hex(unsigned char *in, int len, char *out) + { + int n1, n2; + unsigned char ch; + + for (n1 = 0, n2 = 0; n1 < len; ++n1) + { + /* first nibble */ + ch = in[n1] >> 4; + if (ch <= 0x09) + out[n2++] = ch + '0'; + else + out[n2++] = ch - 10 + 'a'; + /* second nibble */ + ch = in[n1] & 0x0f; + if (ch <= 0x09) + out[n2++] = ch + '0'; + else + out[n2++] = ch - 10 + 'a'; + } + return n2; + } + +/* NB: this return the number of _bits_ read */ +int bint2bin(const char *in, int len, unsigned char *out) + { + int n; + + memset(out,0,len); + for(n=0 ; n < len ; ++n) + if(in[n] == '1') + out[n/8]|=(0x80 >> (n%8)); + return len; + } + +int bin2bint(const unsigned char *in,int len,char *out) + { + int n; + + for(n=0 ; n < len ; ++n) + out[n]=(in[n/8]&(0x80 >> (n%8))) ? '1' : '0'; + return n; + } + +/*-----------------------------------------------*/ + +void PrintValue(char *tag, unsigned char *val, int len) + { +#if VERBOSE + char obuf[2048]; + int olen; + olen = bin2hex(val, len, obuf); + printf("%s = %.*s\n", tag, olen, obuf); +#endif + } + +void DebugValue(char *tag, unsigned char *val, int len) + { + char obuf[2048]; + int olen; + olen = bin2hex(val, len, obuf); + printf("%s = %.*s\n", tag, olen, obuf); + } + +void OutputValue(char *tag, unsigned char *val, int len, FILE *rfp,int bitmode) + { + char obuf[2048]; + int olen; + + if(bitmode) + olen=bin2bint(val,len,obuf); + else + olen=bin2hex(val,len,obuf); + + fprintf(rfp, "%s = %.*s\n", tag, olen, obuf); +#if VERBOSE + printf("%s = %.*s\n", tag, olen, obuf); +#endif + } + +void shiftin(unsigned char *dst,unsigned char *src,int nbits) + { + int n; + + /* move the bytes... */ + memmove(dst,dst+nbits/8,3*8-nbits/8); + /* append new data */ + memcpy(dst+3*8-nbits/8,src,(nbits+7)/8); + /* left shift the bits */ + if(nbits%8) + for(n=0 ; n < 3*8 ; ++n) + dst[n]=(dst[n] << (nbits%8))|(dst[n+1] >> (8-nbits%8)); + } + +/*-----------------------------------------------*/ +char *t_tag[2] = {"PLAINTEXT", "CIPHERTEXT"}; +char *t_mode[6] = {"CBC","ECB","OFB","CFB1","CFB8","CFB64"}; +enum Mode {CBC, ECB, OFB, CFB1, CFB8, CFB64}; +int Sizes[6]={64,64,64,1,8,64}; + +void do_mct(char *amode, + int akeysz, int numkeys, unsigned char *akey,unsigned char *ivec, + int dir, unsigned char *text, int len, + FILE *rfp) + { + int i,imode; + unsigned char nk[4*8]; /* longest key+8 */ + unsigned char text0[8]; + + for (imode=0 ; imode < 6 ; ++imode) + if(!strcmp(amode,t_mode[imode])) + break; + if (imode == 6) + { + printf("Unrecognized mode: %s\n", amode); + exit(1); + } + + for(i=0 ; i < 400 ; ++i) + { + int j; + int n; + EVP_CIPHER_CTX ctx; + int kp=akeysz/64; + unsigned char old_iv[8]; + + fprintf(rfp,"\nCOUNT = %d\n",i); + if(kp == 1) + OutputValue("KEY",akey,8,rfp,0); + else + for(n=0 ; n < kp ; ++n) + { + fprintf(rfp,"KEY%d",n+1); + OutputValue("",akey+n*8,8,rfp,0); + } + + if(imode != ECB) + OutputValue("IV",ivec,8,rfp,0); + OutputValue(t_tag[dir^1],text,len,rfp,imode == CFB1); + + /* compensate for endianness */ + if(imode == CFB1) + text[0]<<=7; + + memcpy(text0,text,8); + + for(j=0 ; j < 10000 ; ++j) + { + unsigned char old_text[8]; + + memcpy(old_text,text,8); + if(j == 0) + { + memcpy(old_iv,ivec,8); + DESTest(&ctx,amode,akeysz,akey,ivec,dir,text,text,len); + } + else + { + memcpy(old_iv,ctx.iv,8); + EVP_Cipher(&ctx,text,text,len); + } + if(j == 9999) + { + OutputValue(t_tag[dir],text,len,rfp,imode == CFB1); + /* memcpy(ivec,text,8); */ + } + /* DebugValue("iv",ctx.iv,8); */ + /* accumulate material for the next key */ + shiftin(nk,text,Sizes[imode]); + /* DebugValue("nk",nk,24);*/ + if((dir && (imode == CFB1 || imode == CFB8 || imode == CFB64 + || imode == CBC)) || imode == OFB) + memcpy(text,old_iv,8); + + if(!dir && (imode == CFB1 || imode == CFB8 || imode == CFB64)) + { + /* the test specifies using the output of the raw DES operation + which we don't have, so reconstruct it... */ + for(n=0 ; n < 8 ; ++n) + text[n]^=old_text[n]; + } + } + for(n=0 ; n < 8 ; ++n) + akey[n]^=nk[16+n]; + for(n=0 ; n < 8 ; ++n) + akey[8+n]^=nk[8+n]; + for(n=0 ; n < 8 ; ++n) + akey[16+n]^=nk[n]; + if(numkeys < 3) + memcpy(&akey[2*8],akey,8); + if(numkeys < 2) + memcpy(&akey[8],akey,8); + DES_set_odd_parity((DES_cblock *)akey); + DES_set_odd_parity((DES_cblock *)(akey+8)); + DES_set_odd_parity((DES_cblock *)(akey+16)); + memcpy(ivec,ctx.iv,8); + + /* pointless exercise - the final text doesn't depend on the + initial text in OFB mode, so who cares what it is? (Who + designed these tests?) */ + if(imode == OFB) + for(n=0 ; n < 8 ; ++n) + text[n]=text0[n]^old_iv[n]; + } + } + +int proc_file(char *rqfile) + { + char afn[256], rfn[256]; + FILE *afp = NULL, *rfp = NULL; + char ibuf[2048]; + int ilen, len, ret = 0; + char amode[8] = ""; + char atest[100] = ""; + int akeysz=0; + unsigned char iVec[20], aKey[40]; + int dir = -1, err = 0, step = 0; + unsigned char plaintext[2048]; + unsigned char ciphertext[2048]; + char *rp; + EVP_CIPHER_CTX ctx; + int numkeys=1; + + if (!rqfile || !(*rqfile)) + { + printf("No req file\n"); + return -1; + } + strcpy(afn, rqfile); + + if ((afp = fopen(afn, "r")) == NULL) + { + printf("Cannot open file: %s, %s\n", + afn, strerror(errno)); + return -1; + } + strcpy(rfn,afn); + rp=strstr(rfn,"req/"); + assert(rp); + memcpy(rp,"rsp",3); + rp = strstr(rfn, ".req"); + memcpy(rp, ".rsp", 4); + if ((rfp = fopen(rfn, "w")) == NULL) + { + printf("Cannot open file: %s, %s\n", + rfn, strerror(errno)); + fclose(afp); + afp = NULL; + return -1; + } + while (!err && (fgets(ibuf, sizeof(ibuf), afp)) != NULL) + { + ilen = strlen(ibuf); + /* printf("step=%d ibuf=%s",step,ibuf);*/ + if(step == 3 && !strcmp(amode,"ECB")) + { + memset(iVec, 0, sizeof(iVec)); + step = (dir)? 4: 5; /* no ivec for ECB */ + } + switch (step) + { + case 0: /* read preamble */ + if (ibuf[0] == '\n') + { /* end of preamble */ + if (*amode == '\0') + { + printf("Missing Mode\n"); + err = 1; + } + else + { + fputs(ibuf, rfp); + ++ step; + } + } + else if (ibuf[0] != '#') + { + printf("Invalid preamble item: %s\n", ibuf); + err = 1; + } + else + { /* process preamble */ + char *xp, *pp = ibuf+2; + int n; + if(*amode) + { /* insert current time & date */ + time_t rtim = time(0); + fprintf(rfp, "# %s", ctime(&rtim)); + } + else + { + fputs(ibuf, rfp); + if(!strncmp(pp,"INVERSE ",8) || !strncmp(pp,"DES ",4) + || !strncmp(pp,"TDES ",5) + || !strncmp(pp,"PERMUTATION ",12) + || !strncmp(pp,"SUBSTITUTION ",13) + || !strncmp(pp,"VARIABLE ",9)) + { + /* get test type */ + if(!strncmp(pp,"DES ",4)) + pp+=4; + else if(!strncmp(pp,"TDES ",5)) + pp+=5; + xp = strchr(pp, ' '); + n = xp-pp; + strncpy(atest, pp, n); + atest[n] = '\0'; + /* get mode */ + xp = strrchr(pp, ' '); /* get mode" */ + n = strlen(xp+1)-1; + strncpy(amode, xp+1, n); + amode[n] = '\0'; + /* amode[3] = '\0'; */ + printf("Test=%s, Mode=%s\n",atest,amode); + } + } + } + break; + + case 1: /* [ENCRYPT] | [DECRYPT] */ + if(ibuf[0] == '\n') + break; + if (ibuf[0] == '[') + { + fputs(ibuf, rfp); + ++step; + if (strncasecmp(ibuf, "[ENCRYPT]", 9) == 0) + dir = 1; + else if (strncasecmp(ibuf, "[DECRYPT]", 9) == 0) + dir = 0; + else + { + printf("Invalid keyword: %s\n", ibuf); + err = 1; + } + break; + } + else if (dir == -1) + { + err = 1; + printf("Missing ENCRYPT/DECRYPT keyword\n"); + break; + } + else + step = 2; + + case 2: /* KEY = xxxx */ + if(*ibuf == '\n') + { + fputs(ibuf, rfp); + break; + } + if(!strncasecmp(ibuf,"COUNT = ",8)) + { + fputs(ibuf, rfp); + break; + } + if(!strncasecmp(ibuf,"COUNT=",6)) + { + fputs(ibuf, rfp); + break; + } + if(!strncasecmp(ibuf,"NumKeys = ",10)) + { + numkeys=atoi(ibuf+10); + break; + } + + fputs(ibuf, rfp); + if(!strncasecmp(ibuf,"KEY = ",6)) + { + akeysz=64; + len = hex2bin((char*)ibuf+6, strlen(ibuf+6)-1, aKey); + if (len < 0) + { + printf("Invalid KEY\n"); + err=1; + break; + } + PrintValue("KEY", aKey, len); + ++step; + } + else if(!strncasecmp(ibuf,"KEYs = ",7)) + { + akeysz=64*3; + len=hex2bin(ibuf+7,strlen(ibuf+7)-1,aKey); + if(len != 8) + { + printf("Invalid KEY\n"); + err=1; + break; + } + memcpy(aKey+8,aKey,8); + memcpy(aKey+16,aKey,8); + ibuf[4]='\0'; + PrintValue("KEYs",aKey,len); + ++step; + } + else if(!strncasecmp(ibuf,"KEY",3)) + { + int n=ibuf[3]-'1'; + + akeysz=64*3; + len=hex2bin(ibuf+7,strlen(ibuf+7)-1,aKey+n*8); + if(len != 8) + { + printf("Invalid KEY\n"); + err=1; + break; + } + ibuf[4]='\0'; + PrintValue(ibuf,aKey,len); + if(n == 2) + ++step; + } + else + { + printf("Missing KEY\n"); + err = 1; + } + break; + + case 3: /* IV = xxxx */ + fputs(ibuf, rfp); + if (strncasecmp(ibuf, "IV = ", 5) != 0) + { + printf("Missing IV\n"); + err = 1; + } + else + { + len = hex2bin((char*)ibuf+5, strlen(ibuf+5)-1, iVec); + if (len < 0) + { + printf("Invalid IV\n"); + err =1; + break; + } + PrintValue("IV", iVec, len); + step = (dir)? 4: 5; + } + break; + + case 4: /* PLAINTEXT = xxxx */ + fputs(ibuf, rfp); + if (strncasecmp(ibuf, "PLAINTEXT = ", 12) != 0) + { + printf("Missing PLAINTEXT\n"); + err = 1; + } + else + { + int nn = strlen(ibuf+12); + if(!strcmp(amode,"CFB1")) + len=bint2bin(ibuf+12,nn-1,plaintext); + else + len=hex2bin(ibuf+12, nn-1,plaintext); + if (len < 0) + { + printf("Invalid PLAINTEXT: %s", ibuf+12); + err =1; + break; + } + if (len >= sizeof(plaintext)) + { + printf("Buffer overflow\n"); + } + PrintValue("PLAINTEXT", (unsigned char*)plaintext, len); + if (strcmp(atest, "Monte") == 0) /* Monte Carlo Test */ + { + do_mct(amode,akeysz,numkeys,aKey,iVec,dir,plaintext,len,rfp); + } + else + { + assert(dir == 1); + ret = DESTest(&ctx, amode, akeysz, aKey, iVec, + dir, /* 0 = decrypt, 1 = encrypt */ + ciphertext, plaintext, len); + OutputValue("CIPHERTEXT",ciphertext,len,rfp, + !strcmp(amode,"CFB1")); + } + step = 6; + } + break; + + case 5: /* CIPHERTEXT = xxxx */ + fputs(ibuf, rfp); + if (strncasecmp(ibuf, "CIPHERTEXT = ", 13) != 0) + { + printf("Missing KEY\n"); + err = 1; + } + else + { + if(!strcmp(amode,"CFB1")) + len=bint2bin(ibuf+13,strlen(ibuf+13)-1,ciphertext); + else + len = hex2bin(ibuf+13,strlen(ibuf+13)-1,ciphertext); + if (len < 0) + { + printf("Invalid CIPHERTEXT\n"); + err =1; + break; + } + + PrintValue("CIPHERTEXT", ciphertext, len); + if (strcmp(atest, "Monte") == 0) /* Monte Carlo Test */ + { + do_mct(amode, akeysz, numkeys, aKey, iVec, + dir, ciphertext, len, rfp); + } + else + { + assert(dir == 0); + ret = DESTest(&ctx, amode, akeysz, aKey, iVec, + dir, /* 0 = decrypt, 1 = encrypt */ + plaintext, ciphertext, len); + OutputValue("PLAINTEXT",(unsigned char *)plaintext,len,rfp, + !strcmp(amode,"CFB1")); + } + step = 6; + } + break; + + case 6: + if (ibuf[0] != '\n') + { + err = 1; + printf("Missing terminator\n"); + } + else if (strcmp(atest, "MCT") != 0) + { /* MCT already added terminating nl */ + fputs(ibuf, rfp); + } + step = 1; + break; + } + } + if (rfp) + fclose(rfp); + if (afp) + fclose(afp); + return err; + } + +/*-------------------------------------------------- + Processes either a single file or + a set of files whose names are passed in a file. + A single file is specified as: + aes_test -f xxx.req + A set of files is specified as: + aes_test -d xxxxx.xxx + The default is: -d req.txt +--------------------------------------------------*/ +int main(int argc, char **argv) + { + char *rqlist = "req.txt"; + FILE *fp = NULL; + char fn[250] = "", rfn[256] = ""; + int f_opt = 0, d_opt = 1; + +#ifdef OPENSSL_FIPS + if(!FIPS_mode_set(1,argv[0])) + { + ERR_load_crypto_strings(); + ERR_print_errors(BIO_new_fp(stderr,BIO_NOCLOSE)); + exit(1); + } +#endif + ERR_load_crypto_strings(); + if (argc > 1) + { + if (strcasecmp(argv[1], "-d") == 0) + { + d_opt = 1; + } + else if (strcasecmp(argv[1], "-f") == 0) + { + f_opt = 1; + d_opt = 0; + } + else + { + printf("Invalid parameter: %s\n", argv[1]); + return 0; + } + if (argc < 3) + { + printf("Missing parameter\n"); + return 0; + } + if (d_opt) + rqlist = argv[2]; + else + strcpy(fn, argv[2]); + } + if (d_opt) + { /* list of files (directory) */ + if (!(fp = fopen(rqlist, "r"))) + { + printf("Cannot open req list file\n"); + return -1; + } + while (fgets(fn, sizeof(fn), fp)) + { + strtok(fn, "\r\n"); + strcpy(rfn, fn); + printf("Processing: %s\n", rfn); + if (proc_file(rfn)) + { + printf(">>> Processing failed for: %s <<<\n", rfn); + exit(1); + } + } + fclose(fp); + } + else /* single file */ + { + printf("Processing: %s\n", fn); + if (proc_file(fn)) + { + printf(">>> Processing failed for: %s <<<\n", fn); + } + } + return 0; + } diff --git a/fips/des/fips_set_key.c b/fips/des/fips_set_key.c new file mode 100644 index 0000000000..1773c2684a --- /dev/null +++ b/fips/des/fips_set_key.c @@ -0,0 +1,415 @@ +/* crypto/des/set_key.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* set_key.c v 1.4 eay 24/9/91 + * 1.4 Speed up by 400% :-) + * 1.3 added register declarations. + * 1.2 unrolled make_key_sched a bit more + * 1.1 added norm_expand_bits + * 1.0 First working version + */ +#include "fips_des_locl.h" +#include "../fips.h" + +#ifdef OPENSSL_FIPS + +OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key); /* defaults to false */ + +static const unsigned char odd_parity[256]={ + 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14, + 16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31, + 32, 32, 35, 35, 37, 37, 38, 38, 41, 41, 42, 42, 44, 44, 47, 47, + 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 59, 59, 61, 61, 62, 62, + 64, 64, 67, 67, 69, 69, 70, 70, 73, 73, 74, 74, 76, 76, 79, 79, + 81, 81, 82, 82, 84, 84, 87, 87, 88, 88, 91, 91, 93, 93, 94, 94, + 97, 97, 98, 98,100,100,103,103,104,104,107,107,109,109,110,110, +112,112,115,115,117,117,118,118,121,121,122,122,124,124,127,127, +128,128,131,131,133,133,134,134,137,137,138,138,140,140,143,143, +145,145,146,146,148,148,151,151,152,152,155,155,157,157,158,158, +161,161,162,162,164,164,167,167,168,168,171,171,173,173,174,174, +176,176,179,179,181,181,182,182,185,185,186,186,188,188,191,191, +193,193,194,194,196,196,199,199,200,200,203,203,205,205,206,206, +208,208,211,211,213,213,214,214,217,217,218,218,220,220,223,223, +224,224,227,227,229,229,230,230,233,233,234,234,236,236,239,239, +241,241,242,242,244,244,247,247,248,248,251,251,253,253,254,254}; + +void DES_set_odd_parity(DES_cblock *key) + { + int i; + + for (i=0; i>(n))^(b))&(m)),\ + * (b)^=(t),\ + * (a)=((a)^((t)<<(n)))) + */ + +#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ + (a)=(a)^(t)^(t>>(16-(n)))) + +static const DES_LONG des_skb[8][64]={ + { + /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ + 0x00000000L,0x00000010L,0x20000000L,0x20000010L, + 0x00010000L,0x00010010L,0x20010000L,0x20010010L, + 0x00000800L,0x00000810L,0x20000800L,0x20000810L, + 0x00010800L,0x00010810L,0x20010800L,0x20010810L, + 0x00000020L,0x00000030L,0x20000020L,0x20000030L, + 0x00010020L,0x00010030L,0x20010020L,0x20010030L, + 0x00000820L,0x00000830L,0x20000820L,0x20000830L, + 0x00010820L,0x00010830L,0x20010820L,0x20010830L, + 0x00080000L,0x00080010L,0x20080000L,0x20080010L, + 0x00090000L,0x00090010L,0x20090000L,0x20090010L, + 0x00080800L,0x00080810L,0x20080800L,0x20080810L, + 0x00090800L,0x00090810L,0x20090800L,0x20090810L, + 0x00080020L,0x00080030L,0x20080020L,0x20080030L, + 0x00090020L,0x00090030L,0x20090020L,0x20090030L, + 0x00080820L,0x00080830L,0x20080820L,0x20080830L, + 0x00090820L,0x00090830L,0x20090820L,0x20090830L, + },{ + /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ + 0x00000000L,0x02000000L,0x00002000L,0x02002000L, + 0x00200000L,0x02200000L,0x00202000L,0x02202000L, + 0x00000004L,0x02000004L,0x00002004L,0x02002004L, + 0x00200004L,0x02200004L,0x00202004L,0x02202004L, + 0x00000400L,0x02000400L,0x00002400L,0x02002400L, + 0x00200400L,0x02200400L,0x00202400L,0x02202400L, + 0x00000404L,0x02000404L,0x00002404L,0x02002404L, + 0x00200404L,0x02200404L,0x00202404L,0x02202404L, + 0x10000000L,0x12000000L,0x10002000L,0x12002000L, + 0x10200000L,0x12200000L,0x10202000L,0x12202000L, + 0x10000004L,0x12000004L,0x10002004L,0x12002004L, + 0x10200004L,0x12200004L,0x10202004L,0x12202004L, + 0x10000400L,0x12000400L,0x10002400L,0x12002400L, + 0x10200400L,0x12200400L,0x10202400L,0x12202400L, + 0x10000404L,0x12000404L,0x10002404L,0x12002404L, + 0x10200404L,0x12200404L,0x10202404L,0x12202404L, + },{ + /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ + 0x00000000L,0x00000001L,0x00040000L,0x00040001L, + 0x01000000L,0x01000001L,0x01040000L,0x01040001L, + 0x00000002L,0x00000003L,0x00040002L,0x00040003L, + 0x01000002L,0x01000003L,0x01040002L,0x01040003L, + 0x00000200L,0x00000201L,0x00040200L,0x00040201L, + 0x01000200L,0x01000201L,0x01040200L,0x01040201L, + 0x00000202L,0x00000203L,0x00040202L,0x00040203L, + 0x01000202L,0x01000203L,0x01040202L,0x01040203L, + 0x08000000L,0x08000001L,0x08040000L,0x08040001L, + 0x09000000L,0x09000001L,0x09040000L,0x09040001L, + 0x08000002L,0x08000003L,0x08040002L,0x08040003L, + 0x09000002L,0x09000003L,0x09040002L,0x09040003L, + 0x08000200L,0x08000201L,0x08040200L,0x08040201L, + 0x09000200L,0x09000201L,0x09040200L,0x09040201L, + 0x08000202L,0x08000203L,0x08040202L,0x08040203L, + 0x09000202L,0x09000203L,0x09040202L,0x09040203L, + },{ + /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ + 0x00000000L,0x00100000L,0x00000100L,0x00100100L, + 0x00000008L,0x00100008L,0x00000108L,0x00100108L, + 0x00001000L,0x00101000L,0x00001100L,0x00101100L, + 0x00001008L,0x00101008L,0x00001108L,0x00101108L, + 0x04000000L,0x04100000L,0x04000100L,0x04100100L, + 0x04000008L,0x04100008L,0x04000108L,0x04100108L, + 0x04001000L,0x04101000L,0x04001100L,0x04101100L, + 0x04001008L,0x04101008L,0x04001108L,0x04101108L, + 0x00020000L,0x00120000L,0x00020100L,0x00120100L, + 0x00020008L,0x00120008L,0x00020108L,0x00120108L, + 0x00021000L,0x00121000L,0x00021100L,0x00121100L, + 0x00021008L,0x00121008L,0x00021108L,0x00121108L, + 0x04020000L,0x04120000L,0x04020100L,0x04120100L, + 0x04020008L,0x04120008L,0x04020108L,0x04120108L, + 0x04021000L,0x04121000L,0x04021100L,0x04121100L, + 0x04021008L,0x04121008L,0x04021108L,0x04121108L, + },{ + /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ + 0x00000000L,0x10000000L,0x00010000L,0x10010000L, + 0x00000004L,0x10000004L,0x00010004L,0x10010004L, + 0x20000000L,0x30000000L,0x20010000L,0x30010000L, + 0x20000004L,0x30000004L,0x20010004L,0x30010004L, + 0x00100000L,0x10100000L,0x00110000L,0x10110000L, + 0x00100004L,0x10100004L,0x00110004L,0x10110004L, + 0x20100000L,0x30100000L,0x20110000L,0x30110000L, + 0x20100004L,0x30100004L,0x20110004L,0x30110004L, + 0x00001000L,0x10001000L,0x00011000L,0x10011000L, + 0x00001004L,0x10001004L,0x00011004L,0x10011004L, + 0x20001000L,0x30001000L,0x20011000L,0x30011000L, + 0x20001004L,0x30001004L,0x20011004L,0x30011004L, + 0x00101000L,0x10101000L,0x00111000L,0x10111000L, + 0x00101004L,0x10101004L,0x00111004L,0x10111004L, + 0x20101000L,0x30101000L,0x20111000L,0x30111000L, + 0x20101004L,0x30101004L,0x20111004L,0x30111004L, + },{ + /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ + 0x00000000L,0x08000000L,0x00000008L,0x08000008L, + 0x00000400L,0x08000400L,0x00000408L,0x08000408L, + 0x00020000L,0x08020000L,0x00020008L,0x08020008L, + 0x00020400L,0x08020400L,0x00020408L,0x08020408L, + 0x00000001L,0x08000001L,0x00000009L,0x08000009L, + 0x00000401L,0x08000401L,0x00000409L,0x08000409L, + 0x00020001L,0x08020001L,0x00020009L,0x08020009L, + 0x00020401L,0x08020401L,0x00020409L,0x08020409L, + 0x02000000L,0x0A000000L,0x02000008L,0x0A000008L, + 0x02000400L,0x0A000400L,0x02000408L,0x0A000408L, + 0x02020000L,0x0A020000L,0x02020008L,0x0A020008L, + 0x02020400L,0x0A020400L,0x02020408L,0x0A020408L, + 0x02000001L,0x0A000001L,0x02000009L,0x0A000009L, + 0x02000401L,0x0A000401L,0x02000409L,0x0A000409L, + 0x02020001L,0x0A020001L,0x02020009L,0x0A020009L, + 0x02020401L,0x0A020401L,0x02020409L,0x0A020409L, + },{ + /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ + 0x00000000L,0x00000100L,0x00080000L,0x00080100L, + 0x01000000L,0x01000100L,0x01080000L,0x01080100L, + 0x00000010L,0x00000110L,0x00080010L,0x00080110L, + 0x01000010L,0x01000110L,0x01080010L,0x01080110L, + 0x00200000L,0x00200100L,0x00280000L,0x00280100L, + 0x01200000L,0x01200100L,0x01280000L,0x01280100L, + 0x00200010L,0x00200110L,0x00280010L,0x00280110L, + 0x01200010L,0x01200110L,0x01280010L,0x01280110L, + 0x00000200L,0x00000300L,0x00080200L,0x00080300L, + 0x01000200L,0x01000300L,0x01080200L,0x01080300L, + 0x00000210L,0x00000310L,0x00080210L,0x00080310L, + 0x01000210L,0x01000310L,0x01080210L,0x01080310L, + 0x00200200L,0x00200300L,0x00280200L,0x00280300L, + 0x01200200L,0x01200300L,0x01280200L,0x01280300L, + 0x00200210L,0x00200310L,0x00280210L,0x00280310L, + 0x01200210L,0x01200310L,0x01280210L,0x01280310L, + },{ + /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ + 0x00000000L,0x04000000L,0x00040000L,0x04040000L, + 0x00000002L,0x04000002L,0x00040002L,0x04040002L, + 0x00002000L,0x04002000L,0x00042000L,0x04042000L, + 0x00002002L,0x04002002L,0x00042002L,0x04042002L, + 0x00000020L,0x04000020L,0x00040020L,0x04040020L, + 0x00000022L,0x04000022L,0x00040022L,0x04040022L, + 0x00002020L,0x04002020L,0x00042020L,0x04042020L, + 0x00002022L,0x04002022L,0x00042022L,0x04042022L, + 0x00000800L,0x04000800L,0x00040800L,0x04040800L, + 0x00000802L,0x04000802L,0x00040802L,0x04040802L, + 0x00002800L,0x04002800L,0x00042800L,0x04042800L, + 0x00002802L,0x04002802L,0x00042802L,0x04042802L, + 0x00000820L,0x04000820L,0x00040820L,0x04040820L, + 0x00000822L,0x04000822L,0x00040822L,0x04040822L, + 0x00002820L,0x04002820L,0x00042820L,0x04042820L, + 0x00002822L,0x04002822L,0x00042822L,0x04042822L, + }}; + +int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule) + { + if (DES_check_key) + { + return DES_set_key_checked(key, schedule); + } + else + { + DES_set_key_unchecked(key, schedule); + return 0; + } + } + +/* return 0 if key parity is odd (correct), + * return -1 if key parity error, + * return -2 if illegal weak key. + */ +int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule) + { + if (!DES_check_key_parity(key)) + return(-1); + if (DES_is_weak_key(key)) + return(-2); + if (FIPS_selftest_fail) + return -3; + + DES_set_key_unchecked(key, schedule); + return 0; + } + +void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule) + { + static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; + register DES_LONG c,d,t,s,t2; + register const unsigned char *in; + register DES_LONG *k; + register int i; + +#ifdef OPENBSD_DEV_CRYPTO + memcpy(schedule->key,key,sizeof schedule->key); + schedule->session=NULL; +#endif + k = &schedule->ks->deslong[0]; + in = &(*key)[0]; + + c2l(in,c); + c2l(in,d); + + /* do PC1 in 47 simple operations :-) + * Thanks to John Fletcher (john_fletcher@lccmail.ocf.llnl.gov) + * for the inspiration. :-) */ + PERM_OP (d,c,t,4,0x0f0f0f0fL); + HPERM_OP(c,t,-2,0xcccc0000L); + HPERM_OP(d,t,-2,0xcccc0000L); + PERM_OP (d,c,t,1,0x55555555L); + PERM_OP (c,d,t,8,0x00ff00ffL); + PERM_OP (d,c,t,1,0x55555555L); + d= (((d&0x000000ffL)<<16L)| (d&0x0000ff00L) | + ((d&0x00ff0000L)>>16L)|((c&0xf0000000L)>>4L)); + c&=0x0fffffffL; + + for (i=0; i>2L)|(c<<26L)); d=((d>>2L)|(d<<26L)); } + else + { c=((c>>1L)|(c<<27L)); d=((d>>1L)|(d<<27L)); } + c&=0x0fffffffL; + d&=0x0fffffffL; + /* could be a few less shifts but I am to lazy at this + * point in time to investigate */ + s= des_skb[0][ (c )&0x3f ]| + des_skb[1][((c>> 6L)&0x03)|((c>> 7L)&0x3c)]| + des_skb[2][((c>>13L)&0x0f)|((c>>14L)&0x30)]| + des_skb[3][((c>>20L)&0x01)|((c>>21L)&0x06) | + ((c>>22L)&0x38)]; + t= des_skb[4][ (d )&0x3f ]| + des_skb[5][((d>> 7L)&0x03)|((d>> 8L)&0x3c)]| + des_skb[6][ (d>>15L)&0x3f ]| + des_skb[7][((d>>21L)&0x0f)|((d>>22L)&0x30)]; + + /* table contained 0213 4657 */ + t2=((t<<16L)|(s&0x0000ffffL))&0xffffffffL; + *(k++)=ROTATE(t2,30)&0xffffffffL; + + t2=((s>>16L)|(t&0xffff0000L)); + *(k++)=ROTATE(t2,26)&0xffffffffL; + } + } + +int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule) + { + return(DES_set_key(key,schedule)); + } +/* +#undef des_fixup_key_parity +void des_fixup_key_parity(des_cblock *key) + { + des_set_odd_parity(key); + } +*/ + +#endif /* def OPENSSL_FIPS */ diff --git a/fips/dsa/Makefile b/fips/dsa/Makefile new file mode 100644 index 0000000000..96cd964ef2 --- /dev/null +++ b/fips/dsa/Makefile @@ -0,0 +1,159 @@ +# +# SSLeay/fips/dsa/Makefile +# + +DIR= dsa +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALL_PREFIX= +OPENSSLDIR= /usr/local/ssl +INSTALLTOP=/usr/local/ssl +MAKEDEPPROG= makedepend +MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) +MAKEFILE= Makefile +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=fips_dsatest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=fips_dsa_ossl.c fips_dsa_gen.c fips_dsa_selftest.c +LIBOBJ=fips_dsa_ossl.o fips_dsa_gen.o fips_dsa_selftest.o + +SRC= $(LIBSRC) + +EXHEADER= +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd $(TOP); $(MAKE) DIRS=fips FDIRS=$(DIR) sub_all) + +all: check lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + $(RANLIB) $(LIB) || echo Never mind. + @sleep 2; touch lib + +check: + TOP=`pwd`/$(TOP) ../fips_check_sha1 fingerprint.sha1 $(SRC) $(HEADER) + +files: + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO + +links: + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/include/openssl $(EXHEADER) + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/test $(TEST) + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/apps $(APPS) + +install: +# some shells don't like empty lists +# @for i in $(EXHEADER) ; \ +# do \ +# (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ +# chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ +# done; + +tags: + ctags $(SRC) + +tests: + +top_fips_dssvs: + (cd $(TOP); $(MAKE) DIRS=fips FDIRS=$(DIR) TARGET=fips_dssvs sub_target) + +fips_dssvs: fips_dssvs.o $(TOP)/libcrypto.a + $(CC) $(CFLAGS) -o fips_dssvs fips_dssvs.o $(PEX_LIBS) $(TOP)/libcrypto.a $(EX_LIBS) + TOP=$(TOP) $(TOP)/fips/openssl_fips_fingerprint $(TOP)/libcrypto.a fips_dssvs + +Q=../testvectors/dsa/req +A=../testvectors/dsa/rsp + +fips_test: top_fips_dssvs + -rm -rf $A + mkdir $A + ./fips_dssvs pqg < $Q/PQGGen.req > $A/PQGGen.rsp + ./fips_dssvs keypair < $Q/KeyPair.req > $A/KeyPair.rsp + ./fips_dssvs siggen < $Q/SigGen.req > $A/SigGen.rsp + ./fips_dssvs sigver < $Q/SigVer.req > $A/SigVer.rsp + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(SRC) $(TEST) + +dclean: + $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff +# DO NOT DELETE THIS LINE -- make depend depends on it. + +fips_dsa_gen.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h +fips_dsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h +fips_dsa_gen.o: ../../include/openssl/bn.h ../../include/openssl/cast.h +fips_dsa_gen.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +fips_dsa_gen.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h +fips_dsa_gen.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h +fips_dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/evp.h +fips_dsa_gen.o: ../../include/openssl/fips.h ../../include/openssl/idea.h +fips_dsa_gen.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h +fips_dsa_gen.o: ../../include/openssl/md4.h ../../include/openssl/md5.h +fips_dsa_gen.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h +fips_dsa_gen.o: ../../include/openssl/objects.h +fips_dsa_gen.o: ../../include/openssl/opensslconf.h +fips_dsa_gen.o: ../../include/openssl/opensslv.h +fips_dsa_gen.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h +fips_dsa_gen.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h +fips_dsa_gen.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h +fips_dsa_gen.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h +fips_dsa_gen.o: ../../include/openssl/sha.h ../../include/openssl/stack.h +fips_dsa_gen.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h +fips_dsa_gen.o: ../../include/openssl/ui_compat.h fips_dsa_gen.c +fips_dsa_ossl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h +fips_dsa_ossl.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h +fips_dsa_ossl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h +fips_dsa_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h +fips_dsa_ossl.o: ../../include/openssl/err.h ../../include/openssl/fips.h +fips_dsa_ossl.o: ../../include/openssl/lhash.h +fips_dsa_ossl.o: ../../include/openssl/opensslconf.h +fips_dsa_ossl.o: ../../include/openssl/opensslv.h +fips_dsa_ossl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h +fips_dsa_ossl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h +fips_dsa_ossl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +fips_dsa_ossl.o: ../../include/openssl/ui.h fips_dsa_ossl.c +fips_dsa_selftest.o: ../../include/openssl/bio.h ../../include/openssl/bn.h +fips_dsa_selftest.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h +fips_dsa_selftest.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h +fips_dsa_selftest.o: ../../include/openssl/err.h ../../include/openssl/fips.h +fips_dsa_selftest.o: ../../include/openssl/lhash.h +fips_dsa_selftest.o: ../../include/openssl/opensslconf.h +fips_dsa_selftest.o: ../../include/openssl/opensslv.h +fips_dsa_selftest.o: ../../include/openssl/ossl_typ.h +fips_dsa_selftest.o: ../../include/openssl/safestack.h +fips_dsa_selftest.o: ../../include/openssl/stack.h +fips_dsa_selftest.o: ../../include/openssl/symhacks.h fips_dsa_selftest.c +fips_dsatest.o: ../../e_os.h ../../include/openssl/asn1.h +fips_dsatest.o: ../../include/openssl/bio.h ../../include/openssl/bn.h +fips_dsatest.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +fips_dsatest.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h +fips_dsatest.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h +fips_dsatest.o: ../../include/openssl/engine.h ../../include/openssl/err.h +fips_dsatest.o: ../../include/openssl/fips.h ../../include/openssl/fips_rand.h +fips_dsatest.o: ../../include/openssl/lhash.h +fips_dsatest.o: ../../include/openssl/opensslconf.h +fips_dsatest.o: ../../include/openssl/opensslv.h +fips_dsatest.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h +fips_dsatest.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h +fips_dsatest.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +fips_dsatest.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +fips_dsatest.o: fips_dsatest.c diff --git a/fips/dsa/fingerprint.sha1 b/fips/dsa/fingerprint.sha1 new file mode 100644 index 0000000000..e81fe003d7 --- /dev/null +++ b/fips/dsa/fingerprint.sha1 @@ -0,0 +1,3 @@ +HMAC-SHA1(fips_dsa_ossl.c)= 1295b5241620e1d5449aaeeb7084b181fc197003 +HMAC-SHA1(fips_dsa_gen.c)= e347a0c5b19cdcde37c73f6abcdc52c794d5dd4e +HMAC-SHA1(fips_dsa_selftest.c)= 4bfc5d3a6b977527b053f3a03d0760a822a26135 diff --git a/fips/dsa/fips_dsa_gen.c b/fips/dsa/fips_dsa_gen.c new file mode 100644 index 0000000000..9524a4e21b --- /dev/null +++ b/fips/dsa/fips_dsa_gen.c @@ -0,0 +1,373 @@ +/* crypto/dsa/dsa_gen.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#undef GENUINE_DSA + +#ifdef GENUINE_DSA +/* Parameter generation follows the original release of FIPS PUB 186, + * Appendix 2.2 (i.e. use SHA as defined in FIPS PUB 180) */ +#define HASH EVP_sha() +#else +/* Parameter generation follows the updated Appendix 2.2 for FIPS PUB 186, + * also Appendix 2.2 of FIPS PUB 186-1 (i.e. use SHA as defined in + * FIPS PUB 180-1) */ +#define HASH EVP_sha1() +#endif + +#include +#include +#include +/*#include "cryptlib.h"*/ +#include +#include +#ifndef OPENSSL_NO_SHA +#include +#endif +#ifndef OPENSSL_NO_RAND +#include +#endif +#ifndef OPENSSL_NO_SHA +#include +#include +#include + +#ifdef OPENSSL_FIPS + +static int fips_check_dsa(DSA *dsa) + { + static const unsigned char str1[]="12345678901234567890"; + unsigned char sig[256]; + unsigned int siglen; + + DSA_sign(0, str1, 20, sig, &siglen, dsa); + if(DSA_verify(0, str1, 20, sig, siglen, dsa) != 1) + { + FIPSerr(FIPS_F_FIPS_CHECK_DSA,FIPS_R_PAIRWISE_TEST_FAILED); + return 0; + } + return 1; + } + +DSA *DSA_generate_parameters(int bits, + unsigned char *seed_in, int seed_len, + int *counter_ret, unsigned long *h_ret, + void (*callback)(int, int, void *), + void *cb_arg) + { + int ok=0; + unsigned char seed[SHA_DIGEST_LENGTH]; + unsigned char md[SHA_DIGEST_LENGTH]; + unsigned char buf[SHA_DIGEST_LENGTH],buf2[SHA_DIGEST_LENGTH]; + BIGNUM *r0,*W,*X,*c,*test; + BIGNUM *g=NULL,*q=NULL,*p=NULL; + BN_MONT_CTX *mont=NULL; + int k,n=0,i,b,m=0; + int counter=0; + int r=0; + BN_CTX *ctx=NULL,*ctx2=NULL,*ctx3=NULL; + unsigned int h=2; + DSA *ret=NULL; + unsigned char *seed_out=seed_in; + + if(FIPS_selftest_fail) + { + FIPSerr(FIPS_F_DSA_GENERATE_PARAMETERS, + FIPS_R_FIPS_SELFTEST_FAILED); + goto err; + } + + if (bits < 512) bits=512; + bits=(bits+63)/64*64; + + if (seed_len < 20) + seed_in = NULL; /* seed buffer too small -- ignore */ + if (seed_len > 20) + seed_len = 20; /* App. 2.2 of FIPS PUB 186 allows larger SEED, + * but our internal buffers are restricted to 160 bits*/ + if ((seed_in != NULL) && (seed_len == 20)) + memcpy(seed,seed_in,seed_len); + + if ((ctx=BN_CTX_new()) == NULL) goto err; + if ((ctx2=BN_CTX_new()) == NULL) goto err; + if ((ctx3=BN_CTX_new()) == NULL) goto err; + if ((ret=DSA_new()) == NULL) goto err; + + if ((mont=BN_MONT_CTX_new()) == NULL) goto err; + + BN_CTX_start(ctx2); + r0 = BN_CTX_get(ctx2); + g = BN_CTX_get(ctx2); + W = BN_CTX_get(ctx2); + q = BN_CTX_get(ctx2); + X = BN_CTX_get(ctx2); + c = BN_CTX_get(ctx2); + p = BN_CTX_get(ctx2); + test = BN_CTX_get(ctx2); + + BN_lshift(test,BN_value_one(),bits-1); + + for (;;) + { + for (;;) /* find q */ + { + int seed_is_random; + + /* step 1 */ + if (callback != NULL) callback(0,m++,cb_arg); + + if (!seed_len) + { + if(RAND_pseudo_bytes(seed,SHA_DIGEST_LENGTH) < 0) + goto err; + seed_is_random = 1; + } + else + { + seed_is_random = 0; + seed_len=0; /* use random seed if 'seed_in' turns out to be bad*/ + } + memcpy(buf,seed,SHA_DIGEST_LENGTH); + memcpy(buf2,seed,SHA_DIGEST_LENGTH); + /* precompute "SEED + 1" for step 7: */ + for (i=SHA_DIGEST_LENGTH-1; i >= 0; i--) + { + buf[i]++; + if (buf[i] != 0) break; + } + + /* step 2 */ + EVP_Digest(seed,SHA_DIGEST_LENGTH,md,NULL,HASH, NULL); + EVP_Digest(buf,SHA_DIGEST_LENGTH,buf2,NULL,HASH, NULL); + for (i=0; i 0) + break; + if (r != 0) + goto err; + + /* do a callback call */ + /* step 5 */ + } + + if (callback != NULL) callback(2,0,cb_arg); + if (callback != NULL) callback(3,0,cb_arg); + + /* step 6 */ + counter=0; + /* "offset = 2" */ + + n=(bits-1)/160; + b=(bits-1)-n*160; + + for (;;) + { + if (callback != NULL && counter != 0) + callback(0,counter,cb_arg); + + /* step 7 */ + BN_zero(W); + /* now 'buf' contains "SEED + offset - 1" */ + for (k=0; k<=n; k++) + { + /* obtain "SEED + offset + k" by incrementing: */ + for (i=SHA_DIGEST_LENGTH-1; i >= 0; i--) + { + buf[i]++; + if (buf[i] != 0) break; + } + + EVP_Digest(buf,SHA_DIGEST_LENGTH,md,NULL,HASH, NULL); + + /* step 8 */ + if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,r0)) + goto err; + BN_lshift(r0,r0,160*k); + BN_add(W,W,r0); + } + + /* more of step 8 */ + BN_mask_bits(W,bits-1); + BN_copy(X,W); /* this should be ok */ + BN_add(X,X,test); /* this should be ok */ + + /* step 9 */ + BN_lshift1(r0,q); + BN_mod(c,X,r0,ctx); + BN_sub(r0,c,BN_value_one()); + BN_sub(p,X,r0); + + /* step 10 */ + if (BN_cmp(p,test) >= 0) + { + /* step 11 */ + r = BN_is_prime_fasttest(p, DSS_prime_checks, callback, ctx3, cb_arg, 1); + if (r > 0) + goto end; /* found it */ + if (r != 0) + goto err; + } + + /* step 13 */ + counter++; + /* "offset = offset + n + 1" */ + + /* step 14 */ + if (counter >= 4096) break; + } + } +end: + if (callback != NULL) callback(2,1,cb_arg); + + /* We now need to generate g */ + /* Set r0=(p-1)/q */ + BN_sub(test,p,BN_value_one()); + BN_div(r0,NULL,test,q,ctx); + + BN_set_word(test,h); + BN_MONT_CTX_set(mont,p,ctx); + + for (;;) + { + /* g=test^r0%p */ + BN_mod_exp_mont(g,test,r0,p,ctx,mont); + if (!BN_is_one(g)) break; + BN_add(test,test,BN_value_one()); + h++; + } + + if (callback != NULL) callback(3,1,cb_arg); + + ok=1; +err: + if (!ok) + { + if (ret != NULL) DSA_free(ret); + } + else + { + ret->p=BN_dup(p); + ret->q=BN_dup(q); + ret->g=BN_dup(g); + if(seed_out != NULL) memcpy(seed_out,seed,20); + if (counter_ret != NULL) *counter_ret=counter; + if (h_ret != NULL) *h_ret=h; + } + if (ctx != NULL) BN_CTX_free(ctx); + if (ctx2 != NULL) + { + BN_CTX_end(ctx2); + BN_CTX_free(ctx2); + } + if (ctx3 != NULL) BN_CTX_free(ctx3); + if (mont != NULL) BN_MONT_CTX_free(mont); + return(ok?ret:NULL); + } + +int DSA_generate_key(DSA *dsa) + { + int ok=0; + BN_CTX *ctx=NULL; + BIGNUM *pub_key=NULL,*priv_key=NULL; + + if ((ctx=BN_CTX_new()) == NULL) goto err; + + if (dsa->priv_key == NULL) + { + if ((priv_key=BN_new()) == NULL) goto err; + } + else + priv_key=dsa->priv_key; + + do + if (!BN_rand_range(priv_key,dsa->q)) goto err; + while (BN_is_zero(priv_key)); + + if (dsa->pub_key == NULL) + { + if ((pub_key=BN_new()) == NULL) goto err; + } + else + pub_key=dsa->pub_key; + + if (!BN_mod_exp(pub_key,dsa->g,priv_key,dsa->p,ctx)) goto err; + + dsa->priv_key=priv_key; + dsa->pub_key=pub_key; + + if(!fips_check_dsa(dsa)) + goto err; + + ok=1; + +err: + if ((pub_key != NULL) && (dsa->pub_key == NULL)) BN_free(pub_key); + if ((priv_key != NULL) && (dsa->priv_key == NULL)) BN_free(priv_key); + if (ctx != NULL) BN_CTX_free(ctx); + return(ok); + } +#endif + +#endif diff --git a/fips/dsa/fips_dsa_ossl.c b/fips/dsa/fips_dsa_ossl.c new file mode 100644 index 0000000000..b47e59c737 --- /dev/null +++ b/fips/dsa/fips_dsa_ossl.c @@ -0,0 +1,387 @@ +/* crypto/dsa/dsa_ossl.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* Original version from Steven Schoch */ + +#include +#include +#include +#include +#include +#ifndef OPENSSL_NO_ENGINE +#include +#endif +#include + +#ifdef OPENSSL_FIPS + +static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); +static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); +static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, + DSA *dsa); +static int dsa_init(DSA *dsa); +static int dsa_finish(DSA *dsa); +static int dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, + BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *in_mont); +static int dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *m_ctx); + +static DSA_METHOD openssl_dsa_meth = { +"OpenSSL FIPS DSA method", +dsa_do_sign, +dsa_sign_setup, +dsa_do_verify, +dsa_mod_exp, +dsa_bn_mod_exp, +dsa_init, +dsa_finish, +0, +NULL +}; + +int FIPS_dsa_check(struct dsa_st *dsa) + { + if(dsa->meth != &openssl_dsa_meth || dsa->meth->dsa_do_sign != dsa_do_sign + || dsa->meth->dsa_sign_setup != dsa_sign_setup + || dsa->meth->dsa_mod_exp != dsa_mod_exp + || dsa->meth->bn_mod_exp != dsa_bn_mod_exp + || dsa->meth->init != dsa_init + || dsa->meth->finish != dsa_finish) + { + FIPSerr(FIPS_F_FIPS_DSA_CHECK,FIPS_R_NON_FIPS_METHOD); + return 0; + } + return 1; + } + +const DSA_METHOD *DSA_OpenSSL(void) +{ + return &openssl_dsa_meth; +} + +static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) + { + BIGNUM *kinv=NULL,*r=NULL,*s=NULL; + BIGNUM m; + BIGNUM xr; + BN_CTX *ctx=NULL; + int i,reason=ERR_R_BN_LIB; + DSA_SIG *ret=NULL; + + if(FIPS_selftest_fail) + { + FIPSerr(FIPS_F_DSA_DO_SIGN,FIPS_R_FIPS_SELFTEST_FAILED); + return NULL; + } + + BN_init(&m); + BN_init(&xr); + + if (!dsa->p || !dsa->q || !dsa->g) + { + reason=DSA_R_MISSING_PARAMETERS; + goto err; + } + + s=BN_new(); + if (s == NULL) goto err; + + i=BN_num_bytes(dsa->q); /* should be 20 */ + if ((dlen > i) || (dlen > 50)) + { + reason=DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE; + goto err; + } + + ctx=BN_CTX_new(); + if (ctx == NULL) goto err; + + if ((dsa->kinv == NULL) || (dsa->r == NULL)) + { + if (!DSA_sign_setup(dsa,ctx,&kinv,&r)) goto err; + } + else + { + kinv=dsa->kinv; + dsa->kinv=NULL; + r=dsa->r; + dsa->r=NULL; + } + + if (BN_bin2bn(dgst,dlen,&m) == NULL) goto err; + + /* Compute s = inv(k) (m + xr) mod q */ + if (!BN_mod_mul(&xr,dsa->priv_key,r,dsa->q,ctx)) goto err;/* s = xr */ + if (!BN_add(s, &xr, &m)) goto err; /* s = m + xr */ + if (BN_cmp(s,dsa->q) > 0) + BN_sub(s,s,dsa->q); + if (!BN_mod_mul(s,s,kinv,dsa->q,ctx)) goto err; + + ret=DSA_SIG_new(); + if (ret == NULL) goto err; + ret->r = r; + ret->s = s; + +err: + if (!ret) + { + DSAerr(DSA_F_DSA_DO_SIGN,reason); + BN_free(r); + BN_free(s); + } + if (ctx != NULL) BN_CTX_free(ctx); + BN_clear_free(&m); + BN_clear_free(&xr); + if (kinv != NULL) /* dsa->kinv is NULL now if we used it */ + BN_clear_free(kinv); + return(ret); + } + +static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) + { + BN_CTX *ctx; + BIGNUM k,*kinv=NULL,*r=NULL; + int ret=0; + + if (!dsa->p || !dsa->q || !dsa->g) + { + DSAerr(DSA_F_DSA_SIGN_SETUP,DSA_R_MISSING_PARAMETERS); + return 0; + } + + BN_init(&k); + + if (ctx_in == NULL) + { + if ((ctx=BN_CTX_new()) == NULL) goto err; + } + else + ctx=ctx_in; + + if ((r=BN_new()) == NULL) goto err; + kinv=NULL; + + /* Get random k */ + do + if (!BN_rand_range(&k, dsa->q)) goto err; + while (BN_is_zero(&k)); + + if ((dsa->method_mont_p == NULL) && (dsa->flags & DSA_FLAG_CACHE_MONT_P)) + { + if ((dsa->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL) + if (!BN_MONT_CTX_set((BN_MONT_CTX *)dsa->method_mont_p, + dsa->p,ctx)) goto err; + } + + /* Compute r = (g^k mod p) mod q */ + if (!dsa->meth->bn_mod_exp(dsa, r,dsa->g,&k,dsa->p,ctx, + (BN_MONT_CTX *)dsa->method_mont_p)) goto err; + if (!BN_mod(r,r,dsa->q,ctx)) goto err; + + /* Compute part of 's = inv(k) (m + xr) mod q' */ + if ((kinv=BN_mod_inverse(NULL,&k,dsa->q,ctx)) == NULL) goto err; + + if (*kinvp != NULL) BN_clear_free(*kinvp); + *kinvp=kinv; + kinv=NULL; + if (*rp != NULL) BN_clear_free(*rp); + *rp=r; + ret=1; +err: + if (!ret) + { + DSAerr(DSA_F_DSA_SIGN_SETUP,ERR_R_BN_LIB); + if (kinv != NULL) BN_clear_free(kinv); + if (r != NULL) BN_clear_free(r); + } + if (ctx_in == NULL) BN_CTX_free(ctx); + if (kinv != NULL) BN_clear_free(kinv); + BN_clear_free(&k); + return(ret); + } + +static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, + DSA *dsa) + { + BN_CTX *ctx; + BIGNUM u1,u2,t1; + BN_MONT_CTX *mont=NULL; + int ret = -1; + + if (!dsa->p || !dsa->q || !dsa->g) + { + DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_MISSING_PARAMETERS); + return -1; + } + + if(FIPS_selftest_fail) + { + FIPSerr(FIPS_F_DSA_DO_VERIFY,FIPS_R_FIPS_SELFTEST_FAILED); + return -1; + } + + BN_init(&u1); + BN_init(&u2); + BN_init(&t1); + + if ((ctx=BN_CTX_new()) == NULL) goto err; + + if (BN_is_zero(sig->r) || sig->r->neg || BN_ucmp(sig->r, dsa->q) >= 0) + { + ret = 0; + goto err; + } + if (BN_is_zero(sig->s) || sig->s->neg || BN_ucmp(sig->s, dsa->q) >= 0) + { + ret = 0; + goto err; + } + + /* Calculate W = inv(S) mod Q + * save W in u2 */ + if ((BN_mod_inverse(&u2,sig->s,dsa->q,ctx)) == NULL) goto err; + + /* save M in u1 */ + if (BN_bin2bn(dgst,dgst_len,&u1) == NULL) goto err; + + /* u1 = M * w mod q */ + if (!BN_mod_mul(&u1,&u1,&u2,dsa->q,ctx)) goto err; + + /* u2 = r * w mod q */ + if (!BN_mod_mul(&u2,sig->r,&u2,dsa->q,ctx)) goto err; + + if ((dsa->method_mont_p == NULL) && (dsa->flags & DSA_FLAG_CACHE_MONT_P)) + { + if ((dsa->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL) + if (!BN_MONT_CTX_set((BN_MONT_CTX *)dsa->method_mont_p, + dsa->p,ctx)) goto err; + } + mont=(BN_MONT_CTX *)dsa->method_mont_p; + +#if 0 + { + BIGNUM t2; + + BN_init(&t2); + /* v = ( g^u1 * y^u2 mod p ) mod q */ + /* let t1 = g ^ u1 mod p */ + if (!BN_mod_exp_mont(&t1,dsa->g,&u1,dsa->p,ctx,mont)) goto err; + /* let t2 = y ^ u2 mod p */ + if (!BN_mod_exp_mont(&t2,dsa->pub_key,&u2,dsa->p,ctx,mont)) goto err; + /* let u1 = t1 * t2 mod p */ + if (!BN_mod_mul(&u1,&t1,&t2,dsa->p,ctx)) goto err_bn; + BN_free(&t2); + } + /* let u1 = u1 mod q */ + if (!BN_mod(&u1,&u1,dsa->q,ctx)) goto err; +#else + { + if (!dsa->meth->dsa_mod_exp(dsa, &t1,dsa->g,&u1,dsa->pub_key,&u2, + dsa->p,ctx,mont)) goto err; + /* BN_copy(&u1,&t1); */ + /* let u1 = u1 mod q */ + if (!BN_mod(&u1,&t1,dsa->q,ctx)) goto err; + } +#endif + /* V is now in u1. If the signature is correct, it will be + * equal to R. */ + ret=(BN_ucmp(&u1, sig->r) == 0); + + err: + if (ret != 1) DSAerr(DSA_F_DSA_DO_VERIFY,ERR_R_BN_LIB); + if (ctx != NULL) BN_CTX_free(ctx); + BN_free(&u1); + BN_free(&u2); + BN_free(&t1); + return(ret); + } + +static int dsa_init(DSA *dsa) +{ + dsa->flags|=DSA_FLAG_CACHE_MONT_P; + return(1); +} + +static int dsa_finish(DSA *dsa) +{ + if(dsa->method_mont_p) + BN_MONT_CTX_free((BN_MONT_CTX *)dsa->method_mont_p); + return(1); +} + +static int dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, + BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *in_mont) +{ + return BN_mod_exp2_mont(rr, a1, p1, a2, p2, m, ctx, in_mont); +} + +static int dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *m_ctx) +{ + return BN_mod_exp_mont(r, a, p, m, ctx, m_ctx); +} + +#else /* ndef OPENSSL_FIPS */ + +static void *dummy=&dummy; + +#endif /* ndef OPENSSL_FIPS */ diff --git a/fips/dsa/fips_dsa_selftest.c b/fips/dsa/fips_dsa_selftest.c new file mode 100644 index 0000000000..2c88f0af44 --- /dev/null +++ b/fips/dsa/fips_dsa_selftest.c @@ -0,0 +1,168 @@ +/* crypto/dsa/dsatest.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include +#include +#include +#include + +#ifdef OPENSSL_FIPS + +/* seed, out_p, out_q, out_g are taken from the updated Appendix 5 to + * FIPS PUB 186 and also appear in Appendix 5 to FIPS PIB 186-1 */ +static unsigned char seed[20]={ + 0xd5,0x01,0x4e,0x4b,0x60,0xef,0x2b,0xa8,0xb6,0x21,0x1b,0x40, + 0x62,0xba,0x32,0x24,0xe0,0x42,0x7d,0xd3, + }; + +static unsigned char out_p[]={ + 0x8d,0xf2,0xa4,0x94,0x49,0x22,0x76,0xaa, + 0x3d,0x25,0x75,0x9b,0xb0,0x68,0x69,0xcb, + 0xea,0xc0,0xd8,0x3a,0xfb,0x8d,0x0c,0xf7, + 0xcb,0xb8,0x32,0x4f,0x0d,0x78,0x82,0xe5, + 0xd0,0x76,0x2f,0xc5,0xb7,0x21,0x0e,0xaf, + 0xc2,0xe9,0xad,0xac,0x32,0xab,0x7a,0xac, + 0x49,0x69,0x3d,0xfb,0xf8,0x37,0x24,0xc2, + 0xec,0x07,0x36,0xee,0x31,0xc8,0x02,0x91, + }; + +static unsigned char out_q[]={ + 0xc7,0x73,0x21,0x8c,0x73,0x7e,0xc8,0xee, + 0x99,0x3b,0x4f,0x2d,0xed,0x30,0xf4,0x8e, + 0xda,0xce,0x91,0x5f, + }; + +static unsigned char out_g[]={ + 0x62,0x6d,0x02,0x78,0x39,0xea,0x0a,0x13, + 0x41,0x31,0x63,0xa5,0x5b,0x4c,0xb5,0x00, + 0x29,0x9d,0x55,0x22,0x95,0x6c,0xef,0xcb, + 0x3b,0xff,0x10,0xf3,0x99,0xce,0x2c,0x2e, + 0x71,0xcb,0x9d,0xe5,0xfa,0x24,0xba,0xbf, + 0x58,0xe5,0xb7,0x95,0x21,0x92,0x5c,0x9c, + 0xc4,0x2e,0x9f,0x6f,0x46,0x4b,0x08,0x8c, + 0xc5,0x72,0xaf,0x53,0xe6,0xd7,0x88,0x02, + }; + +static const unsigned char str1[]="12345678901234567890"; + +void FIPS_corrupt_dsa() + { + ++seed[0]; + } + +int FIPS_selftest_dsa() + { + DSA *dsa=NULL; + int counter,i,j; + unsigned char buf[256]; + unsigned long h; + unsigned char sig[256]; + unsigned int siglen; + + dsa=DSA_generate_parameters(512,seed,20,&counter,&h,NULL,NULL); + + if(dsa == NULL) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_DSA,FIPS_R_SELFTEST_FAILED); + return 0; + } + if (counter != 105) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_DSA,FIPS_R_SELFTEST_FAILED); + return 0; + } + if (h != 2) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_DSA,FIPS_R_SELFTEST_FAILED); + return 0; + } + i=BN_bn2bin(dsa->q,buf); + j=sizeof(out_q); + if (i != j || memcmp(buf,out_q,i) != 0) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_DSA,FIPS_R_SELFTEST_FAILED); + return 0; + } + + i=BN_bn2bin(dsa->p,buf); + j=sizeof(out_p); + if (i != j || memcmp(buf,out_p,i) != 0) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_DSA,FIPS_R_SELFTEST_FAILED); + return 0; + } + + i=BN_bn2bin(dsa->g,buf); + j=sizeof(out_g); + if (i != j || memcmp(buf,out_g,i) != 0) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_DSA,FIPS_R_SELFTEST_FAILED); + return 0; + } + DSA_generate_key(dsa); + DSA_sign(0, str1, 20, sig, &siglen, dsa); + if(DSA_verify(0, str1, 20, sig, siglen, dsa) != 1) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_DSA,FIPS_R_SELFTEST_FAILED); + return 0; + } + DSA_free(dsa); + return 1; + } +#endif diff --git a/fips/dsa/fips_dsatest.c b/fips/dsa/fips_dsatest.c new file mode 100644 index 0000000000..ffc9ccd828 --- /dev/null +++ b/fips/dsa/fips_dsatest.c @@ -0,0 +1,257 @@ +/* crypto/dsa/dsatest.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include +#include +#include +#include + +#include "e_os.h" + +#include +#include +#include +#include +#ifndef OPENSSL_NO_ENGINE +#include +#endif +#include +#include + +#if defined(OPENSSL_NO_DSA) || !defined(OPENSSL_FIPS) +int main(int argc, char *argv[]) +{ + printf("No FIPS DSA support\n"); + return(0); +} +#else +#include + +#ifdef OPENSSL_SYS_WIN16 +#define MS_CALLBACK _far _loadds +#else +#define MS_CALLBACK +#endif + +static void MS_CALLBACK dsa_cb(int p, int n, void *arg); + +/* seed, out_p, out_q, out_g are taken from the updated Appendix 5 to + * FIPS PUB 186 and also appear in Appendix 5 to FIPS PIB 186-1 */ +static unsigned char seed[20]={ + 0xd5,0x01,0x4e,0x4b,0x60,0xef,0x2b,0xa8,0xb6,0x21,0x1b,0x40, + 0x62,0xba,0x32,0x24,0xe0,0x42,0x7d,0xd3, + }; + +static unsigned char out_p[]={ + 0x8d,0xf2,0xa4,0x94,0x49,0x22,0x76,0xaa, + 0x3d,0x25,0x75,0x9b,0xb0,0x68,0x69,0xcb, + 0xea,0xc0,0xd8,0x3a,0xfb,0x8d,0x0c,0xf7, + 0xcb,0xb8,0x32,0x4f,0x0d,0x78,0x82,0xe5, + 0xd0,0x76,0x2f,0xc5,0xb7,0x21,0x0e,0xaf, + 0xc2,0xe9,0xad,0xac,0x32,0xab,0x7a,0xac, + 0x49,0x69,0x3d,0xfb,0xf8,0x37,0x24,0xc2, + 0xec,0x07,0x36,0xee,0x31,0xc8,0x02,0x91, + }; + +static unsigned char out_q[]={ + 0xc7,0x73,0x21,0x8c,0x73,0x7e,0xc8,0xee, + 0x99,0x3b,0x4f,0x2d,0xed,0x30,0xf4,0x8e, + 0xda,0xce,0x91,0x5f, + }; + +static unsigned char out_g[]={ + 0x62,0x6d,0x02,0x78,0x39,0xea,0x0a,0x13, + 0x41,0x31,0x63,0xa5,0x5b,0x4c,0xb5,0x00, + 0x29,0x9d,0x55,0x22,0x95,0x6c,0xef,0xcb, + 0x3b,0xff,0x10,0xf3,0x99,0xce,0x2c,0x2e, + 0x71,0xcb,0x9d,0xe5,0xfa,0x24,0xba,0xbf, + 0x58,0xe5,0xb7,0x95,0x21,0x92,0x5c,0x9c, + 0xc4,0x2e,0x9f,0x6f,0x46,0x4b,0x08,0x8c, + 0xc5,0x72,0xaf,0x53,0xe6,0xd7,0x88,0x02, + }; + +static const unsigned char str1[]="12345678901234567890"; + +static const char rnd_seed[] = "string to make the random number generator think it has entropy"; +static const unsigned char rnd_key1[]="12345678"; +static const unsigned char rnd_key2[]="abcdefgh"; + +static BIO *bio_err=NULL; + +int main(int argc, char **argv) + { + DSA *dsa=NULL; + int counter,ret=0,i,j; + unsigned char buf[256]; + unsigned long h; + unsigned char sig[256]; + unsigned int siglen; + + if (bio_err == NULL) + bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); + +#ifdef OPENSSL_FIPS + if(!FIPS_mode_set(1,argv[0])) + { + ERR_print_errors(bio_err); + exit(1); + } +#endif + CRYPTO_malloc_debug_init(); + CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL); + CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); + + ERR_load_crypto_strings(); + FIPS_set_prng_key(rnd_key1,rnd_key2); + RAND_seed(rnd_seed, sizeof rnd_seed); + + BIO_printf(bio_err,"test generation of DSA parameters\n"); + + dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb,bio_err); + + BIO_printf(bio_err,"seed\n"); + for (i=0; i<20; i+=4) + { + BIO_printf(bio_err,"%02X%02X%02X%02X ", + seed[i],seed[i+1],seed[i+2],seed[i+3]); + } + BIO_printf(bio_err,"\ncounter=%d h=%d\n",counter,h); + + if (dsa == NULL) goto end; + DSA_print(bio_err,dsa,0); + if (counter != 105) + { + BIO_printf(bio_err,"counter should be 105\n"); + goto end; + } + if (h != 2) + { + BIO_printf(bio_err,"h should be 2\n"); + goto end; + } + + i=BN_bn2bin(dsa->q,buf); + j=sizeof(out_q); + if ((i != j) || (memcmp(buf,out_q,i) != 0)) + { + BIO_printf(bio_err,"q value is wrong\n"); + goto end; + } + + i=BN_bn2bin(dsa->p,buf); + j=sizeof(out_p); + if ((i != j) || (memcmp(buf,out_p,i) != 0)) + { + BIO_printf(bio_err,"p value is wrong\n"); + goto end; + } + + i=BN_bn2bin(dsa->g,buf); + j=sizeof(out_g); + if ((i != j) || (memcmp(buf,out_g,i) != 0)) + { + BIO_printf(bio_err,"g value is wrong\n"); + goto end; + } + DSA_generate_key(dsa); + DSA_sign(0, str1, 20, sig, &siglen, dsa); + if (DSA_verify(0, str1, 20, sig, siglen, dsa) == 1) + ret=1; +end: + if (!ret) + ERR_print_errors(bio_err); + if (dsa != NULL) DSA_free(dsa); + CRYPTO_cleanup_all_ex_data(); + ERR_remove_state(0); + ERR_free_strings(); + CRYPTO_mem_leaks(bio_err); + if (bio_err != NULL) + { + BIO_free(bio_err); + bio_err = NULL; + } + EXIT(!ret); + return(0); + } + +static int cb_exit(int ec) + { + EXIT(ec); + return(0); /* To keep some compilers quiet */ + } + +static void MS_CALLBACK dsa_cb(int p, int n, void *arg) + { + char c='*'; + static int ok=0,num=0; + + if (p == 0) { c='.'; num++; }; + if (p == 1) c='+'; + if (p == 2) { c='*'; ok++; } + if (p == 3) c='\n'; + BIO_write(arg,&c,1); + (void)BIO_flush(arg); + + if (!ok && (p == 0) && (num > 1)) + { + BIO_printf((BIO *)arg,"error in dsatest\n"); + cb_exit(1); + } + } +#endif diff --git a/fips/dsa/fips_dssvs.c b/fips/dsa/fips_dssvs.c new file mode 100644 index 0000000000..50a4d96986 --- /dev/null +++ b/fips/dsa/fips_dssvs.c @@ -0,0 +1,306 @@ +#include +#include +#include +#include +#include +#include + +int hex2bin(const char *in, unsigned char *out) + { + int n1, n2; + unsigned char ch; + + for (n1=0,n2=0 ; in[n1] && in[n1] != '\n' ; ) + { /* first byte */ + if ((in[n1] >= '0') && (in[n1] <= '9')) + ch = in[n1++] - '0'; + else if ((in[n1] >= 'A') && (in[n1] <= 'F')) + ch = in[n1++] - 'A' + 10; + else if ((in[n1] >= 'a') && (in[n1] <= 'f')) + ch = in[n1++] - 'a' + 10; + else + return -1; + if(!in[n1]) + { + out[n2++]=ch; + break; + } + out[n2] = ch << 4; + /* second byte */ + if ((in[n1] >= '0') && (in[n1] <= '9')) + ch = in[n1++] - '0'; + else if ((in[n1] >= 'A') && (in[n1] <= 'F')) + ch = in[n1++] - 'A' + 10; + else if ((in[n1] >= 'a') && (in[n1] <= 'f')) + ch = in[n1++] - 'a' + 10; + else + return -1; + out[n2++] |= ch; + } + return n2; + } + +BIGNUM *hex2bn(const char *in) + { + BIGNUM *p=BN_new(); + + BN_hex2bn(&p,in); + + return p; + } + +int bin2hex(const unsigned char *in,int len,char *out) + { + int n1, n2; + unsigned char ch; + + for (n1=0,n2=0 ; n1 < len ; ++n1) + { + ch=in[n1] >> 4; + if (ch <= 0x09) + out[n2++]=ch+'0'; + else + out[n2++]=ch-10+'a'; + ch=in[n1] & 0x0f; + if(ch <= 0x09) + out[n2++]=ch+'0'; + else + out[n2++]=ch-10+'a'; + } + out[n2]='\0'; + return n2; + } + +void pv(const char *tag,const unsigned char *val,int len) + { + char obuf[2048]; + + bin2hex(val,len,obuf); + printf("%s = %s\n",tag,obuf); + } + +void pbn(const char *tag,const BIGNUM *val) + { + printf("%s = %s\n",tag,BN_bn2hex(val)); + } + +void primes() + { + char buf[10240]; + + while(fgets(buf,sizeof buf,stdin) != NULL) + { + fputs(buf,stdout); + if(!strncmp(buf,"Prime= ",7)) + { + BIGNUM *pp; + + pp=BN_new(); + BN_hex2bn(&pp,buf+7); + printf("result= %c\n", + BN_is_prime(pp,20,NULL,NULL,NULL) ? 'P' : 'F'); + } + } + } + +void pqg() + { + char buf[1024]; + int nmod=0; + + while(fgets(buf,sizeof buf,stdin) != NULL) + { + if(!strncmp(buf,"[mod = ",7)) + nmod=atoi(buf+7); + else if(!strncmp(buf,"N = ",4)) + { + int n=atoi(buf+4); + + printf("[mod = %d]\n\n",nmod); + + while(n--) + { + unsigned char seed[20]; + DSA *dsa; + int counter; + unsigned long h; + + dsa=DSA_generate_parameters(nmod,seed,0,&counter,&h,NULL,NULL); + printf("P = %s\n",BN_bn2hex(dsa->p)); + printf("Q = %s\n",BN_bn2hex(dsa->q)); + printf("G = %s\n",BN_bn2hex(dsa->g)); + pv("Seed",seed,20); + printf("c = %d\n",counter); + printf("H = %lx\n",h); + putc('\n',stdout); + } + } + else + fputs(buf,stdout); + } + } + +void keypair() + { + char buf[1024]; + int nmod=0; + + while(fgets(buf,sizeof buf,stdin) != NULL) + { + if(!strncmp(buf,"[mod = ",7)) + nmod=atoi(buf+7); + else if(!strncmp(buf,"N = ",4)) + { + DSA *dsa; + int n=atoi(buf+4); + + printf("[mod = %d]\n\n",nmod); + + dsa=DSA_generate_parameters(nmod,NULL,0,NULL,NULL,NULL,NULL); + pbn("P",dsa->p); + pbn("Q",dsa->q); + pbn("G",dsa->g); + putc('\n',stdout); + + while(n--) + { + DSA_generate_key(dsa); + + pbn("X",dsa->priv_key); + pbn("Y",dsa->pub_key); + putc('\n',stdout); + } + } + } + } + +void siggen() + { + char buf[1024]; + int nmod=0; + DSA *dsa=NULL; + + while(fgets(buf,sizeof buf,stdin) != NULL) + { + if(!strncmp(buf,"[mod = ",7)) + { + nmod=atoi(buf+7); + printf("[mod = %d]\n\n",nmod); + + dsa=DSA_generate_parameters(nmod,NULL,0,NULL,NULL,NULL,NULL); + pbn("P",dsa->p); + pbn("Q",dsa->q); + pbn("G",dsa->g); + putc('\n',stdout); + } + else if(!strncmp(buf,"Msg = ",6)) + { + unsigned char msg[1024]; + unsigned char hash[20]; + int n; + DSA_SIG *sig; + + n=hex2bin(buf+6,msg); + pv("Msg",msg,n); + + DSA_generate_key(dsa); + pbn("Y",dsa->pub_key); + + SHA1(msg,n,hash); + sig=DSA_do_sign(hash,sizeof hash,dsa); + pbn("R",sig->r); + pbn("S",sig->s); + putc('\n',stdout); + } + } + } + +void sigver() + { + DSA *dsa=NULL; + char buf[1024]; + int nmod=0; + unsigned char hash[20]; + DSA_SIG *sig=DSA_SIG_new(); + + while(fgets(buf,sizeof buf,stdin) != NULL) + { + if(!strncmp(buf,"[mod = ",7)) + { + nmod=atoi(buf+7); + if(dsa) + DSA_free(dsa); + dsa=DSA_new(); + } + else if(!strncmp(buf,"P = ",4)) + dsa->p=hex2bn(buf+4); + else if(!strncmp(buf,"Q = ",4)) + dsa->q=hex2bn(buf+4); + else if(!strncmp(buf,"G = ",4)) + { + dsa->g=hex2bn(buf+4); + + printf("[mod = %d]\n\n",nmod); + pbn("P",dsa->p); + pbn("Q",dsa->q); + pbn("G",dsa->g); + putc('\n',stdout); + } + else if(!strncmp(buf,"Msg = ",6)) + { + unsigned char msg[1024]; + int n; + + n=hex2bin(buf+6,msg); + pv("Msg",msg,n); + SHA1(msg,n,hash); + } + else if(!strncmp(buf,"Y = ",4)) + dsa->pub_key=hex2bn(buf+4); + else if(!strncmp(buf,"R = ",4)) + sig->r=hex2bn(buf+4); + else if(!strncmp(buf,"S = ",4)) + { + sig->s=hex2bn(buf+4); + + pbn("Y",dsa->pub_key); + pbn("R",sig->r); + pbn("S",sig->s); + printf("Result = %c\n",DSA_do_verify(hash,sizeof hash,sig,dsa) + ? 'P' : 'F'); + putc('\n',stdout); + } + } + } + +int main(int argc,char **argv) + { + if(argc != 2) + { + fprintf(stderr,"%s [prime|pqg]\n",argv[0]); + exit(1); + } + if(!FIPS_mode_set(1,argv[0])) + { + ERR_load_crypto_strings(); + ERR_print_errors(BIO_new_fp(stderr,BIO_NOCLOSE)); + exit(1); + } + if(!strcmp(argv[1],"prime")) + primes(); + else if(!strcmp(argv[1],"pqg")) + pqg(); + else if(!strcmp(argv[1],"keypair")) + keypair(); + else if(!strcmp(argv[1],"siggen")) + siggen(); + else if(!strcmp(argv[1],"sigver")) + sigver(); + else + { + fprintf(stderr,"Don't know how to %s.\n",argv[1]); + exit(1); + } + + return 0; + } diff --git a/fips/fingerprint.sha1 b/fips/fingerprint.sha1 new file mode 100644 index 0000000000..ff911c04c5 --- /dev/null +++ b/fips/fingerprint.sha1 @@ -0,0 +1,4 @@ +HMAC-SHA1(fips.c)= 5b66ece7a9df3e471f21937165887be733f251e0 +HMAC-SHA1(fips_err_wrapper.c)= d3e2be316062510312269e98f964cb87e7577898 +HMAC-SHA1(fips.h)= 4496c0e51c18d30bdc0ce440c384886870a61c40 +HMAC-SHA1(fips_err.h)= f4203a47100a815c21cf3a97092f91a595938f7c diff --git a/fips/fips.c b/fips/fips.c new file mode 100644 index 0000000000..912bb9d1f7 --- /dev/null +++ b/fips/fips.c @@ -0,0 +1,189 @@ +/* ==================================================================== + * Copyright (c) 2003 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 + * openssl-core@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. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fips_locl.h" + +#ifdef OPENSSL_FIPS + +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + +int FIPS_md5_allowed; +int FIPS_selftest_fail; + +int FIPS_selftest() + { + ERR_load_crypto_strings(); + + return FIPS_selftest_sha1() + && FIPS_selftest_aes() + && FIPS_selftest_des() + && FIPS_selftest_rsa() + && FIPS_selftest_dsa(); + } + +static int FIPS_check_exe(const char *path) + { + char buf[1024]; + char p2[PATH_MAX]; + int n; + char mdbuf[EVP_MAX_MD_SIZE]; + FILE *f; + static char key[]="etaonrishdlcupfm"; + HMAC_CTX hmac; + + f=fopen(path,"rb"); + if(!f) + { + FIPSerr(FIPS_F_FIPS_CHECK_EXE,FIPS_R_CANNOT_READ_EXE); + return 0; + } + HMAC_Init(&hmac,key,strlen(key),EVP_sha1()); + do + { + n=fread(buf,1,sizeof buf,f); + if(n < 0) + { + fclose(f); + FIPSerr(FIPS_F_FIPS_CHECK_EXE,FIPS_R_CANNOT_READ_EXE); + return 0; + } + HMAC_Update(&hmac,buf,n); + } while(n > 0); + fclose(f); + HMAC_Final(&hmac,mdbuf,&n); + BIO_snprintf(p2,sizeof p2,"%s.sha1",path); + f=fopen(p2,"rb"); + if(!f || fread(buf,1,20,f) != 20) + { + if (f) fclose(f); + FIPSerr(FIPS_F_FIPS_CHECK_EXE,FIPS_R_CANNOT_READ_EXE_DIGEST); + return 0; + } + fclose(f); + if(memcmp(buf,mdbuf,20)) + { + FIPSerr(FIPS_F_FIPS_CHECK_EXE,FIPS_R_EXE_DIGEST_DOES_NOT_MATCH); + return 0; + } + return 1; + } + +int FIPS_mode_set(int onoff,const char *path) + { + if(onoff) + { + unsigned char buf[24]; + + FIPS_selftest_fail=0; + + /* Don't go into FIPS mode twice, just so we can do automagic + seeding */ + if(FIPS_mode) + { + FIPSerr(FIPS_F_FIPS_MODE_SET,FIPS_R_FIPS_MODE_ALREADY_SET); + FIPS_selftest_fail=1; + return 0; + } + + if(!FIPS_check_exe(path)) + { + FIPS_selftest_fail=1; + return 0; + } + + /* automagically seed PRNG if not already seeded */ + if(!FIPS_rand_seeded()) + { + RAND_bytes(buf,sizeof buf); + FIPS_set_prng_key(buf,buf+8); + FIPS_rand_seed(buf+16,8); + } + + /* now switch into FIPS mode */ + FIPS_rand_check=FIPS_rand_method(); + RAND_set_rand_method(FIPS_rand_method()); + if(FIPS_selftest()) + FIPS_mode=1; + else + { + FIPS_selftest_fail=1; + return 0; + } + return 1; + } + FIPS_mode=0; + FIPS_selftest_fail=0; + return 1; + } + +void FIPS_allow_md5(int onoff) + { + FIPS_md5_allowed=onoff; + } + +#if 0 +/* here just to cause error codes to exist */ +static void dummy() + { + FIPSerr(FIPS_F_HASH_FINAL,FIPS_F_NON_FIPS_METHOD); + FIPSerr(FIPS_F_HASH_FINAL,FIPS_R_FIPS_SELFTEST_FAILED); + } +#endif + +#endif diff --git a/fips/fips.h b/fips/fips.h new file mode 100644 index 0000000000..e169ebf43e --- /dev/null +++ b/fips/fips.h @@ -0,0 +1,125 @@ +/* ==================================================================== + * Copyright (c) 2003 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 + * openssl-core@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. + * + */ + +#include + +#ifdef OPENSSL_FIPS + +#ifdef __cplusplus +extern "C" { +#endif + +/* Note that these are defined in crypto/cryptlib.c so they're + * available even without -lfips. + */ +extern int FIPS_mode; +extern int FIPS_selftest_fail; +extern void *FIPS_rand_check; +struct dsa_st; + +int FIPS_mode_set(int onoff,const char *path); +void FIPS_allow_md5(int onoff); +int FIPS_dsa_check(struct dsa_st *dsa); +void FIPS_corrupt_sha1(void); +int FIPS_selftest_sha1(void); +void FIPS_corrupt_aes(void); +int FIPS_selftest_aes(void); +void FIPS_corrupt_des(void); +int FIPS_selftest_des(void); +void FIPS_corrupt_rsa(void); +int FIPS_selftest_rsa(void); +void FIPS_corrupt_dsa(void); +int FIPS_selftest_dsa(void); + +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_FIPS_strings(void); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_FIPS_strings(void); + +/* Error codes for the FIPS functions. */ + +/* Function codes. */ +#define FIPS_F_DSA_DO_SIGN 111 +#define FIPS_F_DSA_DO_VERIFY 112 +#define FIPS_F_DSA_GENERATE_PARAMETERS 110 +#define FIPS_F_FIPS_CHECK_DSA 116 +#define FIPS_F_FIPS_CHECK_EXE 106 +#define FIPS_F_FIPS_CHECK_RSA 115 +#define FIPS_F_FIPS_DSA_CHECK 102 +#define FIPS_F_FIPS_MODE_SET 105 +#define FIPS_F_FIPS_SELFTEST_AES 104 +#define FIPS_F_FIPS_SELFTEST_DES 107 +#define FIPS_F_FIPS_SELFTEST_DSA 109 +#define FIPS_F_FIPS_SELFTEST_RSA 108 +#define FIPS_F_FIPS_SELFTEST_SHA1 103 +#define FIPS_F_HASH_FINAL 100 +#define FIPS_F_RSA_EAY_PUBLIC_ENCRYPT 114 +#define FIPS_F_RSA_GENERATE_KEY 113 +#define FIPS_F_SSLEAY_RAND_BYTES 101 + +/* Reason codes. */ +#define FIPS_R_CANNOT_READ_EXE 103 +#define FIPS_R_CANNOT_READ_EXE_DIGEST 104 +#define FIPS_R_EXE_DIGEST_DOES_NOT_MATCH 105 +#define FIPS_R_FIPS_MODE_ALREADY_SET 102 +#define FIPS_R_FIPS_SELFTEST_FAILED 106 +#define FIPS_R_NON_FIPS_METHOD 100 +#define FIPS_R_PAIRWISE_TEST_FAILED 107 +#define FIPS_R_SELFTEST_FAILED 101 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/fips/fips_check_sha1 b/fips/fips_check_sha1 new file mode 100755 index 0000000000..51b40ec6d8 --- /dev/null +++ b/fips/fips_check_sha1 @@ -0,0 +1,8 @@ +#!/bin/sh + +FP=$1 +shift + +egrep 'define OPENSSL_FIPS' $TOP/include/openssl/opensslconf.h > /dev/null || exit 0 + +$TOP/fips/sha1/fips_standalone_sha1 $@ | diff $FP - || { echo; echo "*** Your source code does not match the FIPS certified source ***"; echo; exit 1; } diff --git a/fips/fips_err.h b/fips/fips_err.h new file mode 100644 index 0000000000..e8dafa4900 --- /dev/null +++ b/fips/fips_err.h @@ -0,0 +1,117 @@ +/* fips/fips_err.h */ +/* ==================================================================== + * Copyright (c) 1999-2003 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 + * openssl-core@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. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* NOTE: this file was auto generated by the mkerr.pl script: any changes + * made to it will be overwritten when the script next updates this file, + * only reason strings will be preserved. + */ + +#include +#include +#include + +/* BEGIN ERROR CODES */ +#ifndef OPENSSL_NO_ERR +static ERR_STRING_DATA FIPS_str_functs[]= + { +{ERR_PACK(0,FIPS_F_DSA_DO_SIGN,0), "DSA_do_sign"}, +{ERR_PACK(0,FIPS_F_DSA_DO_VERIFY,0), "DSA_do_verify"}, +{ERR_PACK(0,FIPS_F_DSA_GENERATE_PARAMETERS,0), "DSA_generate_parameters"}, +{ERR_PACK(0,FIPS_F_FIPS_CHECK_DSA,0), "FIPS_CHECK_DSA"}, +{ERR_PACK(0,FIPS_F_FIPS_CHECK_EXE,0), "FIPS_CHECK_EXE"}, +{ERR_PACK(0,FIPS_F_FIPS_CHECK_RSA,0), "FIPS_CHECK_RSA"}, +{ERR_PACK(0,FIPS_F_FIPS_DSA_CHECK,0), "FIPS_dsa_check"}, +{ERR_PACK(0,FIPS_F_FIPS_MODE_SET,0), "FIPS_mode_set"}, +{ERR_PACK(0,FIPS_F_FIPS_SELFTEST_AES,0), "FIPS_selftest_aes"}, +{ERR_PACK(0,FIPS_F_FIPS_SELFTEST_DES,0), "FIPS_selftest_des"}, +{ERR_PACK(0,FIPS_F_FIPS_SELFTEST_DSA,0), "FIPS_selftest_dsa"}, +{ERR_PACK(0,FIPS_F_FIPS_SELFTEST_RSA,0), "FIPS_selftest_rsa"}, +{ERR_PACK(0,FIPS_F_FIPS_SELFTEST_SHA1,0), "FIPS_selftest_sha1"}, +{ERR_PACK(0,FIPS_F_HASH_FINAL,0), "HASH_FINAL"}, +{ERR_PACK(0,FIPS_F_RSA_EAY_PUBLIC_ENCRYPT,0), "RSA_EAY_PUBLIC_ENCRYPT"}, +{ERR_PACK(0,FIPS_F_RSA_GENERATE_KEY,0), "RSA_generate_key"}, +{ERR_PACK(0,FIPS_F_SSLEAY_RAND_BYTES,0), "SSLEAY_RAND_BYTES"}, +{0,NULL} + }; + +static ERR_STRING_DATA FIPS_str_reasons[]= + { +{FIPS_R_CANNOT_READ_EXE ,"cannot read exe"}, +{FIPS_R_CANNOT_READ_EXE_DIGEST ,"cannot read exe digest"}, +{FIPS_R_EXE_DIGEST_DOES_NOT_MATCH ,"exe digest does not match"}, +{FIPS_R_FIPS_MODE_ALREADY_SET ,"fips mode already set"}, +{FIPS_R_FIPS_SELFTEST_FAILED ,"fips selftest failed"}, +{FIPS_R_NON_FIPS_METHOD ,"non fips method"}, +{FIPS_R_PAIRWISE_TEST_FAILED ,"pairwise test failed"}, +{FIPS_R_SELFTEST_FAILED ,"selftest failed"}, +{0,NULL} + }; + +#endif + +void ERR_load_FIPS_strings(void) + { + static int init=1; + + if (init) + { + init=0; +#ifndef OPENSSL_NO_ERR + ERR_load_strings(ERR_LIB_FIPS,FIPS_str_functs); + ERR_load_strings(ERR_LIB_FIPS,FIPS_str_reasons); +#endif + + } + } diff --git a/fips/fips_err_wrapper.c b/fips/fips_err_wrapper.c new file mode 100644 index 0000000000..09f11748f6 --- /dev/null +++ b/fips/fips_err_wrapper.c @@ -0,0 +1,7 @@ +#include + +#ifdef OPENSSL_FIPS +# include "fips_err.h" +#else +static void *dummy=&dummy; +#endif diff --git a/fips/fips_locl.h b/fips/fips_locl.h new file mode 100644 index 0000000000..501fc756f3 --- /dev/null +++ b/fips/fips_locl.h @@ -0,0 +1,62 @@ +/* ==================================================================== + * Copyright (c) 2003 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 + * openssl-core@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. + * + */ + +#ifdef OPENSSL_FIPS + +#ifdef __cplusplus +extern "C" { +#endif + +/* FIPS 140 allows MD5 to be used during certain parts of TLS */ +extern int FIPS_md5_allowed; + +#ifdef __cplusplus +} +#endif +#endif diff --git a/fips/fips_make_sha1 b/fips/fips_make_sha1 new file mode 100755 index 0000000000..3139d9f528 --- /dev/null +++ b/fips/fips_make_sha1 @@ -0,0 +1,27 @@ +#!/bin/sh + +S=`pwd`/fips/sha1/fips_standalone_sha1 + +cd fips/sha1 +$S fips_sha1dgst.c fips_sha1_selftest.c asm/sx86-elf.s fips_standalone_sha1.c fips_sha_locl.h fips_md32_common.h > standalone.sha1 + +cd .. +$S fips.c fips_err_wrapper.c fips.h fips_err.h > fingerprint.sha1 + +cd rand +$S fips_rand.c fips_rand.h > fingerprint.sha1 + +cd ../sha1 +$S fips_sha1dgst.c fips_sha1_selftest.c asm/sx86-elf.s fips_sha_locl.h fips_md32_common.h > fingerprint.sha1 + +cd ../aes +$S fips_aes_core.c fips_aes_selftest.c fips_aes_locl.h > fingerprint.sha1 + +cd ../dsa +$S fips_dsa_ossl.c fips_dsa_gen.c fips_dsa_selftest.c > fingerprint.sha1 + +cd ../des +$S fips_des_enc.c asm/fips-dx86-elf.s fips_des_selftest.c fips_set_key.c fips_des_locl.h > fingerprint.sha1 + +cd ../rsa +$S fips_rsa_eay.c fips_rsa_gen.c fips_rsa_selftest.c > fingerprint.sha1 diff --git a/fips/fips_test_suite.c b/fips/fips_test_suite.c new file mode 100644 index 0000000000..a2f3f13163 --- /dev/null +++ b/fips/fips_test_suite.c @@ -0,0 +1,302 @@ +/* ==================================================================== + * Copyright (c) 2003 The OpenSSL Project. All rights reserved. + * + * + * This command is intended as a test driver for the FIPS-140 testing + * lab performing FIPS-140 validation. It demonstrates the use of the + * OpenSSL library ito perform a variety of common cryptographic + * functions. A power-up self test is demonstrated by deliberately + * pointing to an invalid executable hash + * + * Contributed by Steve Marquess. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef OPENSSL_FIPS +int main(int argc, char *argv[]) + { + printf("No FIPS support\n"); + return(0); + } +#else + +/* AES: encrypt and decrypt known plaintext, verify result matches original plaintext +*/ +static int FIPS_aes_test() + { + unsigned char userkey[16] = { 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed, 0xf0, 0x0d }; + unsigned char plaintext[16] = "etaonrishdlcu"; + unsigned char ciphertext[16]; + unsigned char buf[16]; + AES_KEY key; + AES_KEY dkey; + + ERR_clear_error(); + if (AES_set_encrypt_key( userkey, 128, &key )) + return 0; + AES_encrypt( plaintext, ciphertext, &key); + if (AES_set_decrypt_key( userkey, 128, &dkey )) + return 0; + AES_decrypt( ciphertext, buf, &dkey); + if (memcmp(buf, plaintext, sizeof(buf))) + return 0; + return 1; + } + +/* DES: encrypt and decrypt known plaintext, verify result matches original plaintext +*/ +static int FIPS_des_test() + { + DES_cblock userkey = { 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed, 0xf0, 0x0d }; + DES_cblock plaintext = { 'e', 't', 'a', 'o', 'n', 'r', 'i', 's' }; + + DES_key_schedule key; + DES_cblock ciphertext; + DES_cblock buf; + + ERR_clear_error(); + if (DES_set_key(&userkey, &key)) + return 0; + DES_ecb_encrypt( &plaintext, &ciphertext, &key, 1); + DES_ecb_encrypt( &ciphertext, &buf, &key, 0); + if (memcmp(buf, plaintext, sizeof(buf))) + return 0; + return 1; + } + +/* DSA: generate key and sign a known digest, then verify the signature + * against the digest +*/ +static int FIPS_dsa_test() + { + DSA *dsa = NULL; + unsigned char dgst[] = "etaonrishdlc"; + unsigned char sig[256]; + unsigned int siglen; + + ERR_clear_error(); + dsa = DSA_generate_parameters(512,NULL,0,NULL,NULL,NULL,NULL); + if (!dsa) + return 0; + if (!DSA_generate_key(dsa)) + return 0; + if ( DSA_sign(0,dgst,strlen(dgst),sig,&siglen,dsa) != 1 ) + return 0; + if ( DSA_verify(0,dgst,strlen(dgst),sig,siglen,dsa) != 1 ) + return 0; + DSA_free(dsa); + return 1; + } + +/* RSA: generate keys and encrypt and decrypt known plaintext, verify result + * matches the original plaintext +*/ +static int FIPS_rsa_test() + { + RSA *key; + unsigned char input_ptext[] = "etaonrishdlc"; + unsigned char ctext[256]; + unsigned char ptext[256]; + int n; + + ERR_clear_error(); + key = RSA_generate_key(1024,65537,NULL,NULL); + if (!key) + return 0; + n = RSA_size(key); + n = RSA_public_encrypt(strlen(input_ptext),input_ptext,ctext,key,RSA_PKCS1_PADDING); + if (n < 0) + return 0; + n = RSA_private_decrypt(n,ctext,ptext,key,RSA_PKCS1_PADDING); + if (n < 0) + return 0; + RSA_free(key); + if (memcmp(input_ptext,ptext,strlen(input_ptext))) + return 0; + return 1; + } + +/* SHA1: generate hash of known digest value and compare to known + precomputed correct hash +*/ +static int FIPS_sha1_test() + { + unsigned char digest[SHA_DIGEST_LENGTH] = + { 0x11, 0xf1, 0x9a, 0x3a, 0xec, 0x1a, 0x1e, 0x8e, 0x65, 0xd4, 0x9a, 0x38, 0x0c, 0x8b, 0x1e, 0x2c, 0xe8, 0xb3, 0xc5, 0x18 }; + char str[] = "etaonrishd"; + + unsigned char md[SHA_DIGEST_LENGTH]; + + ERR_clear_error(); + if (!SHA1(str,strlen(str),md)) return 0; + if (memcmp(md,digest,sizeof(md))) + return 0; + return 1; + } + +/* MD5: generate hash of known digest value and compare to known + precomputed correct hash +*/ +static int md5_test() + { + unsigned char digest[MD5_DIGEST_LENGTH] = + { 0x48, 0x50, 0xf0, 0xa3, 0x3a, 0xed, 0xd3, 0xaf, 0x6e, 0x47, 0x7f, 0x83, 0x02, 0xb1, 0x09, 0x68 }; + char str[] = "etaonrishd"; + + unsigned char md[MD5_DIGEST_LENGTH]; + + ERR_clear_error(); + if (!MD5(str,strlen(str),md)) + return 0; + if (memcmp(md,digest,sizeof(md))) + return 0; + return 1; + } + +/* DH: generate shared parameters +*/ +static int dh_test() + { + DH *dh; + + dh = DH_generate_parameters(256, 2, NULL, NULL); + if (dh) + return 0; + return 1; + } + +static int Error; +const char * Fail(const char *msg) + { + Error++; + return msg; + } + +int main(int argc,char **argv) + { + + printf("\tFIPS-mode test application\n\n"); + + if (argv[1]) { + /* Corrupted KAT tests */ + if (!strcmp(argv[1], "aes")) { + FIPS_corrupt_aes(); + printf("3. AES encryption/decryption with corrupted KAT...\n"); + } else if (!strcmp(argv[1], "des")) { + FIPS_corrupt_des(); + printf("5. DES-ECB encryption/decryption with corrupted KAT...\n"); + } else if (!strcmp(argv[1], "dsa")) { + FIPS_corrupt_dsa(); + printf("6. DSA key generation and signature validation with corrupted KAT...\n"); + } else if (!strcmp(argv[1], "rsa")) { + FIPS_corrupt_rsa(); + printf("4. RSA key generation and encryption/decryption with corrupted KAT...\n"); + } else if (!strcmp(argv[1], "sha1")) { + FIPS_corrupt_sha1(); + printf("7. SHA-1 hash with corrupted KAT...\n"); + } else { + printf("Bad argument \"%s\"\n", argv[1]); + exit(1); + } + if (!FIPS_mode_set(1,argv[0])) + { + ERR_load_crypto_strings(); + ERR_print_errors(BIO_new_fp(stderr,BIO_NOCLOSE)); + printf("Power-up self test failed\n"); + exit(1); + } + printf("Power-up self test successful\n"); + exit(0); + } + + /* Non-Approved cryptographic operation + */ + printf("0. Non-Approved cryptographic operation test...\n"); + printf("\ta. MD5..."); + printf( md5_test() ? "successful\n" : Fail("FAILED!\n") ); + printf("\tb. D-H..."); + printf( dh_test() ? "successful\n" : Fail("FAILED!\n") ); + + /* Power-up self test failure + */ + printf("1. Automatic power-up self test..."); + printf( FIPS_mode_set(1,"/dev/null") ? Fail("passed INCORRECTLY!\n") : "failed as expected\n" ); + + /* Algorithm call when uninitialized failure + */ + printf("\ta. AES API failure on failed power-up self test..."); + printf( FIPS_aes_test() ? Fail("passed INCORRECTLY!\n") :"failed as expected\n" ); + printf("\tb. RSA API failure on failed power-up self test..."); + printf( FIPS_rsa_test() ? Fail("passed INCORRECTLY!\n") : "failed as expected\n" ); + printf("\tc. DES API failure on failed power-up self test..."); + printf( FIPS_des_test() ? Fail("passed INCORRECTLY!\n") : "failed as expected\n" ); + printf("\td. DSA API failure on failed power-up self test..."); + printf( FIPS_dsa_test() ? Fail("passed INCORRECTLY!\n") : "failed as expected\n" ); + printf("\te. SHA1 API failure on failed power-up self test..."); + printf( FIPS_sha1_test() ? Fail("passed INCORRECTLY!\n") : "failed as expected\n" ); + + /* Power-up self test retry + */ + ERR_clear_error(); + printf("2. Automatic power-up self test retry..."); + if (!FIPS_mode_set(1,argv[0])) + { + ERR_load_crypto_strings(); + ERR_print_errors(BIO_new_fp(stderr,BIO_NOCLOSE)); + printf(Fail("FAILED!\n")); + exit(1); + } + printf("successful\n"); + + /* AES encryption/decryption + */ + printf("3. AES encryption/decryption..."); + printf( FIPS_aes_test() ? "successful\n" : Fail("FAILED!\n") ); + + /* RSA key generation and encryption/decryption + */ + printf("4. RSA key generation and encryption/decryption..."); + printf( FIPS_rsa_test() ? "successful\n" : Fail("FAILED!\n") ); + + /* DES-CBC encryption/decryption + */ + printf("5. DES-ECB encryption/decryption..."); + printf( FIPS_des_test() ? "successful\n" : Fail("FAILED!\n") ); + + /* DSA key generation and signature validation + */ + printf("6. DSA key generation and signature validation..."); + printf( FIPS_dsa_test() ? "successful\n" : Fail("FAILED!\n") ); + + /* SHA-1 hash + */ + printf("7. SHA-1 hash..."); + printf( FIPS_sha1_test() ? "successful\n" : Fail("FAILED!\n") ); + + /* Non-Approved cryptographic operation + */ + printf("8. Non-Approved cryptographic operation test...\n"); + printf("\ta. MD5..."); + printf( md5_test() ? Fail("passed INCORRECTLY!\n") + : "failed as expected\n" ); + printf("\tb. D-H..."); + printf( dh_test() ? Fail("passed INCORRECTLY!\n") + : "failed as expected\n" ); + + printf("\nAll tests completed with %d errors\n", Error); + return 0; + } +#endif diff --git a/fips/openssl_fips_fingerprint b/fips/openssl_fips_fingerprint new file mode 100755 index 0000000000..e20b38d43c --- /dev/null +++ b/fips/openssl_fips_fingerprint @@ -0,0 +1,25 @@ +#!/bin/sh +# +# Check the library fingerprint and generate an executable fingerprint, or +# return an error + +lib=$1 +exe=$2 + +# deal with the case where we're run from within the build and OpenSSL is +# not yet installed. Also, make sure LD_LIBRARY_PATH is properly set in +# case shared libraries are built. +if [ "X$TOP" != "X" ] +then + PATH=$TOP/apps:$PATH + LD_LIBRARY_PATH=$TOP; export LD_LIBRARY_PATH +else + LD_LIBRARY_PATH=.; export LD_LIBRARY_PATH +fi + +elib=`echo $lib| sed 's/\//\\\\\//g'` +echo "Checking library fingerprint for $lib" +openssl sha1 -hmac etaonrishdlcupfm $lib | sed "s/$elib/libcrypto.a/" | diff ${lib%.a}.sha1 - || { echo "$libs fingerprint mismatch"; exit 1; } + +echo "Making fingerprint for $exe" +openssl sha1 -hmac etaonrishdlcupfm -binary $exe > $exe.sha1 diff --git a/fips/rand/Makefile b/fips/rand/Makefile new file mode 100644 index 0000000000..af359788b6 --- /dev/null +++ b/fips/rand/Makefile @@ -0,0 +1,104 @@ +# +# SSLeay/fips/rand/Makefile +# + +DIR= rand +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALL_PREFIX= +OPENSSLDIR= /usr/local/ssl +INSTALLTOP=/usr/local/ssl +MAKEDEPPROG= makedepend +MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) +MAKEFILE= Makefile +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST= fips_randtest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=fips_rand.c +LIBOBJ=fips_rand.o + +SRC= $(LIBSRC) + +EXHEADER= fips_rand.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd $(TOP); $(MAKE) DIRS=fips SDIRS=$(DIR) sub_all) + +all: check lib + +check: + TOP=`pwd`/$(TOP) ../fips_check_sha1 fingerprint.sha1 $(SRC) $(HEADER) + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + $(RANLIB) $(LIB) || echo Never mind. + @sleep 2; touch lib + +files: + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO + +links: + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/include/openssl $(EXHEADER) + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/test $(TEST) + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ + chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(SRC) $(TEST) + +dclean: + $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +fips_rand.o: ../../e_os.h ../../include/openssl/bio.h +fips_rand.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +fips_rand.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +fips_rand.o: ../../include/openssl/err.h ../../include/openssl/fips_rand.h +fips_rand.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h +fips_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h +fips_rand.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h +fips_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +fips_rand.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +fips_rand.o: fips_rand.c +fips_randtest.o: ../../e_os.h ../../include/openssl/bio.h +fips_randtest.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +fips_randtest.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +fips_randtest.o: ../../include/openssl/err.h ../../include/openssl/fips_rand.h +fips_randtest.o: ../../include/openssl/lhash.h +fips_randtest.o: ../../include/openssl/opensslconf.h +fips_randtest.o: ../../include/openssl/opensslv.h +fips_randtest.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h +fips_randtest.o: ../../include/openssl/safestack.h +fips_randtest.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +fips_randtest.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +fips_randtest.o: fips_randtest.c diff --git a/fips/rand/fingerprint.sha1 b/fips/rand/fingerprint.sha1 new file mode 100644 index 0000000000..f87df9f65e --- /dev/null +++ b/fips/rand/fingerprint.sha1 @@ -0,0 +1,2 @@ +HMAC-SHA1(fips_rand.c)= ab4f589420935782c6bffc4499959ac532c02682 +HMAC-SHA1(fips_rand.h)= 889afc9a526fe59138326134950b733627a7e9cf diff --git a/fips/rand/fips_rand.c b/fips/rand/fips_rand.c new file mode 100644 index 0000000000..6348c95e53 --- /dev/null +++ b/fips/rand/fips_rand.c @@ -0,0 +1,286 @@ +/* ==================================================================== + * Copyright (c) 2003 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 + * openssl-core@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. + * + */ + +/* + * This is a FIPS approved PRNG, ANSI X9.17, as specified in HAC, + * Menezes et al., p.173 + */ + +#include +#include +#include +#include +#include "e_os.h" +#ifndef OPENSSL_SYS_WIN32 +#include +#endif +#include +#ifndef OPENSSL_SYS_WIN32 +# ifdef OPENSSL_UNISTD +# include OPENSSL_UNISTD +# else +# include +# endif +#endif +#include + +#define SEED_SIZE 8 + +static unsigned char seed[SEED_SIZE]; +static int n_seed; +static int o_seed; +static DES_cblock key1; +static DES_cblock key2; +static DES_key_schedule ks1,ks2; +static int key_set; +static int test_mode; +static unsigned char test_faketime[8]; + +static void fips_rand_cleanup(void); +static void fips_rand_add(const void *buf, int num, double add_entropy); +static int fips_rand_bytes(unsigned char *buf, int num); +static int fips_rand_status(void); + +RAND_METHOD rand_fips_meth= + { + FIPS_rand_seed, + fips_rand_bytes, + fips_rand_cleanup, + fips_rand_add, + fips_rand_bytes, + fips_rand_status + }; + +static int second; + +RAND_METHOD *FIPS_rand_method(void) +{ + return &rand_fips_meth; +} + +void FIPS_set_prng_key(const unsigned char k1[8],const unsigned char k2[8]) + { + memcpy(&key1,k1,sizeof key1); + memcpy(&key2,k2,sizeof key2); + key_set=1; + second=0; + } + +void FIPS_test_mode(int test,const unsigned char faketime[8]) + { + test_mode=test; + if(!test_mode) + return; + memcpy(test_faketime,faketime,sizeof test_faketime); + } + +/* NB: this returns true if _partially_ seeded */ +int FIPS_rand_seeded() + { return key_set || n_seed; } + +static void fips_gettime(unsigned char buf[8]) + { +#ifdef OPENSSL_SYS_WIN32 + FILETIME ft; +#else + struct timeval tv; +#endif + + if(test_mode) + { + fprintf(stderr,"WARNING!!! PRNG IN TEST MODE!!!\n"); + memcpy(buf,test_faketime,sizeof test_faketime); + return; + } +#ifdef OPENSSL_SYS_WIN32 + GetSystemTimeAsFileTime(&ft); + buf[0] = (unsigned char) (ft.dwHighDateTime & 0xff); + buf[1] = (unsigned char) ((ft.dwHighDateTime >> 8) & 0xff); + buf[2] = (unsigned char) ((ft.dwHighDateTime >> 16) & 0xff); + buf[3] = (unsigned char) ((ft.dwHighDateTime >> 24) & 0xff); + buf[4] = (unsigned char) (ft.dwLowDateTime & 0xff); + buf[5] = (unsigned char) ((ft.dwLowDateTime >> 8) & 0xff); + buf[6] = (unsigned char) ((ft.dwLowDateTime >> 16) & 0xff); + buf[7] = (unsigned char) ((ft.dwLowDateTime >> 24) & 0xff); +#else + gettimeofday(&tv,NULL); + buf[0] = (unsigned char) (tv.tv_sec & 0xff); + buf[1] = (unsigned char) ((tv.tv_sec >> 8) & 0xff); + buf[2] = (unsigned char) ((tv.tv_sec >> 16) & 0xff); + buf[3] = (unsigned char) ((tv.tv_sec >> 24) & 0xff); + buf[4] = (unsigned char) (tv.tv_usec & 0xff); + buf[5] = (unsigned char) ((tv.tv_usec >> 8) & 0xff); + buf[6] = (unsigned char) ((tv.tv_usec >> 16) & 0xff); + buf[7] = (unsigned char) ((tv.tv_usec >> 24) & 0xff); +#endif + +#if 0 /* This eminently sensible strategy is not acceptable to NIST. Sigh. */ +#ifndef GETPID_IS_MEANINGLESS + /* we mix in the PID to ensure that after a fork the children don't give + * the same results as each other + */ + pid=getpid(); + /* make sure we shift the pid to the MSB */ + if((pid&0xffff0000) == 0) + pid<<=16; + *(long *)&buf[0]^=pid; +#endif +#endif + } + +static void fips_rand_encrypt(unsigned char *out,const unsigned char *in) + { + DES_ecb2_encrypt(in,out,&ks1,&ks2,1); + } + +static void fips_rand_cleanup(void) + { + OPENSSL_cleanse(seed,sizeof seed); + n_seed=0; + } + +void FIPS_rand_seed(const void *buf_, int num) + { + const char *buf=buf_; + int n; + static int init; + + /* If the key hasn't been set, we can't seed! */ + if(!key_set) + return; + + CRYPTO_w_lock(CRYPTO_LOCK_RAND); + if(!init) + { + init=1; + DES_set_key(&key1,&ks1); + DES_set_key(&key2,&ks2); + } + + /* + * This algorithm only uses 64 bits of seed, so ensure that we use + * the most recent 64 bits. + */ + for(n=0 ; n < num ; ) + { + int t=num-n; + + if(o_seed+t > sizeof seed) + t=sizeof seed-o_seed; + memcpy(seed+o_seed,buf+n,t); + n+=t; + o_seed+=t; + if(o_seed == sizeof seed) + o_seed=0; + if(n_seed < sizeof seed) + n_seed+=t; + } + + CRYPTO_w_unlock(CRYPTO_LOCK_RAND); + } + +static void fips_rand_add(const void *buf, int num, double add_entropy) + { + FIPS_rand_seed(buf,num); + } + +static int fips_rand_bytes(unsigned char *buf,int num) + { + int n; + unsigned char timeseed[8]; + unsigned char intermediate[SEED_SIZE]; + unsigned char output[SEED_SIZE]; + static unsigned char previous[SEED_SIZE]; + + if(n_seed < sizeof seed) + { + RANDerr(RAND_F_FIPS_RAND_BYTES,RAND_R_PRNG_NOT_SEEDED); + return 0; + } + + fips_gettime(timeseed); + fips_rand_encrypt(intermediate,timeseed); + + CRYPTO_w_lock(CRYPTO_LOCK_RAND); + + for(n=0 ; n < num ; ) + { + unsigned char t[SEED_SIZE]; + int l; + + /* now generate a full 64 bits of "randomness" */ + for(l=0 ; l < sizeof t ; ++l) + t[l]=intermediate[l]^seed[l]; + fips_rand_encrypt(output,t); + for(l=0 ; l < sizeof t ; ++l) + t[l]=output[l]^seed[l]; + fips_rand_encrypt(seed,t); + + if(second && !memcmp(output,previous,sizeof previous)) + { + RANDerr(RAND_F_FIPS_RAND_BYTES,RAND_R_PRNG_STUCK); + return 0; + } + memcpy(previous,output,sizeof previous); + second=1; + + l=SEED_SIZE < num-n ? SEED_SIZE : num-n; + memcpy(buf+n,output,l); + n+=l; + } + + CRYPTO_w_unlock(CRYPTO_LOCK_RAND); + + return num; + } + +static int fips_rand_status(void) + { + return n_seed == sizeof seed; + } diff --git a/fips/rand/fips_rand.h b/fips/rand/fips_rand.h new file mode 100644 index 0000000000..d50eaa8a50 --- /dev/null +++ b/fips/rand/fips_rand.h @@ -0,0 +1,73 @@ +/* ==================================================================== + * Copyright (c) 2003 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 + * openssl-core@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. + * + */ + +#ifndef HEADER_FIPS_RAND_H +#define HEADER_FIPS_RAND_H + +#include "des.h" + +#ifdef OPENSSL_FIPS + +#ifdef __cplusplus +extern "C" { +#endif + +void FIPS_set_prng_key(const unsigned char k1[8],const unsigned char k2[8]); +void FIPS_test_mode(int test,const unsigned char faketime[8]); +void FIPS_rand_seed(const void *buf, int num); +/* NB: this returns true if _partially_ seeded */ +int FIPS_rand_seeded(void); + +RAND_METHOD *FIPS_rand_method(void); + +#ifdef __cplusplus +} +#endif +#endif +#endif diff --git a/fips/rand/fips_randtest.c b/fips/rand/fips_randtest.c new file mode 100644 index 0000000000..ff9c91cd36 --- /dev/null +++ b/fips/rand/fips_randtest.c @@ -0,0 +1,369 @@ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright (c) 2003 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 + * openssl-core@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. + * + */ + +#include +#include +#include +#include +#include + +#include "e_os.h" + +#ifndef OPENSSL_FIPS +int main(int argc, char *argv[]) +{ + printf("No FIPS RAND support\n"); + return(0); +} + +#else + +/* some FIPS 140-1 random number test */ +/* some simple tests */ + +static DES_cblock prng_key1={0x21,0x58,0x47,0xb7,0xc2,0x97,0x5a,0x8e}; +static DES_cblock prng_key2={0x61,0x23,0x05,0x96,0x18,0x91,0x86,0xac}; +static unsigned char prng_seed[8]={0x6b,0xa3,0x4f,0x07,0xe4,0x2a,0xb0,0xc}; + +typedef struct + { + DES_cblock keys[2]; + const unsigned char time[8]; + const unsigned char seed[8]; + const unsigned char block1[8]; + const unsigned char block100[8]; + } PRNGtest; + +/* FIXME: these test vectors are made up! */ +static PRNGtest t1= + { + { { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07 }, + { 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f }, + }, + { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, + { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, + { 0x33,0xc3,0xdf,0xfe,0x60,0x60,0x49,0x9e }, + { 0x40,0x08,0x95,0x4d,0xb1,0x82,0x98,0x86 } + }; +static PRNGtest t2= + { + { { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, + { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff } }, + { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, + { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, + { 0x65,0xf1,0xa4,0x07,0x42,0x38,0xd5,0x25 }, + { 0x99,0xba,0x8f,0xd2,0x88,0xad,0xf8,0x34 } + }; + +static void dump(const unsigned char *b,int n) + { + while(n-- > 0) + { + printf(" %02x",*b++); + } + } + +static void compare(const unsigned char *result,const unsigned char *expected, + int n) + { + int i; + + for(i=0 ; i < n ; ++i) + if(result[i] != expected[i]) + { + puts("Random test failed, got:"); + dump(result,8); + puts("\n expected:"); + dump(expected,8); + putchar('\n'); + exit(1); + } + } + +static void run_test(const PRNGtest *t) + { + unsigned char buf[8]; + int n; + + FIPS_set_prng_key(t->keys[0],t->keys[1]); + FIPS_test_mode(1,t->time); + RAND_seed(t->seed,sizeof t->seed); + + if(RAND_bytes(buf,8) != 8) + { + ERR_print_errors_fp(stderr); + exit(2); + } + compare(buf,t->block1,8); + for(n=0 ; n < 99 ; ++n) + if(RAND_bytes(buf,8) != 8) + { + ERR_print_errors_fp(stderr); + exit(2); + } + compare(buf,t->block100,8); + FIPS_test_mode(0,NULL); + } + +int main() + { + unsigned char buf[2500]; + int i,j,k,s,sign,nsign,err=0; + unsigned long n1; + unsigned long n2[16]; + unsigned long runs[2][34]; + /*double d; */ + long d; + + ERR_load_crypto_strings(); + RAND_set_rand_method(FIPS_rand_method()); + + run_test(&t1); + run_test(&t2); + + FIPS_set_prng_key(prng_key1,prng_key2); + RAND_seed(prng_seed,sizeof prng_seed); + + i = RAND_pseudo_bytes(buf,2500); + if (i <= 0) + { + printf ("init failed, the rand method is not properly installed\n"); + err++; + goto err; + } + + n1=0; + for (i=0; i<16; i++) n2[i]=0; + for (i=0; i<34; i++) runs[0][i]=runs[1][i]=0; + + /* test 1 and 2 */ + sign=0; + nsign=0; + for (i=0; i<2500; i++) + { + j=buf[i]; + + n2[j&0x0f]++; + n2[(j>>4)&0x0f]++; + + for (k=0; k<8; k++) + { + s=(j&0x01); + if (s == sign) + nsign++; + else + { + if (nsign > 34) nsign=34; + if (nsign != 0) + { + runs[sign][nsign-1]++; + if (nsign > 6) + runs[sign][5]++; + } + sign=s; + nsign=1; + } + + if (s) n1++; + j>>=1; + } + } + if (nsign > 34) nsign=34; + if (nsign != 0) runs[sign][nsign-1]++; + + /* test 1 */ + if (!((9654 < n1) && (n1 < 10346))) + { + printf("test 1 failed, X=%lu\n",n1); + err++; + } + printf("test 1 done\n"); + + /* test 2 */ +#ifdef undef + d=0; + for (i=0; i<16; i++) + d+=n2[i]*n2[i]; + d=d*16.0/5000.0-5000.0; + if (!((1.03 < d) && (d < 57.4))) + { + printf("test 2 failed, X=%.2f\n",d); + err++; + } +#endif + d=0; + for (i=0; i<16; i++) + d+=n2[i]*n2[i]; + d=(d*8)/25-500000; + if (!((103 < d) && (d < 5740))) + { + printf("test 2 failed, X=%ld.%02ld\n",d/100L,d%100L); + err++; + } + printf("test 2 done\n"); + + /* test 3 */ + for (i=0; i<2; i++) + { + if (!((2267 < runs[i][0]) && (runs[i][0] < 2733))) + { + printf("test 3 failed, bit=%d run=%d num=%lu\n", + i,1,runs[i][0]); + err++; + } + if (!((1079 < runs[i][1]) && (runs[i][1] < 1421))) + { + printf("test 3 failed, bit=%d run=%d num=%lu\n", + i,2,runs[i][1]); + err++; + } + if (!(( 502 < runs[i][2]) && (runs[i][2] < 748))) + { + printf("test 3 failed, bit=%d run=%d num=%lu\n", + i,3,runs[i][2]); + err++; + } + if (!(( 223 < runs[i][3]) && (runs[i][3] < 402))) + { + printf("test 3 failed, bit=%d run=%d num=%lu\n", + i,4,runs[i][3]); + err++; + } + if (!(( 90 < runs[i][4]) && (runs[i][4] < 223))) + { + printf("test 3 failed, bit=%d run=%d num=%lu\n", + i,5,runs[i][4]); + err++; + } + if (!(( 90 < runs[i][5]) && (runs[i][5] < 223))) + { + printf("test 3 failed, bit=%d run=%d num=%lu\n", + i,6,runs[i][5]); + err++; + } + } + printf("test 3 done\n"); + + /* test 4 */ + if (runs[0][33] != 0) + { + printf("test 4 failed, bit=%d run=%d num=%lu\n", + 0,34,runs[0][33]); + err++; + } + if (runs[1][33] != 0) + { + printf("test 4 failed, bit=%d run=%d num=%lu\n", + 1,34,runs[1][33]); + err++; + } + printf("test 4 done\n"); + err: + err=((err)?1:0); + EXIT(err); + return(err); + } + +#endif diff --git a/fips/rsa/Makefile b/fips/rsa/Makefile new file mode 100644 index 0000000000..91c2d49c27 --- /dev/null +++ b/fips/rsa/Makefile @@ -0,0 +1,112 @@ +# +# SSLeay/fips/rsa/Makefile +# + +DIR= rsa +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALL_PREFIX= +OPENSSLDIR= /usr/local/ssl +INSTALLTOP=/usr/local/ssl +MAKEDEPPROG= makedepend +MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) +MAKEFILE= Makefile +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=fips_rsa_eay.c fips_rsa_gen.c fips_rsa_selftest.c +LIBOBJ=fips_rsa_eay.o fips_rsa_gen.o fips_rsa_selftest.o + +SRC= $(LIBSRC) + +EXHEADER= +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd $(TOP); $(MAKE) DIRS=fips FDIRS=$(DIR) sub_all) + +all: check lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + $(RANLIB) $(LIB) || echo Never mind. + @sleep 2; touch lib + +check: + TOP=`pwd`/$(TOP) ../fips_check_sha1 fingerprint.sha1 $(SRC) $(HEADER) + +files: + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO + +links: + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/include/openssl $(EXHEADER) + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/test $(TEST) + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/apps $(APPS) + +install: +# some shells don't like empty lists +# @for i in $(EXHEADER) ; \ +# do \ +# (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ +# chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ +# done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(SRC) $(TEST) + +dclean: + $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff +# DO NOT DELETE THIS LINE -- make depend depends on it. + +fips_rsa_eay.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h +fips_rsa_eay.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h +fips_rsa_eay.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +fips_rsa_eay.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h +fips_rsa_eay.o: ../../include/openssl/opensslconf.h +fips_rsa_eay.o: ../../include/openssl/opensslv.h +fips_rsa_eay.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h +fips_rsa_eay.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h +fips_rsa_eay.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +fips_rsa_eay.o: fips_rsa_eay.c +fips_rsa_gen.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h +fips_rsa_gen.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h +fips_rsa_gen.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +fips_rsa_gen.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h +fips_rsa_gen.o: ../../include/openssl/opensslconf.h +fips_rsa_gen.o: ../../include/openssl/opensslv.h +fips_rsa_gen.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rsa.h +fips_rsa_gen.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +fips_rsa_gen.o: ../../include/openssl/symhacks.h fips_rsa_gen.c +fips_rsa_selftest.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h +fips_rsa_selftest.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h +fips_rsa_selftest.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +fips_rsa_selftest.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h +fips_rsa_selftest.o: ../../include/openssl/opensslconf.h +fips_rsa_selftest.o: ../../include/openssl/opensslv.h +fips_rsa_selftest.o: ../../include/openssl/ossl_typ.h +fips_rsa_selftest.o: ../../include/openssl/rsa.h +fips_rsa_selftest.o: ../../include/openssl/safestack.h +fips_rsa_selftest.o: ../../include/openssl/stack.h +fips_rsa_selftest.o: ../../include/openssl/symhacks.h fips_rsa_selftest.c diff --git a/fips/rsa/fingerprint.sha1 b/fips/rsa/fingerprint.sha1 new file mode 100644 index 0000000000..727c71930a --- /dev/null +++ b/fips/rsa/fingerprint.sha1 @@ -0,0 +1,3 @@ +HMAC-SHA1(fips_rsa_eay.c)= 3808fed15de958768052db96ff710699ca9afd92 +HMAC-SHA1(fips_rsa_gen.c)= 0f7eec6b217844f638902ff82fe41e2201ade1d5 +HMAC-SHA1(fips_rsa_selftest.c)= af5b9c9a0237b2219f375849a5b2311d786e711b diff --git a/fips/rsa/fips_rsa_eay.c b/fips/rsa/fips_rsa_eay.c new file mode 100644 index 0000000000..dafc7f1472 --- /dev/null +++ b/fips/rsa/fips_rsa_eay.c @@ -0,0 +1,735 @@ +/* crypto/rsa/rsa_eay.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include +#include +#include +#include +#include + +#if !defined(RSA_NULL) && defined(OPENSSL_FIPS) + +static int RSA_eay_public_encrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +static int RSA_eay_private_encrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +static int RSA_eay_public_decrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +static int RSA_eay_private_decrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *i, RSA *rsa); +static int RSA_eay_init(RSA *rsa); +static int RSA_eay_finish(RSA *rsa); +static RSA_METHOD rsa_pkcs1_eay_meth={ + "Eric Young's PKCS#1 RSA", + RSA_eay_public_encrypt, + RSA_eay_public_decrypt, /* signature verification */ + RSA_eay_private_encrypt, /* signing */ + RSA_eay_private_decrypt, + RSA_eay_mod_exp, + BN_mod_exp_mont, /* XXX probably we should not use Montgomery if e == 3 */ + RSA_eay_init, + RSA_eay_finish, + 0, /* flags */ + NULL, + 0, /* rsa_sign */ + 0 /* rsa_verify */ + }; + +const RSA_METHOD *RSA_PKCS1_SSLeay(void) + { + return(&rsa_pkcs1_eay_meth); + } + +static int RSA_eay_public_encrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, int padding) + { + BIGNUM f,ret; + int i,j,k,num=0,r= -1; + unsigned char *buf=NULL; + BN_CTX *ctx=NULL; + + BN_init(&f); + BN_init(&ret); + + if(FIPS_selftest_fail) + { + FIPSerr(FIPS_F_RSA_EAY_PUBLIC_ENCRYPT,FIPS_R_FIPS_SELFTEST_FAILED); + goto err; + } + + if ((ctx=BN_CTX_new()) == NULL) goto err; + num=BN_num_bytes(rsa->n); + if ((buf=(unsigned char *)OPENSSL_malloc(num)) == NULL) + { + RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT,ERR_R_MALLOC_FAILURE); + goto err; + } + + switch (padding) + { + case RSA_PKCS1_PADDING: + i=RSA_padding_add_PKCS1_type_2(buf,num,from,flen); + break; +#ifndef OPENSSL_NO_SHA + case RSA_PKCS1_OAEP_PADDING: + i=RSA_padding_add_PKCS1_OAEP(buf,num,from,flen,NULL,0); + break; +#endif + case RSA_SSLV23_PADDING: + i=RSA_padding_add_SSLv23(buf,num,from,flen); + break; + case RSA_NO_PADDING: + i=RSA_padding_add_none(buf,num,from,flen); + break; + default: + RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT,RSA_R_UNKNOWN_PADDING_TYPE); + goto err; + } + if (i <= 0) goto err; + + if (BN_bin2bn(buf,num,&f) == NULL) goto err; + + if (BN_ucmp(&f, rsa->n) >= 0) + { + /* usually the padding functions would catch this */ + RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT,RSA_R_DATA_TOO_LARGE_FOR_MODULUS); + goto err; + } + + if ((rsa->_method_mod_n == NULL) && (rsa->flags & RSA_FLAG_CACHE_PUBLIC)) + { + BN_MONT_CTX* bn_mont_ctx; + if ((bn_mont_ctx=BN_MONT_CTX_new()) == NULL) + goto err; + if (!BN_MONT_CTX_set(bn_mont_ctx,rsa->n,ctx)) + { + BN_MONT_CTX_free(bn_mont_ctx); + goto err; + } + if (rsa->_method_mod_n == NULL) /* other thread may have finished first */ + { + CRYPTO_w_lock(CRYPTO_LOCK_RSA); + if (rsa->_method_mod_n == NULL) + { + rsa->_method_mod_n = bn_mont_ctx; + bn_mont_ctx = NULL; + } + CRYPTO_w_unlock(CRYPTO_LOCK_RSA); + } + if (bn_mont_ctx) + BN_MONT_CTX_free(bn_mont_ctx); + } + + if (!rsa->meth->bn_mod_exp(&ret,&f,rsa->e,rsa->n,ctx, + rsa->_method_mod_n)) goto err; + + /* put in leading 0 bytes if the number is less than the + * length of the modulus */ + j=BN_num_bytes(&ret); + i=BN_bn2bin(&ret,&(to[num-j])); + for (k=0; k<(num-i); k++) + to[k]=0; + + r=num; +err: + if (ctx != NULL) BN_CTX_free(ctx); + BN_clear_free(&f); + BN_clear_free(&ret); + if (buf != NULL) + { + OPENSSL_cleanse(buf,num); + OPENSSL_free(buf); + } + return(r); + } + +static int rsa_eay_blinding(RSA *rsa, BN_CTX *ctx) + { + int ret = 1; + CRYPTO_w_lock(CRYPTO_LOCK_RSA); + /* Check again inside the lock - the macro's check is racey */ + if(rsa->blinding == NULL) + ret = RSA_blinding_on(rsa, ctx); + CRYPTO_w_unlock(CRYPTO_LOCK_RSA); + return ret; + } + +#define BLINDING_HELPER(rsa, ctx, err_instr) \ + do { \ + if((!((rsa)->flags & RSA_FLAG_NO_BLINDING)) && \ + ((rsa)->blinding == NULL) && \ + !rsa_eay_blinding(rsa, ctx)) \ + err_instr \ + } while(0) + +static BN_BLINDING *setup_blinding(RSA *rsa, BN_CTX *ctx) + { + BIGNUM *A, *Ai; + BN_BLINDING *ret = NULL; + + /* added in OpenSSL 0.9.6j and 0.9.7b */ + + /* NB: similar code appears in RSA_blinding_on (rsa_lib.c); + * this should be placed in a new function of its own, but for reasons + * of binary compatibility can't */ + + BN_CTX_start(ctx); + A = BN_CTX_get(ctx); + if ((RAND_status() == 0) && rsa->d != NULL && rsa->d->d != NULL) + { + /* if PRNG is not properly seeded, resort to secret exponent as unpredictable seed */ + RAND_add(rsa->d->d, rsa->d->dmax * sizeof rsa->d->d[0], 0); + if (!BN_pseudo_rand_range(A,rsa->n)) goto err; + } + else + { + if (!BN_rand_range(A,rsa->n)) goto err; + } + if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err; + + if (!rsa->meth->bn_mod_exp(A,A,rsa->e,rsa->n,ctx,rsa->_method_mod_n)) + goto err; + ret = BN_BLINDING_new(A,Ai,rsa->n); + BN_free(Ai); +err: + BN_CTX_end(ctx); + return ret; + } + +/* signing */ +static int RSA_eay_private_encrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, int padding) + { + BIGNUM f,ret; + int i,j,k,num=0,r= -1; + unsigned char *buf=NULL; + BN_CTX *ctx=NULL; + int local_blinding = 0; + BN_BLINDING *blinding = NULL; + + BN_init(&f); + BN_init(&ret); + + if ((ctx=BN_CTX_new()) == NULL) goto err; + num=BN_num_bytes(rsa->n); + if ((buf=(unsigned char *)OPENSSL_malloc(num)) == NULL) + { + RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT,ERR_R_MALLOC_FAILURE); + goto err; + } + + switch (padding) + { + case RSA_PKCS1_PADDING: + i=RSA_padding_add_PKCS1_type_1(buf,num,from,flen); + break; + case RSA_NO_PADDING: + i=RSA_padding_add_none(buf,num,from,flen); + break; + case RSA_SSLV23_PADDING: + default: + RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT,RSA_R_UNKNOWN_PADDING_TYPE); + goto err; + } + if (i <= 0) goto err; + + if (BN_bin2bn(buf,num,&f) == NULL) goto err; + + if (BN_ucmp(&f, rsa->n) >= 0) + { + /* usually the padding functions would catch this */ + RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT,RSA_R_DATA_TOO_LARGE_FOR_MODULUS); + goto err; + } + + BLINDING_HELPER(rsa, ctx, goto err;); + blinding = rsa->blinding; + + /* Now unless blinding is disabled, 'blinding' is non-NULL. + * But the BN_BLINDING object may be owned by some other thread + * (we don't want to keep it constant and we don't want to use + * lots of locking to avoid race conditions, so only a single + * thread can use it; other threads have to use local blinding + * factors) */ + if (!(rsa->flags & RSA_FLAG_NO_BLINDING)) + { + if (blinding == NULL) + { + RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT, ERR_R_INTERNAL_ERROR); + goto err; + } + } + + if (blinding != NULL) + { + if (blinding->thread_id != CRYPTO_thread_id()) + { + /* we need a local one-time blinding factor */ + + blinding = setup_blinding(rsa, ctx); + if (blinding == NULL) + goto err; + local_blinding = 1; + } + } + + if (blinding) + if (!BN_BLINDING_convert(&f, blinding, ctx)) goto err; + + if ( (rsa->flags & RSA_FLAG_EXT_PKEY) || + ((rsa->p != NULL) && + (rsa->q != NULL) && + (rsa->dmp1 != NULL) && + (rsa->dmq1 != NULL) && + (rsa->iqmp != NULL)) ) + { if (!rsa->meth->rsa_mod_exp(&ret,&f,rsa)) goto err; } + else + { + if (!rsa->meth->bn_mod_exp(&ret,&f,rsa->d,rsa->n,ctx,NULL)) goto err; + } + + if (blinding) + if (!BN_BLINDING_invert(&ret, blinding, ctx)) goto err; + + /* put in leading 0 bytes if the number is less than the + * length of the modulus */ + j=BN_num_bytes(&ret); + i=BN_bn2bin(&ret,&(to[num-j])); + for (k=0; k<(num-i); k++) + to[k]=0; + + r=num; +err: + if (ctx != NULL) BN_CTX_free(ctx); + BN_clear_free(&ret); + BN_clear_free(&f); + if (local_blinding) + BN_BLINDING_free(blinding); + if (buf != NULL) + { + OPENSSL_cleanse(buf,num); + OPENSSL_free(buf); + } + return(r); + } + +static int RSA_eay_private_decrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, int padding) + { + BIGNUM f,ret; + int j,num=0,r= -1; + unsigned char *p; + unsigned char *buf=NULL; + BN_CTX *ctx=NULL; + int local_blinding = 0; + BN_BLINDING *blinding = NULL; + + BN_init(&f); + BN_init(&ret); + ctx=BN_CTX_new(); + if (ctx == NULL) goto err; + + num=BN_num_bytes(rsa->n); + + if ((buf=(unsigned char *)OPENSSL_malloc(num)) == NULL) + { + RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,ERR_R_MALLOC_FAILURE); + goto err; + } + + /* This check was for equality but PGP does evil things + * and chops off the top '0' bytes */ + if (flen > num) + { + RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,RSA_R_DATA_GREATER_THAN_MOD_LEN); + goto err; + } + + /* make data into a big number */ + if (BN_bin2bn(from,(int)flen,&f) == NULL) goto err; + + if (BN_ucmp(&f, rsa->n) >= 0) + { + RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,RSA_R_DATA_TOO_LARGE_FOR_MODULUS); + goto err; + } + + BLINDING_HELPER(rsa, ctx, goto err;); + blinding = rsa->blinding; + + /* Now unless blinding is disabled, 'blinding' is non-NULL. + * But the BN_BLINDING object may be owned by some other thread + * (we don't want to keep it constant and we don't want to use + * lots of locking to avoid race conditions, so only a single + * thread can use it; other threads have to use local blinding + * factors) */ + if (!(rsa->flags & RSA_FLAG_NO_BLINDING)) + { + if (blinding == NULL) + { + RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, ERR_R_INTERNAL_ERROR); + goto err; + } + } + + if (blinding != NULL) + { + if (blinding->thread_id != CRYPTO_thread_id()) + { + /* we need a local one-time blinding factor */ + + blinding = setup_blinding(rsa, ctx); + if (blinding == NULL) + goto err; + local_blinding = 1; + } + } + + if (blinding) + if (!BN_BLINDING_convert(&f, blinding, ctx)) goto err; + + /* do the decrypt */ + if ( (rsa->flags & RSA_FLAG_EXT_PKEY) || + ((rsa->p != NULL) && + (rsa->q != NULL) && + (rsa->dmp1 != NULL) && + (rsa->dmq1 != NULL) && + (rsa->iqmp != NULL)) ) + { if (!rsa->meth->rsa_mod_exp(&ret,&f,rsa)) goto err; } + else + { + if (!rsa->meth->bn_mod_exp(&ret,&f,rsa->d,rsa->n,ctx,NULL)) + goto err; + } + + if (blinding) + if (!BN_BLINDING_invert(&ret, blinding, ctx)) goto err; + + p=buf; + j=BN_bn2bin(&ret,p); /* j is only used with no-padding mode */ + + switch (padding) + { + case RSA_PKCS1_PADDING: + r=RSA_padding_check_PKCS1_type_2(to,num,buf,j,num); + break; +#ifndef OPENSSL_NO_SHA + case RSA_PKCS1_OAEP_PADDING: + r=RSA_padding_check_PKCS1_OAEP(to,num,buf,j,num,NULL,0); + break; +#endif + case RSA_SSLV23_PADDING: + r=RSA_padding_check_SSLv23(to,num,buf,j,num); + break; + case RSA_NO_PADDING: + r=RSA_padding_check_none(to,num,buf,j,num); + break; + default: + RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,RSA_R_UNKNOWN_PADDING_TYPE); + goto err; + } + if (r < 0) + RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,RSA_R_PADDING_CHECK_FAILED); + +err: + if (ctx != NULL) BN_CTX_free(ctx); + BN_clear_free(&f); + BN_clear_free(&ret); + if (local_blinding) + BN_BLINDING_free(blinding); + if (buf != NULL) + { + OPENSSL_cleanse(buf,num); + OPENSSL_free(buf); + } + return(r); + } + +/* signature verification */ +static int RSA_eay_public_decrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, int padding) + { + BIGNUM f,ret; + int i,num=0,r= -1; + unsigned char *p; + unsigned char *buf=NULL; + BN_CTX *ctx=NULL; + + BN_init(&f); + BN_init(&ret); + ctx=BN_CTX_new(); + if (ctx == NULL) goto err; + + num=BN_num_bytes(rsa->n); + buf=(unsigned char *)OPENSSL_malloc(num); + if (buf == NULL) + { + RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,ERR_R_MALLOC_FAILURE); + goto err; + } + + /* This check was for equality but PGP does evil things + * and chops off the top '0' bytes */ + if (flen > num) + { + RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,RSA_R_DATA_GREATER_THAN_MOD_LEN); + goto err; + } + + if (BN_bin2bn(from,flen,&f) == NULL) goto err; + + if (BN_ucmp(&f, rsa->n) >= 0) + { + RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,RSA_R_DATA_TOO_LARGE_FOR_MODULUS); + goto err; + } + + /* do the decrypt */ + if ((rsa->_method_mod_n == NULL) && (rsa->flags & RSA_FLAG_CACHE_PUBLIC)) + { + BN_MONT_CTX* bn_mont_ctx; + if ((bn_mont_ctx=BN_MONT_CTX_new()) == NULL) + goto err; + if (!BN_MONT_CTX_set(bn_mont_ctx,rsa->n,ctx)) + { + BN_MONT_CTX_free(bn_mont_ctx); + goto err; + } + if (rsa->_method_mod_n == NULL) /* other thread may have finished first */ + { + CRYPTO_w_lock(CRYPTO_LOCK_RSA); + if (rsa->_method_mod_n == NULL) + { + rsa->_method_mod_n = bn_mont_ctx; + bn_mont_ctx = NULL; + } + CRYPTO_w_unlock(CRYPTO_LOCK_RSA); + } + if (bn_mont_ctx) + BN_MONT_CTX_free(bn_mont_ctx); + } + + if (!rsa->meth->bn_mod_exp(&ret,&f,rsa->e,rsa->n,ctx, + rsa->_method_mod_n)) goto err; + + p=buf; + i=BN_bn2bin(&ret,p); + + switch (padding) + { + case RSA_PKCS1_PADDING: + r=RSA_padding_check_PKCS1_type_1(to,num,buf,i,num); + break; + case RSA_NO_PADDING: + r=RSA_padding_check_none(to,num,buf,i,num); + break; + default: + RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,RSA_R_UNKNOWN_PADDING_TYPE); + goto err; + } + if (r < 0) + RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,RSA_R_PADDING_CHECK_FAILED); + +err: + if (ctx != NULL) BN_CTX_free(ctx); + BN_clear_free(&f); + BN_clear_free(&ret); + if (buf != NULL) + { + OPENSSL_cleanse(buf,num); + OPENSSL_free(buf); + } + return(r); + } + +static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa) + { + BIGNUM r1,m1,vrfy; + int ret=0; + BN_CTX *ctx; + + BN_init(&m1); + BN_init(&r1); + BN_init(&vrfy); + if ((ctx=BN_CTX_new()) == NULL) goto err; + + if (rsa->flags & RSA_FLAG_CACHE_PRIVATE) + { + if (rsa->_method_mod_p == NULL) + { + BN_MONT_CTX* bn_mont_ctx; + if ((bn_mont_ctx=BN_MONT_CTX_new()) == NULL) + goto err; + if (!BN_MONT_CTX_set(bn_mont_ctx,rsa->p,ctx)) + { + BN_MONT_CTX_free(bn_mont_ctx); + goto err; + } + if (rsa->_method_mod_p == NULL) /* other thread may have finished first */ + { + CRYPTO_w_lock(CRYPTO_LOCK_RSA); + if (rsa->_method_mod_p == NULL) + { + rsa->_method_mod_p = bn_mont_ctx; + bn_mont_ctx = NULL; + } + CRYPTO_w_unlock(CRYPTO_LOCK_RSA); + } + if (bn_mont_ctx) + BN_MONT_CTX_free(bn_mont_ctx); + } + + if (rsa->_method_mod_q == NULL) + { + BN_MONT_CTX* bn_mont_ctx; + if ((bn_mont_ctx=BN_MONT_CTX_new()) == NULL) + goto err; + if (!BN_MONT_CTX_set(bn_mont_ctx,rsa->q,ctx)) + { + BN_MONT_CTX_free(bn_mont_ctx); + goto err; + } + if (rsa->_method_mod_q == NULL) /* other thread may have finished first */ + { + CRYPTO_w_lock(CRYPTO_LOCK_RSA); + if (rsa->_method_mod_q == NULL) + { + rsa->_method_mod_q = bn_mont_ctx; + bn_mont_ctx = NULL; + } + CRYPTO_w_unlock(CRYPTO_LOCK_RSA); + } + if (bn_mont_ctx) + BN_MONT_CTX_free(bn_mont_ctx); + } + } + + if (!BN_mod(&r1,I,rsa->q,ctx)) goto err; + if (!rsa->meth->bn_mod_exp(&m1,&r1,rsa->dmq1,rsa->q,ctx, + rsa->_method_mod_q)) goto err; + + if (!BN_mod(&r1,I,rsa->p,ctx)) goto err; + if (!rsa->meth->bn_mod_exp(r0,&r1,rsa->dmp1,rsa->p,ctx, + rsa->_method_mod_p)) goto err; + + if (!BN_sub(r0,r0,&m1)) goto err; + /* This will help stop the size of r0 increasing, which does + * affect the multiply if it optimised for a power of 2 size */ + if (r0->neg) + if (!BN_add(r0,r0,rsa->p)) goto err; + + if (!BN_mul(&r1,r0,rsa->iqmp,ctx)) goto err; + if (!BN_mod(r0,&r1,rsa->p,ctx)) goto err; + /* If p < q it is occasionally possible for the correction of + * adding 'p' if r0 is negative above to leave the result still + * negative. This can break the private key operations: the following + * second correction should *always* correct this rare occurrence. + * This will *never* happen with OpenSSL generated keys because + * they ensure p > q [steve] + */ + if (r0->neg) + if (!BN_add(r0,r0,rsa->p)) goto err; + if (!BN_mul(&r1,r0,rsa->q,ctx)) goto err; + if (!BN_add(r0,&r1,&m1)) goto err; + + if (rsa->e && rsa->n) + { + if (!rsa->meth->bn_mod_exp(&vrfy,r0,rsa->e,rsa->n,ctx,NULL)) goto err; + /* If 'I' was greater than (or equal to) rsa->n, the operation + * will be equivalent to using 'I mod n'. However, the result of + * the verify will *always* be less than 'n' so we don't check + * for absolute equality, just congruency. */ + if (!BN_sub(&vrfy, &vrfy, I)) goto err; + if (!BN_mod(&vrfy, &vrfy, rsa->n, ctx)) goto err; + if (vrfy.neg) + if (!BN_add(&vrfy, &vrfy, rsa->n)) goto err; + if (!BN_is_zero(&vrfy)) + /* 'I' and 'vrfy' aren't congruent mod n. Don't leak + * miscalculated CRT output, just do a raw (slower) + * mod_exp and return that instead. */ + if (!rsa->meth->bn_mod_exp(r0,I,rsa->d,rsa->n,ctx,NULL)) goto err; + } + ret=1; +err: + BN_clear_free(&m1); + BN_clear_free(&r1); + BN_clear_free(&vrfy); + BN_CTX_free(ctx); + return(ret); + } + +static int RSA_eay_init(RSA *rsa) + { + rsa->flags|=RSA_FLAG_CACHE_PUBLIC|RSA_FLAG_CACHE_PRIVATE; + return(1); + } + +static int RSA_eay_finish(RSA *rsa) + { + if (rsa->_method_mod_n != NULL) + BN_MONT_CTX_free(rsa->_method_mod_n); + if (rsa->_method_mod_p != NULL) + BN_MONT_CTX_free(rsa->_method_mod_p); + if (rsa->_method_mod_q != NULL) + BN_MONT_CTX_free(rsa->_method_mod_q); + return(1); + } + +#endif diff --git a/fips/rsa/fips_rsa_gen.c b/fips/rsa/fips_rsa_gen.c new file mode 100644 index 0000000000..e191baa926 --- /dev/null +++ b/fips/rsa/fips_rsa_gen.c @@ -0,0 +1,249 @@ +/* crypto/rsa/rsa_gen.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef OPENSSL_FIPS + +static int fips_check_rsa(RSA *rsa) + { + int n; + unsigned char ctext[256]; + unsigned char ptext[256]; + /* The longest we can have with OAEP padding and a 512 bit key */ + static unsigned char original_ptext[] = + "\x01\x23\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a\xbc\xde\xf0" + "\x23\x45\x67\x89\xab\xcd"; + + /* this will fail for keys shorter than 512 bits */ + n=RSA_public_encrypt(sizeof(original_ptext)-1,original_ptext,ctext,rsa, + RSA_PKCS1_OAEP_PADDING); + if(n < 0) + { + ERR_print_errors_fp(stderr); + exit(1); + } + if(!memcmp(ctext,original_ptext,n)) + { + FIPSerr(FIPS_F_FIPS_CHECK_RSA,FIPS_R_PAIRWISE_TEST_FAILED); + return 0; + } + n=RSA_private_decrypt(n,ctext,ptext,rsa,RSA_PKCS1_OAEP_PADDING); + if(n < 0) + { + ERR_print_errors_fp(stderr); + exit(1); + } + if(n != sizeof(original_ptext)-1 || memcmp(ptext,original_ptext,n)) + { + FIPSerr(FIPS_F_FIPS_CHECK_RSA,FIPS_R_PAIRWISE_TEST_FAILED); + return 0; + } + + return 1; + } + +RSA *RSA_generate_key(int bits, unsigned long e_value, + void (*callback)(int,int,void *), void *cb_arg) + { + RSA *rsa=NULL; + BIGNUM *r0=NULL,*r1=NULL,*r2=NULL,*r3=NULL,*tmp; + int bitsp,bitsq,ok= -1,n=0,i; + BN_CTX *ctx=NULL,*ctx2=NULL; + + if(FIPS_selftest_fail) + { + FIPSerr(FIPS_F_RSA_GENERATE_KEY,FIPS_R_FIPS_SELFTEST_FAILED); + return NULL; + } + + ctx=BN_CTX_new(); + if (ctx == NULL) goto err; + ctx2=BN_CTX_new(); + if (ctx2 == NULL) goto err; + BN_CTX_start(ctx); + r0 = BN_CTX_get(ctx); + r1 = BN_CTX_get(ctx); + r2 = BN_CTX_get(ctx); + r3 = BN_CTX_get(ctx); + if (r3 == NULL) goto err; + + bitsp=(bits+1)/2; + bitsq=bits-bitsp; + rsa=RSA_new(); + if (rsa == NULL) goto err; + + /* set e */ + rsa->e=BN_new(); + if (rsa->e == NULL) goto err; + +#if 1 + /* The problem is when building with 8, 16, or 32 BN_ULONG, + * unsigned long can be larger */ + for (i=0; ie,i); + } +#else + if (!BN_set_word(rsa->e,e_value)) goto err; +#endif + + /* generate p and q */ + for (;;) + { + rsa->p=BN_generate_prime(NULL,bitsp,0,NULL,NULL,callback,cb_arg); + if (rsa->p == NULL) goto err; + if (!BN_sub(r2,rsa->p,BN_value_one())) goto err; + if (!BN_gcd(r1,r2,rsa->e,ctx)) goto err; + if (BN_is_one(r1)) break; + if (callback != NULL) callback(2,n++,cb_arg); + BN_free(rsa->p); + } + if (callback != NULL) callback(3,0,cb_arg); + for (;;) + { + rsa->q=BN_generate_prime(NULL,bitsq,0,NULL,NULL,callback,cb_arg); + if (rsa->q == NULL) goto err; + if (!BN_sub(r2,rsa->q,BN_value_one())) goto err; + if (!BN_gcd(r1,r2,rsa->e,ctx)) goto err; + if (BN_is_one(r1) && (BN_cmp(rsa->p,rsa->q) != 0)) + break; + if (callback != NULL) callback(2,n++,cb_arg); + BN_free(rsa->q); + } + if (callback != NULL) callback(3,1,cb_arg); + if (BN_cmp(rsa->p,rsa->q) < 0) + { + tmp=rsa->p; + rsa->p=rsa->q; + rsa->q=tmp; + } + + /* calculate n */ + rsa->n=BN_new(); + if (rsa->n == NULL) goto err; + if (!BN_mul(rsa->n,rsa->p,rsa->q,ctx)) goto err; + + /* calculate d */ + if (!BN_sub(r1,rsa->p,BN_value_one())) goto err; /* p-1 */ + if (!BN_sub(r2,rsa->q,BN_value_one())) goto err; /* q-1 */ + if (!BN_mul(r0,r1,r2,ctx)) goto err; /* (p-1)(q-1) */ + +/* should not be needed, since gcd(p-1,e) == 1 and gcd(q-1,e) == 1 */ +/* for (;;) + { + if (!BN_gcd(r3,r0,rsa->e,ctx)) goto err; + if (BN_is_one(r3)) break; + + if (1) + { + if (!BN_add_word(rsa->e,2L)) goto err; + continue; + } + RSAerr(RSA_F_RSA_GENERATE_KEY,RSA_R_BAD_E_VALUE); + goto err; + } +*/ + rsa->d=BN_mod_inverse(NULL,rsa->e,r0,ctx2); /* d */ + if (rsa->d == NULL) goto err; + + /* calculate d mod (p-1) */ + rsa->dmp1=BN_new(); + if (rsa->dmp1 == NULL) goto err; + if (!BN_mod(rsa->dmp1,rsa->d,r1,ctx)) goto err; + + /* calculate d mod (q-1) */ + rsa->dmq1=BN_new(); + if (rsa->dmq1 == NULL) goto err; + if (!BN_mod(rsa->dmq1,rsa->d,r2,ctx)) goto err; + + /* calculate inverse of q mod p */ + rsa->iqmp=BN_mod_inverse(NULL,rsa->q,rsa->p,ctx2); + if (rsa->iqmp == NULL) goto err; + + if(!fips_check_rsa(rsa)) + goto err; + + ok=1; +err: + if (ok == -1) + { + RSAerr(RSA_F_RSA_GENERATE_KEY,ERR_LIB_BN); + ok=0; + } + BN_CTX_end(ctx); + BN_CTX_free(ctx); + BN_CTX_free(ctx2); + + if (!ok) + { + if (rsa != NULL) RSA_free(rsa); + return(NULL); + } + else + return(rsa); + } + +#endif diff --git a/fips/rsa/fips_rsa_selftest.c b/fips/rsa/fips_rsa_selftest.c new file mode 100644 index 0000000000..cf3bf02aab --- /dev/null +++ b/fips/rsa/fips_rsa_selftest.c @@ -0,0 +1,207 @@ +/* ==================================================================== + * Copyright (c) 2003 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 + * openssl-core@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. + * + */ + +#include +#include +#include +#include +#include + +#ifdef OPENSSL_FIPS +#define SetKey \ + key->n = BN_bin2bn(n, sizeof(n)-1, key->n); \ + key->e = BN_bin2bn(e, sizeof(e)-1, key->e); \ + key->d = BN_bin2bn(d, sizeof(d)-1, key->d); \ + key->p = BN_bin2bn(p, sizeof(p)-1, key->p); \ + key->q = BN_bin2bn(q, sizeof(q)-1, key->q); \ + key->dmp1 = BN_bin2bn(dmp1, sizeof(dmp1)-1, key->dmp1); \ + key->dmq1 = BN_bin2bn(dmq1, sizeof(dmq1)-1, key->dmq1); \ + key->iqmp = BN_bin2bn(iqmp, sizeof(iqmp)-1, key->iqmp); \ + memcpy(c, ctext_ex, sizeof(ctext_ex) - 1); \ + return (sizeof(ctext_ex) - 1); + +static unsigned char n[] = +"\x00\xBB\xF8\x2F\x09\x06\x82\xCE\x9C\x23\x38\xAC\x2B\x9D\xA8\x71" +"\xF7\x36\x8D\x07\xEE\xD4\x10\x43\xA4\x40\xD6\xB6\xF0\x74\x54\xF5" +"\x1F\xB8\xDF\xBA\xAF\x03\x5C\x02\xAB\x61\xEA\x48\xCE\xEB\x6F\xCD" +"\x48\x76\xED\x52\x0D\x60\xE1\xEC\x46\x19\x71\x9D\x8A\x5B\x8B\x80" +"\x7F\xAF\xB8\xE0\xA3\xDF\xC7\x37\x72\x3E\xE6\xB4\xB7\xD9\x3A\x25" +"\x84\xEE\x6A\x64\x9D\x06\x09\x53\x74\x88\x34\xB2\x45\x45\x98\x39" +"\x4E\xE0\xAA\xB1\x2D\x7B\x61\xA5\x1F\x52\x7A\x9A\x41\xF6\xC1\x68" +"\x7F\xE2\x53\x72\x98\xCA\x2A\x8F\x59\x46\xF8\xE5\xFD\x09\x1D\xBD" +"\xCB"; + + +static int setrsakey(RSA *key, unsigned char *c) + { + static unsigned char e[] = "\x11"; + + static unsigned char d[] = +"\x00\xA5\xDA\xFC\x53\x41\xFA\xF2\x89\xC4\xB9\x88\xDB\x30\xC1\xCD" +"\xF8\x3F\x31\x25\x1E\x06\x68\xB4\x27\x84\x81\x38\x01\x57\x96\x41" +"\xB2\x94\x10\xB3\xC7\x99\x8D\x6B\xC4\x65\x74\x5E\x5C\x39\x26\x69" +"\xD6\x87\x0D\xA2\xC0\x82\xA9\x39\xE3\x7F\xDC\xB8\x2E\xC9\x3E\xDA" +"\xC9\x7F\xF3\xAD\x59\x50\xAC\xCF\xBC\x11\x1C\x76\xF1\xA9\x52\x94" +"\x44\xE5\x6A\xAF\x68\xC5\x6C\x09\x2C\xD3\x8D\xC3\xBE\xF5\xD2\x0A" +"\x93\x99\x26\xED\x4F\x74\xA1\x3E\xDD\xFB\xE1\xA1\xCE\xCC\x48\x94" +"\xAF\x94\x28\xC2\xB7\xB8\x88\x3F\xE4\x46\x3A\x4B\xC8\x5B\x1C\xB3" +"\xC1"; + + static unsigned char p[] = +"\x00\xEE\xCF\xAE\x81\xB1\xB9\xB3\xC9\x08\x81\x0B\x10\xA1\xB5\x60" +"\x01\x99\xEB\x9F\x44\xAE\xF4\xFD\xA4\x93\xB8\x1A\x9E\x3D\x84\xF6" +"\x32\x12\x4E\xF0\x23\x6E\x5D\x1E\x3B\x7E\x28\xFA\xE7\xAA\x04\x0A" +"\x2D\x5B\x25\x21\x76\x45\x9D\x1F\x39\x75\x41\xBA\x2A\x58\xFB\x65" +"\x99"; + + static unsigned char q[] = +"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9" +"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5A\x0F\x20\x35\x02\x8B\x9D" +"\x86\x98\x40\xB4\x16\x66\xB4\x2E\x92\xEA\x0D\xA3\xB4\x32\x04\xB5" +"\xCF\xCE\x33\x52\x52\x4D\x04\x16\xA5\xA4\x41\xE7\x00\xAF\x46\x15" +"\x03"; + + static unsigned char dmp1[] = +"\x54\x49\x4C\xA6\x3E\xBA\x03\x37\xE4\xE2\x40\x23\xFC\xD6\x9A\x5A" +"\xEB\x07\xDD\xDC\x01\x83\xA4\xD0\xAC\x9B\x54\xB0\x51\xF2\xB1\x3E" +"\xD9\x49\x09\x75\xEA\xB7\x74\x14\xFF\x59\xC1\xF7\x69\x2E\x9A\x2E" +"\x20\x2B\x38\xFC\x91\x0A\x47\x41\x74\xAD\xC9\x3C\x1F\x67\xC9\x81"; + + static unsigned char dmq1[] = +"\x47\x1E\x02\x90\xFF\x0A\xF0\x75\x03\x51\xB7\xF8\x78\x86\x4C\xA9" +"\x61\xAD\xBD\x3A\x8A\x7E\x99\x1C\x5C\x05\x56\xA9\x4C\x31\x46\xA7" +"\xF9\x80\x3F\x8F\x6F\x8A\xE3\x42\xE9\x31\xFD\x8A\xE4\x7A\x22\x0D" +"\x1B\x99\xA4\x95\x84\x98\x07\xFE\x39\xF9\x24\x5A\x98\x36\xDA\x3D"; + + static unsigned char iqmp[] = +"\x00\xB0\x6C\x4F\xDA\xBB\x63\x01\x19\x8D\x26\x5B\xDB\xAE\x94\x23" +"\xB3\x80\xF2\x71\xF7\x34\x53\x88\x50\x93\x07\x7F\xCD\x39\xE2\x11" +"\x9F\xC9\x86\x32\x15\x4F\x58\x83\xB1\x67\xA9\x67\xBF\x40\x2B\x4E" +"\x9E\x2E\x0F\x96\x56\xE6\x98\xEA\x36\x66\xED\xFB\x25\x79\x80\x39" +"\xF7"; + + static unsigned char ctext_ex[] = +"\x42\x4b\xc9\x51\x61\xd4\xca\xa0\x18\x6c\x4d\xca\x61\x8f\x2d\x07" +"\x8c\x63\xc5\x6b\xa2\x4c\x32\xb1\xda\xb7\xdd\x32\xb6\x51\x68\xc3" +"\x6e\x98\x46\xd6\xbb\x1a\xd5\x99\x05\x92\x7c\xd7\xbc\x08\x9e\xe4" +"\xc3\x70\x4d\xe6\x99\x7e\x61\x31\x07\x7a\x19\xdb\x3e\x11\xfa\x3d" +"\x7c\x61\xd7\x78\x14\x3f\x05\x16\xa0\xc4\xbf\xcd\xee\xca\x67\x4c" +"\x80\x4e\xca\x43\x2f\x35\x43\x58\xa7\x50\x7e\x3e\x52\x82\xab\xac" +"\xa6\x50\xe8\x39\x9f\xe0\x7f\x58\x1d\x1b\x90\x93\x04\xec\xb3\xf9" +"\x24\xd3\x75\x3e\x39\xd1\x14\xc6\x33\xce\xd6\xee\x20\x47\xec\xe4"; + + SetKey; + } + +void FIPS_corrupt_rsa() + { + n[0]++; + } + +int FIPS_selftest_rsa() + { + int clen; + RSA *key; + unsigned char expected_ctext[256]; + unsigned char ctext[256]; + unsigned char ptext[256]; + static unsigned char original_ptext[] = + "\x01\x23\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a\xbc\xde\xf0" + "\x23\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a\xbc\xde\xf0\x12" + "\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a\xbc\xde\xf0\x12\x34" + "\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a\xbc\xde\xf0\x12\x34\x56" + "\x89\xab\xcd\xef\x12\x34\x56\x78\x9a\xbc\xde\xf0\x12\x34\x56\x78" + "\xab\xcd\xef\x12\x34\x56\x78\x9a\xbc\xde\xf0\x12\x34\x56\x78\x9a" + "\xcd\xef\x12\x34\x56\x78\x9a\xbc\xde\xf0\x12\x34\x56\x78\x9a\xbc" + "\xef\x12\x34\x56\x78\x9a\xbc\xde\xf0\x12\x34\x56\x78\x9a\xbc\xde"; + int n; + + /* Perform pairwise consistency test by: ... */ + + key=RSA_new(); + clen=setrsakey(key,expected_ctext); + /* ...1) apply public key to plaintext, resulting ciphertext must be + * different + */ + n=RSA_public_encrypt(sizeof(original_ptext)-1,original_ptext,ctext,key, + RSA_NO_PADDING); + if(n < 0) + { + ERR_print_errors_fp(stderr); + exit(1); + } + if(n != clen || memcmp(ctext,expected_ctext,n)) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_RSA,FIPS_R_SELFTEST_FAILED); + return 0; + } + if(!memcmp(ctext,original_ptext,n)) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_RSA,FIPS_R_SELFTEST_FAILED); + return 0; + } + /* ...2) apply private key to ciphertext and compare result to + * original plaintext; results must be equal + */ + n=RSA_private_decrypt(n,ctext,ptext,key,RSA_NO_PADDING); + if(n < 0) + { + ERR_print_errors_fp(stderr); + exit(1); + } + if(n != sizeof(original_ptext)-1 || memcmp(ptext,original_ptext,n)) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_RSA,FIPS_R_SELFTEST_FAILED); + return 0; + } + RSA_free(key); + return 1; + } + +#endif /* def OPENSSL_FIPS */ diff --git a/fips/sha1/.cvsignore b/fips/sha1/.cvsignore new file mode 100644 index 0000000000..c128993548 --- /dev/null +++ b/fips/sha1/.cvsignore @@ -0,0 +1,2 @@ +fips_standalone_sha1 +lib diff --git a/fips/sha1/Makefile b/fips/sha1/Makefile new file mode 100644 index 0000000000..f98c084b49 --- /dev/null +++ b/fips/sha1/Makefile @@ -0,0 +1,158 @@ +# +# SSLeay/fips/sha1/Makefile +# + +DIR= sha1 +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALL_PREFIX= +OPENSSLDIR= /usr/local/ssl +INSTALLTOP=/usr/local/ssl +MAKEDEPPROG= makedepend +MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) +MAKEFILE= Makefile +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST= fips_sha1test.c +TESTDATA= sha1vectors.txt sha1hashes.txt +APPS= +EXE= fips_standalone_sha1 + +LIB=$(TOP)/libcrypto.a +LIBSRC=fips_sha1dgst.c fips_sha1_selftest.c asm/sx86-elf.s +LIBOBJ=fips_sha1dgst.o fips_sha1_selftest.o $(FIPS_SHA1_ASM_OBJ) + +SRC= $(LIBSRC) fips_standalone_sha1.c + +EXHEADER= +HEADER= $(EXHEADER) fips_sha_locl.h fips_md32_common.h + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd $(TOP); $(MAKE) DIRS=fips SDIRS=$(DIR) sub_all) + +all: check_standalone check lib + +check: + TOP=`pwd`/$(TOP) ../fips_check_sha1 fingerprint.sha1 $(LIBSRC) $(HEADER) + +check_standalone: fips_standalone_sha1 + TOP=`pwd`/$(TOP) ../fips_check_sha1 standalone.sha1 $(SRC) $(HEADER) + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + $(RANLIB) $(LIB) || echo Never mind. + @sleep 2; touch lib + +fips_standalone_sha1: fips_standalone_sha1.o fips_sha1dgst.o $(FIPS_SHA1_ASM_OBJ) + $(CC) -o fips_standalone_sha1 $(CFLAGS) fips_standalone_sha1.o \ + fips_sha1dgst.o $(FIPS_SHA1_ASM_OBJ) + +files: + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO + +links: + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/include/openssl $(EXHEADER) + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/test $(TEST) + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/test $(TESTDATA) + @$(PERL) $(TOP)/util/mklink.pl $(TOP)/apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ + chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +top_fips_sha1test: + (cd $(TOP); $(MAKE) DIRS=fips FDIRS=$(DIR) TARGET=fips_sha1test sub_target) + +fips_sha1test: fips_sha1test.o $(TOP)/libcrypto.a + $(CC) $(CFLAGS) -o fips_sha1test fips_sha1test.o $(PEX_LIBS) $(TOP)/libcrypto.a $(EX_LIBS) + TOP=$(TOP) $(TOP)/fips/openssl_fips_fingerprint $(TOP)/libcrypto.a fips_sha1test + +fips_test: top_fips_sha1test + -rm -rf ../testvectors/sha1/rsp + mkdir ../testvectors/sha1/rsp + ./fips_sha1test ../testvectors/sha1/req/sha.req > ../testvectors/sha1/rsp/sha.rsp + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(SRC) $(TEST) + +dclean: + $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE) + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +fips_sha1_selftest.o: ../../include/openssl/bio.h +fips_sha1_selftest.o: ../../include/openssl/crypto.h +fips_sha1_selftest.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +fips_sha1_selftest.o: ../../include/openssl/fips.h +fips_sha1_selftest.o: ../../include/openssl/lhash.h +fips_sha1_selftest.o: ../../include/openssl/opensslconf.h +fips_sha1_selftest.o: ../../include/openssl/opensslv.h +fips_sha1_selftest.o: ../../include/openssl/safestack.h +fips_sha1_selftest.o: ../../include/openssl/sha.h ../../include/openssl/stack.h +fips_sha1_selftest.o: ../../include/openssl/symhacks.h fips_sha1_selftest.c +fips_sha1dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/fips.h +fips_sha1dgst.o: ../../include/openssl/opensslconf.h +fips_sha1dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h +fips_sha1dgst.o: fips_md32_common.h fips_sha1dgst.c fips_sha_locl.h +fips_sha1test.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h +fips_sha1test.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +fips_sha1test.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h +fips_sha1test.o: ../../include/openssl/opensslconf.h +fips_sha1test.o: ../../include/openssl/opensslv.h +fips_sha1test.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h +fips_sha1test.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +fips_sha1test.o: fips_sha1test.c +fips_standalone_sha1.o: ../../include/openssl/aes.h +fips_standalone_sha1.o: ../../include/openssl/asn1.h +fips_standalone_sha1.o: ../../include/openssl/bio.h +fips_standalone_sha1.o: ../../include/openssl/blowfish.h +fips_standalone_sha1.o: ../../include/openssl/bn.h ../../include/openssl/cast.h +fips_standalone_sha1.o: ../../include/openssl/crypto.h +fips_standalone_sha1.o: ../../include/openssl/des.h +fips_standalone_sha1.o: ../../include/openssl/des_old.h +fips_standalone_sha1.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h +fips_standalone_sha1.o: ../../include/openssl/e_os2.h +fips_standalone_sha1.o: ../../include/openssl/evp.h +fips_standalone_sha1.o: ../../include/openssl/hmac.h +fips_standalone_sha1.o: ../../include/openssl/idea.h +fips_standalone_sha1.o: ../../include/openssl/md2.h ../../include/openssl/md4.h +fips_standalone_sha1.o: ../../include/openssl/md5.h +fips_standalone_sha1.o: ../../include/openssl/mdc2.h +fips_standalone_sha1.o: ../../include/openssl/obj_mac.h +fips_standalone_sha1.o: ../../include/openssl/objects.h +fips_standalone_sha1.o: ../../include/openssl/opensslconf.h +fips_standalone_sha1.o: ../../include/openssl/opensslv.h +fips_standalone_sha1.o: ../../include/openssl/ossl_typ.h +fips_standalone_sha1.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h +fips_standalone_sha1.o: ../../include/openssl/rc5.h +fips_standalone_sha1.o: ../../include/openssl/ripemd.h +fips_standalone_sha1.o: ../../include/openssl/rsa.h +fips_standalone_sha1.o: ../../include/openssl/safestack.h +fips_standalone_sha1.o: ../../include/openssl/sha.h +fips_standalone_sha1.o: ../../include/openssl/stack.h +fips_standalone_sha1.o: ../../include/openssl/symhacks.h +fips_standalone_sha1.o: ../../include/openssl/ui.h +fips_standalone_sha1.o: ../../include/openssl/ui_compat.h +fips_standalone_sha1.o: fips_standalone_sha1.c diff --git a/fips/sha1/asm/sx86-elf.s b/fips/sha1/asm/sx86-elf.s new file mode 100644 index 0000000000..2cdd009a24 --- /dev/null +++ b/fips/sha1/asm/sx86-elf.s @@ -0,0 +1,1568 @@ + + + + + + + .file "sha1-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align 16 +.globl sha1_block_asm_data_order + .type sha1_block_asm_data_order,@function +sha1_block_asm_data_order: + movl 12(%esp), %ecx + pushl %esi + sall $6, %ecx + movl 12(%esp), %esi + pushl %ebp + addl %esi, %ecx + pushl %ebx + movl 16(%esp), %ebp + pushl %edi + movl 12(%ebp), %edx + subl $108, %esp + movl 16(%ebp), %edi + movl 8(%ebp), %ebx + movl %ecx, 68(%esp) + +.L000start: + + movl (%esi), %eax + movl 4(%esi), %ecx + + xchg %al, %ah + rorl $16, %eax + xchg %al, %ah + + xchg %cl, %ch + rorl $16, %ecx + xchg %cl, %ch + movl %eax, (%esp) + movl %ecx, 4(%esp) + movl 8(%esi), %eax + movl 12(%esi), %ecx + + xchg %al, %ah + rorl $16, %eax + xchg %al, %ah + + xchg %cl, %ch + rorl $16, %ecx + xchg %cl, %ch + movl %eax, 8(%esp) + movl %ecx, 12(%esp) + movl 16(%esi), %eax + movl 20(%esi), %ecx + + xchg %al, %ah + rorl $16, %eax + xchg %al, %ah + + xchg %cl, %ch + rorl $16, %ecx + xchg %cl, %ch + movl %eax, 16(%esp) + movl %ecx, 20(%esp) + movl 24(%esi), %eax + movl 28(%esi), %ecx + + xchg %al, %ah + rorl $16, %eax + xchg %al, %ah + + xchg %cl, %ch + rorl $16, %ecx + xchg %cl, %ch + movl %eax, 24(%esp) + movl %ecx, 28(%esp) + movl 32(%esi), %eax + movl 36(%esi), %ecx + + xchg %al, %ah + rorl $16, %eax + xchg %al, %ah + + xchg %cl, %ch + rorl $16, %ecx + xchg %cl, %ch + movl %eax, 32(%esp) + movl %ecx, 36(%esp) + movl 40(%esi), %eax + movl 44(%esi), %ecx + + xchg %al, %ah + rorl $16, %eax + xchg %al, %ah + + xchg %cl, %ch + rorl $16, %ecx + xchg %cl, %ch + movl %eax, 40(%esp) + movl %ecx, 44(%esp) + movl 48(%esi), %eax + movl 52(%esi), %ecx + + xchg %al, %ah + rorl $16, %eax + xchg %al, %ah + + xchg %cl, %ch + rorl $16, %ecx + xchg %cl, %ch + movl %eax, 48(%esp) + movl %ecx, 52(%esp) + movl 56(%esi), %eax + movl 60(%esi), %ecx + + xchg %al, %ah + rorl $16, %eax + xchg %al, %ah + + xchg %cl, %ch + rorl $16, %ecx + xchg %cl, %ch + movl %eax, 56(%esp) + movl %ecx, 60(%esp) + + + movl %esi, 132(%esp) +.L001shortcut: + + + movl (%ebp), %eax + movl 4(%ebp), %ecx + + movl %eax, %ebp + movl %ebx, %esi + roll $5, %ebp + xorl %edx, %esi + andl %ecx, %esi + rorl $2, %ecx + addl %edi, %ebp + movl (%esp), %edi + xorl %edx, %esi + leal 1518500249(%ebp,%edi,1),%ebp + addl %ebp, %esi + + movl %esi, %ebp + movl %ecx, %edi + roll $5, %ebp + xorl %ebx, %edi + andl %eax, %edi + rorl $2, %eax + addl %edx, %ebp + movl 4(%esp), %edx + xorl %ebx, %edi + leal 1518500249(%ebp,%edx,1),%ebp + addl %ebp, %edi + + movl %edi, %ebp + movl %eax, %edx + roll $5, %ebp + xorl %ecx, %edx + andl %esi, %edx + rorl $2, %esi + addl %ebx, %ebp + movl 8(%esp), %ebx + xorl %ecx, %edx + leal 1518500249(%ebp,%ebx,1),%ebp + addl %ebp, %edx + + movl %edx, %ebp + movl %esi, %ebx + roll $5, %ebp + xorl %eax, %ebx + andl %edi, %ebx + rorl $2, %edi + addl %ecx, %ebp + movl 12(%esp), %ecx + xorl %eax, %ebx + leal 1518500249(%ebp,%ecx,1),%ebp + addl %ebp, %ebx + + movl %ebx, %ebp + movl %edi, %ecx + roll $5, %ebp + xorl %esi, %ecx + andl %edx, %ecx + rorl $2, %edx + addl %eax, %ebp + movl 16(%esp), %eax + xorl %esi, %ecx + leal 1518500249(%ebp,%eax,1),%ebp + addl %ebp, %ecx + + movl %ecx, %ebp + movl %edx, %eax + roll $5, %ebp + xorl %edi, %eax + andl %ebx, %eax + rorl $2, %ebx + addl %esi, %ebp + movl 20(%esp), %esi + xorl %edi, %eax + leal 1518500249(%ebp,%esi,1),%ebp + addl %ebp, %eax + + movl %eax, %ebp + movl %ebx, %esi + roll $5, %ebp + xorl %edx, %esi + andl %ecx, %esi + rorl $2, %ecx + addl %edi, %ebp + movl 24(%esp), %edi + xorl %edx, %esi + leal 1518500249(%ebp,%edi,1),%ebp + addl %ebp, %esi + + movl %esi, %ebp + movl %ecx, %edi + roll $5, %ebp + xorl %ebx, %edi + andl %eax, %edi + rorl $2, %eax + addl %edx, %ebp + movl 28(%esp), %edx + xorl %ebx, %edi + leal 1518500249(%ebp,%edx,1),%ebp + addl %ebp, %edi + + movl %edi, %ebp + movl %eax, %edx + roll $5, %ebp + xorl %ecx, %edx + andl %esi, %edx + rorl $2, %esi + addl %ebx, %ebp + movl 32(%esp), %ebx + xorl %ecx, %edx + leal 1518500249(%ebp,%ebx,1),%ebp + addl %ebp, %edx + + movl %edx, %ebp + movl %esi, %ebx + roll $5, %ebp + xorl %eax, %ebx + andl %edi, %ebx + rorl $2, %edi + addl %ecx, %ebp + movl 36(%esp), %ecx + xorl %eax, %ebx + leal 1518500249(%ebp,%ecx,1),%ebp + addl %ebp, %ebx + + movl %ebx, %ebp + movl %edi, %ecx + roll $5, %ebp + xorl %esi, %ecx + andl %edx, %ecx + rorl $2, %edx + addl %eax, %ebp + movl 40(%esp), %eax + xorl %esi, %ecx + leal 1518500249(%ebp,%eax,1),%ebp + addl %ebp, %ecx + + movl %ecx, %ebp + movl %edx, %eax + roll $5, %ebp + xorl %edi, %eax + andl %ebx, %eax + rorl $2, %ebx + addl %esi, %ebp + movl 44(%esp), %esi + xorl %edi, %eax + leal 1518500249(%ebp,%esi,1),%ebp + addl %ebp, %eax + + movl %eax, %ebp + movl %ebx, %esi + roll $5, %ebp + xorl %edx, %esi + andl %ecx, %esi + rorl $2, %ecx + addl %edi, %ebp + movl 48(%esp), %edi + xorl %edx, %esi + leal 1518500249(%ebp,%edi,1),%ebp + addl %ebp, %esi + + movl %esi, %ebp + movl %ecx, %edi + roll $5, %ebp + xorl %ebx, %edi + andl %eax, %edi + rorl $2, %eax + addl %edx, %ebp + movl 52(%esp), %edx + xorl %ebx, %edi + leal 1518500249(%ebp,%edx,1),%ebp + addl %ebp, %edi + + movl %edi, %ebp + movl %eax, %edx + roll $5, %ebp + xorl %ecx, %edx + andl %esi, %edx + rorl $2, %esi + addl %ebx, %ebp + movl 56(%esp), %ebx + xorl %ecx, %edx + leal 1518500249(%ebp,%ebx,1),%ebp + addl %ebp, %edx + + movl %edx, %ebp + movl %esi, %ebx + roll $5, %ebp + xorl %eax, %ebx + andl %edi, %ebx + rorl $2, %edi + addl %ecx, %ebp + movl 60(%esp), %ecx + xorl %eax, %ebx + leal 1518500249(%ebp,%ecx,1),%ebp + addl %ebp, %ebx + + movl 8(%esp), %ecx + movl %edi, %ebp + xorl (%esp), %ecx + xorl %esi, %ebp + xorl 32(%esp), %ecx + andl %edx, %ebp + xorl 52(%esp), %ecx + rorl $2, %edx + xorl %esi, %ebp +.byte 209 +.byte 193 + movl %ecx, (%esp) + leal 1518500249(%ecx,%eax,1),%ecx + movl %ebx, %eax + addl %ebp, %ecx + roll $5, %eax + addl %eax, %ecx + + movl 12(%esp), %eax + movl %edx, %ebp + xorl 4(%esp), %eax + xorl %edi, %ebp + xorl 36(%esp), %eax + andl %ebx, %ebp + xorl 56(%esp), %eax + rorl $2, %ebx + xorl %edi, %ebp +.byte 209 +.byte 192 + movl %eax, 4(%esp) + leal 1518500249(%eax,%esi,1),%eax + movl %ecx, %esi + addl %ebp, %eax + roll $5, %esi + addl %esi, %eax + + movl 16(%esp), %esi + movl %ebx, %ebp + xorl 8(%esp), %esi + xorl %edx, %ebp + xorl 40(%esp), %esi + andl %ecx, %ebp + xorl 60(%esp), %esi + rorl $2, %ecx + xorl %edx, %ebp +.byte 209 +.byte 198 + movl %esi, 8(%esp) + leal 1518500249(%esi,%edi,1),%esi + movl %eax, %edi + addl %ebp, %esi + roll $5, %edi + addl %edi, %esi + + movl 20(%esp), %edi + movl %ecx, %ebp + xorl 12(%esp), %edi + xorl %ebx, %ebp + xorl 44(%esp), %edi + andl %eax, %ebp + xorl (%esp), %edi + rorl $2, %eax + xorl %ebx, %ebp +.byte 209 +.byte 199 + movl %edi, 12(%esp) + leal 1518500249(%edi,%edx,1),%edi + movl %esi, %edx + addl %ebp, %edi + roll $5, %edx + addl %edx, %edi + + movl 16(%esp), %edx + movl %esi, %ebp + xorl 24(%esp), %edx + rorl $2, %esi + xorl 48(%esp), %edx + xorl %eax, %ebp + xorl 4(%esp), %edx + xorl %ecx, %ebp +.byte 209 +.byte 194 + movl %edx, 16(%esp) + leal 1859775393(%edx,%ebx,1),%edx + movl %edi, %ebx + roll $5, %ebx + addl %ebp, %edx + addl %ebx, %edx + + movl 20(%esp), %ebx + movl %edi, %ebp + xorl 28(%esp), %ebx + rorl $2, %edi + xorl 52(%esp), %ebx + xorl %esi, %ebp + xorl 8(%esp), %ebx + xorl %eax, %ebp +.byte 209 +.byte 195 + movl %ebx, 20(%esp) + leal 1859775393(%ebx,%ecx,1),%ebx + movl %edx, %ecx + roll $5, %ecx + addl %ebp, %ebx + addl %ecx, %ebx + + movl 24(%esp), %ecx + movl %edx, %ebp + xorl 32(%esp), %ecx + rorl $2, %edx + xorl 56(%esp), %ecx + xorl %edi, %ebp + xorl 12(%esp), %ecx + xorl %esi, %ebp +.byte 209 +.byte 193 + movl %ecx, 24(%esp) + leal 1859775393(%ecx,%eax,1),%ecx + movl %ebx, %eax + roll $5, %eax + addl %ebp, %ecx + addl %eax, %ecx + + movl 28(%esp), %eax + movl %ebx, %ebp + xorl 36(%esp), %eax + rorl $2, %ebx + xorl 60(%esp), %eax + xorl %edx, %ebp + xorl 16(%esp), %eax + xorl %edi, %ebp +.byte 209 +.byte 192 + movl %eax, 28(%esp) + leal 1859775393(%eax,%esi,1),%eax + movl %ecx, %esi + roll $5, %esi + addl %ebp, %eax + addl %esi, %eax + + movl 32(%esp), %esi + movl %ecx, %ebp + xorl 40(%esp), %esi + rorl $2, %ecx + xorl (%esp), %esi + xorl %ebx, %ebp + xorl 20(%esp), %esi + xorl %edx, %ebp +.byte 209 +.byte 198 + movl %esi, 32(%esp) + leal 1859775393(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi + addl %ebp, %esi + addl %edi, %esi + + movl 36(%esp), %edi + movl %eax, %ebp + xorl 44(%esp), %edi + rorl $2, %eax + xorl 4(%esp), %edi + xorl %ecx, %ebp + xorl 24(%esp), %edi + xorl %ebx, %ebp +.byte 209 +.byte 199 + movl %edi, 36(%esp) + leal 1859775393(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx + addl %ebp, %edi + addl %edx, %edi + + movl 40(%esp), %edx + movl %esi, %ebp + xorl 48(%esp), %edx + rorl $2, %esi + xorl 8(%esp), %edx + xorl %eax, %ebp + xorl 28(%esp), %edx + xorl %ecx, %ebp +.byte 209 +.byte 194 + movl %edx, 40(%esp) + leal 1859775393(%edx,%ebx,1),%edx + movl %edi, %ebx + roll $5, %ebx + addl %ebp, %edx + addl %ebx, %edx + + movl 44(%esp), %ebx + movl %edi, %ebp + xorl 52(%esp), %ebx + rorl $2, %edi + xorl 12(%esp), %ebx + xorl %esi, %ebp + xorl 32(%esp), %ebx + xorl %eax, %ebp +.byte 209 +.byte 195 + movl %ebx, 44(%esp) + leal 1859775393(%ebx,%ecx,1),%ebx + movl %edx, %ecx + roll $5, %ecx + addl %ebp, %ebx + addl %ecx, %ebx + + movl 48(%esp), %ecx + movl %edx, %ebp + xorl 56(%esp), %ecx + rorl $2, %edx + xorl 16(%esp), %ecx + xorl %edi, %ebp + xorl 36(%esp), %ecx + xorl %esi, %ebp +.byte 209 +.byte 193 + movl %ecx, 48(%esp) + leal 1859775393(%ecx,%eax,1),%ecx + movl %ebx, %eax + roll $5, %eax + addl %ebp, %ecx + addl %eax, %ecx + + movl 52(%esp), %eax + movl %ebx, %ebp + xorl 60(%esp), %eax + rorl $2, %ebx + xorl 20(%esp), %eax + xorl %edx, %ebp + xorl 40(%esp), %eax + xorl %edi, %ebp +.byte 209 +.byte 192 + movl %eax, 52(%esp) + leal 1859775393(%eax,%esi,1),%eax + movl %ecx, %esi + roll $5, %esi + addl %ebp, %eax + addl %esi, %eax + + movl 56(%esp), %esi + movl %ecx, %ebp + xorl (%esp), %esi + rorl $2, %ecx + xorl 24(%esp), %esi + xorl %ebx, %ebp + xorl 44(%esp), %esi + xorl %edx, %ebp +.byte 209 +.byte 198 + movl %esi, 56(%esp) + leal 1859775393(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi + addl %ebp, %esi + addl %edi, %esi + + movl 60(%esp), %edi + movl %eax, %ebp + xorl 4(%esp), %edi + rorl $2, %eax + xorl 28(%esp), %edi + xorl %ecx, %ebp + xorl 48(%esp), %edi + xorl %ebx, %ebp +.byte 209 +.byte 199 + movl %edi, 60(%esp) + leal 1859775393(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx + addl %ebp, %edi + addl %edx, %edi + + movl (%esp), %edx + movl %esi, %ebp + xorl 8(%esp), %edx + rorl $2, %esi + xorl 32(%esp), %edx + xorl %eax, %ebp + xorl 52(%esp), %edx + xorl %ecx, %ebp +.byte 209 +.byte 194 + movl %edx, (%esp) + leal 1859775393(%edx,%ebx,1),%edx + movl %edi, %ebx + roll $5, %ebx + addl %ebp, %edx + addl %ebx, %edx + + movl 4(%esp), %ebx + movl %edi, %ebp + xorl 12(%esp), %ebx + rorl $2, %edi + xorl 36(%esp), %ebx + xorl %esi, %ebp + xorl 56(%esp), %ebx + xorl %eax, %ebp +.byte 209 +.byte 195 + movl %ebx, 4(%esp) + leal 1859775393(%ebx,%ecx,1),%ebx + movl %edx, %ecx + roll $5, %ecx + addl %ebp, %ebx + addl %ecx, %ebx + + movl 8(%esp), %ecx + movl %edx, %ebp + xorl 16(%esp), %ecx + rorl $2, %edx + xorl 40(%esp), %ecx + xorl %edi, %ebp + xorl 60(%esp), %ecx + xorl %esi, %ebp +.byte 209 +.byte 193 + movl %ecx, 8(%esp) + leal 1859775393(%ecx,%eax,1),%ecx + movl %ebx, %eax + roll $5, %eax + addl %ebp, %ecx + addl %eax, %ecx + + movl 12(%esp), %eax + movl %ebx, %ebp + xorl 20(%esp), %eax + rorl $2, %ebx + xorl 44(%esp), %eax + xorl %edx, %ebp + xorl (%esp), %eax + xorl %edi, %ebp +.byte 209 +.byte 192 + movl %eax, 12(%esp) + leal 1859775393(%eax,%esi,1),%eax + movl %ecx, %esi + roll $5, %esi + addl %ebp, %eax + addl %esi, %eax + + movl 16(%esp), %esi + movl %ecx, %ebp + xorl 24(%esp), %esi + rorl $2, %ecx + xorl 48(%esp), %esi + xorl %ebx, %ebp + xorl 4(%esp), %esi + xorl %edx, %ebp +.byte 209 +.byte 198 + movl %esi, 16(%esp) + leal 1859775393(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi + addl %ebp, %esi + addl %edi, %esi + + movl 20(%esp), %edi + movl %eax, %ebp + xorl 28(%esp), %edi + rorl $2, %eax + xorl 52(%esp), %edi + xorl %ecx, %ebp + xorl 8(%esp), %edi + xorl %ebx, %ebp +.byte 209 +.byte 199 + movl %edi, 20(%esp) + leal 1859775393(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx + addl %ebp, %edi + addl %edx, %edi + + movl 24(%esp), %edx + movl %esi, %ebp + xorl 32(%esp), %edx + rorl $2, %esi + xorl 56(%esp), %edx + xorl %eax, %ebp + xorl 12(%esp), %edx + xorl %ecx, %ebp +.byte 209 +.byte 194 + movl %edx, 24(%esp) + leal 1859775393(%edx,%ebx,1),%edx + movl %edi, %ebx + roll $5, %ebx + addl %ebp, %edx + addl %ebx, %edx + + movl 28(%esp), %ebx + movl %edi, %ebp + xorl 36(%esp), %ebx + rorl $2, %edi + xorl 60(%esp), %ebx + xorl %esi, %ebp + xorl 16(%esp), %ebx + xorl %eax, %ebp +.byte 209 +.byte 195 + movl %ebx, 28(%esp) + leal 1859775393(%ebx,%ecx,1),%ebx + movl %edx, %ecx + roll $5, %ecx + addl %ebp, %ebx + addl %ecx, %ebx + + movl 32(%esp), %ecx + movl %edx, %ebp + xorl 40(%esp), %ecx + orl %edi, %ebp + xorl (%esp), %ecx + andl %esi, %ebp + xorl 20(%esp), %ecx +.byte 209 +.byte 193 + movl %ecx, 32(%esp) + leal 2400959708(%ecx,%eax,1),%ecx + movl %edx, %eax + rorl $2, %edx + andl %edi, %eax + orl %eax, %ebp + movl %ebx, %eax + roll $5, %eax + addl %eax, %ebp + addl %ebp, %ecx + + movl 36(%esp), %eax + movl %ebx, %ebp + xorl 44(%esp), %eax + orl %edx, %ebp + xorl 4(%esp), %eax + andl %edi, %ebp + xorl 24(%esp), %eax +.byte 209 +.byte 192 + movl %eax, 36(%esp) + leal 2400959708(%eax,%esi,1),%eax + movl %ebx, %esi + rorl $2, %ebx + andl %edx, %esi + orl %esi, %ebp + movl %ecx, %esi + roll $5, %esi + addl %esi, %ebp + addl %ebp, %eax + + movl 40(%esp), %esi + movl %ecx, %ebp + xorl 48(%esp), %esi + orl %ebx, %ebp + xorl 8(%esp), %esi + andl %edx, %ebp + xorl 28(%esp), %esi +.byte 209 +.byte 198 + movl %esi, 40(%esp) + leal 2400959708(%esi,%edi,1),%esi + movl %ecx, %edi + rorl $2, %ecx + andl %ebx, %edi + orl %edi, %ebp + movl %eax, %edi + roll $5, %edi + addl %edi, %ebp + addl %ebp, %esi + + movl 44(%esp), %edi + movl %eax, %ebp + xorl 52(%esp), %edi + orl %ecx, %ebp + xorl 12(%esp), %edi + andl %ebx, %ebp + xorl 32(%esp), %edi +.byte 209 +.byte 199 + movl %edi, 44(%esp) + leal 2400959708(%edi,%edx,1),%edi + movl %eax, %edx + rorl $2, %eax + andl %ecx, %edx + orl %edx, %ebp + movl %esi, %edx + roll $5, %edx + addl %edx, %ebp + addl %ebp, %edi + + movl 48(%esp), %edx + movl %esi, %ebp + xorl 56(%esp), %edx + orl %eax, %ebp + xorl 16(%esp), %edx + andl %ecx, %ebp + xorl 36(%esp), %edx +.byte 209 +.byte 194 + movl %edx, 48(%esp) + leal 2400959708(%edx,%ebx,1),%edx + movl %esi, %ebx + rorl $2, %esi + andl %eax, %ebx + orl %ebx, %ebp + movl %edi, %ebx + roll $5, %ebx + addl %ebx, %ebp + addl %ebp, %edx + + movl 52(%esp), %ebx + movl %edi, %ebp + xorl 60(%esp), %ebx + orl %esi, %ebp + xorl 20(%esp), %ebx + andl %eax, %ebp + xorl 40(%esp), %ebx +.byte 209 +.byte 195 + movl %ebx, 52(%esp) + leal 2400959708(%ebx,%ecx,1),%ebx + movl %edi, %ecx + rorl $2, %edi + andl %esi, %ecx + orl %ecx, %ebp + movl %edx, %ecx + roll $5, %ecx + addl %ecx, %ebp + addl %ebp, %ebx + + movl 56(%esp), %ecx + movl %edx, %ebp + xorl (%esp), %ecx + orl %edi, %ebp + xorl 24(%esp), %ecx + andl %esi, %ebp + xorl 44(%esp), %ecx +.byte 209 +.byte 193 + movl %ecx, 56(%esp) + leal 2400959708(%ecx,%eax,1),%ecx + movl %edx, %eax + rorl $2, %edx + andl %edi, %eax + orl %eax, %ebp + movl %ebx, %eax + roll $5, %eax + addl %eax, %ebp + addl %ebp, %ecx + + movl 60(%esp), %eax + movl %ebx, %ebp + xorl 4(%esp), %eax + orl %edx, %ebp + xorl 28(%esp), %eax + andl %edi, %ebp + xorl 48(%esp), %eax +.byte 209 +.byte 192 + movl %eax, 60(%esp) + leal 2400959708(%eax,%esi,1),%eax + movl %ebx, %esi + rorl $2, %ebx + andl %edx, %esi + orl %esi, %ebp + movl %ecx, %esi + roll $5, %esi + addl %esi, %ebp + addl %ebp, %eax + + movl (%esp), %esi + movl %ecx, %ebp + xorl 8(%esp), %esi + orl %ebx, %ebp + xorl 32(%esp), %esi + andl %edx, %ebp + xorl 52(%esp), %esi +.byte 209 +.byte 198 + movl %esi, (%esp) + leal 2400959708(%esi,%edi,1),%esi + movl %ecx, %edi + rorl $2, %ecx + andl %ebx, %edi + orl %edi, %ebp + movl %eax, %edi + roll $5, %edi + addl %edi, %ebp + addl %ebp, %esi + + movl 4(%esp), %edi + movl %eax, %ebp + xorl 12(%esp), %edi + orl %ecx, %ebp + xorl 36(%esp), %edi + andl %ebx, %ebp + xorl 56(%esp), %edi +.byte 209 +.byte 199 + movl %edi, 4(%esp) + leal 2400959708(%edi,%edx,1),%edi + movl %eax, %edx + rorl $2, %eax + andl %ecx, %edx + orl %edx, %ebp + movl %esi, %edx + roll $5, %edx + addl %edx, %ebp + addl %ebp, %edi + + movl 8(%esp), %edx + movl %esi, %ebp + xorl 16(%esp), %edx + orl %eax, %ebp + xorl 40(%esp), %edx + andl %ecx, %ebp + xorl 60(%esp), %edx +.byte 209 +.byte 194 + movl %edx, 8(%esp) + leal 2400959708(%edx,%ebx,1),%edx + movl %esi, %ebx + rorl $2, %esi + andl %eax, %ebx + orl %ebx, %ebp + movl %edi, %ebx + roll $5, %ebx + addl %ebx, %ebp + addl %ebp, %edx + + movl 12(%esp), %ebx + movl %edi, %ebp + xorl 20(%esp), %ebx + orl %esi, %ebp + xorl 44(%esp), %ebx + andl %eax, %ebp + xorl (%esp), %ebx +.byte 209 +.byte 195 + movl %ebx, 12(%esp) + leal 2400959708(%ebx,%ecx,1),%ebx + movl %edi, %ecx + rorl $2, %edi + andl %esi, %ecx + orl %ecx, %ebp + movl %edx, %ecx + roll $5, %ecx + addl %ecx, %ebp + addl %ebp, %ebx + + movl 16(%esp), %ecx + movl %edx, %ebp + xorl 24(%esp), %ecx + orl %edi, %ebp + xorl 48(%esp), %ecx + andl %esi, %ebp + xorl 4(%esp), %ecx +.byte 209 +.byte 193 + movl %ecx, 16(%esp) + leal 2400959708(%ecx,%eax,1),%ecx + movl %edx, %eax + rorl $2, %edx + andl %edi, %eax + orl %eax, %ebp + movl %ebx, %eax + roll $5, %eax + addl %eax, %ebp + addl %ebp, %ecx + + movl 20(%esp), %eax + movl %ebx, %ebp + xorl 28(%esp), %eax + orl %edx, %ebp + xorl 52(%esp), %eax + andl %edi, %ebp + xorl 8(%esp), %eax +.byte 209 +.byte 192 + movl %eax, 20(%esp) + leal 2400959708(%eax,%esi,1),%eax + movl %ebx, %esi + rorl $2, %ebx + andl %edx, %esi + orl %esi, %ebp + movl %ecx, %esi + roll $5, %esi + addl %esi, %ebp + addl %ebp, %eax + + movl 24(%esp), %esi + movl %ecx, %ebp + xorl 32(%esp), %esi + orl %ebx, %ebp + xorl 56(%esp), %esi + andl %edx, %ebp + xorl 12(%esp), %esi +.byte 209 +.byte 198 + movl %esi, 24(%esp) + leal 2400959708(%esi,%edi,1),%esi + movl %ecx, %edi + rorl $2, %ecx + andl %ebx, %edi + orl %edi, %ebp + movl %eax, %edi + roll $5, %edi + addl %edi, %ebp + addl %ebp, %esi + + movl 28(%esp), %edi + movl %eax, %ebp + xorl 36(%esp), %edi + orl %ecx, %ebp + xorl 60(%esp), %edi + andl %ebx, %ebp + xorl 16(%esp), %edi +.byte 209 +.byte 199 + movl %edi, 28(%esp) + leal 2400959708(%edi,%edx,1),%edi + movl %eax, %edx + rorl $2, %eax + andl %ecx, %edx + orl %edx, %ebp + movl %esi, %edx + roll $5, %edx + addl %edx, %ebp + addl %ebp, %edi + + movl 32(%esp), %edx + movl %esi, %ebp + xorl 40(%esp), %edx + orl %eax, %ebp + xorl (%esp), %edx + andl %ecx, %ebp + xorl 20(%esp), %edx +.byte 209 +.byte 194 + movl %edx, 32(%esp) + leal 2400959708(%edx,%ebx,1),%edx + movl %esi, %ebx + rorl $2, %esi + andl %eax, %ebx + orl %ebx, %ebp + movl %edi, %ebx + roll $5, %ebx + addl %ebx, %ebp + addl %ebp, %edx + + movl 36(%esp), %ebx + movl %edi, %ebp + xorl 44(%esp), %ebx + orl %esi, %ebp + xorl 4(%esp), %ebx + andl %eax, %ebp + xorl 24(%esp), %ebx +.byte 209 +.byte 195 + movl %ebx, 36(%esp) + leal 2400959708(%ebx,%ecx,1),%ebx + movl %edi, %ecx + rorl $2, %edi + andl %esi, %ecx + orl %ecx, %ebp + movl %edx, %ecx + roll $5, %ecx + addl %ecx, %ebp + addl %ebp, %ebx + + movl 40(%esp), %ecx + movl %edx, %ebp + xorl 48(%esp), %ecx + orl %edi, %ebp + xorl 8(%esp), %ecx + andl %esi, %ebp + xorl 28(%esp), %ecx +.byte 209 +.byte 193 + movl %ecx, 40(%esp) + leal 2400959708(%ecx,%eax,1),%ecx + movl %edx, %eax + rorl $2, %edx + andl %edi, %eax + orl %eax, %ebp + movl %ebx, %eax + roll $5, %eax + addl %eax, %ebp + addl %ebp, %ecx + + movl 44(%esp), %eax + movl %ebx, %ebp + xorl 52(%esp), %eax + orl %edx, %ebp + xorl 12(%esp), %eax + andl %edi, %ebp + xorl 32(%esp), %eax +.byte 209 +.byte 192 + movl %eax, 44(%esp) + leal 2400959708(%eax,%esi,1),%eax + movl %ebx, %esi + rorl $2, %ebx + andl %edx, %esi + orl %esi, %ebp + movl %ecx, %esi + roll $5, %esi + addl %esi, %ebp + addl %ebp, %eax + + movl 48(%esp), %esi + movl %ecx, %ebp + xorl 56(%esp), %esi + rorl $2, %ecx + xorl 16(%esp), %esi + xorl %ebx, %ebp + xorl 36(%esp), %esi + xorl %edx, %ebp +.byte 209 +.byte 198 + movl %esi, 48(%esp) + leal 3395469782(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi + addl %ebp, %esi + addl %edi, %esi + + movl 52(%esp), %edi + movl %eax, %ebp + xorl 60(%esp), %edi + rorl $2, %eax + xorl 20(%esp), %edi + xorl %ecx, %ebp + xorl 40(%esp), %edi + xorl %ebx, %ebp +.byte 209 +.byte 199 + movl %edi, 52(%esp) + leal 3395469782(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx + addl %ebp, %edi + addl %edx, %edi + + movl 56(%esp), %edx + movl %esi, %ebp + xorl (%esp), %edx + rorl $2, %esi + xorl 24(%esp), %edx + xorl %eax, %ebp + xorl 44(%esp), %edx + xorl %ecx, %ebp +.byte 209 +.byte 194 + movl %edx, 56(%esp) + leal 3395469782(%edx,%ebx,1),%edx + movl %edi, %ebx + roll $5, %ebx + addl %ebp, %edx + addl %ebx, %edx + + movl 60(%esp), %ebx + movl %edi, %ebp + xorl 4(%esp), %ebx + rorl $2, %edi + xorl 28(%esp), %ebx + xorl %esi, %ebp + xorl 48(%esp), %ebx + xorl %eax, %ebp +.byte 209 +.byte 195 + movl %ebx, 60(%esp) + leal 3395469782(%ebx,%ecx,1),%ebx + movl %edx, %ecx + roll $5, %ecx + addl %ebp, %ebx + addl %ecx, %ebx + + movl (%esp), %ecx + movl %edx, %ebp + xorl 8(%esp), %ecx + rorl $2, %edx + xorl 32(%esp), %ecx + xorl %edi, %ebp + xorl 52(%esp), %ecx + xorl %esi, %ebp +.byte 209 +.byte 193 + movl %ecx, (%esp) + leal 3395469782(%ecx,%eax,1),%ecx + movl %ebx, %eax + roll $5, %eax + addl %ebp, %ecx + addl %eax, %ecx + + movl 4(%esp), %eax + movl %ebx, %ebp + xorl 12(%esp), %eax + rorl $2, %ebx + xorl 36(%esp), %eax + xorl %edx, %ebp + xorl 56(%esp), %eax + xorl %edi, %ebp +.byte 209 +.byte 192 + movl %eax, 4(%esp) + leal 3395469782(%eax,%esi,1),%eax + movl %ecx, %esi + roll $5, %esi + addl %ebp, %eax + addl %esi, %eax + + movl 8(%esp), %esi + movl %ecx, %ebp + xorl 16(%esp), %esi + rorl $2, %ecx + xorl 40(%esp), %esi + xorl %ebx, %ebp + xorl 60(%esp), %esi + xorl %edx, %ebp +.byte 209 +.byte 198 + movl %esi, 8(%esp) + leal 3395469782(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi + addl %ebp, %esi + addl %edi, %esi + + movl 12(%esp), %edi + movl %eax, %ebp + xorl 20(%esp), %edi + rorl $2, %eax + xorl 44(%esp), %edi + xorl %ecx, %ebp + xorl (%esp), %edi + xorl %ebx, %ebp +.byte 209 +.byte 199 + movl %edi, 12(%esp) + leal 3395469782(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx + addl %ebp, %edi + addl %edx, %edi + + movl 16(%esp), %edx + movl %esi, %ebp + xorl 24(%esp), %edx + rorl $2, %esi + xorl 48(%esp), %edx + xorl %eax, %ebp + xorl 4(%esp), %edx + xorl %ecx, %ebp +.byte 209 +.byte 194 + movl %edx, 16(%esp) + leal 3395469782(%edx,%ebx,1),%edx + movl %edi, %ebx + roll $5, %ebx + addl %ebp, %edx + addl %ebx, %edx + + movl 20(%esp), %ebx + movl %edi, %ebp + xorl 28(%esp), %ebx + rorl $2, %edi + xorl 52(%esp), %ebx + xorl %esi, %ebp + xorl 8(%esp), %ebx + xorl %eax, %ebp +.byte 209 +.byte 195 + movl %ebx, 20(%esp) + leal 3395469782(%ebx,%ecx,1),%ebx + movl %edx, %ecx + roll $5, %ecx + addl %ebp, %ebx + addl %ecx, %ebx + + movl 24(%esp), %ecx + movl %edx, %ebp + xorl 32(%esp), %ecx + rorl $2, %edx + xorl 56(%esp), %ecx + xorl %edi, %ebp + xorl 12(%esp), %ecx + xorl %esi, %ebp +.byte 209 +.byte 193 + movl %ecx, 24(%esp) + leal 3395469782(%ecx,%eax,1),%ecx + movl %ebx, %eax + roll $5, %eax + addl %ebp, %ecx + addl %eax, %ecx + + movl 28(%esp), %eax + movl %ebx, %ebp + xorl 36(%esp), %eax + rorl $2, %ebx + xorl 60(%esp), %eax + xorl %edx, %ebp + xorl 16(%esp), %eax + xorl %edi, %ebp +.byte 209 +.byte 192 + movl %eax, 28(%esp) + leal 3395469782(%eax,%esi,1),%eax + movl %ecx, %esi + roll $5, %esi + addl %ebp, %eax + addl %esi, %eax + + movl 32(%esp), %esi + movl %ecx, %ebp + xorl 40(%esp), %esi + rorl $2, %ecx + xorl (%esp), %esi + xorl %ebx, %ebp + xorl 20(%esp), %esi + xorl %edx, %ebp +.byte 209 +.byte 198 + movl %esi, 32(%esp) + leal 3395469782(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi + addl %ebp, %esi + addl %edi, %esi + + movl 36(%esp), %edi + movl %eax, %ebp + xorl 44(%esp), %edi + rorl $2, %eax + xorl 4(%esp), %edi + xorl %ecx, %ebp + xorl 24(%esp), %edi + xorl %ebx, %ebp +.byte 209 +.byte 199 + movl %edi, 36(%esp) + leal 3395469782(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx + addl %ebp, %edi + addl %edx, %edi + + movl 40(%esp), %edx + movl %esi, %ebp + xorl 48(%esp), %edx + rorl $2, %esi + xorl 8(%esp), %edx + xorl %eax, %ebp + xorl 28(%esp), %edx + xorl %ecx, %ebp +.byte 209 +.byte 194 + movl %edx, 40(%esp) + leal 3395469782(%edx,%ebx,1),%edx + movl %edi, %ebx + roll $5, %ebx + addl %ebp, %edx + addl %ebx, %edx + + movl 44(%esp), %ebx + movl %edi, %ebp + xorl 52(%esp), %ebx + rorl $2, %edi + xorl 12(%esp), %ebx + xorl %esi, %ebp + xorl 32(%esp), %ebx + xorl %eax, %ebp +.byte 209 +.byte 195 + movl %ebx, 44(%esp) + leal 3395469782(%ebx,%ecx,1),%ebx + movl %edx, %ecx + roll $5, %ecx + addl %ebp, %ebx + addl %ecx, %ebx + + movl 48(%esp), %ecx + movl %edx, %ebp + xorl 56(%esp), %ecx + rorl $2, %edx + xorl 16(%esp), %ecx + xorl %edi, %ebp + xorl 36(%esp), %ecx + xorl %esi, %ebp +.byte 209 +.byte 193 + movl %ecx, 48(%esp) + leal 3395469782(%ecx,%eax,1),%ecx + movl %ebx, %eax + roll $5, %eax + addl %ebp, %ecx + addl %eax, %ecx + + movl 52(%esp), %eax + movl %ebx, %ebp + xorl 60(%esp), %eax + rorl $2, %ebx + xorl 20(%esp), %eax + xorl %edx, %ebp + xorl 40(%esp), %eax + xorl %edi, %ebp +.byte 209 +.byte 192 + movl %eax, 52(%esp) + leal 3395469782(%eax,%esi,1),%eax + movl %ecx, %esi + roll $5, %esi + addl %ebp, %eax + addl %esi, %eax + + movl 56(%esp), %esi + movl %ecx, %ebp + xorl (%esp), %esi + rorl $2, %ecx + xorl 24(%esp), %esi + xorl %ebx, %ebp + xorl 44(%esp), %esi + xorl %edx, %ebp +.byte 209 +.byte 198 + movl %esi, 56(%esp) + leal 3395469782(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi + addl %ebp, %esi + addl %edi, %esi + + movl 60(%esp), %edi + movl %eax, %ebp + xorl 4(%esp), %edi + rorl $2, %eax + xorl 28(%esp), %edi + xorl %ecx, %ebp + xorl 48(%esp), %edi + xorl %ebx, %ebp +.byte 209 +.byte 199 + movl %edi, 60(%esp) + leal 3395469782(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx + addl %ebp, %edi + addl %edx, %edi + + + movl 128(%esp), %ebp + movl 12(%ebp), %edx + addl %ecx, %edx + movl 4(%ebp), %ecx + addl %esi, %ecx + movl %eax, %esi + movl (%ebp), %eax + movl %edx, 12(%ebp) + addl %edi, %eax + movl 16(%ebp), %edi + addl %ebx, %edi + movl 8(%ebp), %ebx + addl %esi, %ebx + movl %eax, (%ebp) + movl 132(%esp), %esi + movl %ebx, 8(%ebp) + addl $64, %esi + movl 68(%esp), %eax + movl %edi, 16(%ebp) + cmpl %eax, %esi + movl %ecx, 4(%ebp) + jl .L000start + addl $108, %esp + popl %edi + popl %ebx + popl %ebp + popl %esi + ret +.L_sha1_block_asm_data_order_end: + .size sha1_block_asm_data_order,.L_sha1_block_asm_data_order_end-sha1_block_asm_data_order +.ident "desasm.pl" +.text + .align 16 +.globl sha1_block_asm_host_order + .type sha1_block_asm_host_order,@function +sha1_block_asm_host_order: + movl 12(%esp), %ecx + pushl %esi + sall $6, %ecx + movl 12(%esp), %esi + pushl %ebp + addl %esi, %ecx + pushl %ebx + movl 16(%esp), %ebp + pushl %edi + movl 12(%ebp), %edx + subl $108, %esp + movl 16(%ebp), %edi + movl 8(%ebp), %ebx + movl %ecx, 68(%esp) + + movl (%esi), %eax + movl 4(%esi), %ecx + movl %eax, (%esp) + movl %ecx, 4(%esp) + movl 8(%esi), %eax + movl 12(%esi), %ecx + movl %eax, 8(%esp) + movl %ecx, 12(%esp) + movl 16(%esi), %eax + movl 20(%esi), %ecx + movl %eax, 16(%esp) + movl %ecx, 20(%esp) + movl 24(%esi), %eax + movl 28(%esi), %ecx + movl %eax, 24(%esp) + movl %ecx, 28(%esp) + movl 32(%esi), %eax + movl 36(%esi), %ecx + movl %eax, 32(%esp) + movl %ecx, 36(%esp) + movl 40(%esi), %eax + movl 44(%esi), %ecx + movl %eax, 40(%esp) + movl %ecx, 44(%esp) + movl 48(%esi), %eax + movl 52(%esi), %ecx + movl %eax, 48(%esp) + movl %ecx, 52(%esp) + movl 56(%esi), %eax + movl 60(%esi), %ecx + movl %eax, 56(%esp) + movl %ecx, 60(%esp) + jmp .L001shortcut +.L_sha1_block_asm_host_order_end: + .size sha1_block_asm_host_order,.L_sha1_block_asm_host_order_end-sha1_block_asm_host_order +.ident "desasm.pl" diff --git a/fips/sha1/fingerprint.sha1 b/fips/sha1/fingerprint.sha1 new file mode 100644 index 0000000000..c7fd5fbe80 --- /dev/null +++ b/fips/sha1/fingerprint.sha1 @@ -0,0 +1,5 @@ +HMAC-SHA1(fips_sha1dgst.c)= 10575600a9540eb15188a7d3b0b031e60aedbc18 +HMAC-SHA1(fips_sha1_selftest.c)= 98910a0c85eff1688bd7adb23e738dc75b39546e +HMAC-SHA1(asm/sx86-elf.s)= 6286cba0ea3b071e67ab5c1e607d1387de6a871d +HMAC-SHA1(fips_sha_locl.h)= 199ceca9016ba5514997ce1fcd22be7d4f66e9b5 +HMAC-SHA1(fips_md32_common.h)= 4dd5d27e9bedbbaab6c6c5536b254e040137471e diff --git a/fips/sha1/fips_md32_common.h b/fips/sha1/fips_md32_common.h new file mode 100644 index 0000000000..573850b122 --- /dev/null +++ b/fips/sha1/fips_md32_common.h @@ -0,0 +1,637 @@ +/* crypto/md32_common.h */ +/* ==================================================================== + * Copyright (c) 1999-2002 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. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* + * This is a generic 32 bit "collector" for message digest algorithms. + * Whenever needed it collects input character stream into chunks of + * 32 bit values and invokes a block function that performs actual hash + * calculations. + * + * Porting guide. + * + * Obligatory macros: + * + * DATA_ORDER_IS_BIG_ENDIAN or DATA_ORDER_IS_LITTLE_ENDIAN + * this macro defines byte order of input stream. + * HASH_CBLOCK + * size of a unit chunk HASH_BLOCK operates on. + * HASH_LONG + * has to be at lest 32 bit wide, if it's wider, then + * HASH_LONG_LOG2 *has to* be defined along + * HASH_CTX + * context structure that at least contains following + * members: + * typedef struct { + * ... + * HASH_LONG Nl,Nh; + * HASH_LONG data[HASH_LBLOCK]; + * int num; + * ... + * } HASH_CTX; + * HASH_UPDATE + * name of "Update" function, implemented here. + * HASH_TRANSFORM + * name of "Transform" function, implemented here. + * HASH_FINAL + * name of "Final" function, implemented here. + * HASH_BLOCK_HOST_ORDER + * name of "block" function treating *aligned* input message + * in host byte order, implemented externally. + * HASH_BLOCK_DATA_ORDER + * name of "block" function treating *unaligned* input message + * in original (data) byte order, implemented externally (it + * actually is optional if data and host are of the same + * "endianess"). + * HASH_MAKE_STRING + * macro convering context variables to an ASCII hash string. + * + * Optional macros: + * + * B_ENDIAN or L_ENDIAN + * defines host byte-order. + * HASH_LONG_LOG2 + * defaults to 2 if not states otherwise. + * HASH_LBLOCK + * assumed to be HASH_CBLOCK/4 if not stated otherwise. + * HASH_BLOCK_DATA_ORDER_ALIGNED + * alternative "block" function capable of treating + * aligned input message in original (data) order, + * implemented externally. + * + * MD5 example: + * + * #define DATA_ORDER_IS_LITTLE_ENDIAN + * + * #define HASH_LONG MD5_LONG + * #define HASH_LONG_LOG2 MD5_LONG_LOG2 + * #define HASH_CTX MD5_CTX + * #define HASH_CBLOCK MD5_CBLOCK + * #define HASH_LBLOCK MD5_LBLOCK + * #define HASH_UPDATE MD5_Update + * #define HASH_TRANSFORM MD5_Transform + * #define HASH_FINAL MD5_Final + * #define HASH_BLOCK_HOST_ORDER md5_block_host_order + * #define HASH_BLOCK_DATA_ORDER md5_block_data_order + * + * + */ + +#if !defined(DATA_ORDER_IS_BIG_ENDIAN) && !defined(DATA_ORDER_IS_LITTLE_ENDIAN) +#error "DATA_ORDER must be defined!" +#endif + +#ifndef HASH_CBLOCK +#error "HASH_CBLOCK must be defined!" +#endif +#ifndef HASH_LONG +#error "HASH_LONG must be defined!" +#endif +#ifndef HASH_CTX +#error "HASH_CTX must be defined!" +#endif + +#ifndef HASH_UPDATE +#error "HASH_UPDATE must be defined!" +#endif +#ifndef HASH_TRANSFORM +#error "HASH_TRANSFORM must be defined!" +#endif +#ifndef HASH_FINAL +#error "HASH_FINAL must be defined!" +#endif + +#ifndef HASH_BLOCK_HOST_ORDER +#error "HASH_BLOCK_HOST_ORDER must be defined!" +#endif + +#if 0 +/* + * Moved below as it's required only if HASH_BLOCK_DATA_ORDER_ALIGNED + * isn't defined. + */ +#ifndef HASH_BLOCK_DATA_ORDER +#error "HASH_BLOCK_DATA_ORDER must be defined!" +#endif +#endif + +#ifndef HASH_LBLOCK +#define HASH_LBLOCK (HASH_CBLOCK/4) +#endif + +#ifndef HASH_LONG_LOG2 +#define HASH_LONG_LOG2 2 +#endif + +/* + * Engage compiler specific rotate intrinsic function if available. + */ +#undef ROTATE +#ifndef PEDANTIC +# if 0 /* defined(_MSC_VER) */ +# define ROTATE(a,n) _lrotl(a,n) +# elif defined(__MWERKS__) +# if defined(__POWERPC__) +# define ROTATE(a,n) __rlwinm(a,n,0,31) +# elif defined(__MC68K__) + /* Motorola specific tweak. */ +# define ROTATE(a,n) ( n<24 ? __rol(a,n) : __ror(a,32-n) ) +# else +# define ROTATE(a,n) __rol(a,n) +# endif +# elif defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) + /* + * Some GNU C inline assembler templates. Note that these are + * rotates by *constant* number of bits! But that's exactly + * what we need here... + * + * + */ +# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) +# define ROTATE(a,n) ({ register unsigned int ret; \ + asm ( \ + "roll %1,%0" \ + : "=r"(ret) \ + : "I"(n), "0"(a) \ + : "cc"); \ + ret; \ + }) +# elif defined(__powerpc) || defined(__ppc) +# define ROTATE(a,n) ({ register unsigned int ret; \ + asm ( \ + "rlwinm %0,%1,%2,0,31" \ + : "=r"(ret) \ + : "r"(a), "I"(n)); \ + ret; \ + }) +# endif +# endif + +/* + * Engage compiler specific "fetch in reverse byte order" + * intrinsic function if available. + */ +# if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) + /* some GNU C inline assembler templates by */ +# if (defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)) && !defined(I386_ONLY) +# define BE_FETCH32(a) ({ register unsigned int l=(a);\ + asm ( \ + "bswapl %0" \ + : "=r"(l) : "0"(l)); \ + l; \ + }) +# elif defined(__powerpc) +# define LE_FETCH32(a) ({ register unsigned int l; \ + asm ( \ + "lwbrx %0,0,%1" \ + : "=r"(l) \ + : "r"(a)); \ + l; \ + }) + +# elif defined(__sparc) && defined(OPENSSL_SYS_ULTRASPARC) +# define LE_FETCH32(a) ({ register unsigned int l; \ + asm ( \ + "lda [%1]#ASI_PRIMARY_LITTLE,%0"\ + : "=r"(l) \ + : "r"(a)); \ + l; \ + }) +# endif +# endif +#endif /* PEDANTIC */ + +#if HASH_LONG_LOG2==2 /* Engage only if sizeof(HASH_LONG)== 4 */ +/* A nice byte order reversal from Wei Dai */ +#ifdef ROTATE +/* 5 instructions with rotate instruction, else 9 */ +#define REVERSE_FETCH32(a,l) ( \ + l=*(const HASH_LONG *)(a), \ + ((ROTATE(l,8)&0x00FF00FF)|(ROTATE((l&0x00FF00FF),24))) \ + ) +#else +/* 6 instructions with rotate instruction, else 8 */ +#define REVERSE_FETCH32(a,l) ( \ + l=*(const HASH_LONG *)(a), \ + l=(((l>>8)&0x00FF00FF)|((l&0x00FF00FF)<<8)), \ + ROTATE(l,16) \ + ) +/* + * Originally the middle line started with l=(((l&0xFF00FF00)>>8)|... + * It's rewritten as above for two reasons: + * - RISCs aren't good at long constants and have to explicitely + * compose 'em with several (well, usually 2) instructions in a + * register before performing the actual operation and (as you + * already realized:-) having same constant should inspire the + * compiler to permanently allocate the only register for it; + * - most modern CPUs have two ALUs, but usually only one has + * circuitry for shifts:-( this minor tweak inspires compiler + * to schedule shift instructions in a better way... + * + * + */ +#endif +#endif + +#ifndef ROTATE +#define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n)))) +#endif + +/* + * Make some obvious choices. E.g., HASH_BLOCK_DATA_ORDER_ALIGNED + * and HASH_BLOCK_HOST_ORDER ought to be the same if input data + * and host are of the same "endianess". It's possible to mask + * this with blank #define HASH_BLOCK_DATA_ORDER though... + * + * + */ +#if defined(B_ENDIAN) +# if defined(DATA_ORDER_IS_BIG_ENDIAN) +# if !defined(HASH_BLOCK_DATA_ORDER_ALIGNED) && HASH_LONG_LOG2==2 +# define HASH_BLOCK_DATA_ORDER_ALIGNED HASH_BLOCK_HOST_ORDER +# endif +# elif defined(DATA_ORDER_IS_LITTLE_ENDIAN) +# ifndef HOST_FETCH32 +# ifdef LE_FETCH32 +# define HOST_FETCH32(p,l) LE_FETCH32(p) +# elif defined(REVERSE_FETCH32) +# define HOST_FETCH32(p,l) REVERSE_FETCH32(p,l) +# endif +# endif +# endif +#elif defined(L_ENDIAN) +# if defined(DATA_ORDER_IS_LITTLE_ENDIAN) +# if !defined(HASH_BLOCK_DATA_ORDER_ALIGNED) && HASH_LONG_LOG2==2 +# define HASH_BLOCK_DATA_ORDER_ALIGNED HASH_BLOCK_HOST_ORDER +# endif +# elif defined(DATA_ORDER_IS_BIG_ENDIAN) +# ifndef HOST_FETCH32 +# ifdef BE_FETCH32 +# define HOST_FETCH32(p,l) BE_FETCH32(p) +# elif defined(REVERSE_FETCH32) +# define HOST_FETCH32(p,l) REVERSE_FETCH32(p,l) +# endif +# endif +# endif +#endif + +#if !defined(HASH_BLOCK_DATA_ORDER_ALIGNED) +#ifndef HASH_BLOCK_DATA_ORDER +#error "HASH_BLOCK_DATA_ORDER must be defined!" +#endif +#endif + +#if defined(DATA_ORDER_IS_BIG_ENDIAN) + +#define HOST_c2l(c,l) (l =(((unsigned long)(*((c)++)))<<24), \ + l|=(((unsigned long)(*((c)++)))<<16), \ + l|=(((unsigned long)(*((c)++)))<< 8), \ + l|=(((unsigned long)(*((c)++))) ), \ + l) +#define HOST_p_c2l(c,l,n) { \ + switch (n) { \ + case 0: l =((unsigned long)(*((c)++)))<<24; \ + case 1: l|=((unsigned long)(*((c)++)))<<16; \ + case 2: l|=((unsigned long)(*((c)++)))<< 8; \ + case 3: l|=((unsigned long)(*((c)++))); \ + } } +#define HOST_p_c2l_p(c,l,sc,len) { \ + switch (sc) { \ + case 0: l =((unsigned long)(*((c)++)))<<24; \ + if (--len == 0) break; \ + case 1: l|=((unsigned long)(*((c)++)))<<16; \ + if (--len == 0) break; \ + case 2: l|=((unsigned long)(*((c)++)))<< 8; \ + } } +/* NOTE the pointer is not incremented at the end of this */ +#define HOST_c2l_p(c,l,n) { \ + l=0; (c)+=n; \ + switch (n) { \ + case 3: l =((unsigned long)(*(--(c))))<< 8; \ + case 2: l|=((unsigned long)(*(--(c))))<<16; \ + case 1: l|=((unsigned long)(*(--(c))))<<24; \ + } } +#define HOST_l2c(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff), \ + l) + +#elif defined(DATA_ORDER_IS_LITTLE_ENDIAN) + +#define HOST_c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \ + l|=(((unsigned long)(*((c)++)))<< 8), \ + l|=(((unsigned long)(*((c)++)))<<16), \ + l|=(((unsigned long)(*((c)++)))<<24), \ + l) +#define HOST_p_c2l(c,l,n) { \ + switch (n) { \ + case 0: l =((unsigned long)(*((c)++))); \ + case 1: l|=((unsigned long)(*((c)++)))<< 8; \ + case 2: l|=((unsigned long)(*((c)++)))<<16; \ + case 3: l|=((unsigned long)(*((c)++)))<<24; \ + } } +#define HOST_p_c2l_p(c,l,sc,len) { \ + switch (sc) { \ + case 0: l =((unsigned long)(*((c)++))); \ + if (--len == 0) break; \ + case 1: l|=((unsigned long)(*((c)++)))<< 8; \ + if (--len == 0) break; \ + case 2: l|=((unsigned long)(*((c)++)))<<16; \ + } } +/* NOTE the pointer is not incremented at the end of this */ +#define HOST_c2l_p(c,l,n) { \ + l=0; (c)+=n; \ + switch (n) { \ + case 3: l =((unsigned long)(*(--(c))))<<16; \ + case 2: l|=((unsigned long)(*(--(c))))<< 8; \ + case 1: l|=((unsigned long)(*(--(c)))); \ + } } +#define HOST_l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24)&0xff), \ + l) + +#endif + +/* + * Time for some action:-) + */ + +int HASH_UPDATE (HASH_CTX *c, const void *data_, unsigned long len) + { + const unsigned char *data=data_; + register HASH_LONG * p; + register unsigned long l; + int sw,sc,ew,ec; + + if (len==0) return 1; + + l=(c->Nl+(len<<3))&0xffffffffL; + /* 95-05-24 eay Fixed a bug with the overflow handling, thanks to + * Wei Dai for pointing it out. */ + if (l < c->Nl) /* overflow */ + c->Nh++; + c->Nh+=(len>>29); + c->Nl=l; + + if (c->num != 0) + { + p=c->data; + sw=c->num>>2; + sc=c->num&0x03; + + if ((c->num+len) >= HASH_CBLOCK) + { + l=p[sw]; HOST_p_c2l(data,l,sc); p[sw++]=l; + for (; swnum); + c->num=0; + /* drop through and do the rest */ + } + else + { + c->num+=len; + if ((sc+len) < 4) /* ugly, add char's to a word */ + { + l=p[sw]; HOST_p_c2l_p(data,l,sc,len); p[sw]=l; + } + else + { + ew=(c->num>>2); + ec=(c->num&0x03); + if (sc) + l=p[sw]; + HOST_p_c2l(data,l,sc); + p[sw++]=l; + for (; sw < ew; sw++) + { + HOST_c2l(data,l); p[sw]=l; + } + if (ec) + { + HOST_c2l_p(data,l,ec); p[sw]=l; + } + } + return 1; + } + } + + sw=len/HASH_CBLOCK; + if (sw > 0) + { +#if defined(HASH_BLOCK_DATA_ORDER_ALIGNED) + /* + * Note that HASH_BLOCK_DATA_ORDER_ALIGNED gets defined + * only if sizeof(HASH_LONG)==4. + */ + if ((((unsigned long)data)%4) == 0) + { + /* data is properly aligned so that we can cast it: */ + HASH_BLOCK_DATA_ORDER_ALIGNED (c,(HASH_LONG *)data,sw); + sw*=HASH_CBLOCK; + data+=sw; + len-=sw; + } + else +#if !defined(HASH_BLOCK_DATA_ORDER) + while (sw--) + { + memcpy (p=c->data,data,HASH_CBLOCK); + HASH_BLOCK_DATA_ORDER_ALIGNED(c,p,1); + data+=HASH_CBLOCK; + len-=HASH_CBLOCK; + } +#endif +#endif +#if defined(HASH_BLOCK_DATA_ORDER) + { + HASH_BLOCK_DATA_ORDER(c,data,sw); + sw*=HASH_CBLOCK; + data+=sw; + len-=sw; + } +#endif + } + + if (len!=0) + { + p = c->data; + c->num = len; + ew=len>>2; /* words to copy */ + ec=len&0x03; + for (; ew; ew--,p++) + { + HOST_c2l(data,l); *p=l; + } + HOST_c2l_p(data,l,ec); + *p=l; + } + return 1; + } + + +void HASH_TRANSFORM (HASH_CTX *c, const unsigned char *data) + { +#if defined(HASH_BLOCK_DATA_ORDER_ALIGNED) + if ((((unsigned long)data)%4) == 0) + /* data is properly aligned so that we can cast it: */ + HASH_BLOCK_DATA_ORDER_ALIGNED (c,(HASH_LONG *)data,1); + else +#if !defined(HASH_BLOCK_DATA_ORDER) + { + memcpy (c->data,data,HASH_CBLOCK); + HASH_BLOCK_DATA_ORDER_ALIGNED (c,c->data,1); + } +#endif +#endif +#if defined(HASH_BLOCK_DATA_ORDER) + HASH_BLOCK_DATA_ORDER (c,data,1); +#endif + } + + +int HASH_FINAL (unsigned char *md, HASH_CTX *c) + { + register HASH_LONG *p; + register unsigned long l; + register int i,j; + static const unsigned char end[4]={0x80,0x00,0x00,0x00}; + const unsigned char *cp=end; + + /* c->num should definitly have room for at least one more byte. */ + p=c->data; + i=c->num>>2; + j=c->num&0x03; + +#if 0 + /* purify often complains about the following line as an + * Uninitialized Memory Read. While this can be true, the + * following p_c2l macro will reset l when that case is true. + * This is because j&0x03 contains the number of 'valid' bytes + * already in p[i]. If and only if j&0x03 == 0, the UMR will + * occur but this is also the only time p_c2l will do + * l= *(cp++) instead of l|= *(cp++) + * Many thanks to Alex Tang for pickup this + * 'potential bug' */ +#ifdef PURIFY + if (j==0) p[i]=0; /* Yeah, but that's not the way to fix it:-) */ +#endif + l=p[i]; +#else + l = (j==0) ? 0 : p[i]; +#endif + HOST_p_c2l(cp,l,j); p[i++]=l; /* i is the next 'undefined word' */ + + if (i>(HASH_LBLOCK-2)) /* save room for Nl and Nh */ + { + if (iNh; + p[HASH_LBLOCK-1]=c->Nl; +#elif defined(DATA_ORDER_IS_LITTLE_ENDIAN) + p[HASH_LBLOCK-2]=c->Nl; + p[HASH_LBLOCK-1]=c->Nh; +#endif + HASH_BLOCK_HOST_ORDER (c,p,1); + +#ifndef HASH_MAKE_STRING +#error "HASH_MAKE_STRING must be defined!" +#else + HASH_MAKE_STRING(c,md); +#endif + + c->num=0; + /* clear stuff, HASH_BLOCK may be leaving some stuff on the stack + * but I'm not worried :-) + OPENSSL_cleanse((void *)c,sizeof(HASH_CTX)); + */ + return 1; + } + +#ifndef MD32_REG_T +#define MD32_REG_T long +/* + * This comment was originaly written for MD5, which is why it + * discusses A-D. But it basically applies to all 32-bit digests, + * which is why it was moved to common header file. + * + * In case you wonder why A-D are declared as long and not + * as MD5_LONG. Doing so results in slight performance + * boost on LP64 architectures. The catch is we don't + * really care if 32 MSBs of a 64-bit register get polluted + * with eventual overflows as we *save* only 32 LSBs in + * *either* case. Now declaring 'em long excuses the compiler + * from keeping 32 MSBs zeroed resulting in 13% performance + * improvement under SPARC Solaris7/64 and 5% under AlphaLinux. + * Well, to be honest it should say that this *prevents* + * performance degradation. + * + * Apparently there're LP64 compilers that generate better + * code if A-D are declared int. Most notably GCC-x86_64 + * generates better code. + * + */ +#endif diff --git a/fips/sha1/fips_sha1_selftest.c b/fips/sha1/fips_sha1_selftest.c new file mode 100644 index 0000000000..248539acb0 --- /dev/null +++ b/fips/sha1/fips_sha1_selftest.c @@ -0,0 +1,97 @@ +/* ==================================================================== + * Copyright (c) 2003 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 + * openssl-core@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. + * + */ + +#include +#include +#include +#include + +#ifdef OPENSSL_FIPS +static char *test[]= + { + "", + "abc", + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + NULL, + }; + +static unsigned char ret[][SHA_DIGEST_LENGTH]= + { + { 0xda,0x39,0xa3,0xee,0x5e,0x6b,0x4b,0x0d,0x32,0x55, + 0xbf,0xef,0x95,0x60,0x18,0x90,0xaf,0xd8,0x07,0x09 }, + { 0xa9,0x99,0x3e,0x36,0x47,0x06,0x81,0x6a,0xba,0x3e, + 0x25,0x71,0x78,0x50,0xc2,0x6c,0x9c,0xd0,0xd8,0x9d }, + { 0x84,0x98,0x3e,0x44,0x1c,0x3b,0xd2,0x6e,0xba,0xae, + 0x4a,0xa1,0xf9,0x51,0x29,0xe5,0xe5,0x46,0x70,0xf1 }, + }; + +void FIPS_corrupt_sha1() + { + ret[0][0]++; + } + +int FIPS_selftest_sha1() + { + int n; + + for(n=0 ; test[n] ; ++n) + { + unsigned char md[SHA_DIGEST_LENGTH]; + + SHA1((unsigned char*)test[n],strlen(test[n]),md); + if(memcmp(md,ret[n],sizeof md)) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_SHA1,FIPS_R_SELFTEST_FAILED); + return 0; + } + } + return 1; + } + +#endif diff --git a/fips/sha1/fips_sha1dgst.c b/fips/sha1/fips_sha1dgst.c new file mode 100644 index 0000000000..dc2ce7daf0 --- /dev/null +++ b/fips/sha1/fips_sha1dgst.c @@ -0,0 +1,80 @@ +/* crypto/sha/sha1dgst.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#if !defined(OPENSSL_NO_SHA1) && !defined(OPENSSL_NO_SHA) + +#undef SHA_0 +#define SHA_1 + +#include +#include + +#ifdef OPENSSL_FIPS +const char *SHA1_version="SHA1" OPENSSL_VERSION_PTEXT; + +/* The implementation is in fips_md32_common.h */ +#include "fips_sha_locl.h" + +#else /* ndef OPENSSL_FIPS */ + +static void *dummy=&dummy; + +#endif /* ndef OPENSSL_FIPS */ + +#endif + diff --git a/fips/sha1/fips_sha1test.c b/fips/sha1/fips_sha1test.c new file mode 100644 index 0000000000..5a5ed2b69b --- /dev/null +++ b/fips/sha1/fips_sha1test.c @@ -0,0 +1,145 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef OPENSSL_FIPS +int main(int argc, char *argv[]) +{ + printf("No FIPS SHA1 support\n"); + return(0); +} +#else + +#define MAX_TEST_BITS 103432 + +static void dump(const unsigned char *b,int n) + { + while(n-- > 0) + printf("%02X",*b++); + } + +static void bitfill(unsigned char *buf,int bit,int b,int n) + { + for( ; n > 0 ; --n,++bit) + { + assert(bit < MAX_TEST_BITS); + buf[bit/8]|=b << (7-bit%8); + } + } + +void montecarlo(unsigned char *seed,int n) + { + int i,j; + unsigned char m[10240]; + + memcpy(m,seed,n); + for(j=0 ; j < 100 ; ++j) + { + for(i=1 ; i <= 50000 ; ++i) + { + memset(m+n,'\0',j/4+3); + n+=j/4+3; + m[n++]=i >> 24; + m[n++]=i >> 16; + m[n++]=i >> 8; + m[n++]=i; +/* putchar(' '); */ +/* dump(m,bit/8); */ +/* putchar('\n'); */ + SHA1(m,n,m); + n=20; + } + dump(m,20); + puts(" ^"); + } + } + +int main(int argc,char **argv) + { + FILE *fp; + int phase; + + if(argc != 2) + { + fprintf(stderr,"%s \n",argv[0]); + exit(1); + } + + if(!FIPS_mode_set(1,argv[0])) + { + ERR_load_crypto_strings(); + ERR_print_errors(BIO_new_fp(stderr,BIO_NOCLOSE)); + exit(1); + } + fp=fopen(argv[1],"r"); + if(!fp) + { + perror(argv[1]); + exit(2); + } + + for(phase=0 ; ; ) + { + unsigned char buf[MAX_TEST_BITS/8]; + unsigned char md[20]; + char line[10240]; + int n,t,b,bit; + char *p; + + fgets(line,1024,fp); + if(feof(fp)) + break; + n=strlen(line); + line[n-1]='\0'; + if(!strcmp(line,"D>")) + ++phase; + + if(!isdigit(line[0])) + { + puts(line); + continue; + } + for( ; ; ) + { + assert(n > 1); + if(line[n-2] == '^') + break; + fgets(line+n-1,sizeof(line)-n+1,fp); + n=strlen(line); + /* printf("line=%s\n",line); */ + assert(!feof(fp)); + } + + p=strtok(line," "); + t=atoi(p); + p=strtok(NULL," "); + b=atoi(p); + memset(buf,'\0',sizeof buf); + for(bit=0,p=strtok(NULL," ") ; p && *p != '^' ; p=strtok(NULL," ")) + { + assert(t-- > 0); + bitfill(buf,bit,b,atoi(p)); + bit+=atoi(p); + b=1-b; + } + assert(t == 0); + assert((bit%8) == 0); + /* dump(buf,bit/8); */ + /* putchar('\n'); */ + if(phase < 3) + { + SHA1(buf,bit/8,md); + dump(md,20); + puts(" ^"); + } + else + montecarlo(buf,bit/8); + } + return 0; + } +#endif diff --git a/fips/sha1/fips_sha_locl.h b/fips/sha1/fips_sha_locl.h new file mode 100644 index 0000000000..61d4146501 --- /dev/null +++ b/fips/sha1/fips_sha_locl.h @@ -0,0 +1,479 @@ +/* crypto/sha/sha_locl.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include + +#include +#include +#include + +#ifndef SHA_LONG_LOG2 +#define SHA_LONG_LOG2 2 /* default to 32 bits */ +#endif + +#define DATA_ORDER_IS_BIG_ENDIAN + +#define HASH_LONG SHA_LONG +#define HASH_LONG_LOG2 SHA_LONG_LOG2 +#define HASH_CTX SHA_CTX +#define HASH_CBLOCK SHA_CBLOCK +#define HASH_LBLOCK SHA_LBLOCK +#define HASH_MAKE_STRING(c,s) do { \ + unsigned long ll; \ + ll=(c)->h0; HOST_l2c(ll,(s)); \ + ll=(c)->h1; HOST_l2c(ll,(s)); \ + ll=(c)->h2; HOST_l2c(ll,(s)); \ + ll=(c)->h3; HOST_l2c(ll,(s)); \ + ll=(c)->h4; HOST_l2c(ll,(s)); \ + } while (0) + +#if defined(SHA_0) + +# define HASH_UPDATE SHA_Update +# define HASH_TRANSFORM SHA_Transform +# define HASH_FINAL SHA_Final +# define HASH_INIT SHA_Init +# define HASH_BLOCK_HOST_ORDER sha_block_host_order +# define HASH_BLOCK_DATA_ORDER sha_block_data_order +# define Xupdate(a,ix,ia,ib,ic,id) (ix=(a)=(ia^ib^ic^id)) + + void sha_block_host_order (SHA_CTX *c, const void *p,int num); + void sha_block_data_order (SHA_CTX *c, const void *p,int num); + +#elif defined(SHA_1) + +# define HASH_UPDATE SHA1_Update +# define HASH_TRANSFORM SHA1_Transform +# define HASH_FINAL SHA1_Final +# define HASH_INIT SHA1_Init +# define HASH_BLOCK_HOST_ORDER sha1_block_host_order +# define HASH_BLOCK_DATA_ORDER sha1_block_data_order +# if defined(__MWERKS__) && defined(__MC68K__) + /* Metrowerks for Motorola fails otherwise:-( */ +# define Xupdate(a,ix,ia,ib,ic,id) do { (a)=(ia^ib^ic^id); \ + ix=(a)=ROTATE((a),1); \ + } while (0) +# else +# define Xupdate(a,ix,ia,ib,ic,id) ( (a)=(ia^ib^ic^id), \ + ix=(a)=ROTATE((a),1) \ + ) +# endif + +# ifdef SHA1_ASM +# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__) +# define sha1_block_host_order sha1_block_asm_host_order +# define DONT_IMPLEMENT_BLOCK_HOST_ORDER +# define sha1_block_data_order sha1_block_asm_data_order +# define DONT_IMPLEMENT_BLOCK_DATA_ORDER +# define HASH_BLOCK_DATA_ORDER_ALIGNED sha1_block_asm_data_order +# endif +# endif + void sha1_block_host_order (SHA_CTX *c, const void *p,int num); + void sha1_block_data_order (SHA_CTX *c, const void *p,int num); + +#else +# error "Either SHA_0 or SHA_1 must be defined." +#endif + +#include "fips_md32_common.h" + +#define INIT_DATA_h0 0x67452301UL +#define INIT_DATA_h1 0xefcdab89UL +#define INIT_DATA_h2 0x98badcfeUL +#define INIT_DATA_h3 0x10325476UL +#define INIT_DATA_h4 0xc3d2e1f0UL + +int HASH_INIT (SHA_CTX *c) + { + c->h0=INIT_DATA_h0; + c->h1=INIT_DATA_h1; + c->h2=INIT_DATA_h2; + c->h3=INIT_DATA_h3; + c->h4=INIT_DATA_h4; + c->Nl=0; + c->Nh=0; + c->num=0; + return 1; + } + +#define K_00_19 0x5a827999UL +#define K_20_39 0x6ed9eba1UL +#define K_40_59 0x8f1bbcdcUL +#define K_60_79 0xca62c1d6UL + +/* As pointed out by Wei Dai , F() below can be + * simplified to the code in F_00_19. Wei attributes these optimisations + * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel. + * #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z))) + * I've just become aware of another tweak to be made, again from Wei Dai, + * in F_40_59, (x&a)|(y&a) -> (x|y)&a + */ +#define F_00_19(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) +#define F_20_39(b,c,d) ((b) ^ (c) ^ (d)) +#define F_40_59(b,c,d) (((b) & (c)) | (((b)|(c)) & (d))) +#define F_60_79(b,c,d) F_20_39(b,c,d) + +#define BODY_00_15(i,a,b,c,d,e,f,xi) \ + (f)=xi+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_16_19(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \ + Xupdate(f,xi,xa,xb,xc,xd); \ + (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_20_31(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \ + Xupdate(f,xi,xa,xb,xc,xd); \ + (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_32_39(i,a,b,c,d,e,f,xa,xb,xc,xd) \ + Xupdate(f,xa,xa,xb,xc,xd); \ + (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_40_59(i,a,b,c,d,e,f,xa,xb,xc,xd) \ + Xupdate(f,xa,xa,xb,xc,xd); \ + (f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_60_79(i,a,b,c,d,e,f,xa,xb,xc,xd) \ + Xupdate(f,xa,xa,xb,xc,xd); \ + (f)=xa+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#ifdef X +#undef X +#endif +#ifndef MD32_XARRAY + /* + * Originally X was an array. As it's automatic it's natural + * to expect RISC compiler to accomodate at least part of it in + * the register bank, isn't it? Unfortunately not all compilers + * "find" this expectation reasonable:-( On order to make such + * compilers generate better code I replace X[] with a bunch of + * X0, X1, etc. See the function body below... + * + */ +# define X(i) XX##i +#else + /* + * However! Some compilers (most notably HP C) get overwhelmed by + * that many local variables so that we have to have the way to + * fall down to the original behavior. + */ +# define X(i) XX[i] +#endif + +#ifndef DONT_IMPLEMENT_BLOCK_HOST_ORDER +void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, int num) + { + const SHA_LONG *W=d; + register unsigned MD32_REG_T A,B,C,D,E,T; +#ifndef MD32_XARRAY + unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, + XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; +#else + SHA_LONG XX[16]; +#endif + + if(FIPS_selftest_fail) + return; + + A=c->h0; + B=c->h1; + C=c->h2; + D=c->h3; + E=c->h4; + + for (;;) + { + BODY_00_15( 0,A,B,C,D,E,T,W[ 0]); + BODY_00_15( 1,T,A,B,C,D,E,W[ 1]); + BODY_00_15( 2,E,T,A,B,C,D,W[ 2]); + BODY_00_15( 3,D,E,T,A,B,C,W[ 3]); + BODY_00_15( 4,C,D,E,T,A,B,W[ 4]); + BODY_00_15( 5,B,C,D,E,T,A,W[ 5]); + BODY_00_15( 6,A,B,C,D,E,T,W[ 6]); + BODY_00_15( 7,T,A,B,C,D,E,W[ 7]); + BODY_00_15( 8,E,T,A,B,C,D,W[ 8]); + BODY_00_15( 9,D,E,T,A,B,C,W[ 9]); + BODY_00_15(10,C,D,E,T,A,B,W[10]); + BODY_00_15(11,B,C,D,E,T,A,W[11]); + BODY_00_15(12,A,B,C,D,E,T,W[12]); + BODY_00_15(13,T,A,B,C,D,E,W[13]); + BODY_00_15(14,E,T,A,B,C,D,W[14]); + BODY_00_15(15,D,E,T,A,B,C,W[15]); + + BODY_16_19(16,C,D,E,T,A,B,X( 0),W[ 0],W[ 2],W[ 8],W[13]); + BODY_16_19(17,B,C,D,E,T,A,X( 1),W[ 1],W[ 3],W[ 9],W[14]); + BODY_16_19(18,A,B,C,D,E,T,X( 2),W[ 2],W[ 4],W[10],W[15]); + BODY_16_19(19,T,A,B,C,D,E,X( 3),W[ 3],W[ 5],W[11],X( 0)); + + BODY_20_31(20,E,T,A,B,C,D,X( 4),W[ 4],W[ 6],W[12],X( 1)); + BODY_20_31(21,D,E,T,A,B,C,X( 5),W[ 5],W[ 7],W[13],X( 2)); + BODY_20_31(22,C,D,E,T,A,B,X( 6),W[ 6],W[ 8],W[14],X( 3)); + BODY_20_31(23,B,C,D,E,T,A,X( 7),W[ 7],W[ 9],W[15],X( 4)); + BODY_20_31(24,A,B,C,D,E,T,X( 8),W[ 8],W[10],X( 0),X( 5)); + BODY_20_31(25,T,A,B,C,D,E,X( 9),W[ 9],W[11],X( 1),X( 6)); + BODY_20_31(26,E,T,A,B,C,D,X(10),W[10],W[12],X( 2),X( 7)); + BODY_20_31(27,D,E,T,A,B,C,X(11),W[11],W[13],X( 3),X( 8)); + BODY_20_31(28,C,D,E,T,A,B,X(12),W[12],W[14],X( 4),X( 9)); + BODY_20_31(29,B,C,D,E,T,A,X(13),W[13],W[15],X( 5),X(10)); + BODY_20_31(30,A,B,C,D,E,T,X(14),W[14],X( 0),X( 6),X(11)); + BODY_20_31(31,T,A,B,C,D,E,X(15),W[15],X( 1),X( 7),X(12)); + + BODY_32_39(32,E,T,A,B,C,D,X( 0),X( 2),X( 8),X(13)); + BODY_32_39(33,D,E,T,A,B,C,X( 1),X( 3),X( 9),X(14)); + BODY_32_39(34,C,D,E,T,A,B,X( 2),X( 4),X(10),X(15)); + BODY_32_39(35,B,C,D,E,T,A,X( 3),X( 5),X(11),X( 0)); + BODY_32_39(36,A,B,C,D,E,T,X( 4),X( 6),X(12),X( 1)); + BODY_32_39(37,T,A,B,C,D,E,X( 5),X( 7),X(13),X( 2)); + BODY_32_39(38,E,T,A,B,C,D,X( 6),X( 8),X(14),X( 3)); + BODY_32_39(39,D,E,T,A,B,C,X( 7),X( 9),X(15),X( 4)); + + BODY_40_59(40,C,D,E,T,A,B,X( 8),X(10),X( 0),X( 5)); + BODY_40_59(41,B,C,D,E,T,A,X( 9),X(11),X( 1),X( 6)); + BODY_40_59(42,A,B,C,D,E,T,X(10),X(12),X( 2),X( 7)); + BODY_40_59(43,T,A,B,C,D,E,X(11),X(13),X( 3),X( 8)); + BODY_40_59(44,E,T,A,B,C,D,X(12),X(14),X( 4),X( 9)); + BODY_40_59(45,D,E,T,A,B,C,X(13),X(15),X( 5),X(10)); + BODY_40_59(46,C,D,E,T,A,B,X(14),X( 0),X( 6),X(11)); + BODY_40_59(47,B,C,D,E,T,A,X(15),X( 1),X( 7),X(12)); + BODY_40_59(48,A,B,C,D,E,T,X( 0),X( 2),X( 8),X(13)); + BODY_40_59(49,T,A,B,C,D,E,X( 1),X( 3),X( 9),X(14)); + BODY_40_59(50,E,T,A,B,C,D,X( 2),X( 4),X(10),X(15)); + BODY_40_59(51,D,E,T,A,B,C,X( 3),X( 5),X(11),X( 0)); + BODY_40_59(52,C,D,E,T,A,B,X( 4),X( 6),X(12),X( 1)); + BODY_40_59(53,B,C,D,E,T,A,X( 5),X( 7),X(13),X( 2)); + BODY_40_59(54,A,B,C,D,E,T,X( 6),X( 8),X(14),X( 3)); + BODY_40_59(55,T,A,B,C,D,E,X( 7),X( 9),X(15),X( 4)); + BODY_40_59(56,E,T,A,B,C,D,X( 8),X(10),X( 0),X( 5)); + BODY_40_59(57,D,E,T,A,B,C,X( 9),X(11),X( 1),X( 6)); + BODY_40_59(58,C,D,E,T,A,B,X(10),X(12),X( 2),X( 7)); + BODY_40_59(59,B,C,D,E,T,A,X(11),X(13),X( 3),X( 8)); + + BODY_60_79(60,A,B,C,D,E,T,X(12),X(14),X( 4),X( 9)); + BODY_60_79(61,T,A,B,C,D,E,X(13),X(15),X( 5),X(10)); + BODY_60_79(62,E,T,A,B,C,D,X(14),X( 0),X( 6),X(11)); + BODY_60_79(63,D,E,T,A,B,C,X(15),X( 1),X( 7),X(12)); + BODY_60_79(64,C,D,E,T,A,B,X( 0),X( 2),X( 8),X(13)); + BODY_60_79(65,B,C,D,E,T,A,X( 1),X( 3),X( 9),X(14)); + BODY_60_79(66,A,B,C,D,E,T,X( 2),X( 4),X(10),X(15)); + BODY_60_79(67,T,A,B,C,D,E,X( 3),X( 5),X(11),X( 0)); + BODY_60_79(68,E,T,A,B,C,D,X( 4),X( 6),X(12),X( 1)); + BODY_60_79(69,D,E,T,A,B,C,X( 5),X( 7),X(13),X( 2)); + BODY_60_79(70,C,D,E,T,A,B,X( 6),X( 8),X(14),X( 3)); + BODY_60_79(71,B,C,D,E,T,A,X( 7),X( 9),X(15),X( 4)); + BODY_60_79(72,A,B,C,D,E,T,X( 8),X(10),X( 0),X( 5)); + BODY_60_79(73,T,A,B,C,D,E,X( 9),X(11),X( 1),X( 6)); + BODY_60_79(74,E,T,A,B,C,D,X(10),X(12),X( 2),X( 7)); + BODY_60_79(75,D,E,T,A,B,C,X(11),X(13),X( 3),X( 8)); + BODY_60_79(76,C,D,E,T,A,B,X(12),X(14),X( 4),X( 9)); + BODY_60_79(77,B,C,D,E,T,A,X(13),X(15),X( 5),X(10)); + BODY_60_79(78,A,B,C,D,E,T,X(14),X( 0),X( 6),X(11)); + BODY_60_79(79,T,A,B,C,D,E,X(15),X( 1),X( 7),X(12)); + + c->h0=(c->h0+E)&0xffffffffL; + c->h1=(c->h1+T)&0xffffffffL; + c->h2=(c->h2+A)&0xffffffffL; + c->h3=(c->h3+B)&0xffffffffL; + c->h4=(c->h4+C)&0xffffffffL; + + if (--num <= 0) break; + + A=c->h0; + B=c->h1; + C=c->h2; + D=c->h3; + E=c->h4; + + W+=SHA_LBLOCK; + } + } +#endif + +#ifndef DONT_IMPLEMENT_BLOCK_DATA_ORDER +void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, int num) + { + const unsigned char *data=p; + register unsigned MD32_REG_T A,B,C,D,E,T,l; +#ifndef MD32_XARRAY + unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, + XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; +#else + SHA_LONG XX[16]; +#endif + + if(FIPS_selftest_fail) + return; + + A=c->h0; + B=c->h1; + C=c->h2; + D=c->h3; + E=c->h4; + + for (;;) + { + + HOST_c2l(data,l); X( 0)=l; HOST_c2l(data,l); X( 1)=l; + BODY_00_15( 0,A,B,C,D,E,T,X( 0)); HOST_c2l(data,l); X( 2)=l; + BODY_00_15( 1,T,A,B,C,D,E,X( 1)); HOST_c2l(data,l); X( 3)=l; + BODY_00_15( 2,E,T,A,B,C,D,X( 2)); HOST_c2l(data,l); X( 4)=l; + BODY_00_15( 3,D,E,T,A,B,C,X( 3)); HOST_c2l(data,l); X( 5)=l; + BODY_00_15( 4,C,D,E,T,A,B,X( 4)); HOST_c2l(data,l); X( 6)=l; + BODY_00_15( 5,B,C,D,E,T,A,X( 5)); HOST_c2l(data,l); X( 7)=l; + BODY_00_15( 6,A,B,C,D,E,T,X( 6)); HOST_c2l(data,l); X( 8)=l; + BODY_00_15( 7,T,A,B,C,D,E,X( 7)); HOST_c2l(data,l); X( 9)=l; + BODY_00_15( 8,E,T,A,B,C,D,X( 8)); HOST_c2l(data,l); X(10)=l; + BODY_00_15( 9,D,E,T,A,B,C,X( 9)); HOST_c2l(data,l); X(11)=l; + BODY_00_15(10,C,D,E,T,A,B,X(10)); HOST_c2l(data,l); X(12)=l; + BODY_00_15(11,B,C,D,E,T,A,X(11)); HOST_c2l(data,l); X(13)=l; + BODY_00_15(12,A,B,C,D,E,T,X(12)); HOST_c2l(data,l); X(14)=l; + BODY_00_15(13,T,A,B,C,D,E,X(13)); HOST_c2l(data,l); X(15)=l; + BODY_00_15(14,E,T,A,B,C,D,X(14)); + BODY_00_15(15,D,E,T,A,B,C,X(15)); + + BODY_16_19(16,C,D,E,T,A,B,X( 0),X( 0),X( 2),X( 8),X(13)); + BODY_16_19(17,B,C,D,E,T,A,X( 1),X( 1),X( 3),X( 9),X(14)); + BODY_16_19(18,A,B,C,D,E,T,X( 2),X( 2),X( 4),X(10),X(15)); + BODY_16_19(19,T,A,B,C,D,E,X( 3),X( 3),X( 5),X(11),X( 0)); + + BODY_20_31(20,E,T,A,B,C,D,X( 4),X( 4),X( 6),X(12),X( 1)); + BODY_20_31(21,D,E,T,A,B,C,X( 5),X( 5),X( 7),X(13),X( 2)); + BODY_20_31(22,C,D,E,T,A,B,X( 6),X( 6),X( 8),X(14),X( 3)); + BODY_20_31(23,B,C,D,E,T,A,X( 7),X( 7),X( 9),X(15),X( 4)); + BODY_20_31(24,A,B,C,D,E,T,X( 8),X( 8),X(10),X( 0),X( 5)); + BODY_20_31(25,T,A,B,C,D,E,X( 9),X( 9),X(11),X( 1),X( 6)); + BODY_20_31(26,E,T,A,B,C,D,X(10),X(10),X(12),X( 2),X( 7)); + BODY_20_31(27,D,E,T,A,B,C,X(11),X(11),X(13),X( 3),X( 8)); + BODY_20_31(28,C,D,E,T,A,B,X(12),X(12),X(14),X( 4),X( 9)); + BODY_20_31(29,B,C,D,E,T,A,X(13),X(13),X(15),X( 5),X(10)); + BODY_20_31(30,A,B,C,D,E,T,X(14),X(14),X( 0),X( 6),X(11)); + BODY_20_31(31,T,A,B,C,D,E,X(15),X(15),X( 1),X( 7),X(12)); + + BODY_32_39(32,E,T,A,B,C,D,X( 0),X( 2),X( 8),X(13)); + BODY_32_39(33,D,E,T,A,B,C,X( 1),X( 3),X( 9),X(14)); + BODY_32_39(34,C,D,E,T,A,B,X( 2),X( 4),X(10),X(15)); + BODY_32_39(35,B,C,D,E,T,A,X( 3),X( 5),X(11),X( 0)); + BODY_32_39(36,A,B,C,D,E,T,X( 4),X( 6),X(12),X( 1)); + BODY_32_39(37,T,A,B,C,D,E,X( 5),X( 7),X(13),X( 2)); + BODY_32_39(38,E,T,A,B,C,D,X( 6),X( 8),X(14),X( 3)); + BODY_32_39(39,D,E,T,A,B,C,X( 7),X( 9),X(15),X( 4)); + + BODY_40_59(40,C,D,E,T,A,B,X( 8),X(10),X( 0),X( 5)); + BODY_40_59(41,B,C,D,E,T,A,X( 9),X(11),X( 1),X( 6)); + BODY_40_59(42,A,B,C,D,E,T,X(10),X(12),X( 2),X( 7)); + BODY_40_59(43,T,A,B,C,D,E,X(11),X(13),X( 3),X( 8)); + BODY_40_59(44,E,T,A,B,C,D,X(12),X(14),X( 4),X( 9)); + BODY_40_59(45,D,E,T,A,B,C,X(13),X(15),X( 5),X(10)); + BODY_40_59(46,C,D,E,T,A,B,X(14),X( 0),X( 6),X(11)); + BODY_40_59(47,B,C,D,E,T,A,X(15),X( 1),X( 7),X(12)); + BODY_40_59(48,A,B,C,D,E,T,X( 0),X( 2),X( 8),X(13)); + BODY_40_59(49,T,A,B,C,D,E,X( 1),X( 3),X( 9),X(14)); + BODY_40_59(50,E,T,A,B,C,D,X( 2),X( 4),X(10),X(15)); + BODY_40_59(51,D,E,T,A,B,C,X( 3),X( 5),X(11),X( 0)); + BODY_40_59(52,C,D,E,T,A,B,X( 4),X( 6),X(12),X( 1)); + BODY_40_59(53,B,C,D,E,T,A,X( 5),X( 7),X(13),X( 2)); + BODY_40_59(54,A,B,C,D,E,T,X( 6),X( 8),X(14),X( 3)); + BODY_40_59(55,T,A,B,C,D,E,X( 7),X( 9),X(15),X( 4)); + BODY_40_59(56,E,T,A,B,C,D,X( 8),X(10),X( 0),X( 5)); + BODY_40_59(57,D,E,T,A,B,C,X( 9),X(11),X( 1),X( 6)); + BODY_40_59(58,C,D,E,T,A,B,X(10),X(12),X( 2),X( 7)); + BODY_40_59(59,B,C,D,E,T,A,X(11),X(13),X( 3),X( 8)); + + BODY_60_79(60,A,B,C,D,E,T,X(12),X(14),X( 4),X( 9)); + BODY_60_79(61,T,A,B,C,D,E,X(13),X(15),X( 5),X(10)); + BODY_60_79(62,E,T,A,B,C,D,X(14),X( 0),X( 6),X(11)); + BODY_60_79(63,D,E,T,A,B,C,X(15),X( 1),X( 7),X(12)); + BODY_60_79(64,C,D,E,T,A,B,X( 0),X( 2),X( 8),X(13)); + BODY_60_79(65,B,C,D,E,T,A,X( 1),X( 3),X( 9),X(14)); + BODY_60_79(66,A,B,C,D,E,T,X( 2),X( 4),X(10),X(15)); + BODY_60_79(67,T,A,B,C,D,E,X( 3),X( 5),X(11),X( 0)); + BODY_60_79(68,E,T,A,B,C,D,X( 4),X( 6),X(12),X( 1)); + BODY_60_79(69,D,E,T,A,B,C,X( 5),X( 7),X(13),X( 2)); + BODY_60_79(70,C,D,E,T,A,B,X( 6),X( 8),X(14),X( 3)); + BODY_60_79(71,B,C,D,E,T,A,X( 7),X( 9),X(15),X( 4)); + BODY_60_79(72,A,B,C,D,E,T,X( 8),X(10),X( 0),X( 5)); + BODY_60_79(73,T,A,B,C,D,E,X( 9),X(11),X( 1),X( 6)); + BODY_60_79(74,E,T,A,B,C,D,X(10),X(12),X( 2),X( 7)); + BODY_60_79(75,D,E,T,A,B,C,X(11),X(13),X( 3),X( 8)); + BODY_60_79(76,C,D,E,T,A,B,X(12),X(14),X( 4),X( 9)); + BODY_60_79(77,B,C,D,E,T,A,X(13),X(15),X( 5),X(10)); + BODY_60_79(78,A,B,C,D,E,T,X(14),X( 0),X( 6),X(11)); + BODY_60_79(79,T,A,B,C,D,E,X(15),X( 1),X( 7),X(12)); + + c->h0=(c->h0+E)&0xffffffffL; + c->h1=(c->h1+T)&0xffffffffL; + c->h2=(c->h2+A)&0xffffffffL; + c->h3=(c->h3+B)&0xffffffffL; + c->h4=(c->h4+C)&0xffffffffL; + + if (--num <= 0) break; + + A=c->h0; + B=c->h1; + C=c->h2; + D=c->h3; + E=c->h4; + + } + } +#endif diff --git a/fips/sha1/fips_standalone_sha1.c b/fips/sha1/fips_standalone_sha1.c new file mode 100644 index 0000000000..bd3e72c719 --- /dev/null +++ b/fips/sha1/fips_standalone_sha1.c @@ -0,0 +1,156 @@ +/* ==================================================================== + * Copyright (c) 2003 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 + * openssl-core@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. + * + */ + +#include +#include +#include +#include +#include +#include + +int FIPS_selftest_fail; + +#ifdef OPENSSL_FIPS + +static void hmac_init(SHA_CTX *md_ctx,SHA_CTX *o_ctx, + const char *key) + { + int len=strlen(key); + int i; + unsigned char keymd[HMAC_MAX_MD_CBLOCK]; + unsigned char pad[HMAC_MAX_MD_CBLOCK]; + + if (len > SHA_CBLOCK) + { + SHA1_Init(md_ctx); + SHA1_Update(md_ctx,key,len); + SHA1_Final(keymd,md_ctx); + len=20; + } + else + memcpy(keymd,key,len); + memset(&keymd[len],'\0',HMAC_MAX_MD_CBLOCK-len); + + for(i=0 ; i < HMAC_MAX_MD_CBLOCK ; i++) + pad[i]=0x36^keymd[i]; + SHA1_Init(md_ctx); + SHA1_Update(md_ctx,pad,SHA_CBLOCK); + + for(i=0 ; i < HMAC_MAX_MD_CBLOCK ; i++) + pad[i]=0x5c^keymd[i]; + SHA1_Init(o_ctx); + SHA1_Update(o_ctx,pad,SHA_CBLOCK); + } + +static void hmac_final(unsigned char *md,SHA_CTX *md_ctx,SHA_CTX *o_ctx) + { + unsigned char buf[20]; + + SHA1_Final(buf,md_ctx); + SHA1_Update(o_ctx,buf,sizeof buf); + SHA1_Final(md,o_ctx); + } + +#endif + +int main(int argc,char **argv) + { +#ifdef OPENSSL_FIPS + static char key[]="etaonrishdlcupfm"; + int n; + + if(argc < 2) + { + fprintf(stderr,"%s []+\n",argv[0]); + exit(1); + } + + for(n=1 ; n < argc ; ++n) + { + FILE *f=fopen(argv[n],"rb"); + SHA_CTX md_ctx,o_ctx; + unsigned char md[20]; + int i; + + if(!f) + { + perror(argv[n]); + exit(2); + } + + hmac_init(&md_ctx,&o_ctx,key); + for( ; ; ) + { + char buf[1024]; + int l=fread(buf,1,sizeof buf,f); + + if(l == 0) + { + if(ferror(f)) + { + perror(argv[n]); + exit(3); + } + else + break; + } + SHA1_Update(&md_ctx,buf,l); + } + hmac_final(md,&md_ctx,&o_ctx); + + printf("HMAC-SHA1(%s)= ",argv[n]); + for(i=0 ; i < 20 ; ++i) + printf("%02x",md[i]); + printf("\n"); + } +#endif + return 0; + } + + diff --git a/fips/sha1/sha1hashes.txt b/fips/sha1/sha1hashes.txt new file mode 100644 index 0000000000..4adfa197e9 --- /dev/null +++ b/fips/sha1/sha1hashes.txt @@ -0,0 +1,342 @@ +# Configuration information for "SHA-1 Test" +# SHA tests are configured for BYTE oriented implementations +H>SHS Type 1 Hashes +DA39A3EE5E6B4B0D3255BFEF95601890AFD80709 ^ +3CDF2936DA2FC556BFA533AB1EB59CE710AC80E5 ^ +19C1E2048FA7393CFBF2D310AD8209EC11D996E5 ^ +CA775D8C80FAA6F87FA62BECA6CA6089D63B56E5 ^ +71AC973D0E4B50AE9E5043FF4D615381120A25A0 ^ +A6B5B9F854CFB76701C3BDDBF374B3094EA49CBA ^ +D87A0EE74E4B9AD72E6847C87BDEEB3D07844380 ^ +1976B8DD509FE66BF09C9A8D33534D4EF4F63BFD ^ +5A78F439B6DB845BB8A558E4CEB106CD7B7FF783 ^ +F871BCE62436C1E280357416695EE2EF9B83695C ^ +62B243D1B780E1D31CF1BA2DE3F01C72AEEA0E47 ^ +1698994A273404848E56E7FDA4457B5900DE1342 ^ +056F4CDC02791DA7ED1EB2303314F7667518DEEF ^ +9FE2DA967BD8441EEA1C32DF68DDAA9DC1FC8E4B ^ +73A31777B4ACE9384EFA8BBEAD45C51A71ABA6DD ^ +3F9D7C4E2384EDDABFF5DD8A31E23DE3D03F42AC ^ +4814908F72B93FFD011135BEE347DE9A08DA838F ^ +0978374B67A412A3102C5AA0B10E1A6596FC68EB ^ +44AD6CB618BD935460D46D3F921D87B99AB91C1E ^ +02DC989AF265B09CF8485640842128DCF95E9F39 ^ +67507B8D497B35D6E99FC01976D73F54AECA75CF ^ +1EAE0373C1317CB60C36A42A867B716039D441F5 ^ +9C3834589E5BFFAC9F50950E0199B3EC2620BEC8 ^ +209F7ABC7F3B878EE46CDF3A1FBB9C21C3474F32 ^ +05FC054B00D97753A9B3E2DA8FBBA3EE808CEF22 ^ +0C4980EA3A46C757DFBFC5BAA38AC6C8E72DDCE7 ^ +96A460D2972D276928B69864445BEA353BDCFFD2 ^ +F3EF04D8FA8C6FA9850F394A4554C080956FA64B ^ +F2A31D875D1D7B30874D416C4D2EA6BAF0FFBAFE ^ +F4942D3B9E9588DCFDC6312A84DF75D05F111C20 ^ +310207DF35B014E4676D30806FA34424813734DD ^ +4DA1955B2FA7C7E74E3F47D7360CE530BBF57CA3 ^ +74C4BC5B26FB4A08602D40CCEC6C6161B6C11478 ^ +0B103CE297338DFC7395F7715EE47539B556DDB6 ^ +EFC72D99E3D2311CE14190C0B726BDC68F4B0821 ^ +660EDAC0A8F4CE33DA0D8DBAE597650E97687250 ^ +FE0A55A988B3B93946A63EB36B23785A5E6EFC3E ^ +0CBDF2A5781C59F907513147A0DE3CC774B54BF3 ^ +663E40FEE5A44BFCB1C99EA5935A6B5BC9F583B0 ^ +00162134256952DD9AE6B51EFB159B35C3C138C7 ^ +CEB88E4736E354416E2010FC1061B3B53B81664B ^ +A6A2C4B6BCC41DDC67278F3DF4D8D0B9DD7784EF ^ +C23D083CD8820B57800A869F5F261D45E02DC55D ^ +E8AC31927B78DDEC41A31CA7A44EB7177165E7AB ^ +E864EC5DBAB0F9FF6984AB6AD43A8C9B81CC9F9C ^ +CFED6269069417A84D6DE2347220F4B858BCD530 ^ +D9217BFB46C96348722C3783D29D4B1A3FEDA38C ^ +DEC24E5554F79697218D317315FA986229CE3350 ^ +83A099DF7071437BA5495A5B0BFBFEFE1C0EF7F3 ^ +AA3198E30891A83E33CE3BFA0587D86A197D4F80 ^ +9B6ACBEB4989CBEE7015C7D515A75672FFDE3442 ^ +B021EB08A436B02658EAA7BA3C88D49F1219C035 ^ +CAE36DAB8AEA29F62E0855D9CB3CD8E7D39094B1 ^ +02DE8BA699F3C1B0CB5AD89A01F2346E630459D7 ^ +88021458847DD39B4495368F7254941859FAD44B ^ +91A165295C666FE85C2ADBC5A10329DAF0CB81A0 ^ +4B31312EAF8B506811151A9DBD162961F7548C4B ^ +3FE70971B20558F7E9BAC303ED2BC14BDE659A62 ^ +93FB769D5BF49D6C563685954E2AECC024DC02D6 ^ +BC8827C3E614D515E83DEA503989DEA4FDA6EA13 ^ +E83868DBE4A389AB48E61CFC4ED894F32AE112AC ^ +55C95459CDE4B33791B4B2BCAAF840930AF3F3BD ^ +36BB0E2BA438A3E03214D9ED2B28A4D5C578FCAA ^ +3ACBF874199763EBA20F3789DFC59572ACA4CF33 ^ +86BE037C4D509C9202020767D860DAB039CADACE ^ +51B57D7080A87394EEC3EB2E0B242E553F2827C9 ^ +1EFBFA78866315CE6A71E457F3A750A38FACAB41 ^ +57D6CB41AEEC20236F365B3A490C61D0CFA39611 ^ +C532CB64B4BA826372BCCF2B4B5793D5B88BB715 ^ +15833B5631032663E783686A209C6A2B47A1080E ^ +D04F2043C96E10CD83B574B1E1C217052CD4A6B2 ^ +E8882627C64DB743F7DB8B4413DD033FC63BEB20 ^ +CD2D32286B8867BC124A0AF2236FC74BE3622199 ^ +019B70D745375091ED5C7B218445EC986D0F5A82 ^ +E5FF5FEC1DADBAED02BF2DAD4026BE6A96B3F2AF ^ +6F4E23B3F2E2C068D13921FE4E5E053FFED4E146 ^ +25E179602A575C915067566FBA6DA930E97F8678 ^ +67DED0E68E235C8A523E051E86108EEB757EFBFD ^ +AF78536EA83C822796745556D62A3EE82C7BE098 ^ +64D7AC52E47834BE72455F6C64325F9C358B610D ^ +9D4866BAA3639C13E541F250FFA3D8BC157A491F ^ +2E258811961D3EB876F30E7019241A01F9517BEC ^ +8E0EBC487146F83BC9077A1630E0FB3AB3C89E63 ^ +CE8953741FFF3425D2311FBBF4AB481B669DEF70 ^ +789D1D2DAB52086BD90C0E137E2515ED9C6B59B5 ^ +B76CE7472700DD68D6328B7AA8437FB051D15745 ^ +F218669B596C5FFB0B1C14BD03C467FC873230A0 ^ +1FF3BDBE0D504CB0CDFAB17E6C37ABA6B3CFFDED ^ +2F3CBACBB14405A4652ED52793C1814FD8C4FCE0 ^ +982C8AB6CE164F481915AF59AAED9FFF2A391752 ^ +5CD92012D488A07ECE0E47901D0E083B6BD93E3F ^ +69603FEC02920851D4B3B8782E07B92BB2963009 ^ +3E90F76437B1EA44CF98A08D83EA24CECF6E6191 ^ +34C09F107C42D990EB4881D4BF2DDDCAB01563AE ^ +474BE0E5892EB2382109BFC5E3C8249A9283B03D ^ +A04B4F75051786682483252438F6A75BF4705EC6 ^ +BE88A6716083EB50ED9416719D6A247661299383 ^ +C67E38717FEE1A5F65EC6C7C7C42AFC00CD37F04 ^ +959AC4082388E19E9BE5DE571C047EF10C174A8D ^ +BAA7AA7B7753FA0ABDC4A541842B5D238D949F0A ^ +351394DCEBC08155D100FCD488578E6AE71D0E9C ^ +AB8BE94C5AF60D9477EF1252D604E58E27B2A9EE ^ +3429EC74A695FDD3228F152564952308AFE0680A ^ +907FA46C029BC67EAA8E4F46E3C2A232F85BD122 ^ +2644C87D1FBBBC0FC8D65F64BCA2492DA15BAAE4 ^ +110A3EEB408756E2E81ABAF4C5DCD4D4C6AFCF6D ^ +CD4FDC35FAC7E1ADB5DE40F47F256EF74D584959 ^ +8E6E273208AC256F9ECCF296F3F5A37BC8A0F9F7 ^ +FE0606100BDBC268DB39B503E0FDFE3766185828 ^ +6C63C3E58047BCDB35A17F74EEBA4E9B14420809 ^ +BCC2BD305F0BCDA8CF2D478EF9FE080486CB265F ^ +CE5223FD3DD920A3B666481D5625B16457DCB5E8 ^ +948886776E42E4F5FAE1B2D0C906AC3759E3F8B0 ^ +4C12A51FCFE242F832E3D7329304B11B75161EFB ^ +C54BDD2050504D92F551D378AD5FC72C9ED03932 ^ +8F53E8FA79EA09FD1B682AF5ED1515ECA965604C ^ +2D7E17F6294524CE78B33EAB72CDD08E5FF6E313 ^ +64582B4B57F782C9302BFE7D07F74AA176627A3A ^ +6D88795B71D3E386BBD1EB830FB9F161BA98869F ^ +86AD34A6463F12CEE6DE9596ABA72F0DF1397FD1 ^ +7EB46685A57C0D466152DC339C8122548C757ED1 ^ +E7A98FB0692684054407CC221ABC60C199D6F52A ^ +34DF1306662206FD0A5FC2969A4BEEC4EB0197F7 ^ +56CF7EBF08D10F0CB9FE7EE3B63A5C3A02BCB450 ^ +3BAE5CB8226642088DA760A6F78B0CF8EDDEA9F1 ^ +6475DF681E061FA506672C27CBABFA9AA6DDFF62 ^ +79D81991FA4E4957C8062753439DBFD47BBB277D ^ +BAE224477B20302E881F5249F52EC6C34DA8ECEF ^ +EDE4DEB4293CFE4138C2C056B7C46FF821CC0ACC ^ +SHS Type 2 Hashes +A771FA5C812BD0C9596D869EC99E4F4AC988B13F ^ +E99D566212BBBCEEE903946F6100C9C96039A8F4 ^ +B48CE6B1D13903E3925AE0C88CB931388C013F9C ^ +E647D5BAF670D4BF3AFC0A6B72A2424B0C64F194 ^ +65C1CD932A06B05CD0B43AFB3BC7891F6BCEF45C ^ +70FFAE353A5CD0F8A65A8B2746D0F16281B25EC7 ^ +CC8221F2B829B8CF39646BF46888317C3EB378EA ^ +26ACCC2D6D51FF7BF3E5895588907765111BB69B ^ +01072915B8E868D9B28E759CF2BC1AEA4BB92165 ^ +3016115711D74236ADF0C371E47992F87A428598 ^ +BF30417999C1368F008C1F19FECA4D18A5E1C3C9 ^ +62BA49087185F2742C26E1C1F4844112178BF673 ^ +E1F6B9536F384DD3098285BBFD495A474140DC5A ^ +B522DAE1D67726EBA7C4136D4E2F6D6D645AC43E ^ +E9A021C3EB0B9F2C710554D4BF21B19F78E09478 ^ +DF13573188F3BF705E697A3E1F580145F2183377 ^ +188835CFE52ECFA0C4135C2825F245DC29973970 ^ +41B615A34EE2CEC9D84A91B141CFAB115821950B ^ +AB3DD6221D2AFE6613B815DA1C389EEC74AA0337 ^ +0706D414B4AA7FB4A9051AA70D6856A7264054FB ^ +3CBF8151F3A00B1D5A809CBB8C4F3135055A6BD1 ^ +DA5D6A0319272BBCCEA63ACFA6799756FFDA6840 ^ +FB4429C95F6277B346D3B389413758DFFFEEDC98 ^ +2C6E30D9C895B42DCCCFC84C906EC88C09B20DE1 ^ +3DE3189A5E19F225CDCE254DFF23DACD22C61363 ^ +93530A9BC9A817F6922518A73A1505C411D05DA2 ^ +E31354345F832D31E05C1B842D405D4BD4588EC8 ^ +3FF76957E80B60CF74D015AD431FCA147B3AF232 ^ +34AE3B806BE143A84DCE82E4B830EB7D3D2BAC69 ^ +D7447E53D66BB5E4C26E8B41F83EFD107BF4ADDA ^ +77DD2A4482705BC2E9DC96EC0A13395771AC850C ^ +EAA1465DB1F59DE3F25EB8629602B568E693BB57 ^ +9329D5B40E0DC43AA25FED69A0FA9C211A948411 ^ +E94C0B6AA62AA08C625FAF817DDF8F51EC645273 ^ +7FF02B909D82AD668E31E547E0FB66CB8E213771 ^ +5BB3570858FA1744123BAC2873B0BB9810F53FA1 ^ +905F43940B3591CE39D1145ACB1ECA80AB5E43CD ^ +336C79FBD82F33E490C577E3F791C3CBFE842AFF ^ +5C6D07A6B44F7A75A64F6CE592F3BAE91E022210 ^ +7E0D3E9D33127F4A30EB8D9C134A58409FA8695B ^ +9A5F50DFCFB19286206C229019F0ABF25283028C ^ +DCA737E269F9D8626D488988C996E06B352C0708 ^ +B8FFC1D4972FCE63241E0E77850AC46DDE75DBFA ^ +E9C9BF41C8549354151B977003CE1D830BE667DB ^ +0942908960B54F96CB43452E583F4F9CB66E398A ^ +FCE34051C34D4B81B85DDC4B543CDE8007E284B3 ^ +61E8916532503627F4024D13884640A46F1D61D4 ^ +F008D5D7853B6A17B7466CD9E18BD135E520FAF4 ^ +BD8D2E873CF659B5C77AAC1616827EF8A3B1A3B3 ^ +B25A04DD425302ED211A1C2412D2410FA10C63B6 ^ +A404E21588123E0893718B4B44E91414A785B91F ^ +A1E13BC55BF6DAD83CF3AABDA3287AD68681EA64 ^ +D5FD35FFABED6733C92365929DF0FB4CAE864D15 ^ +C12E9C280EE9C079E0506FF89F9B20536E0A83EF ^ +E22769DC00748A9BBD6C05BBC8E81F2CD1DC4E2D ^ +F29835A93475740E888E8C14318F3CA45A3C8606 ^ +1A1D77C6D0F97C4B620FAA90F3F8644408E4B13D ^ +4EC84870E9BDD25F523C6DFB6EDD605052CA4EAA ^ +D689513FED08B80C39B67371959BC4E3FECB0537 ^ +C4FED58F209FC3C34AD19F86A6DACADC86C04D33 ^ +051888C6D00029C176DE792B84DECE2DC1C74B00 ^ +1A3540BEE05518505827954F58B751C475AEECE0 ^ +DFA19180359D5A7A38E842F172359CAF4208FC05 ^ +7B0FA84EBBCFF7D7F4500F73D79660C4A3431B67 ^ +9E886081C9ACAAD0F97B10810D1DE6FCDCE6B5F4 ^ +A4D46E4BA0AE4B012F75B1B50D0534D578AE9CB6 ^ +6342B199EE64C7B2C9CBCD4F2DCB65ACEF51516F ^ +AABFD63688EB678357869130083E1B52F6EA861D ^ +F732B7372DAF44801F81EFFE3108726239837936 ^ +5E9347FE4574CDCB80281ED092191199BADD7B42 ^ +D5776B7DFFF75C1358ABDBBB3F27A20BB6CA7C55 ^ +022B7ADA472FB7A9DA9219621C9C5F563D3792F6 ^ +7F1DE4ECA20362DA624653D225A5B3F7964A9FF2 ^ +CA0F2B1BFB4469C11ED006A994734F0F2F5EFD17 ^ +833D63F5C2EA0CD43EC15F2B9DD97FF12B030479 ^ +14FD356190416C00592B86FF7CA50B622F85593A ^ +4AB6B57EDDEF1CE935622F935C1619AE7C1667D6 ^ +B456A6A968ACD66CAA974F96A9A916E700AA3C5D ^ +FD1C257FE046B2A27E2F0CD55ED2DECA845F01D7 ^ +66E0D01780F1063E2929EAAD74826BC64060E38C ^ +A8478DF406F179FD4EF97F4574D7F99EA1CE9EB8 ^ +248E58CF09A372114FC2F93B09C5FC14F3D0059E ^ +F15767DE91796A6816977EFA4FCED4B7FD9B8A57 ^ +36A6BC5E680E15675D9696338C88B36248BBBAF4 ^ +4DEA6251B2A6DF017A8093AB066EE3863A4EC369 ^ +D30E70E357D57E3D82CA554B8A3D58DFF528FA94 ^ +70CA84D827F7FD61446233F88CF2F990B0F3E2AA ^ +8D500C9CFDE0288530A2106B70BED39326C52C3C ^ +F3D4D139EDFC24596377BC97A96FB7621F27FFC7 ^ +5509BAFFAC6D507860CEFC5AB5832CB63CD4B687 ^ +0C0AEA0C2FD7A620C77866B1A177481E26B4F592 ^ +149176007FEE58A591E3F00F8DB658B605F8390C ^ +17C0D7B0256159F3626786FFDB20237AE154FA84 ^ +741A58618ABEB1D983D67AFDCBC49AA397A3B8E0 ^ +B738D6B3409EB9ED2F1719B84D13F7C36169CDEC ^ +3D33DE31F64055D3B128AC9A6AA3F92DFD4F5330 ^ +B6925F4DF94949B8844C867428BA3DEDF4CF2B51 ^ +CF5E7256292ABEC431D8E8B9CBEAF22AF072377E ^ +975DCE94902923977F129C0E4ACF40AD28DDB9AA ^ +333B0259B18CE64D6B52CF563DD3041E5F63A516 ^ +SHS Type 3 Hashes +80E044703A880C20EC41F645120A8A5B5D194ECE ^ +E142829CA08FC9787F17AA16CE727396169B2713 ^ +6A2BAF62469D311F9257A0727F52C7EAA87CCEB4 ^ +362E3E7136CA611D7FBF687D3BBDC54CDA64843F ^ +F5900ADC6223A5D24A7526ABFC60FA8E2D59A5AB ^ +AD0CAC6A21D5B10833DDE7FA85927D74EDA142A9 ^ +47AD337EAFFDC177AAF7CBD035BE6F398B9D0536 ^ +9CF58595DF80872535BCC7C056E223546F0BB4EE ^ +7151CEB1918278CED2902B1D663D596F8D1B986F ^ +ADDC9F09AA4026EF6C4B7F1A84D3A13B4CDC65B3 ^ +921FE78A863A317B1FA1FB3CA3BE1948DE7EF754 ^ +64BE10732D71D52CE8A486DA23E6B453DF7C6FBD ^ +4A450659470DD759ABFAE1D73972A6D2E63AC16C ^ +0D665E4BBF30B7EAB955BDE84759E185EECAB4CB ^ +0C1B8EE94D61CDD0837EAED9FE33DE4A8334B596 ^ +D93BFE2A6227A4BF9B7C61EBCE4A8CDE131593FE ^ +BDA883F804B470C90BD6AC490DFC34EBC27F9648 ^ +46A0969373552213632591C52030C38E5DBDC49E ^ +4781289E48B910C550DC23CA7D3AF5324C03532D ^ +693A34CFCDDED0F3AC72E7197FCE9BB66A8E3981 ^ +AE088AF1D8865140963B3ABFB63E32E04CD1506F ^ +ADF0F8F1D85CA97586F5DC6DC5FD11FA39270F55 ^ +E484F5AD86C5F4D09E366ADF6E0DE73449F97B28 ^ +81C49842BA3D7072FB42288E03CE737A2672C091 ^ +F6CC71AD897C23A16835490DED289BFD45500AB0 ^ +23E71AED62FE8E28F34F58E7FE5594EC5EB0486C ^ +92BA7934AA5867EE52960F4E0EDFB90AA7B69305 ^ +C3D1CC8CBD1B6FFEE0D90CE962CD9C09AB1548AA ^ +3CE37A583B71A6A77BE325066A0F00C5D11DFC3E ^ +76EF5D236E1042D356A3234A422C092F86003064 ^ +8C3F703436C6C882E60263540A8E4C3E5646DC15 ^ +6138F9F3AB43B988DD3857422CCB304352459F40 ^ +B812DE98775B4690B4FC2ECFCAB61C73C7271DC7 ^ +06660985CD80D48E7B9F88455B4233924C3B64BB ^ +76AB4B6378D6F63499A94EB67EB1CB31AFF8D775 ^ +F31F6B0BE7AB059A1F59A46481967E88392979E6 ^ +0C1638498FBB7DB9600B98B4B22EF85E0FE245FB ^ +5607C6AF600939736795AC523FA43B736F41A118 ^ +8A03244866BDD21B9D8A82E98436C894FAD86ECC ^ +8A75BFD911AF87303B9B8FB7A1A47CCA52D3D98A ^ +16F0F3B5D37411236A1E3D6B1EDAB74CDA25ED4B ^ +AC72BF45477481F58A302628DC5299FFA32E7C9F ^ +74CFFD5881F75AC20726E1447DCF7F47024380EF ^ +5BFBECEECBC27DA05729C4D1AC8C1286EA6DCEC9 ^ +012AACBC0579FA4CB4F107E9A9AD1A86AD2F6A4D ^ +F7D552CBC5EF90F1A579388B5A8A9EC71EB67681 ^ +10C70115C4C34753274BFED477DF01440A67A361 ^ +078D2FACD293B6B6219D89899C16AA1AA8E3DE82 ^ +83C6BF9FB0D3091ADF374EBFA0A69916F17E6D26 ^ +2CDB1924DA62AB64C007C6505FF657E4ADDEA9C1 ^ +E95D209BCB9864B076FF4DFCA8F8BD75D62D1B48 ^ +632824CF5025F8F90AD2923BDDF449550D64C0F5 ^ +02B1C0B41FC27EC5A32E586F1AC480BF0061E56A ^ +28156BC6769AE390BF32C6512C46169181E1536D ^ +F730E6E287D992E7F3E013B6F1E088F0B9C41598 ^ +B056A6A832FA5FE964EF77FF3E0BE1C32E0D58C0 ^ +D5B3D19AFBB48FB56BA6D44A82DE6BD08DB208DE ^ +0215AD79BD6B8023C05FD2F8966211897DF6337A ^ +EC4CF38C244EB6526A44F70570925247145DA8CA ^ +C0D931262ECE93DA5A6ABC89CD6AD3162EA6B09E ^ +6BB48FAC26AA2B4859BBDEFCFB53AE4D1D9A0340 ^ +58611D43741E67A7F0DA9CB337A59DCD1EBE758E ^ +7C2AEC216AF231509E47B7EED06BB17859812B7E ^ +F60EE5DBF4A7A676EC98B3DDB1CDD6CDF3CDA33B ^ +0492E59B1F4C94E97F29A26C3EE7D57E1B0FDD72 ^ +4FCF549D902D9BE1101A756DB9E45415FB61BCD2 ^ +95C71D26AD6B38CC771376B4A4F962F12E1E3D4F ^ +F6A2449E773C72FB886B3C43E2B30EC2A1B7454A ^ +CDE86695E00AEC9A5DB6FDDB5D5A5934448D58E0 ^ +502318A758FABFF6AC53844E9E2BCD159C678510 ^ +589D295148F95F75DAE964DD743FE981FA236D4E ^ +7973DD33AE3599A556BACC77E8656E782E029EFF ^ +9F5BE43AADD43C6DB3883C9DA4B52E1A50257AEE ^ +454289D8FFB237A56D5214EAE88F0A9D328FEA1A ^ +7E686B36595BEB4C0D4528FF960EDB55088A028D ^ +F9789D1EF19A0084AC0E9F43A4BC0EE0478939EF ^ +2F32B0E7CC8BE19C325545C816E77056D7BBE70F ^ +6B1617746F073CFCD2CEBCAFBBE6FD0E28ED2D56 ^ +CF8D2EA3888AD76761799383E5A15979F6DB7A88 ^ +557AF6D9D5947203C60E98C9A79B92B8BD085E2B ^ +C61A217423DE68ED6CD34C91756C8DD3A650A2A2 ^ +73F3F79C151B6C1BD9369EDB26B932C2362B0593 ^ +364141E5FBCDE83F210C5BBBEB6810F6299DE14B ^ +F806BECD025D264FD59E93D9E3606A674C40F216 ^ +E0C761A57F00CBFB07D49BCB034C36A7122F4C5B ^ +5D3831044B9E0032FBE3C3425FFD13698F413B33 ^ +7EB1AB41E9997753C5D530DF118E71E72D7B86FC ^ +CC053EA1556269D7E8BCBA30B208FCBF0EE2EE64 ^ +A57739B1DD41E7DC0C40D6B6159A7E73CE2748AA ^ +90DA527C9DB9ACC2FD530D560A2F1191A80D0567 ^ +6AC1F2A0B8CA0E5ABC9FDF1ADCE588FBDF5CC53E ^ +43C1A0A0EE4163EC929726989F92B03639B233AB ^ +8927F299462413AC29A74080E54D8EE2DB7165E7 ^ +0C8D7E22226D91B423E781B508F31517EAAB607B ^ +7286E20D7F08D18A893254FBD3CC833F7973DCAF ^ +0CB8C235928B8E936C43B8F29EF3758B9FD54A7B ^ +F67C24CC23E440CA3F206CEEB5504ECA54CD5CA3 ^ +D78A25DEAA1E7ADADDB3C145ED0E5263BA4F2910 ^ +00AA68174D29492C578AC853FFCD55908292D41A ^ +D5570EEDB09A62A5948F7F311F7ED5EF247F9AD9 ^ +SHS Type 1 Strings +0 1 ^ +5 0 2 1 2 1 2 ^ +5 0 1 3 4 4 4 ^ +7 0 4 3 4 4 1 4 4 ^ +10 0 4 1 5 3 4 4 3 1 3 4 ^ +10 0 3 1 6 5 5 1 3 6 6 4 ^ +13 1 3 2 5 3 3 3 4 6 6 1 4 6 2 ^ +16 1 3 5 5 1 2 1 3 3 6 3 5 2 3 5 7 2 ^ +15 1 8 1 5 3 2 7 4 5 6 7 3 3 1 6 3 ^ +15 1 4 6 8 2 1 4 2 5 1 6 8 8 6 4 7 ^ +18 1 1 2 7 3 8 6 7 5 4 3 4 3 5 3 3 2 6 8 ^ +16 0 9 8 1 8 1 7 6 7 7 1 2 6 9 5 4 7 ^ +18 0 7 1 7 3 9 4 7 7 5 2 8 1 7 8 2 7 2 9 ^ +19 1 2 3 1 8 8 6 9 10 3 10 8 9 2 4 1 5 1 5 9 ^ +19 1 8 5 4 8 1 3 9 5 7 7 2 7 2 7 8 7 4 8 10 ^ +20 1 1 9 7 4 1 4 5 1 10 8 6 4 4 9 9 9 8 2 9 10 ^ +19 1 11 6 7 7 2 6 2 6 10 6 9 10 5 11 1 6 8 11 4 ^ +22 0 10 5 10 3 7 8 9 9 1 1 1 10 2 1 5 10 2 9 9 9 7 8 ^ +21 0 1 10 1 6 9 4 2 5 2 11 8 12 12 9 8 1 3 10 7 11 12 ^ +24 1 3 9 5 12 3 4 2 9 12 11 6 6 1 1 9 5 9 1 4 9 4 10 8 9 ^ +25 1 3 2 3 11 1 12 5 6 2 7 8 4 8 8 9 9 8 4 9 1 4 8 10 9 9 ^ +23 0 11 10 7 10 10 6 10 9 4 5 10 5 8 4 1 10 12 4 6 1 8 11 6 ^ +22 0 12 8 10 4 3 8 5 5 7 11 13 11 12 11 4 12 3 6 5 11 10 5 ^ +26 1 10 9 6 9 7 2 10 4 4 5 5 2 12 13 5 3 1 10 1 4 7 8 13 13 12 9 ^ +31 0 2 6 5 4 7 3 10 6 13 6 3 9 6 2 10 5 3 8 4 1 11 3 5 3 7 11 1 12 9 12 5 ^ +27 1 14 5 1 3 7 2 3 9 3 4 14 4 4 10 8 5 14 1 11 12 12 10 4 13 7 11 9 ^ +30 1 4 9 5 5 8 9 5 10 4 2 4 7 9 9 6 3 5 1 8 3 2 13 3 14 9 8 9 10 14 10 ^ +27 0 12 9 5 8 7 2 14 12 3 8 14 6 6 4 7 5 7 10 7 11 10 1 9 6 7 12 14 ^ +24 0 12 9 9 2 11 13 12 11 11 6 14 13 10 5 6 8 10 4 3 11 11 14 5 14 ^ +24 0 15 4 5 3 8 12 15 8 14 15 9 12 12 3 10 13 6 11 10 4 13 14 8 8 ^ +28 1 1 8 1 5 11 4 9 12 4 13 15 5 9 11 7 14 11 1 11 7 8 8 11 1 13 15 12 13 ^ +32 1 5 8 3 8 10 7 8 1 5 13 12 14 5 3 6 4 12 15 6 6 10 11 13 9 1 11 6 10 3 7 14 +2 ^ +31 0 10 3 5 1 14 11 11 16 1 2 2 11 6 13 15 12 6 5 16 2 14 2 10 12 2 5 5 6 10 13 +15 ^ +34 0 3 10 8 16 9 5 12 15 4 11 13 3 6 5 10 8 1 3 9 3 11 1 2 16 12 10 6 1 9 1 16 +5 6 14 ^ +30 1 1 12 4 4 2 15 13 15 11 15 5 11 9 7 15 16 6 16 12 3 2 10 16 5 5 7 1 7 11 16 +^ +34 0 7 9 11 2 5 5 5 4 13 13 14 4 7 12 6 4 8 2 9 9 13 13 3 3 6 7 16 7 6 15 5 8 +15 14 ^ +36 1 4 6 16 15 11 14 14 4 7 10 3 4 10 3 6 7 14 4 6 6 5 2 7 8 16 2 12 16 10 14 3 +2 3 7 14 3 ^ +32 0 15 10 9 1 14 10 14 6 6 16 3 2 3 8 3 12 8 11 17 3 9 7 16 14 4 11 15 5 13 9 +5 17 ^ +30 0 17 17 13 8 2 6 8 16 1 12 5 17 2 9 8 10 13 14 11 17 12 5 14 9 11 9 11 4 11 +12 ^ +30 1 16 6 10 5 8 3 17 16 14 1 15 15 15 6 13 2 11 6 13 11 13 4 6 7 11 11 12 16 +13 16 ^ +33 1 16 16 14 16 2 4 16 11 6 15 7 4 17 6 5 7 6 3 14 16 5 17 11 13 1 1 14 13 3 6 +14 5 16 ^ +39 1 2 16 13 7 8 6 2 15 1 9 12 4 4 11 13 7 2 11 9 18 4 5 4 8 2 14 9 9 1 8 13 11 +15 8 5 9 10 16 7 ^ +34 0 2 7 1 1 17 13 6 11 10 8 5 12 15 6 15 10 12 4 18 1 2 8 11 12 16 10 12 18 11 +16 12 11 17 6 ^ +34 1 4 7 13 7 10 7 10 6 1 12 7 18 11 18 2 10 15 10 14 8 18 9 9 12 12 3 13 12 6 +4 9 17 13 17 ^ +40 0 5 7 3 2 1 17 14 4 16 6 13 1 13 6 6 10 1 3 18 3 11 7 9 5 7 11 17 1 9 16 5 +15 10 17 3 8 15 17 8 12 ^ +40 0 11 3 15 17 11 1 1 4 3 14 18 4 2 18 8 15 6 4 6 3 15 11 16 10 17 17 9 6 3 2 +6 16 4 9 12 6 8 1 11 17 ^ +37 1 2 19 12 8 16 14 2 9 16 2 6 6 7 9 10 9 11 9 14 11 15 5 16 9 2 17 2 8 15 8 4 +3 14 14 16 16 12 ^ +37 1 11 10 16 12 11 7 14 14 14 6 10 10 1 6 13 19 5 6 4 7 12 12 10 5 10 15 15 8 +5 13 17 13 5 6 14 1 19 ^ +38 1 2 6 5 17 9 11 18 18 8 6 13 15 3 3 15 5 13 18 3 2 5 5 14 7 13 4 17 7 2 17 3 +18 15 7 15 16 18 11 ^ +38 1 12 8 6 3 17 12 13 19 15 9 7 17 16 15 3 11 11 5 2 13 19 16 2 4 16 7 8 1 2 9 +17 12 3 5 18 19 11 9 ^ +39 1 14 16 14 8 9 16 5 1 6 3 17 18 16 9 1 15 9 10 9 19 1 3 3 20 11 13 17 1 19 8 +3 4 3 7 1 14 19 19 19 ^ +37 1 18 13 11 5 18 4 19 10 6 19 11 17 10 10 7 9 13 16 9 10 18 4 12 5 16 5 20 12 +3 8 10 1 18 1 6 20 14 ^ +36 0 8 9 6 12 11 7 7 3 17 13 6 20 17 9 20 16 10 12 17 8 11 8 11 10 5 10 14 18 8 +19 9 12 12 2 20 19 ^ +39 0 12 16 20 3 9 9 19 17 13 13 4 17 2 11 7 14 3 6 16 13 10 13 5 16 10 2 8 2 17 +19 4 17 7 19 6 9 15 15 6 ^ +43 0 7 2 18 5 7 18 5 2 15 7 11 10 9 3 2 14 19 3 11 8 18 15 5 3 5 12 15 16 10 17 +7 19 16 2 1 16 6 3 19 12 5 18 16 ^ +49 1 9 11 2 1 12 11 14 12 14 10 4 11 6 8 16 7 5 11 20 8 17 4 14 4 15 3 2 2 4 3 +2 3 14 15 10 2 12 7 3 7 20 20 19 10 2 3 1 10 20 ^ +36 0 19 20 12 5 19 21 5 21 11 14 19 1 17 8 9 4 19 3 17 1 14 21 14 7 6 5 20 14 +21 20 4 6 21 7 11 12 ^ +41 0 12 9 11 6 16 18 18 10 11 20 6 12 11 5 7 21 19 18 6 15 21 10 4 14 9 19 10 3 +3 5 13 1 8 12 3 13 9 7 10 17 14 ^ +45 0 10 6 8 3 17 18 3 21 19 6 17 15 4 9 15 9 15 14 4 7 14 8 10 13 4 11 10 7 6 +21 1 14 5 11 7 7 2 13 13 3 9 13 8 14 20 ^ +39 1 3 7 18 4 9 9 5 15 13 17 10 15 16 20 8 19 9 10 9 1 19 14 21 2 18 13 10 4 18 +16 4 21 15 10 18 19 3 12 18 ^ +41 0 14 4 13 11 1 11 1 10 2 12 4 21 10 21 18 9 2 16 7 20 6 7 12 19 20 1 13 12 +10 8 21 15 7 19 13 6 8 19 20 18 19 ^ +37 0 11 18 1 17 14 15 20 16 20 8 2 17 10 4 21 5 19 19 14 22 21 18 13 14 1 3 12 +11 11 4 22 13 5 18 7 21 21 ^ +48 0 9 22 19 12 8 16 5 17 5 9 1 2 9 6 12 6 1 7 4 3 15 1 14 1 12 3 10 2 10 14 21 +13 17 6 6 17 1 21 2 14 16 17 9 11 20 21 11 18 ^ +50 1 12 8 20 13 2 9 20 9 14 10 1 16 2 22 6 4 16 14 15 1 12 4 14 9 21 3 3 9 8 21 +15 14 8 4 14 4 2 3 8 12 8 6 1 2 18 20 15 3 19 10 ^ +44 0 10 20 14 6 3 4 21 1 12 4 18 2 6 7 6 9 20 14 10 10 19 17 21 12 15 17 7 10 +11 8 10 12 1 19 19 9 18 21 4 18 11 9 22 5 ^ +47 0 15 8 15 3 5 6 2 19 12 17 4 20 8 11 20 2 18 4 16 20 12 9 9 6 16 21 16 3 16 +18 3 19 5 16 2 4 2 12 11 15 11 14 17 2 10 18 8 ^ +48 1 5 13 3 21 5 3 6 18 18 10 1 21 21 7 1 13 12 19 1 14 6 8 21 19 21 11 19 13 2 +13 4 1 10 22 16 4 9 4 10 16 3 7 15 11 9 13 17 12 ^ +45 0 14 7 6 2 20 3 6 19 19 10 2 22 12 17 12 1 20 7 7 15 20 6 18 8 3 14 23 18 15 +4 7 5 23 15 7 14 10 10 19 17 2 4 15 17 21 ^ +45 1 15 11 8 9 17 5 12 18 14 6 20 17 21 12 16 9 22 9 20 15 2 22 11 2 6 11 9 8 2 +4 14 19 3 21 21 23 8 2 11 4 8 4 20 22 11 ^ +38 0 21 18 22 10 19 9 14 17 23 21 10 7 15 13 16 5 4 10 13 14 20 23 12 20 23 18 +10 12 8 21 11 6 12 7 19 14 18 17 ^ +40 0 18 22 6 9 22 5 23 13 6 8 23 20 22 5 22 15 19 20 9 9 1 13 13 10 14 13 5 22 +14 21 9 21 19 14 14 4 18 13 12 14 ^ +48 1 7 3 15 5 17 14 23 14 5 17 22 11 1 8 13 23 6 21 3 6 11 7 23 8 6 21 4 4 22 +19 13 8 5 19 7 5 23 1 4 19 11 23 11 21 14 1 3 21 ^ +43 0 22 14 11 7 18 16 17 24 12 12 3 13 19 16 22 4 16 4 6 23 8 18 11 2 3 20 22 9 +21 8 23 1 23 20 7 16 13 23 4 13 3 7 22 ^ +47 1 23 6 13 19 2 3 7 2 9 9 15 6 13 4 22 6 19 20 1 9 7 14 1 15 3 23 24 22 18 12 +12 17 19 10 8 11 22 12 10 2 20 15 18 17 18 7 19 ^ +47 1 12 21 6 12 4 7 18 17 3 2 14 24 14 1 23 1 11 15 10 6 18 20 7 1 8 1 16 6 20 +23 23 21 10 10 12 24 10 11 23 2 12 23 9 3 24 24 10 ^ +52 0 14 10 18 15 14 5 16 11 22 2 15 24 8 22 1 4 24 9 10 15 3 9 5 4 17 15 9 12 +19 19 1 3 10 6 8 3 17 8 18 24 19 3 4 15 4 9 2 24 5 20 13 13 ^ +42 0 20 17 19 22 13 8 10 19 15 11 1 14 17 20 22 10 7 11 16 9 21 22 17 23 12 15 +4 24 7 21 18 2 21 16 1 19 18 20 11 3 15 17 ^ +50 0 18 1 6 14 5 5 5 19 13 10 24 19 16 24 15 13 2 19 15 24 21 17 4 13 17 1 1 9 +1 10 2 18 1 21 19 5 18 12 2 22 16 23 15 19 6 18 9 1 23 5 ^ +51 0 21 13 14 11 18 12 13 3 19 9 20 22 20 2 11 12 6 1 12 16 18 2 9 8 4 3 11 17 +11 5 4 19 16 11 23 13 18 1 20 8 2 16 16 21 4 19 5 5 20 24 16 ^ +53 1 20 25 17 11 8 4 19 25 17 7 16 21 6 4 8 2 15 9 2 9 19 3 6 3 3 10 25 13 15 7 +8 20 21 12 10 12 5 24 11 20 3 13 13 16 9 13 10 3 9 16 3 7 25 ^ +49 1 9 9 14 2 13 17 25 2 18 5 19 23 9 25 9 10 23 12 12 7 13 8 15 7 1 6 21 2 8 7 +6 16 14 14 12 15 13 24 10 15 11 10 8 14 15 21 25 21 25 ^ +47 0 9 18 20 22 21 20 11 14 23 22 10 13 14 8 19 12 2 11 20 23 13 4 10 6 5 7 23 +11 3 16 8 21 4 8 18 5 12 14 8 6 20 19 24 8 23 17 23 ^ +48 1 7 19 1 18 1 14 22 13 14 5 8 22 18 14 25 17 11 12 22 2 12 12 16 12 13 18 17 +12 17 14 18 8 25 9 23 5 3 8 14 24 17 7 3 3 23 17 22 19 ^ +51 1 19 17 16 22 24 14 16 20 23 20 9 19 16 7 12 16 5 8 9 7 10 21 24 10 11 19 1 +21 14 14 19 3 22 8 12 20 1 18 5 6 5 12 14 1 1 11 9 22 3 24 4 ^ +52 1 6 1 11 16 1 12 8 11 11 17 10 22 7 3 10 2 6 4 24 16 24 19 4 5 18 11 12 9 20 +21 25 2 21 18 10 20 25 21 3 17 17 5 8 22 25 19 8 10 19 7 11 18 ^ +44 0 26 14 21 25 25 4 9 13 5 8 9 21 8 12 26 24 9 24 15 1 23 22 16 14 8 22 15 19 +24 20 7 8 15 24 12 4 4 23 21 13 19 15 21 12 ^ +59 1 15 7 3 21 20 8 22 14 23 26 19 2 10 18 3 5 3 1 9 15 15 3 7 13 23 9 7 1 13 +17 14 25 9 16 2 2 6 13 7 19 25 17 1 5 21 2 7 22 5 6 25 3 12 19 6 2 4 24 17 ^ +60 0 9 18 20 19 4 11 14 1 6 8 26 6 9 22 4 10 2 7 21 9 8 24 25 14 22 12 22 3 23 +3 3 20 6 11 23 6 1 7 5 18 5 15 25 26 1 1 10 11 11 4 12 11 20 3 14 2 3 2 23 15 ^ +49 0 12 17 24 11 8 6 24 16 15 22 21 14 6 12 20 19 5 5 12 11 6 23 2 16 23 7 24 6 +21 2 17 17 5 25 11 25 20 25 24 18 6 12 19 25 7 6 5 2 25 ^ +54 1 12 16 1 15 7 1 26 19 19 13 20 11 17 6 20 5 24 24 1 21 11 9 20 21 15 10 19 +26 3 2 6 7 12 9 10 8 14 10 15 5 17 8 21 1 20 25 6 19 8 3 22 16 16 20 ^ +63 0 17 13 11 10 17 15 12 6 13 14 17 4 12 10 24 5 13 24 3 5 2 5 11 14 8 5 10 17 +16 8 4 14 21 15 3 6 17 25 8 2 3 3 19 10 13 22 22 8 2 13 25 17 2 1 19 1 14 20 2 +5 4 15 24 ^ +49 0 14 20 7 25 20 26 20 16 7 17 17 22 1 13 6 5 1 18 14 15 23 15 10 5 19 18 18 +26 12 13 3 25 12 21 16 24 4 16 3 6 26 26 10 20 13 1 20 24 15 ^ +56 0 3 8 14 5 5 7 11 13 11 26 11 4 26 17 20 19 11 10 3 10 14 9 6 9 7 16 10 4 4 +19 19 2 26 13 19 17 15 24 15 4 21 22 13 13 12 22 2 14 20 5 18 7 17 24 20 20 ^ +58 1 6 17 9 20 2 10 19 3 22 4 1 11 3 5 3 21 11 15 12 23 26 5 2 27 6 5 16 6 3 2 +23 5 3 20 20 4 24 2 18 21 7 14 10 27 23 6 24 6 19 23 3 9 22 16 21 17 19 23 ^ +58 1 17 7 21 19 6 16 15 15 20 14 2 25 19 14 18 19 7 9 1 14 11 10 16 3 23 14 26 +10 11 1 18 1 12 24 19 19 1 7 2 3 24 7 12 9 2 8 16 20 24 5 26 26 4 9 2 7 25 17 ^ +54 1 8 12 18 14 26 7 17 18 4 20 1 16 14 21 26 4 6 8 24 11 25 15 24 16 23 4 10 +23 21 24 15 10 9 26 7 14 24 21 6 20 5 17 16 17 1 3 12 1 4 13 3 9 21 26 ^ +56 1 7 18 11 1 19 20 23 12 12 27 13 13 15 16 13 1 16 15 12 26 3 16 16 8 17 13 +21 4 6 5 19 14 16 4 16 11 14 18 18 27 9 13 21 3 26 22 3 7 6 4 26 3 15 8 25 21 ^ +50 1 20 13 9 11 20 6 11 21 27 25 20 7 4 18 26 16 27 5 12 19 7 23 6 25 25 2 11 +13 25 21 18 17 6 12 14 13 24 11 14 19 26 27 25 6 1 15 4 7 27 15 ^ +51 0 15 16 26 27 23 14 12 28 22 15 8 19 2 20 13 1 24 2 25 1 6 19 19 8 11 24 24 +21 13 27 5 11 28 17 7 25 6 23 24 14 25 12 5 13 26 2 5 8 10 16 17 ^ +58 1 5 26 18 19 21 3 12 11 13 4 14 22 22 14 16 13 3 22 16 23 5 19 6 13 10 26 17 +27 26 4 3 25 6 14 2 3 5 7 23 11 22 8 25 2 9 25 18 17 8 2 14 4 19 1 5 27 13 24 ^ +53 0 2 27 28 2 17 23 10 27 18 26 7 22 16 3 27 1 26 21 28 10 3 6 2 2 10 17 13 16 +6 17 21 23 13 20 22 5 6 11 12 12 8 23 13 17 9 23 20 3 28 27 12 17 22 ^ +59 0 28 19 5 21 4 27 8 1 19 14 20 6 7 9 1 6 22 3 19 26 14 8 6 7 19 15 23 1 17 +16 6 26 14 5 22 25 4 7 10 16 21 10 18 19 24 16 23 8 3 17 28 18 10 2 5 3 21 21 +15 ^ +58 0 6 24 1 4 24 18 10 22 1 21 12 5 4 4 20 25 24 26 8 25 11 2 7 27 22 19 4 18 +27 10 28 4 12 24 8 16 12 11 16 17 25 8 12 16 1 9 9 10 5 24 23 18 5 14 18 8 4 28 +^ +61 0 5 17 8 28 1 22 4 11 3 2 17 3 14 9 27 13 18 24 9 8 7 28 25 14 21 27 24 6 18 +16 2 12 15 9 14 10 1 8 17 4 6 15 26 11 15 2 28 20 26 16 3 7 5 8 9 26 10 12 25 +11 22 ^ +53 0 9 13 24 15 20 2 4 8 2 22 20 19 4 15 14 28 13 25 10 10 12 28 24 22 26 28 15 +9 11 26 19 22 27 2 21 8 20 23 26 12 10 21 9 15 13 25 7 26 1 13 5 9 20 ^ +58 0 3 9 21 22 7 1 23 28 1 2 8 22 12 18 28 5 18 14 7 11 17 20 20 7 21 13 8 28 +21 22 2 16 20 15 28 9 3 22 13 10 23 4 16 11 14 1 10 8 14 14 15 18 13 12 21 18 +25 28 ^ +60 1 29 20 2 29 22 8 16 20 4 12 9 6 12 16 16 7 9 20 29 11 9 4 1 15 25 16 29 10 +22 7 2 8 5 18 14 23 24 4 6 26 3 11 6 12 1 7 14 24 14 6 10 21 16 23 29 25 6 14 +17 24 ^ +64 0 12 10 5 10 15 25 8 15 3 7 13 25 16 14 1 29 22 26 15 27 9 1 8 8 28 6 13 5 +13 3 15 5 23 8 23 2 5 5 4 17 13 14 7 17 12 27 3 18 5 7 5 26 18 15 22 28 16 13 7 +2 23 19 25 15 ^ +56 1 17 7 16 25 23 11 11 15 2 13 9 26 2 24 26 7 28 11 2 29 7 22 23 5 28 19 1 27 +29 1 24 11 18 20 3 13 11 7 3 15 17 24 1 18 13 6 3 25 27 16 28 18 24 8 23 22 ^ +51 1 29 28 6 28 14 12 28 27 22 4 14 25 1 3 9 7 11 14 15 16 10 19 12 19 11 20 13 +28 4 27 28 7 27 12 4 28 21 17 22 20 17 15 15 23 22 13 12 21 22 21 29 ^ +64 1 12 14 12 18 27 8 7 4 9 14 16 15 8 11 21 20 10 10 21 23 20 2 11 23 1 11 1 5 +3 23 16 15 27 14 5 16 3 22 2 3 24 3 19 29 4 4 10 8 20 14 15 1 26 12 27 25 4 28 +22 11 19 19 24 9 ^ +60 1 20 8 9 5 25 19 17 19 15 7 24 24 21 3 20 16 8 3 17 28 18 29 9 23 9 10 29 4 +12 24 15 5 8 22 17 29 12 3 8 29 15 21 21 4 7 20 7 10 7 26 10 16 24 6 7 12 8 12 +15 17 ^ +60 0 9 17 11 28 12 26 26 6 29 13 10 20 6 23 10 4 3 26 26 14 20 20 25 14 13 15 +24 14 11 4 23 27 24 20 9 16 17 24 13 12 6 1 14 26 25 7 8 21 1 19 3 2 2 17 21 13 +5 9 21 11 ^ +54 0 25 1 27 24 6 23 16 5 1 20 29 22 25 9 25 10 3 28 28 25 19 18 16 24 14 15 5 +28 12 28 26 29 2 15 15 9 5 18 19 22 12 15 4 6 15 24 16 9 4 26 25 18 27 12 ^ +61 1 20 4 26 12 3 22 1 22 30 3 28 10 9 24 14 29 6 30 3 10 20 14 6 3 19 21 21 28 +16 18 11 30 11 20 30 1 9 8 11 5 19 10 24 4 22 4 2 26 5 15 20 8 3 13 30 18 8 1 +25 28 19 ^ +56 1 20 15 21 18 18 12 16 13 24 9 21 2 28 6 1 23 9 18 27 27 4 9 13 10 8 14 16 +15 12 11 14 21 14 10 11 25 17 17 30 21 13 27 26 26 22 14 13 17 21 19 9 9 20 23 +13 28 ^ +59 1 10 28 24 10 22 27 23 27 8 17 14 6 4 21 26 15 1 8 29 27 6 28 15 3 27 25 25 +14 19 13 29 8 24 2 8 2 4 12 19 11 10 6 26 14 22 24 30 10 11 12 2 12 17 23 8 8 +12 28 12 ^ +56 0 14 28 2 17 4 8 3 26 9 23 21 30 30 20 4 13 28 29 9 3 17 7 19 30 28 1 2 20 9 +12 24 15 30 20 27 3 23 11 6 29 25 23 26 17 20 10 22 15 23 6 25 5 4 30 2 29 ^ +63 1 23 15 27 14 26 1 1 7 19 12 7 6 20 18 14 4 15 17 28 7 11 7 8 9 22 17 12 5 +23 18 25 18 6 12 26 30 12 30 14 3 1 18 10 20 27 21 8 6 24 26 20 11 24 7 2 4 18 +15 14 30 16 19 14 ^ +52 0 27 15 4 19 25 29 29 7 14 18 9 11 9 27 11 15 29 9 28 20 2 30 26 21 17 8 28 +17 22 29 24 8 11 18 29 15 6 7 27 27 17 24 18 23 11 19 8 30 5 24 22 24 ^ +66 1 25 15 28 23 5 10 21 5 8 7 3 10 19 17 6 9 15 29 10 7 4 1 16 21 16 29 13 18 +5 3 8 15 8 21 29 20 5 27 2 13 27 7 7 30 2 18 26 10 2 5 29 21 15 25 26 24 8 12 +20 3 9 10 30 7 12 29 ^ +53 1 30 26 20 11 22 19 27 2 16 10 6 4 24 17 20 25 20 15 8 23 23 20 30 18 16 3 +30 15 26 23 28 7 21 8 7 31 31 14 26 18 3 1 26 28 15 25 11 31 3 25 9 21 30 ^ +67 0 2 6 14 4 9 5 28 8 17 22 1 4 8 7 10 14 19 10 14 8 27 9 24 26 4 30 11 8 19 5 +21 7 2 27 20 16 20 20 22 14 13 16 26 14 10 3 25 22 25 23 21 10 15 15 29 8 13 4 +2 13 22 20 7 4 20 31 23 ^ +65 0 2 2 28 13 19 14 12 23 27 6 2 14 2 22 6 25 30 29 31 13 14 16 31 12 16 30 5 +14 31 11 4 1 1 25 21 13 26 22 21 5 22 14 29 1 21 3 14 30 4 2 29 12 15 23 3 15 5 +1 6 23 22 13 1 14 23 ^ +59 1 25 5 15 6 13 3 22 11 23 31 24 6 5 20 4 14 3 29 8 29 19 7 29 23 25 28 19 11 +15 27 21 14 1 19 20 26 12 7 12 1 18 13 29 28 23 29 14 23 7 1 9 29 24 5 30 18 5 +25 30 ^ +55 1 31 25 13 7 24 25 24 1 12 19 9 7 6 28 20 14 28 21 19 31 20 20 6 24 18 27 24 +4 18 21 1 31 15 1 15 2 27 4 26 25 4 23 19 2 31 22 30 21 22 5 27 12 30 28 31 ^ +62 0 27 15 18 14 25 15 17 7 28 11 28 29 30 1 17 12 10 2 18 20 21 2 11 12 5 4 12 +25 14 5 5 24 22 18 31 15 22 29 11 3 21 31 21 27 3 28 7 10 25 2 15 30 9 30 7 22 +15 9 3 20 24 14 ^ +60 0 28 14 18 9 27 14 22 27 31 10 8 14 7 15 7 20 5 26 1 29 7 17 17 8 3 13 27 18 +8 31 27 28 22 22 17 19 18 18 11 19 13 25 10 19 6 28 4 31 23 10 18 26 31 5 10 13 +12 8 15 27 ^ +60 1 24 22 4 29 22 31 28 20 4 16 21 3 1 15 5 15 6 30 3 29 29 7 27 20 2 20 31 22 +26 9 29 16 4 26 32 17 20 14 28 17 19 6 24 11 26 28 5 18 15 8 16 20 21 4 9 12 4 +8 17 29 ^ +SHS Type 2 Strings +69 1 5 3 11 15 12 24 31 23 1 6 28 2 8 31 6 7 30 5 19 23 12 6 9 31 19 17 24 25 +22 6 12 16 3 7 9 9 11 29 4 11 2 5 13 29 10 12 30 32 18 28 18 27 3 30 4 4 26 6 +13 31 13 2 11 7 24 4 17 29 12 ^ +95 0 21 19 21 23 11 42 36 2 13 4 1 33 22 16 27 9 4 33 16 3 30 15 11 32 13 17 38 +32 9 38 4 36 15 32 27 19 42 18 6 36 22 10 29 12 25 40 15 29 23 28 30 4 8 11 24 +9 10 31 28 43 23 16 29 33 5 40 26 3 19 12 36 43 5 35 37 5 14 11 45 35 16 10 8 +32 4 15 35 26 2 39 22 37 22 30 29 ^ +106 1 18 14 51 2 6 32 51 9 32 50 44 46 51 8 11 53 45 55 16 10 3 52 8 20 20 46 +46 13 32 2 46 50 43 25 54 9 31 29 2 47 15 29 24 45 44 18 37 14 28 39 36 44 47 +16 50 10 44 24 53 35 22 40 20 15 51 22 18 22 42 6 54 49 38 21 7 13 30 16 7 52 +16 22 13 38 7 11 44 33 9 25 13 37 42 14 45 53 30 38 5 25 5 35 38 22 28 53 ^ +127 0 58 35 43 28 5 28 63 8 12 25 9 47 53 29 62 7 37 2 3 48 5 12 55 56 28 35 12 +63 6 58 27 27 48 44 35 14 17 22 56 10 8 1 16 15 42 63 14 51 57 19 41 7 8 56 47 +34 52 22 48 60 43 9 1 52 4 21 49 61 18 50 23 13 46 62 23 45 62 9 56 18 23 31 8 +30 27 36 13 38 4 58 53 47 24 18 41 58 19 12 18 52 42 29 44 45 26 63 34 32 41 64 +15 26 55 19 2 49 6 30 53 13 54 12 53 37 12 37 43 ^ +148 0 60 4 51 47 58 38 17 63 33 23 28 43 12 69 70 33 17 12 50 18 18 36 45 2 67 +4 45 20 4 33 38 29 45 8 22 58 39 71 38 32 53 35 19 53 31 29 51 35 4 63 18 33 26 +47 70 9 64 62 63 30 15 1 35 28 16 40 20 14 50 33 19 38 30 27 55 10 16 46 47 7 +55 12 53 26 56 33 29 55 25 17 48 43 21 43 18 24 63 27 68 46 38 33 35 10 18 11 +27 5 9 58 35 70 36 36 39 47 2 10 66 47 5 18 21 44 71 51 57 3 22 7 56 55 28 25 +14 40 16 24 48 37 66 50 24 45 18 39 53 55 ^ +165 1 15 62 35 29 15 40 19 76 67 4 5 71 46 61 26 8 77 48 1 23 12 60 40 24 44 33 +29 42 73 66 49 61 20 30 1 54 52 42 39 64 23 65 37 24 20 11 26 66 22 77 22 57 7 +38 57 33 61 73 7 64 1 49 35 76 14 27 21 45 68 38 58 73 13 72 47 73 33 8 66 23 +38 4 56 77 47 10 71 13 20 31 41 6 51 3 18 17 61 47 14 48 76 46 28 34 43 1 56 4 +25 7 65 41 1 34 37 23 59 59 27 26 13 15 14 75 60 14 1 28 59 26 65 61 16 23 17 +28 6 19 2 35 49 30 29 48 2 63 73 59 1 3 76 41 11 19 18 43 54 63 67 51 4 9 78 60 +66 ^ +181 0 18 19 84 17 12 10 57 18 77 51 52 16 39 74 49 52 63 38 72 2 15 64 83 62 49 +56 11 26 68 58 83 33 23 50 63 71 53 27 84 22 39 41 52 58 11 64 7 60 45 70 22 5 +73 38 30 30 48 21 75 80 40 21 8 53 9 26 30 34 81 71 71 51 23 75 33 41 23 32 5 8 +66 40 72 40 16 66 45 14 48 34 21 41 27 3 55 27 37 23 41 65 4 57 51 74 22 19 75 +42 16 19 46 16 10 48 20 19 37 41 14 57 9 17 55 38 5 60 7 46 20 43 36 39 52 20 +10 62 45 23 46 7 35 75 29 70 35 36 34 25 12 15 84 26 10 6 71 29 79 33 32 25 59 +76 82 64 58 7 8 19 41 74 2 53 65 24 1 55 51 36 21 79 7 ^ +184 1 60 66 66 6 3 9 73 12 7 40 70 18 71 70 65 51 14 14 27 50 9 87 81 50 22 19 +40 37 16 79 12 34 37 76 82 10 61 7 81 49 67 26 45 82 50 81 63 45 69 31 31 76 51 +9 59 34 51 54 34 83 10 33 51 86 81 82 69 18 8 22 64 19 86 62 58 33 37 17 34 5 +29 83 42 76 50 54 66 39 9 1 36 43 17 65 6 35 56 72 71 83 88 10 1 8 87 22 6 21 +78 25 89 43 62 40 55 85 31 89 74 63 46 28 24 26 31 17 7 8 27 19 12 85 17 20 27 +77 10 2 54 80 17 52 74 76 69 78 11 20 80 4 29 24 85 75 18 39 23 70 83 29 57 67 +72 70 33 4 15 46 42 2 69 13 53 33 69 64 33 64 14 40 69 59 78 54 ^ +193 1 68 43 95 53 38 58 55 28 20 16 67 48 17 86 32 44 68 67 28 16 14 79 25 15 +72 67 50 80 18 30 10 75 1 60 45 87 78 28 95 49 63 70 59 26 6 51 73 60 65 18 26 +8 87 5 58 31 25 57 40 46 78 57 34 78 61 36 66 57 38 80 22 32 68 71 30 74 37 81 +66 77 66 55 2 51 24 93 61 40 68 45 61 12 63 24 89 59 52 72 43 20 20 69 36 40 88 +46 9 62 55 77 84 20 18 6 77 15 52 39 75 3 26 4 85 17 62 29 11 92 46 58 29 59 28 +42 80 71 96 2 49 85 37 63 4 61 14 2 53 87 25 86 6 75 76 93 41 39 93 92 42 56 41 +63 26 28 18 77 11 50 78 79 1 12 12 91 29 13 58 5 56 92 66 59 4 39 47 95 5 5 62 +33 13 80 27 ^ +203 1 35 28 11 7 20 7 17 3 3 30 89 13 65 56 66 63 22 82 16 31 55 56 77 91 91 71 +101 13 10 85 101 95 17 99 98 91 33 14 20 48 32 7 64 29 38 35 25 4 95 23 34 1 85 +81 23 31 96 71 84 50 15 79 47 25 51 45 35 66 19 61 60 9 31 93 64 70 30 42 86 53 +1 71 46 42 22 38 96 10 99 34 76 26 55 73 63 63 97 23 92 81 64 46 1 30 31 35 86 +91 88 64 87 16 37 69 84 94 60 100 3 47 52 8 71 87 57 29 76 43 18 45 46 15 65 12 +44 42 66 60 15 68 19 58 39 62 76 9 92 101 57 32 4 34 15 41 62 32 89 71 43 35 31 +41 21 17 82 33 96 27 62 29 82 57 46 62 15 24 99 37 83 40 52 46 56 80 98 3 91 74 +6 27 7 58 94 10 41 79 97 84 77 74 26 99 35 ^ +212 1 26 101 17 91 45 97 80 59 102 30 68 4 85 9 4 39 16 18 85 70 11 87 62 72 78 +38 3 41 53 82 82 35 18 13 94 64 52 39 77 59 26 9 65 46 64 98 32 29 86 79 16 63 +54 76 56 98 16 98 78 22 72 33 103 104 52 84 12 65 15 85 101 97 84 31 51 26 100 +100 38 80 13 2 78 7 24 44 84 103 27 7 28 16 33 99 25 103 54 14 42 62 87 92 27 +22 42 5 52 100 84 73 72 63 24 48 56 52 23 5 17 76 31 1 95 58 43 60 50 62 30 23 +35 79 20 35 3 72 32 45 51 87 41 84 27 79 77 70 102 15 54 15 100 8 52 69 105 3 +30 84 42 93 66 89 69 74 24 33 42 97 4 38 99 106 13 93 6 106 74 100 54 45 21 59 +56 37 9 50 32 75 79 31 77 9 61 1 8 68 6 60 81 7 100 99 14 61 48 25 73 26 70 72 +94 34 ^ +233 0 11 98 110 88 35 110 35 64 49 88 93 28 85 6 78 65 90 52 24 97 51 39 51 59 +23 1 3 49 33 11 78 27 35 55 64 5 102 4 70 25 56 58 38 66 11 31 96 66 104 59 41 +86 58 29 79 41 40 72 51 12 92 34 52 44 69 104 21 97 89 96 48 21 4 61 40 28 67 +34 23 85 44 22 62 52 33 84 23 30 73 74 4 79 12 81 47 80 53 47 89 40 19 80 62 34 +61 29 41 95 43 1 70 63 55 53 18 19 13 48 10 19 89 49 4 52 53 56 76 10 8 104 77 +15 28 38 75 109 3 85 90 8 40 8 93 90 43 39 14 60 17 36 78 56 105 80 35 75 36 58 +82 50 100 98 45 74 13 66 95 72 71 95 34 14 98 72 33 38 37 52 6 14 107 59 3 29 +61 67 98 92 5 93 17 98 36 87 41 75 71 57 88 17 25 91 84 3 58 20 92 69 51 50 36 +31 14 25 18 30 18 1 41 104 30 82 59 87 70 34 96 28 47 62 81 103 48 ^ +234 1 63 90 108 108 102 64 82 88 4 111 76 97 22 1 108 41 34 91 33 20 25 24 26 8 +83 11 31 7 85 109 106 4 105 85 68 28 33 99 53 8 16 12 11 74 17 83 66 70 16 30 9 +67 68 34 24 81 47 92 72 47 37 33 38 92 17 8 28 88 22 62 69 32 89 75 3 72 96 85 +13 105 24 38 37 94 115 83 72 108 114 24 93 76 103 60 99 102 9 43 10 59 95 46 33 +93 15 26 69 44 2 86 107 55 45 61 65 92 66 9 55 39 70 83 29 98 67 13 111 15 20 +31 62 8 2 51 20 19 33 44 14 115 71 112 97 10 41 28 53 51 26 57 15 38 98 55 106 +22 56 31 50 95 107 110 84 70 10 108 96 73 100 25 36 55 88 71 63 96 30 90 96 79 +22 7 30 23 28 59 89 8 51 99 47 86 34 18 43 65 98 104 107 49 7 79 71 8 57 21 29 +80 2 74 78 44 57 9 61 22 13 68 52 91 74 98 43 30 58 68 95 101 72 102 76 42 99 +61 ^ +249 0 27 117 45 119 80 2 59 52 8 76 20 94 102 69 96 42 46 106 67 9 110 89 71 69 +34 31 15 85 16 29 100 82 37 62 68 95 108 44 23 114 34 36 56 93 11 30 96 12 31 +67 14 114 14 66 70 30 81 46 53 119 85 6 104 47 92 72 70 5 70 15 115 68 105 33 +97 13 85 106 14 61 29 22 86 45 57 69 91 38 38 28 66 13 60 95 103 3 15 5 113 38 +23 62 5 65 94 107 73 104 37 47 102 117 3 78 35 7 95 56 78 45 52 28 46 43 37 32 +53 19 55 29 47 97 76 115 83 71 11 45 62 73 99 116 2 24 116 7 28 41 2 29 37 52 +23 5 118 79 31 57 89 61 24 101 78 50 93 73 41 7 33 45 47 24 1 48 73 36 3 25 87 +46 28 108 54 68 53 67 119 28 36 118 104 42 88 27 112 4 74 85 1 63 39 97 71 74 +75 76 10 49 12 79 11 50 103 118 94 117 118 37 27 12 94 60 28 51 47 82 110 17 15 +105 23 52 43 12 21 22 81 41 12 74 90 42 108 117 98 67 4 69 85 ^ +243 0 76 81 26 101 13 68 62 106 87 19 98 32 81 63 79 93 31 121 123 75 52 11 66 +41 54 87 38 5 104 62 51 38 55 29 31 120 44 16 48 94 46 105 91 66 78 27 43 6 64 +2 55 79 75 84 113 22 4 113 109 31 33 17 96 11 29 63 98 103 107 116 34 14 9 95 +38 18 51 75 33 109 118 55 66 4 76 7 75 70 82 74 23 1 26 69 40 112 99 47 65 31 +70 119 52 103 88 85 86 28 16 12 76 25 22 78 64 21 86 27 61 77 72 108 2 18 106 +119 121 54 16 85 72 2 73 26 88 66 60 80 35 24 117 63 24 44 67 52 122 119 33 72 +16 99 98 69 54 19 42 28 53 114 32 117 81 100 57 49 123 56 21 68 80 53 95 1 45 +95 107 98 87 1 27 24 99 116 16 67 1 113 91 84 25 40 25 72 3 28 90 87 112 80 16 +117 45 77 36 90 105 59 88 122 64 108 108 71 98 18 50 115 93 105 77 35 6 46 55 +47 102 4 26 87 111 120 81 113 4 57 105 3 84 94 115 61 73 ^ +255 1 91 47 51 9 57 9 55 94 61 61 68 46 107 6 35 81 114 78 96 74 14 89 73 67 67 +69 113 107 11 98 113 109 20 92 17 67 70 88 57 10 124 9 60 122 93 91 45 7 15 24 +51 5 98 115 24 49 90 104 117 66 128 94 64 80 12 43 91 46 111 59 58 77 30 14 88 +60 123 68 41 44 68 40 104 118 41 43 93 90 105 92 16 127 26 54 125 114 79 71 24 +48 21 25 118 40 103 49 91 44 67 65 25 119 109 18 48 23 69 112 38 61 64 87 84 +104 119 110 122 92 22 1 8 83 34 100 32 62 41 46 112 34 102 76 56 39 4 127 30 13 +19 110 124 7 16 128 95 4 124 11 104 116 126 49 95 3 55 96 70 90 101 4 122 96 75 +118 39 128 99 92 18 42 20 87 83 35 75 111 61 67 71 28 101 9 56 34 105 95 71 23 +73 71 26 57 15 23 76 55 99 89 128 98 117 68 43 88 62 38 62 39 2 83 36 15 26 60 +128 96 73 74 10 1 12 42 22 2 77 33 33 32 57 13 14 82 57 12 39 3 58 80 14 87 85 +44 69 109 119 ^ +283 0 102 55 53 41 60 88 25 67 58 76 44 22 68 118 108 40 95 96 81 90 85 28 77 +18 11 37 72 93 60 110 124 119 95 131 91 37 109 126 8 73 69 72 80 17 83 5 76 20 +32 15 10 1 103 18 22 116 98 9 51 104 102 44 33 15 12 24 31 89 1 6 28 101 8 64 +72 106 30 5 52 89 111 39 108 64 85 17 57 124 22 105 78 115 3 40 108 66 108 77 +128 103 44 35 38 13 95 10 111 63 98 117 61 51 126 69 96 70 70 59 39 13 97 33 +112 2 77 7 123 70 83 29 66 67 49 79 19 104 115 14 60 2 55 40 71 33 28 114 51 91 +17 46 45 128 57 87 62 25 115 38 50 55 90 74 8 51 102 79 43 94 36 122 94 12 41 +36 25 104 91 24 7 99 80 30 126 32 63 122 107 114 27 28 79 41 12 35 51 115 122 +70 22 79 65 2 88 27 17 59 15 23 44 57 5 65 6 26 78 80 125 93 84 100 45 22 129 +68 36 111 74 118 11 50 42 120 47 21 8 86 112 26 67 60 99 45 93 47 8 38 59 52 56 +124 20 82 18 117 24 18 46 106 19 117 26 41 47 45 130 7 15 1 4 5 100 10 85 50 44 +11 48 92 119 108 42 118 125 ^ +272 0 8 61 99 70 96 20 87 123 134 82 22 2 110 118 33 86 5 7 5 94 56 15 60 96 54 +13 22 55 99 4 25 105 17 37 69 10 38 117 117 30 70 13 9 109 115 62 94 52 66 117 +100 135 7 75 23 5 81 110 31 118 29 1 62 11 41 88 109 119 102 37 3 30 123 47 31 +56 134 29 124 116 118 99 21 56 77 91 23 37 135 81 44 51 67 95 51 133 30 57 67 +116 122 48 100 7 132 97 106 69 93 4 95 125 102 103 119 81 57 133 96 37 118 50 +117 113 81 127 17 45 103 32 121 129 60 43 65 127 30 36 132 110 52 53 35 71 12 +76 22 72 130 112 99 76 26 21 73 63 63 97 23 58 115 132 114 1 132 31 35 18 23 54 +30 53 118 37 35 84 94 60 100 3 47 18 110 105 87 57 63 76 43 52 45 46 49 65 12 +10 42 66 60 117 34 19 92 5 28 76 9 126 101 125 32 38 34 15 7 62 32 21 3 43 69 +31 109 123 51 116 135 130 129 130 63 14 57 80 62 15 126 31 105 83 108 120 80 +124 46 98 105 91 6 6 27 7 58 128 78 7 79 63 84 77 74 128 65 61 95 121 17 24 123 +117 51 122 ^ +284 0 44 71 43 20 126 58 53 47 98 18 19 119 93 29 70 39 94 112 44 115 135 98 82 +10 67 29 102 113 68 80 19 75 1 91 114 87 80 7 40 37 86 120 16 104 136 117 82 +138 32 65 114 119 137 121 8 12 46 126 26 119 73 130 60 76 113 100 14 133 26 116 +34 120 80 95 84 53 15 24 44 51 4 10 23 77 24 99 66 37 54 63 42 136 21 34 76 5 +17 128 101 1 59 40 113 112 32 97 31 93 105 79 91 18 39 1 103 132 51 68 124 111 +13 97 43 128 69 84 85 72 15 12 26 87 16 16 92 101 13 77 4 118 89 103 56 42 16 +60 44 39 126 46 18 83 93 41 105 3 82 106 115 91 6 4 54 115 15 120 109 113 48 41 +9 95 20 62 67 105 111 25 132 7 116 46 138 44 83 61 124 131 35 107 6 109 81 114 +67 41 137 77 56 74 73 34 12 14 69 52 11 98 47 54 83 81 6 1 15 88 35 139 80 83 +49 89 27 47 130 92 133 87 51 112 76 49 109 49 57 93 73 22 117 50 64 58 97 139 +36 131 111 133 58 33 8 88 55 38 90 46 30 118 57 29 82 74 41 117 38 46 94 92 5 +105 15 117 70 103 68 60 120 48 21 110 85 40 81 66 ^ +291 0 46 113 52 134 79 74 64 57 18 23 9 52 8 16 103 57 138 59 59 65 92 2 7 130 +92 8 34 40 86 131 140 100 112 4 42 1 110 108 43 37 15 67 19 35 94 61 130 98 35 +88 34 65 104 56 126 118 50 87 10 81 109 90 86 118 32 6 114 88 39 38 39 62 3 12 +134 72 137 35 75 81 115 106 140 112 11 123 41 103 45 95 84 71 107 13 26 110 96 +62 16 109 84 59 53 38 27 8 28 13 32 137 17 138 41 122 36 99 65 99 83 36 112 29 +49 70 96 126 136 131 116 3 18 17 126 142 14 37 141 141 123 42 13 20 83 42 139 +83 54 49 58 42 7 137 29 48 16 121 127 34 52 140 106 128 58 36 124 83 24 69 54 +61 112 17 6 95 97 24 57 86 124 59 71 119 67 1 109 54 68 49 57 132 32 5 71 113 +40 80 104 75 106 133 31 126 130 104 62 9 39 44 66 116 141 135 96 132 19 41 121 +126 124 77 8 4 60 82 6 101 124 89 51 123 48 40 85 77 21 112 10 69 66 115 87 16 +108 30 84 65 80 103 32 131 134 73 47 10 63 39 50 93 37 135 114 69 48 34 58 23 +27 133 37 9 40 98 41 115 99 70 83 29 42 67 133 55 79 80 91 122 12 2 115 112 47 ^ +293 1 33 13 99 138 1 42 89 118 87 113 99 12 134 142 100 38 5 55 75 14 110 108 +42 64 130 79 138 62 64 69 57 11 123 25 59 16 111 94 24 65 30 51 119 48 107 92 +84 69 28 136 143 54 20 6 70 47 142 64 4 65 59 73 99 134 146 102 125 116 57 137 +137 72 48 128 78 5 80 63 54 85 30 22 129 68 21 21 74 28 128 107 27 60 2 93 95 +71 37 11 37 15 39 102 3 104 65 80 59 52 113 34 20 67 60 27 81 135 46 106 106 +102 68 128 17 15 100 124 15 43 136 122 100 67 142 35 14 53 120 2 89 93 99 73 9 +122 39 77 15 96 90 43 79 134 60 92 105 55 96 31 119 77 97 72 23 140 38 30 43 83 +136 88 107 117 72 109 118 58 91 119 73 95 100 59 138 123 54 49 143 50 133 66 +106 45 80 88 42 93 5 59 77 101 74 110 104 40 92 19 77 76 86 102 129 3 144 101 +139 134 56 90 18 91 94 85 55 10 137 11 58 1 107 113 70 22 7 56 29 143 111 8 46 +45 116 122 129 89 7 121 53 95 14 49 118 62 125 91 37 97 15 35 100 63 140 63 50 +51 58 26 127 6 45 59 102 121 114 85 141 135 10 72 19 106 66 66 41 53 13 38 1 21 +103 50 108 46 119 ^ +297 1 46 31 132 112 28 63 124 97 129 43 40 72 99 107 132 137 96 139 99 145 121 +144 118 37 81 39 94 60 55 109 47 109 110 75 42 12 139 137 43 128 106 107 19 126 +12 101 148 127 15 117 125 125 62 96 13 76 70 96 101 110 138 8 95 76 143 17 32 +97 79 149 39 31 94 123 21 41 135 55 84 70 33 135 118 50 62 121 81 1 45 144 93 +60 5 64 137 8 105 91 82 67 27 113 119 53 18 98 79 48 84 32 135 128 5 1 20 76 17 +85 108 72 36 141 140 49 150 105 104 3 149 14 54 18 148 64 49 125 37 28 28 101 +22 104 91 32 82 117 12 114 69 58 2 58 115 9 108 47 59 65 14 92 7 4 86 98 16 82 +92 95 38 94 10 10 48 97 104 66 115 97 142 115 122 119 40 97 16 32 47 34 88 89 +26 50 12 76 80 51 40 9 133 24 44 40 122 84 108 22 142 140 99 44 15 54 8 42 125 +150 130 21 79 124 62 46 119 15 29 91 57 150 42 138 71 61 68 80 114 6 1 70 121 +18 35 113 56 87 86 10 73 14 29 41 72 89 1 133 87 101 123 59 90 142 77 133 52 78 +48 34 138 134 27 17 60 131 147 61 93 148 39 132 49 62 71 36 91 4 139 49 100 120 +43 113 144 30 94 73 127 40 125 ^ +313 1 35 97 95 76 105 88 32 138 30 69 61 40 47 21 107 6 39 81 114 53 125 53 147 +14 4 73 146 96 98 13 136 11 98 117 138 153 67 146 71 99 88 7 139 24 13 35 47 97 +145 74 36 119 3 51 84 48 119 53 49 15 79 17 120 103 148 64 30 41 97 120 75 111 +63 58 131 134 18 13 10 48 18 16 48 43 15 54 18 41 47 122 144 80 92 145 77 1 33 +89 54 46 78 48 21 54 43 40 53 24 16 73 42 94 29 44 34 151 152 23 123 12 142 140 +43 37 88 29 19 35 72 96 151 130 62 112 34 36 91 120 50 112 138 2 105 60 68 137 +131 5 17 19 139 74 11 120 78 149 58 128 15 104 16 126 78 20 57 134 71 49 90 76 +108 126 100 54 68 39 132 153 42 147 146 124 62 87 35 75 61 65 46 100 82 105 113 +31 63 5 95 54 71 77 127 150 80 36 144 2 130 59 74 39 3 152 121 122 18 117 12 +117 141 118 135 62 36 69 5 39 53 150 52 153 143 30 66 96 126 131 56 137 8 7 86 +142 14 7 111 141 93 136 137 134 43 12 89 23 44 9 152 146 121 97 19 38 110 91 67 +14 32 110 66 68 8 130 84 73 118 59 24 41 72 121 150 55 37 138 27 104 66 124 9 +51 109 47 125 109 148 8 29 47 72 146 149 61 93 10 20 54 15 76 133 125 106 110 +67 ^ +330 0 23 9 26 136 27 51 115 122 44 106 6 146 108 113 85 51 8 96 47 56 137 62 59 +89 143 71 140 14 85 156 139 99 154 30 53 115 35 147 108 148 58 52 28 103 19 92 +95 152 152 10 11 13 155 67 11 83 101 69 153 152 45 141 14 120 129 140 119 59 2 +89 73 70 83 29 16 67 81 29 1 54 65 96 117 2 37 47 128 33 3 89 108 98 139 49 78 +27 103 39 119 94 132 90 38 132 55 65 131 90 58 2 54 100 69 118 22 44 19 7 148 +93 25 29 123 81 64 131 55 30 1 89 38 97 82 64 9 28 86 123 151 10 133 40 154 102 +4 111 65 9 63 59 124 116 72 105 76 57 137 97 32 145 108 78 112 50 43 34 75 20 +22 129 68 11 118 74 125 118 57 17 20 129 53 65 61 144 1 17 142 156 52 100 54 15 +20 59 52 63 131 20 57 124 31 125 46 106 76 92 8 98 154 152 80 114 15 140 136 +112 100 17 92 25 151 150 80 99 69 83 49 43 156 102 19 57 122 96 30 3 39 134 40 +32 75 5 76 127 138 99 17 57 52 150 130 18 127 33 23 116 107 78 77 77 42 69 68 +48 41 69 33 75 40 49 128 103 4 146 93 10 83 66 96 152 30 38 12 33 5 39 47 41 34 +60 74 20 42 156 67 46 56 102 89 3 124 81 99 104 56 50 8 61 74 55 15 87 108 28 +138 47 93 60 2 124 46 126 103 91 145 36 25 116 122 51 ^ +322 0 75 7 107 158 81 105 154 90 20 125 77 114 69 92 7 58 21 98 154 50 128 149 +117 127 153 45 3 18 121 86 29 71 79 101 2 5 22 143 10 27 53 146 157 148 112 33 +22 80 123 24 147 1 112 82 159 63 74 97 109 33 151 32 89 87 132 117 46 129 59 +115 91 114 118 37 21 9 94 60 25 89 47 79 110 55 12 143 99 87 43 88 56 57 160 76 +12 71 128 77 146 117 95 105 42 66 3 76 20 76 101 100 118 149 45 26 143 148 32 +57 39 129 19 31 84 123 1 152 135 5 54 30 13 125 68 30 62 101 51 142 5 94 83 20 +116 24 107 109 105 91 42 17 27 93 69 3 139 68 79 38 84 2 85 128 126 122 131 46 +17 35 98 42 26 111 100 29 120 55 84 114 109 145 14 18 138 14 9 85 7 18 129 91 2 +94 51 133 82 87 123 64 39 8 103 38 75 110 78 7 9 45 115 42 138 135 86 78 16 62 +52 75 159 54 151 121 149 77 74 16 85 47 102 105 82 119 10 67 137 153 148 135 28 +49 26 151 153 36 80 11 130 113 24 44 30 102 24 58 133 122 140 99 24 156 54 119 +42 115 140 90 132 19 94 2 157 99 136 19 71 7 130 153 108 51 21 58 70 74 137 1 +40 111 149 5 103 6 27 76 141 23 125 140 1 72 29 152 103 87 51 93 29 80 132 77 +123 153 68 159 14 98 114 158 121 158 81 131 ^ +322 0 35 93 109 125 119 10 10 19 135 26 4 74 135 35 120 129 113 92 17 29 47 88 +14 159 149 87 45 36 75 68 22 138 20 59 61 144 151 11 107 6 153 81 114 43 85 157 +97 148 118 73 126 56 58 137 96 11 98 67 98 103 57 146 21 59 88 151 139 148 127 +25 17 47 115 34 160 109 107 51 64 28 69 13 49 149 69 141 90 93 118 64 10 1 67 +80 35 111 13 58 101 124 132 147 154 18 162 6 162 33 5 34 142 41 161 82 114 70 +92 145 57 155 137 114 79 44 36 48 48 21 14 13 40 33 14 150 33 32 54 143 14 4 +101 142 23 93 136 132 120 147 17 38 163 143 5 52 46 151 130 32 72 34 124 150 51 +100 112 128 126 65 10 28 87 81 159 131 19 99 54 125 110 58 119 28 78 129 104 +140 126 38 154 27 114 61 153 90 66 98 76 50 158 48 39 82 123 22 147 136 114 52 +37 35 75 41 15 150 60 52 55 103 21 23 129 95 24 71 47 97 130 50 140 144 106 100 +9 64 19 117 122 71 92 8 77 156 97 121 98 85 2 36 39 109 143 23 120 156 133 93 +154 36 66 116 131 160 127 162 161 46 142 14 141 81 141 63 86 117 104 3 146 39 +127 34 133 102 106 91 57 9 28 60 61 7 158 12 80 26 8 122 80 44 63 68 49 158 21 +32 81 150 15 141 108 161 64 46 124 123 31 99 27 105 109 98 112 144 ^ +336 1 34 161 107 149 48 67 138 109 156 104 37 133 60 80 84 81 160 9 16 96 164 1 +95 112 4 86 163 116 98 103 55 31 8 56 37 36 127 32 9 89 103 31 100 161 85 106 +119 89 154 43 115 162 137 108 128 38 42 155 103 9 62 65 102 122 10 138 160 125 +47 158 43 91 69 123 132 35 121 4 110 89 130 69 29 139 69 53 70 83 29 163 67 41 +9 108 34 45 76 87 2 144 164 98 33 160 79 78 48 89 9 38 134 93 146 79 54 122 80 +38 112 55 55 101 70 8 129 44 70 59 98 149 24 136 124 138 63 25 166 83 51 34 91 +45 30 118 59 28 87 72 44 116 28 36 103 101 113 10 114 62 111 71 65 126 53 19 +114 86 42 85 36 57 137 57 159 95 88 78 72 20 23 14 65 10 22 129 68 1 68 74 75 +108 7 7 147 109 13 35 51 104 158 164 122 126 2 50 4 132 127 59 52 13 81 20 47 +107 74 148 115 46 106 46 82 115 68 144 142 60 104 15 90 136 102 100 134 42 15 +141 100 40 49 49 73 166 13 156 82 166 37 82 96 137 130 166 134 20 139 45 122 56 +107 98 79 124 17 32 130 120 165 77 23 130 96 67 68 47 37 12 29 18 38 158 19 160 +55 147 39 118 83 121 96 43 137 33 66 86 112 147 155 149 140 5 19 17 148 161 10 +44 159 146 57 16 26 102 49 3 104 61 59 74 56 10 165 31 54 25 142 157 37 58 165 +128 154 73 50 149 94 137 ^ +330 1 61 51 65 132 23 169 116 122 14 66 7 98 131 72 69 127 72 163 125 68 69 51 +47 159 31 164 71 118 50 83 113 81 127 153 45 137 134 121 68 163 26 43 65 127 +166 138 98 144 18 53 137 139 148 76 158 4 62 78 167 102 144 94 55 141 63 29 97 +91 24 115 166 80 69 132 99 1 120 23 88 64 87 118 37 137 152 94 60 168 71 47 52 +110 37 155 125 63 42 43 52 11 12 151 31 12 44 110 32 128 117 68 87 24 39 164 76 +145 58 101 91 100 140 151 143 130 32 21 3 111 1 31 75 123 153 116 135 130 27 +164 165 116 23 12 62 83 24 133 139 49 74 154 80 158 80 64 105 91 6 142 27 75 24 +128 112 41 79 29 84 145 40 128 99 95 95 19 17 160 89 15 17 84 64 11 93 10 66 78 +73 127 148 18 129 139 143 49 150 9 84 82 154 85 15 88 82 60 87 19 12 133 58 20 +39 65 51 141 134 27 70 167 120 117 86 60 16 44 16 57 132 18 142 85 104 59 47 +141 58 2 66 96 46 119 153 40 110 126 103 90 144 13 26 106 144 80 145 134 103 95 +24 44 21 84 140 13 97 104 140 99 6 147 54 83 42 106 131 54 96 135 67 118 121 81 +109 10 53 132 112 117 81 33 155 49 61 38 119 1 13 102 131 148 94 131 143 67 123 +148 89 104 135 72 145 152 76 87 6 66 2 71 123 77 114 108 59 123 166 62 96 140 +94 149 116 169 ^ +349 0 125 17 93 82 80 110 156 147 156 99 154 4 29 90 163 120 84 113 56 8 157 29 +61 169 141 113 78 48 50 13 138 11 50 61 99 106 2 107 6 117 81 114 34 49 112 52 +130 82 73 108 20 22 110 60 11 98 22 62 58 48 146 149 23 88 142 139 121 91 16 +163 2 88 171 133 100 62 51 46 10 24 150 49 131 60 114 63 84 91 64 165 138 40 44 +172 111 141 58 74 115 96 129 145 164 153 170 126 24 169 16 115 41 125 46 87 61 +92 145 39 155 92 78 70 35 27 21 48 21 151 159 40 15 5 132 170 23 18 107 160 150 +56 133 23 66 109 123 102 102 172 166 145 116 151 34 1 151 130 5 36 34 97 114 15 +82 128 112 119 99 29 138 165 42 36 159 95 19 63 36 89 101 40 92 1 33 93 104 113 +126 2 136 96 52 108 90 57 89 31 5 113 30 39 37 96 4 147 127 105 43 165 35 75 23 +143 105 24 25 10 94 12 160 102 95 170 71 20 70 112 23 95 144 61 73 137 55 1 81 +95 26 65 172 41 147 79 103 80 40 121 36 12 64 98 169 93 111 115 48 127 9 39 107 +131 115 118 162 161 10 142 14 123 54 141 36 41 99 77 140 128 167 82 25 106 57 +70 64 21 19 15 34 126 149 167 53 163 127 86 35 8 54 23 40 140 3 169 45 150 152 +96 81 143 28 28 124 87 13 90 9 87 109 53 67 164 28 131 89 149 42 55 126 79 132 +74 19 133 30 68 72 75 148 9 10 72 152 144 83 106 153 74 163 98 152 ^ +375 1 94 28 13 8 20 28 18 118 5 140 89 67 171 64 152 85 61 101 80 154 149 34 +115 135 128 108 110 20 33 128 103 35 38 57 95 10 111 151 98 29 149 7 82 69 96 +114 26 103 171 101 53 121 24 2 121 51 35 70 83 29 154 67 5 167 63 16 27 58 60 2 +99 128 71 33 160 70 51 3 44 149 2 89 84 101 43 18 113 71 38 94 55 46 74 52 139 +102 35 43 50 80 122 6 100 88 129 36 25 148 47 24 7 55 36 30 82 32 19 78 63 26 +71 28 167 85 56 167 95 159 78 26 66 35 65 90 44 159 105 59 15 67 57 137 21 132 +50 70 78 36 169 5 172 56 1 22 129 68 168 23 74 30 99 138 174 120 91 153 8 42 68 +158 155 104 99 133 5 135 96 82 59 52 144 36 20 38 62 29 112 106 46 106 19 73 70 +41 135 133 42 95 15 45 136 93 100 98 173 6 132 55 4 4 31 64 130 162 156 64 157 +19 46 96 92 103 139 134 2 94 18 86 38 89 62 61 79 157 14 112 111 156 32 14 85 +78 31 59 20 1 161 169 149 29 122 150 133 37 102 30 109 65 85 51 174 110 164 66 +77 76 111 119 131 95 5 1 166 103 134 141 17 158 123 137 48 165 175 102 13 3 86 +43 23 47 56 150 165 4 36 174 115 157 168 13 147 119 109 55 41 140 67 27 31 27 +53 126 17 163 116 122 160 60 7 92 113 66 45 109 60 151 125 62 39 39 17 153 13 +152 53 94 50 53 89 57 127 153 45 119 104 121 56 145 172 19 41 103 166 108 68 +126 12 53 131 127 148 52 134 168 50 48 155 72 132 82 37 129 63 175 160 ^ +366 1 73 15 79 139 71 51 132 81 135 111 166 61 37 60 118 37 92 134 94 60 150 53 +47 25 110 19 137 107 27 176 43 16 145 146 142 165 12 17 92 166 110 117 41 69 6 +12 164 76 109 40 101 82 82 131 134 115 143 112 32 164 146 93 162 31 66 123 144 +80 135 94 137 156 107 157 173 62 65 176 124 112 4 65 127 44 131 53 19 105 91 +149 106 27 57 158 92 85 14 79 20 84 127 174 128 72 68 59 171 17 124 80 167 8 57 +28 172 66 144 48 42 37 109 121 18 120 103 116 13 132 39 73 145 76 158 43 82 33 +51 153 164 97 13 2 3 20 24 114 98 9 25 131 102 99 86 42 16 26 159 39 105 161 +133 49 59 41 20 105 31 136 30 87 10 119 135 13 83 99 58 45 99 156 26 61 135 143 +80 118 107 76 77 24 44 12 66 95 147 61 86 140 99 167 138 54 47 42 97 122 18 60 +90 40 73 85 63 82 1 35 96 94 81 54 15 128 40 52 2 101 1 165 93 113 130 85 95 98 +58 105 112 53 68 108 72 100 152 49 87 140 39 154 62 114 77 105 63 50 87 157 26 +78 122 67 140 71 170 119 5 93 64 50 104 144 129 138 75 130 4 178 60 139 120 54 +113 32 2 133 17 43 163 129 89 72 149 155 30 38 7 138 5 44 61 69 76 175 107 6 93 +81 114 28 25 82 22 118 58 73 96 175 177 92 36 11 98 171 38 28 42 146 125 178 88 +136 139 103 67 10 151 151 70 153 115 94 32 51 34 177 173 132 49 119 54 96 45 78 +73 64 159 120 22 20 154 111 117 58 56 109 72 143 ^ +372 1 136 146 144 170 90 15 169 180 88 41 89 10 60 52 92 145 21 155 47 42 61 26 +18 176 48 21 124 141 40 179 178 114 143 14 164 71 142 132 11 124 23 39 82 114 +84 57 163 130 127 89 133 16 138 151 130 160 34 70 78 161 64 92 112 110 72 175 +102 138 179 173 159 59 19 27 18 53 92 22 65 156 170 57 104 86 126 148 118 155 +78 43 63 90 48 80 168 142 68 12 39 174 69 168 147 118 96 34 129 35 75 5 107 60 +170 180 147 85 3 133 75 95 152 71 175 43 94 178 50 144 16 46 101 46 165 45 68 +163 38 172 5 138 61 85 62 177 76 36 167 19 53 151 66 66 97 3 100 164 12 98 131 +70 109 162 161 156 142 14 105 27 141 9 178 81 50 113 110 131 37 16 79 12 34 37 +167 173 10 152 7 81 140 158 26 136 82 50 172 154 45 160 31 122 167 142 9 150 +125 51 54 125 174 10 124 51 177 81 173 69 109 8 22 155 19 86 62 149 33 37 108 +34 96 29 174 133 167 50 54 66 130 9 1 36 134 108 65 97 126 56 163 71 83 88 10 1 +8 178 22 6 112 169 116 89 43 153 40 146 85 31 89 74 154 137 28 115 117 122 108 +98 8 27 110 103 176 17 20 27 77 10 93 145 80 17 143 165 76 69 78 102 20 91 171 +95 29 115 176 166 109 39 23 70 83 29 148 67 163 161 33 4 15 46 42 2 69 104 53 +33 160 64 33 155 14 131 160 59 78 71 19 176 107 65 38 82 55 40 56 40 115 84 29 +25 44 68 104 176 76 64 123 18 25 136 23 6 171 31 30 30 58 14 13 72 57 14 41 177 +^ +363 0 135 69 16 167 79 143 46 178 26 3 65 58 36 135 97 35 175 51 152 57 137 173 +108 10 54 78 4 153 173 164 48 177 22 129 68 168 167 74 174 91 106 174 96 75 129 +168 34 36 158 147 88 75 101 149 103 64 42 59 52 112 180 20 30 22 173 80 98 46 +106 179 65 30 17 127 125 26 87 15 5 136 85 100 66 141 182 124 15 156 148 15 56 +98 146 156 48 149 3 14 96 52 79 115 134 170 54 178 54 22 73 30 45 39 133 182 96 +103 148 176 6 45 62 183 51 180 153 145 145 117 21 90 118 109 21 62 22 101 49 53 +11 142 86 132 66 69 44 79 87 115 55 5 169 150 63 110 109 177 150 91 129 40 149 +159 102 165 3 70 27 175 23 56 126 165 164 20 158 91 157 136 157 131 111 69 39 +33 132 43 19 175 179 37 118 9 155 116 122 128 52 7 84 89 58 13 85 44 135 125 54 +183 23 161 145 173 136 29 62 50 13 57 25 127 153 45 95 64 121 40 121 140 171 9 +71 166 68 28 102 4 53 123 111 148 20 102 160 34 8 139 32 116 66 13 113 63 143 +97 63 10 59 124 66 41 132 71 115 106 151 46 22 45 118 37 67 124 94 60 140 43 47 +10 110 9 127 97 7 156 43 180 125 126 137 145 12 2 82 146 100 117 26 59 180 181 +164 76 89 30 101 77 72 126 114 95 143 102 32 149 131 83 157 31 61 123 139 60 +135 74 169 122 151 102 137 168 62 55 166 119 97 163 60 112 24 116 38 178 105 91 +134 86 27 47 138 72 70 183 79 15 84 117 154 128 57 53 39 161 88 ^ +393 1 92 72 151 33 183 164 42 112 32 10 5 93 97 18 112 71 92 168 116 179 186 65 +137 68 134 3 82 9 19 121 148 65 160 173 158 167 90 66 180 172 99 86 83 86 26 16 +10 135 23 81 137 125 17 19 25 183 73 7 104 185 79 165 119 119 176 59 75 18 5 59 +132 26 21 127 119 80 94 83 52 61 24 44 4 50 55 115 29 70 140 99 159 130 54 15 +42 89 114 173 28 50 16 33 53 47 58 180 19 64 78 49 30 186 104 32 44 157 85 1 +149 85 97 114 77 63 58 50 89 80 21 36 84 72 60 152 25 87 108 15 138 54 106 77 +97 23 42 55 149 181 62 106 43 132 31 138 111 176 93 40 10 96 128 105 114 43 98 +4 146 20 107 120 14 113 181 101 1 19 155 113 57 64 117 131 6 22 186 138 184 36 +61 29 36 175 107 6 61 81 114 20 180 42 169 102 26 73 80 151 153 68 4 11 98 139 +6 175 34 146 93 154 88 128 139 79 35 2 135 119 46 129 91 86 179 51 18 169 141 +108 49 103 46 72 21 70 49 64 151 96 185 175 130 111 85 58 32 101 40 101 131 136 +139 170 70 10 169 175 73 41 69 177 45 47 92 145 11 155 22 22 56 21 13 166 48 21 +109 131 40 174 178 104 128 9 149 51 132 122 173 119 23 24 67 109 74 32 158 110 +117 74 123 6 118 151 130 150 167 34 55 58 146 54 72 112 105 57 160 82 123 159 +153 159 39 19 7 8 33 87 12 50 146 150 37 104 71 126 133 108 145 68 38 38 90 43 +75 148 122 43 2 39 154 54 163 147 113 91 29 109 35 75 182 87 35 155 170 127 80 +185 118 60 95 142 71 165 28 84 168 25 144 178 31 81 41 160 25 53 143 ^ +381 1 14 172 163 130 45 69 46 145 36 36 151 169 13 135 42 26 81 153 76 148 178 +90 131 30 101 162 161 132 142 14 89 3 141 175 146 65 26 89 94 99 187 8 55 162 2 +13 143 173 2 120 173 41 132 150 2 112 42 18 140 130 37 128 23 106 159 118 167 +150 101 11 30 109 150 184 124 19 169 73 165 53 109 158 172 147 11 46 38 149 25 +21 92 184 64 179 158 133 135 34 38 58 114 9 183 4 118 76 49 89 102 40 163 47 75 +80 176 175 8 154 14 180 104 153 84 89 11 129 8 138 85 181 73 66 154 121 20 115 +93 114 108 82 182 19 86 103 176 183 186 177 53 10 69 137 56 1 135 141 68 69 54 +86 12 75 171 87 187 107 144 150 93 23 7 70 83 29 140 67 139 153 183 178 189 30 +18 2 29 72 29 33 160 56 9 123 164 107 136 19 70 31 177 152 99 57 38 66 55 32 32 +24 83 60 21 1 36 52 80 168 44 32 115 184 25 120 181 172 155 189 22 30 26 180 5 +64 49 188 1 28 111 57 176 167 67 131 22 160 186 169 65 34 30 117 91 17 163 39 +134 57 137 155 90 170 42 78 170 141 167 158 42 177 22 129 68 168 143 74 150 85 +82 174 78 63 111 156 28 12 158 141 76 57 77 125 79 40 12 59 52 88 156 20 24 182 +149 56 92 46 106 167 59 189 121 119 14 81 15 165 136 79 100 42 117 182 118 175 +138 124 3 50 74 134 156 36 143 181 180 96 22 61 97 134 164 24 166 30 10 61 6 33 +9 115 176 84 97 142 152 15 50 165 45 168 135 133 127 93 15 66 94 91 9 32 16 95 +37 29 171 118 68 108 66 63 20 55 186 ^ +396 1 97 10 5 160 132 18 83 73 159 141 55 120 31 131 141 102 138 3 52 9 148 189 +56 99 165 146 2 140 64 157 100 121 113 102 24 21 24 123 16 10 139 152 19 109 +146 116 122 92 43 7 75 62 49 170 58 26 117 125 45 147 5 125 136 155 118 2 26 50 +161 21 182 127 153 45 68 19 121 22 94 104 144 166 35 166 23 176 75 188 53 114 +93 148 177 66 151 16 156 121 180 98 48 179 95 63 107 97 45 1 23 97 57 23 132 53 +79 97 124 19 188 18 118 37 22 106 94 60 122 25 47 176 110 184 109 79 164 120 43 +153 89 90 128 109 12 168 64 110 82 117 192 41 171 163 164 76 53 12 101 68 54 +117 78 59 143 84 32 122 104 65 148 31 52 123 130 24 135 38 151 95 142 93 101 +159 62 37 148 110 70 127 51 85 181 89 11 142 105 91 107 50 27 29 102 36 43 165 +79 6 84 99 118 128 30 26 3 143 17 68 66 139 187 15 165 158 24 88 20 179 174 81 +79 18 106 47 74 150 104 179 162 59 131 62 116 166 82 184 188 97 136 41 136 167 +140 143 175 72 42 174 148 75 74 71 86 14 16 191 117 11 63 119 119 186 182 13 +171 49 182 80 167 73 147 119 107 164 41 57 181 168 29 114 26 184 121 101 80 76 +65 34 49 24 44 191 38 25 91 5 58 140 99 153 124 54 184 42 83 108 155 4 20 191 3 +29 35 40 180 7 40 66 25 12 180 86 26 38 139 73 1 137 79 85 102 71 39 28 44 77 +56 190 12 66 72 30 152 7 87 84 190 126 48 100 77 91 186 36 31 143 163 50 94 25 +126 1 114 105 170 93 22 173 90 116 87 96 19 74 4 122 183 83 120 177 113 169 181 +77 182 1 149 186 ^ +384 1 25 56 85 107 177 6 186 138 184 28 61 184 191 175 107 6 29 81 114 12 156 2 +137 86 189 73 64 127 129 44 167 11 98 107 169 143 26 146 61 130 88 120 139 55 3 +189 119 87 22 105 67 78 147 51 2 161 109 84 49 87 38 48 192 62 25 64 143 72 169 +151 106 111 53 58 8 93 8 85 123 120 131 170 38 2 169 167 49 41 37 153 21 39 92 +145 190 155 177 185 48 13 5 150 48 21 85 115 40 166 178 88 104 1 125 19 116 106 +141 111 23 43 101 58 187 150 78 101 50 107 185 86 151 130 134 143 34 31 26 122 +38 40 112 97 33 136 50 99 127 121 159 7 19 170 187 1 79 191 26 130 118 5 104 47 +126 109 92 129 52 30 193 90 35 67 116 90 3 181 39 122 30 155 147 105 83 21 77 +35 75 174 55 190 131 154 95 72 185 94 36 95 126 71 149 4 68 152 180 144 146 7 +49 33 152 188 29 111 194 172 148 125 35 59 36 125 11 36 141 149 183 125 27 1 71 +133 61 138 168 85 131 5 96 162 161 117 142 14 79 183 141 165 126 55 11 74 84 79 +167 3 40 142 177 193 128 173 192 100 163 16 127 145 182 97 17 193 120 115 32 +108 18 96 154 103 152 150 86 181 15 99 135 179 124 194 164 68 160 43 109 138 +152 142 6 21 23 149 20 11 82 164 44 159 148 133 115 24 28 53 104 9 183 179 108 +56 39 84 87 30 163 32 70 75 166 170 8 139 9 175 99 143 64 89 186 114 183 133 85 +161 63 61 154 111 15 115 78 109 108 72 177 14 71 103 176 173 176 157 38 10 54 +132 41 186 130 126 63 69 39 76 7 65 171 82 172 102 124 140 83 113 ^ +396 1 189 70 83 29 132 67 115 145 151 170 181 14 192 2 187 40 5 33 160 48 183 +91 132 83 112 177 62 189 153 128 91 49 38 50 55 24 8 8 51 36 13 175 28 36 56 +160 12 107 168 25 104 157 156 139 165 14 30 192 164 195 56 41 180 159 28 79 41 +144 167 51 115 188 136 154 145 65 2 22 93 83 191 147 23 110 57 137 131 66 138 +26 78 146 125 159 150 34 177 22 129 68 168 111 74 118 77 50 174 54 47 87 140 20 +178 158 133 60 33 45 93 47 8 170 59 52 56 124 20 16 150 117 24 84 46 106 151 51 +158 173 113 111 196 73 15 133 136 71 100 10 85 182 110 143 114 92 185 42 42 118 +156 20 135 173 156 96 180 37 73 134 156 182 150 196 192 45 172 17 167 91 168 68 +89 134 120 190 173 34 141 37 152 111 117 103 61 7 34 62 67 191 190 8 87 21 195 +139 86 44 76 66 55 186 23 31 87 183 5 155 122 191 68 53 149 136 35 115 26 121 +131 102 123 3 42 197 133 179 56 84 165 136 190 130 49 157 80 101 103 97 197 11 +19 118 1 5 119 137 9 104 193 141 116 122 72 38 7 70 47 44 155 43 16 107 125 40 +127 193 105 131 145 108 185 6 50 141 1 167 127 153 45 53 192 121 12 79 84 129 +151 15 166 196 156 60 188 53 109 83 148 162 46 146 6 136 111 160 88 38 169 85 +63 87 97 35 194 3 82 52 13 132 43 59 92 109 4 178 3 118 37 195 96 94 60 112 15 +47 166 110 179 99 69 149 100 43 138 69 70 123 89 12 158 54 90 72 117 182 31 166 +153 164 76 33 2 101 63 44 112 58 39 143 74 32 107 89 55 143 31 47 123 125 4 135 +18 141 80 137 88 81 154 187 ^ +406 0 23 134 103 49 99 44 64 160 68 190 114 105 91 86 22 27 15 74 8 22 151 79 +199 84 85 90 128 9 5 175 129 17 40 59 125 187 194 144 151 3 60 6 158 153 67 58 +18 99 19 53 129 90 179 134 52 124 55 95 138 82 170 167 69 122 13 108 160 119 +115 161 51 14 167 120 47 60 57 86 16 184 96 197 42 98 112 165 154 199 157 21 +168 52 146 66 126 119 93 150 20 36 153 140 194 93 26 156 114 80 80 55 44 13 35 +24 44 191 24 190 63 177 44 140 99 146 117 54 163 42 76 101 134 176 185 177 168 +1 21 19 180 193 12 52 197 191 173 65 19 31 118 59 1 123 72 71 88 64 11 193 37 +63 28 169 184 45 72 195 152 186 87 56 176 112 41 93 77 84 158 29 3 136 142 36 +80 4 119 166 86 98 163 93 1 145 83 102 66 75 191 46 4 94 155 55 120 149 113 148 +181 49 175 180 142 87 5 51 65 92 167 196 186 138 184 23 61 164 171 175 107 6 9 +81 114 7 141 177 117 76 174 73 54 112 114 29 152 11 98 87 154 123 21 146 41 115 +88 115 139 40 183 189 109 67 7 90 52 73 127 51 192 156 89 69 49 77 33 33 182 57 +10 64 138 57 159 136 91 111 33 58 193 88 188 75 118 110 126 170 18 197 169 162 +34 41 17 138 6 34 92 145 185 155 157 170 43 8 140 48 21 70 105 40 161 178 78 89 +196 110 199 106 96 121 106 23 185 28 96 48 167 145 58 91 35 97 180 66 151 130 +124 128 34 16 6 107 28 20 112 92 18 121 30 84 107 101 159 187 19 155 182 181 74 +186 11 120 98 185 104 32 126 94 82 119 42 25 173 90 30 62 96 70 178 176 39 102 +15 150 147 100 78 16 57 35 75 169 35 170 116 144 75 146 ^ +409 1 185 70 12 95 110 71 133 183 52 136 148 144 114 186 17 25 144 164 5 79 178 +172 124 117 19 43 20 93 174 36 125 117 151 109 3 164 55 101 37 122 152 77 131 +168 88 162 161 93 142 14 63 167 141 149 94 39 190 50 68 47 135 198 16 110 153 +177 104 173 192 68 147 179 119 137 166 73 180 169 88 91 24 76 10 80 146 79 128 +150 62 149 194 83 111 171 124 170 156 60 152 27 109 106 120 134 201 184 202 149 +12 198 66 132 12 127 132 133 83 8 12 45 88 9 183 155 92 24 23 76 63 14 163 8 62 +67 150 162 8 115 1 167 91 127 32 89 162 90 159 125 85 129 47 53 154 95 7 115 54 +101 108 56 169 6 47 103 176 157 160 125 14 10 30 124 17 178 122 102 55 69 15 60 +202 49 171 74 148 94 92 124 67 200 184 70 83 29 127 67 100 140 131 165 176 4 +182 2 167 20 193 33 160 43 173 71 112 68 97 157 57 169 138 113 86 44 38 40 55 +19 196 201 31 21 8 165 23 26 41 155 195 183 102 158 25 94 142 146 129 150 9 30 +177 154 195 51 36 175 139 28 59 31 124 167 41 105 173 121 134 130 65 185 17 78 +78 181 137 13 95 57 137 116 51 118 16 78 131 115 154 145 29 177 22 129 68 168 +91 74 98 72 30 174 39 37 72 130 15 163 158 128 50 18 25 73 27 191 150 59 52 36 +104 20 11 130 97 4 79 46 106 141 46 138 163 108 106 191 68 15 113 136 66 100 +193 65 182 105 123 99 72 180 37 22 108 156 10 130 168 141 96 160 22 58 134 151 +162 140 181 187 35 157 7 147 76 163 58 84 129 100 190 153 24 126 32 142 96 107 +88 41 2 14 42 52 186 170 3 82 11 180 119 66 29 56 66 50 171 3 11 77 163 5 150 +112 128 ^ +413 1 47 25 135 129 7 108 19 107 117 102 102 3 28 190 112 165 56 63 165 122 183 +116 28 157 52 73 89 90 169 202 12 111 185 203 91 116 200 97 193 134 116 122 44 +31 7 63 26 37 134 22 2 93 125 33 99 186 77 124 131 94 171 183 50 113 178 146 +127 153 45 32 164 121 203 58 56 108 130 192 166 168 128 39 188 53 102 69 148 +141 18 139 197 108 97 132 74 24 155 71 63 59 97 21 194 180 61 45 204 132 29 31 +85 88 188 164 187 118 37 167 82 94 60 98 1 47 152 110 172 85 55 128 72 43 117 +41 42 116 61 12 144 40 62 58 117 168 17 159 139 164 76 5 193 101 56 30 105 30 +11 143 60 32 86 68 41 136 31 40 123 118 181 135 195 127 59 130 81 53 147 62 13 +124 98 34 79 39 49 145 53 180 94 105 91 71 2 27 5 54 193 7 141 79 199 84 75 70 +128 199 195 160 119 17 20 54 115 187 184 129 146 193 40 201 143 138 57 43 18 94 +204 38 114 80 179 114 47 119 50 80 118 82 160 152 49 112 198 88 155 104 95 151 +36 199 162 100 27 50 47 86 195 16 179 81 192 27 83 107 150 134 194 147 1 158 32 +131 61 111 119 83 140 5 21 133 120 174 78 26 136 109 65 80 40 29 203 25 24 44 +191 14 170 43 162 34 140 99 141 112 54 148 42 71 96 119 161 165 167 148 186 11 +4 180 188 197 42 182 181 168 50 14 26 103 49 1 113 67 61 78 59 196 173 32 53 8 +154 169 30 72 175 152 176 87 36 166 102 36 88 77 79 138 24 188 131 127 26 70 +194 114 146 66 93 158 93 191 125 78 92 51 60 176 26 4 74 135 35 120 129 113 133 +181 29 170 170 137 77 190 46 45 77 157 191 186 138 184 18 61 144 151 175 107 6 +194 81 114 2 126 110 ^ +427 1 85 60 150 73 38 88 90 5 128 11 98 55 130 91 13 146 9 91 88 107 139 16 159 +189 93 35 191 66 28 65 95 51 184 148 57 45 49 61 25 9 166 49 194 64 130 33 143 +112 67 111 1 58 177 80 164 59 110 94 118 170 194 197 169 154 10 41 193 114 190 +26 92 145 177 155 125 146 35 200 124 48 21 46 89 40 153 178 62 65 196 86 175 90 +80 89 98 23 169 4 88 32 135 137 26 75 11 81 172 34 151 130 108 104 34 200 182 +83 12 196 112 84 202 97 206 60 75 69 159 163 19 131 174 157 66 178 195 104 66 +161 104 8 126 70 66 103 26 17 141 90 22 54 64 38 146 168 39 70 199 142 147 92 +70 8 25 35 75 161 3 138 92 128 43 59 185 55 205 95 100 71 123 173 42 126 128 +144 94 176 205 20 139 149 198 59 168 172 109 112 9 33 10 73 154 36 115 97 131 +99 196 144 45 81 22 112 142 72 131 148 83 162 161 78 142 14 53 157 141 139 74 +29 180 35 58 27 115 198 1 90 138 167 89 173 192 48 137 159 114 132 156 58 160 +154 68 76 19 56 5 70 141 64 113 150 47 129 184 73 96 166 124 155 151 55 147 17 +109 86 100 129 201 164 192 149 7 193 56 112 200 107 122 133 63 206 2 40 78 9 +183 140 82 4 13 71 48 4 163 201 57 62 140 157 8 100 204 162 86 117 12 89 147 75 +144 120 85 109 37 48 154 85 2 115 39 96 108 46 164 1 32 103 176 147 150 105 207 +10 15 119 2 173 117 87 50 69 50 202 39 171 69 133 89 72 114 57 195 179 70 83 29 +122 67 85 135 111 160 171 202 172 2 147 183 33 160 38 163 51 92 53 82 137 52 +149 123 98 81 39 38 30 55 14 186 196 11 6 3 155 18 16 26 150 180 168 97 148 25 +84 127 136 119 135 4 30 162 144 195 46 31 170 119 28 190 ^ +443 1 17 96 167 27 91 152 100 106 109 65 164 10 57 71 167 123 209 74 57 137 95 +30 90 2 78 110 101 147 138 22 177 22 129 68 168 63 74 70 65 2 174 18 23 51 116 +8 142 158 121 36 207 207 45 209 170 122 59 52 8 76 20 4 102 69 186 72 46 106 +127 39 110 149 101 99 184 61 15 85 136 59 100 172 37 182 98 95 78 44 173 30 204 +94 156 206 123 161 120 96 132 1 37 134 144 134 126 160 180 21 136 203 119 55 +156 44 77 122 72 190 125 10 105 25 128 75 93 67 13 205 196 14 31 179 142 206 75 +207 159 91 38 8 28 66 43 150 185 193 63 135 5 143 98 143 32 5 125 124 197 103 +14 97 107 102 87 3 18 185 97 155 56 48 165 112 178 106 13 157 32 53 79 85 149 +197 7 106 175 203 71 101 195 92 193 129 116 122 24 26 7 58 11 32 119 7 202 83 +125 28 79 181 57 119 121 84 161 168 50 93 163 131 127 153 45 17 144 121 198 43 +36 93 115 177 166 148 108 24 188 53 97 59 148 126 208 134 192 88 87 112 64 14 +145 61 63 39 97 11 194 165 46 40 199 132 19 11 80 73 178 154 177 118 37 147 72 +94 60 88 201 47 142 110 167 75 45 113 52 43 102 21 22 111 41 12 134 30 42 48 +117 158 7 154 129 164 76 195 188 101 51 20 100 10 201 143 50 32 71 53 31 131 31 +35 123 113 166 135 180 117 44 125 76 33 142 62 3 114 93 19 59 34 34 130 38 170 +74 105 91 56 192 27 205 34 178 202 131 79 199 84 65 50 128 189 185 145 109 17 +49 105 187 174 114 141 183 20 196 128 123 47 28 18 89 189 23 99 70 179 94 42 +114 45 65 98 82 150 137 29 102 183 68 150 89 75 141 21 184 157 80 7 40 37 86 +190 16 174 66 187 12 68 102 135 114 189 137 191 148 12 116 56 96 119 73 130 200 +6 113 100 154 63 26 116 104 50 80 25 14 193 83 ^ +436 1 24 44 191 211 138 11 138 18 140 99 133 104 54 124 42 63 88 95 137 133 151 +116 162 208 193 180 180 173 26 158 165 160 26 6 18 79 33 1 97 59 45 62 51 172 +141 24 37 189 130 145 6 72 143 152 160 87 4 150 86 28 80 77 71 106 16 164 123 +103 10 54 178 106 114 34 85 150 93 175 93 70 76 27 36 152 207 4 42 103 3 120 97 +113 109 181 210 162 154 129 61 166 38 13 53 141 183 186 138 184 10 61 112 119 +175 107 6 170 81 114 207 102 125 65 50 135 73 28 73 75 203 113 11 98 35 115 71 +8 146 202 76 88 102 139 1 144 189 83 15 181 51 13 60 75 51 179 143 37 30 49 51 +20 207 156 44 184 64 125 18 133 97 52 111 194 58 167 75 149 49 105 84 113 170 +179 197 169 149 208 41 178 99 180 21 92 145 172 155 105 131 30 208 200 114 48 +21 31 79 40 148 178 52 50 196 71 160 80 70 69 93 23 159 202 83 22 115 132 6 65 +209 71 167 14 151 130 98 89 34 190 167 68 2 181 112 79 192 82 191 45 55 49 159 +148 19 116 169 142 61 173 185 94 46 146 104 206 126 55 56 93 16 12 121 90 17 49 +44 18 126 163 39 50 189 137 147 87 65 3 5 35 75 156 196 118 77 118 23 54 185 40 +195 95 90 71 113 163 32 116 108 144 74 166 190 15 134 134 188 39 158 172 94 107 +212 23 53 134 36 105 77 111 89 186 124 35 61 7 102 132 67 131 128 78 162 161 63 +142 14 43 147 141 129 54 19 170 20 48 7 95 198 199 70 123 157 74 173 192 28 127 +139 109 127 146 43 140 139 48 61 14 36 60 136 49 98 150 32 109 174 63 81 161 +124 140 146 50 142 7 109 66 80 124 201 144 182 149 2 188 46 92 185 87 112 133 +43 201 205 35 68 9 183 125 72 197 3 66 33 207 163 191 52 57 130 152 8 85 204 +157 81 107 205 187 ^ +462 1 126 54 123 113 85 81 23 41 154 71 210 115 18 89 108 32 157 209 11 103 176 +133 136 77 193 10 209 112 196 166 110 66 43 69 194 36 202 25 171 62 112 82 44 +100 43 188 172 70 83 29 115 67 64 128 83 153 164 195 158 2 119 187 169 33 160 +31 149 23 64 32 61 109 45 121 102 77 74 32 38 16 55 7 172 189 198 200 211 141 +11 2 5 143 159 147 90 134 25 70 106 122 105 114 212 30 141 130 195 39 24 163 91 +28 11 7 76 167 17 81 137 85 86 94 65 149 5 42 66 157 113 204 59 57 137 80 15 70 +207 78 95 91 142 133 17 177 22 129 68 168 43 74 50 60 197 174 3 13 36 106 3 127 +158 116 26 197 192 25 194 155 102 59 52 203 56 20 214 82 49 171 67 46 106 117 +34 90 139 96 94 179 56 15 65 136 54 100 157 17 182 93 75 63 24 168 25 189 84 +156 201 118 156 105 96 112 201 22 134 139 114 116 145 175 11 121 198 99 40 151 +34 72 117 52 190 105 90 20 118 60 83 52 208 205 181 209 16 174 122 206 70 202 +144 71 18 208 8 66 38 135 170 178 53 115 5 138 88 123 17 200 115 119 182 98 9 +87 97 102 72 3 8 180 82 145 56 33 165 102 173 96 213 157 12 33 69 80 129 192 2 +101 165 203 51 86 190 87 193 124 116 122 4 21 7 53 211 27 104 207 197 73 125 23 +59 176 37 114 111 74 151 153 50 73 148 116 127 153 45 2 124 121 193 28 16 78 +100 162 166 128 88 9 188 53 92 49 148 111 193 129 187 68 77 92 54 4 135 51 63 +19 97 1 194 150 31 35 194 132 9 206 75 58 168 144 167 118 37 127 62 94 60 78 +196 47 132 110 162 65 35 98 32 43 87 1 2 106 21 12 124 20 22 38 117 148 212 149 +119 164 76 180 183 101 46 10 95 205 186 143 40 32 56 38 21 126 31 30 123 108 +151 135 165 107 29 120 71 13 137 62 208 104 88 4 39 29 19 115 23 160 54 105 91 +41 177 27 200 14 163 124 ^ +453 0 115 79 199 84 49 18 128 173 169 121 93 17 186 41 89 187 158 90 133 167 +206 188 104 99 31 4 18 81 165 217 75 54 179 62 34 106 37 41 66 82 134 113 215 +86 159 36 142 65 43 125 215 160 149 48 193 24 21 86 182 16 166 42 179 206 44 94 +111 82 181 121 167 132 198 92 48 72 119 57 114 184 200 81 68 122 39 26 84 96 26 +80 1 208 177 217 24 44 191 206 118 209 123 8 140 99 128 99 54 109 42 58 83 80 +122 113 141 96 147 203 183 180 175 158 16 143 155 155 11 1 13 64 23 1 87 54 35 +52 46 157 121 19 27 174 115 130 209 72 123 152 150 87 202 140 76 23 75 77 66 86 +11 149 118 88 44 168 101 94 14 80 145 93 165 73 65 66 12 21 137 192 4 22 83 201 +120 77 113 94 181 195 157 144 124 51 151 33 211 38 131 178 186 138 184 5 61 92 +99 175 107 6 155 81 114 207 87 105 45 40 120 73 18 58 60 193 98 11 98 15 100 51 +3 146 187 61 88 97 139 204 129 189 73 213 171 36 216 55 55 51 174 138 17 15 49 +41 15 197 146 39 174 64 120 3 123 82 37 111 179 58 157 70 134 39 100 74 108 170 +164 197 169 144 198 41 163 84 170 16 92 145 167 155 85 116 25 208 200 104 48 21 +16 69 40 143 178 42 35 196 56 145 70 60 49 88 23 149 192 78 12 95 127 204 55 +199 61 162 212 151 130 88 74 34 180 152 53 210 166 112 74 182 67 176 30 35 29 +159 133 19 101 164 127 56 168 175 84 26 131 104 196 126 40 46 83 6 7 101 90 12 +44 24 216 106 158 39 30 179 132 147 82 60 216 203 35 75 151 181 98 62 108 3 49 +185 25 185 95 80 71 103 153 22 106 88 144 54 156 175 10 129 119 178 19 148 172 +79 102 207 13 208 33 114 36 95 57 91 79 176 104 25 41 210 92 122 62 131 108 73 +162 161 48 142 14 33 137 141 119 34 9 160 5 38 205 75 198 189 50 108 112 ^ +454 1 53 173 192 113 111 102 120 132 22 112 118 20 40 7 8 213 46 129 28 77 150 +11 81 160 49 60 154 124 119 139 43 135 213 109 38 52 117 201 116 168 149 215 +181 32 64 164 59 98 133 15 194 198 28 54 9 183 104 58 176 209 59 12 200 163 177 +45 50 116 145 8 64 204 150 74 93 184 89 111 39 108 108 85 61 13 36 154 61 210 +115 3 84 108 22 152 209 216 103 176 123 126 57 183 10 199 107 186 161 105 51 38 +69 184 26 202 15 171 57 97 77 24 90 33 183 167 70 83 29 110 67 49 123 63 148 +159 190 148 2 99 172 159 33 160 26 139 3 44 17 46 89 40 101 87 62 69 27 38 6 55 +2 162 184 183 190 211 131 6 212 210 138 144 132 85 124 25 60 91 112 95 99 212 +30 126 120 195 34 19 158 71 28 211 217 56 167 7 71 122 70 66 79 65 134 27 61 +147 103 199 44 57 137 65 50 202 78 80 81 137 128 12 177 22 129 68 168 23 74 30 +55 182 174 208 3 21 96 218 112 158 111 16 187 177 5 179 140 82 59 52 188 36 20 +214 62 29 156 62 46 106 107 29 70 129 91 89 174 51 15 45 136 49 100 142 217 182 +88 55 48 4 163 20 174 74 156 196 113 151 90 96 92 191 7 134 134 94 106 130 170 +1 106 193 79 25 146 24 67 112 32 190 85 210 75 15 108 45 73 37 193 205 166 194 +1 169 102 206 65 197 129 51 218 198 208 66 33 120 155 163 43 95 5 133 78 103 2 +185 105 114 167 93 4 77 87 102 57 3 218 175 67 135 56 18 165 92 168 86 203 157 +212 13 59 75 109 187 217 96 155 203 31 71 185 82 193 119 116 122 204 16 7 48 +201 22 89 197 192 63 125 18 39 171 17 109 101 64 141 138 50 53 133 101 127 153 +45 207 104 121 188 13 216 63 85 147 166 108 68 214 188 53 87 39 148 96 178 124 +182 48 67 72 44 214 125 41 63 219 97 211 194 135 16 30 189 132 219 191 70 43 +158 181 ^ +475 0 153 118 37 99 48 94 60 64 189 47 118 110 155 51 21 77 4 43 66 195 196 99 +215 12 110 6 216 24 117 134 205 142 105 164 76 159 176 101 39 218 88 184 165 +143 26 32 35 17 7 119 31 23 123 101 130 135 144 93 8 113 64 207 130 62 201 90 +81 205 11 22 220 94 2 146 26 105 91 20 156 27 193 208 142 178 107 79 199 84 41 +2 128 165 161 109 85 17 174 37 81 187 150 78 129 159 194 184 92 87 23 214 18 77 +153 209 63 46 179 46 30 102 33 29 50 82 126 101 203 78 147 20 138 53 27 117 207 +148 145 32 181 16 13 86 178 16 162 30 175 198 32 90 99 66 177 113 155 124 186 +80 44 60 119 49 106 176 192 65 52 106 27 26 68 92 14 80 211 200 169 213 24 44 +191 202 102 197 111 140 99 124 95 54 97 42 54 79 68 110 97 133 80 135 199 175 +180 171 146 8 131 147 151 221 219 9 52 15 1 79 50 27 44 42 145 105 15 19 162 +103 118 201 72 107 152 142 87 190 132 68 19 71 77 62 70 7 137 114 76 214 36 160 +97 78 220 76 141 93 157 57 61 58 9 125 180 4 6 67 189 120 61 113 82 181 183 153 +136 120 43 139 29 199 26 123 174 186 138 184 1 61 76 83 175 107 6 143 81 114 +207 75 89 29 32 108 73 10 46 48 185 86 11 98 221 88 35 221 146 175 49 88 93 139 +196 117 189 65 201 163 24 208 51 39 51 170 134 1 3 49 33 11 189 138 35 166 64 +116 213 115 70 25 111 167 58 149 66 122 31 96 66 104 170 152 197 169 140 190 41 +151 72 162 12 92 145 163 155 69 104 21 208 200 96 48 21 4 61 40 139 178 34 23 +196 44 133 62 52 33 84 23 141 184 74 4 79 123 192 47 191 53 158 200 151 130 80 +62 34 172 140 41 206 154 112 70 174 55 164 18 19 13 159 121 19 89 160 115 52 +164 167 76 10 119 104 188 126 28 38 75 220 3 85 90 8 40 8 204 90 154 39 14 171 +128 147 78 56 216 191 35 75 147 169 82 50 100 209 45 185 13 177 95 150 ^ +471 0 71 89 139 8 92 60 144 26 142 154 3 122 98 164 216 134 172 58 95 200 224 +201 5 86 36 81 29 63 65 162 76 11 13 196 78 108 55 131 80 66 162 161 27 142 14 +19 123 141 105 6 220 146 209 24 184 47 198 175 22 87 133 38 173 192 205 103 91 +97 115 122 7 92 103 25 2 213 213 36 124 13 62 150 221 61 150 39 45 149 124 104 +134 38 130 208 109 18 32 112 201 96 158 149 215 176 22 44 149 39 88 133 220 189 +193 23 44 9 183 89 48 161 204 54 222 195 163 167 40 45 106 140 8 49 204 145 69 +83 169 89 96 24 93 103 85 41 3 31 154 51 210 115 213 79 108 12 147 209 206 103 +176 113 116 37 173 10 189 102 176 156 100 36 33 69 174 16 202 5 171 52 82 72 4 +80 23 178 162 70 83 29 105 67 34 118 43 143 154 185 138 2 79 157 149 33 160 21 +129 208 24 2 31 69 35 81 72 47 64 22 38 221 55 222 152 179 168 180 211 121 1 +207 200 133 129 117 80 114 25 50 76 102 85 84 212 30 111 110 195 29 14 153 51 +28 196 212 36 167 222 61 107 55 46 64 65 119 220 12 56 137 93 194 29 57 137 50 +210 30 197 78 65 71 132 123 7 177 22 129 68 168 3 74 10 50 167 174 198 218 6 86 +218 97 158 106 6 177 162 210 164 125 62 59 52 173 16 20 214 42 9 141 57 46 106 +97 24 50 119 86 84 169 46 15 25 136 44 100 127 202 182 83 35 33 209 158 15 159 +64 156 191 108 146 75 96 72 181 217 134 129 74 96 115 165 216 91 188 59 10 141 +14 62 107 12 190 65 205 60 10 98 30 63 22 178 205 151 179 211 164 82 206 60 192 +114 31 203 188 193 66 28 105 140 148 33 75 5 128 68 83 212 170 95 109 152 88 +224 67 77 102 42 3 213 170 52 125 56 3 165 82 163 76 193 157 197 218 49 70 89 +182 217 91 145 203 11 56 180 77 193 114 116 122 189 11 7 43 191 17 74 187 187 +53 125 13 19 166 222 104 91 54 131 123 50 33 118 86 127 167 ^ +480 1 45 193 76 121 181 219 195 42 64 126 166 80 40 200 188 53 80 25 148 75 157 +117 175 20 53 44 30 207 111 27 63 198 97 204 194 114 222 23 182 132 212 170 63 +22 144 120 143 118 37 79 38 94 60 54 184 47 108 110 150 41 11 62 211 43 51 180 +181 94 200 12 100 223 201 14 117 124 200 137 95 164 76 144 171 101 34 213 83 +169 150 143 16 32 20 2 224 114 31 18 123 96 115 135 129 83 220 108 59 192 125 +62 196 80 76 195 218 17 210 79 214 136 6 105 91 5 141 27 188 193 127 168 97 79 +199 84 31 209 128 155 151 94 75 17 159 32 71 187 140 63 124 149 179 179 77 72 +13 204 18 72 138 199 48 36 179 26 25 97 28 14 30 82 116 86 188 68 132 133 38 7 +107 197 133 140 12 166 6 3 86 173 16 157 15 170 188 17 85 84 46 172 103 140 114 +171 65 39 45 119 39 96 166 182 45 32 86 12 26 48 87 226 80 201 190 159 208 24 +44 191 197 82 182 96 217 140 99 119 90 54 82 42 49 74 53 95 77 123 60 120 194 +165 180 166 131 225 116 137 146 211 219 4 37 5 1 69 45 17 34 37 130 85 10 9 147 +88 103 191 72 87 152 132 87 175 122 58 14 66 77 57 50 2 122 109 61 209 26 150 +92 58 205 71 136 93 147 37 56 48 212 221 110 165 4 213 47 174 120 41 113 67 181 +168 148 126 115 33 124 24 184 11 113 169 186 138 184 223 61 56 63 175 107 6 128 +81 114 207 60 69 9 22 93 73 31 33 175 71 11 98 206 73 15 221 146 160 34 88 88 +139 186 102 189 55 186 153 9 198 46 19 51 165 129 208 215 49 23 6 179 128 30 +156 64 111 203 105 55 10 111 152 58 139 61 107 21 91 56 99 170 137 197 169 135 +180 41 136 57 152 7 92 145 158 155 49 89 16 208 200 86 48 21 216 51 40 134 178 +24 8 196 29 118 52 42 13 79 23 131 174 69 221 59 118 177 37 181 43 153 185 151 +130 70 47 34 162 125 26 201 139 112 65 164 40 149 3 226 220 159 106 19 74 155 +100 47 159 157 193 ^ +471 0 211 98 104 174 126 7 24 61 213 225 57 90 1 33 209 183 62 147 39 215 157 +121 147 71 49 216 170 35 75 140 148 54 29 86 188 38 185 221 163 95 58 71 81 131 +84 44 144 10 134 142 228 118 86 156 204 126 172 46 91 196 220 197 218 70 36 73 +13 47 57 154 60 3 226 188 70 100 51 131 64 62 162 161 15 142 14 11 115 141 97 +219 216 138 201 16 172 31 198 167 6 75 125 26 173 192 193 95 75 93 111 114 224 +76 91 213 13 227 201 213 28 120 1 50 150 213 45 142 31 33 145 124 92 130 34 126 +204 109 2 16 108 201 80 150 149 215 172 14 28 137 23 80 133 208 185 189 19 36 9 +183 77 40 149 200 50 214 191 163 159 36 41 98 136 8 37 204 141 65 75 157 89 84 +12 81 99 85 25 224 27 154 43 210 115 205 75 108 4 143 209 198 103 176 105 108 +21 165 10 181 98 168 152 96 24 29 69 166 8 202 226 171 48 70 68 217 72 15 174 +158 70 83 29 101 67 22 114 27 139 150 181 130 2 63 145 141 33 160 17 121 196 8 +219 19 53 31 65 60 35 60 18 38 217 55 222 144 175 156 172 211 113 226 203 192 +129 117 105 76 106 25 42 64 94 77 72 212 30 99 102 195 25 10 149 35 28 184 208 +20 167 218 53 95 43 30 52 65 107 220 52 129 85 190 17 57 137 38 202 14 193 78 +53 63 128 119 3 177 22 129 68 168 216 74 223 46 155 174 190 214 223 78 218 85 +158 102 227 169 150 198 152 113 46 59 52 161 20 214 26 222 129 53 46 106 89 20 +34 111 82 80 165 42 15 9 136 40 100 115 190 182 79 19 21 197 154 11 147 56 156 +187 104 142 63 96 56 173 209 134 125 58 88 103 161 212 79 184 43 227 137 6 58 +103 225 190 49 201 48 6 90 18 55 10 166 205 139 167 203 160 66 206 56 188 102 +15 191 180 181 66 24 93 128 136 25 59 5 124 60 67 204 158 87 105 140 84 224 59 +69 102 30 3 209 166 40 117 56 220 165 74 159 68 185 157 185 206 41 66 167 ^ +490 1 176 217 85 133 203 218 38 174 71 193 108 116 122 171 5 7 37 179 11 56 175 +181 41 125 7 226 160 204 98 79 42 119 105 50 9 100 68 127 153 45 185 60 121 177 +211 183 30 52 114 166 64 24 192 188 53 76 17 148 63 145 113 171 4 45 28 22 203 +103 19 63 186 97 200 194 102 214 19 178 132 208 158 59 10 136 112 135 118 37 63 +30 94 60 46 180 47 100 110 146 33 3 50 199 43 39 168 169 90 188 12 92 219 189 6 +117 116 196 133 87 164 76 132 167 101 30 209 79 157 138 143 8 32 8 221 220 110 +31 14 123 92 103 135 117 75 212 104 55 180 121 62 192 72 72 187 206 13 202 67 +206 128 221 105 91 224 129 27 184 181 115 160 89 79 199 84 23 197 128 147 143 +82 67 17 147 28 63 187 132 51 120 141 167 175 65 60 5 196 18 68 126 191 36 28 +179 10 21 93 24 2 14 82 108 74 176 60 120 215 129 26 222 99 189 121 136 227 154 +229 226 86 169 16 153 3 166 180 5 81 72 30 168 95 128 106 159 53 35 33 119 31 +88 158 174 29 16 70 26 32 83 218 80 193 182 151 204 24 44 191 193 66 170 84 213 +140 99 115 86 54 70 42 45 70 41 83 61 115 44 108 190 157 180 162 119 221 104 +129 142 203 219 25 228 1 61 41 9 26 33 118 69 6 1 135 76 91 183 72 71 152 124 +87 163 114 50 10 62 77 53 34 229 110 105 49 205 18 142 88 42 193 67 132 93 139 +21 52 40 204 213 98 153 4 201 31 162 120 25 113 55 181 156 144 118 111 25 112 +20 172 230 105 165 186 138 184 223 61 40 47 175 107 6 116 81 114 207 48 53 224 +14 81 73 223 19 21 167 59 11 98 194 61 230 221 146 148 22 88 84 139 178 90 189 +47 174 145 228 190 42 3 51 161 125 196 207 49 15 2 171 120 26 148 64 107 195 97 +43 229 111 140 58 131 57 95 13 87 48 95 170 125 197 169 131 172 41 124 45 144 3 +92 145 154 155 33 77 12 208 200 78 48 21 208 43 40 130 178 16 227 196 17 106 44 +34 228 75 23 123 166 65 217 43 114 165 29 173 35 200 ^ +479 0 167 151 130 58 29 34 150 107 8 195 121 112 59 152 22 131 218 208 202 159 +88 19 56 149 82 41 153 145 54 199 86 104 166 126 228 16 53 209 225 41 90 230 29 +197 171 46 143 39 203 149 117 147 67 45 216 158 35 75 136 136 38 17 78 176 34 +185 213 155 95 50 71 73 123 225 76 28 144 227 126 130 228 114 74 148 192 118 +172 34 87 192 216 193 206 54 36 65 230 31 49 146 44 228 214 180 62 92 47 131 48 +58 162 161 3 142 14 3 107 141 89 207 212 130 193 8 160 15 198 159 223 63 117 14 +173 192 181 87 59 89 107 106 216 60 79 201 1 227 189 213 20 116 222 38 150 205 +29 134 23 21 141 124 80 126 30 122 200 109 219 104 201 64 142 149 215 168 6 12 +125 7 72 133 196 181 185 15 28 9 183 65 32 137 196 46 206 187 163 151 32 37 90 +132 8 25 204 137 61 67 145 89 72 69 95 85 9 220 23 154 35 210 115 197 71 108 +229 139 209 190 103 176 97 100 5 157 10 173 94 160 148 92 12 25 69 158 202 222 +171 44 58 64 205 64 7 170 154 70 83 29 97 67 10 110 11 135 146 177 122 2 47 133 +133 33 160 13 113 184 225 211 7 37 27 49 48 23 56 14 38 213 55 222 136 171 144 +164 211 105 226 199 184 125 105 93 72 98 25 34 52 86 69 60 212 30 87 94 195 21 +6 145 19 28 172 204 4 167 214 45 83 31 14 40 65 95 220 221 48 121 77 186 5 57 +137 26 194 231 189 78 41 55 124 115 232 177 22 129 68 168 204 74 211 42 143 174 +182 210 215 70 218 73 158 98 223 161 138 186 140 101 30 59 52 149 217 20 214 10 +210 117 49 46 106 81 16 18 103 78 76 161 38 15 226 136 36 100 103 178 182 75 3 +9 185 150 7 135 48 156 183 100 138 51 96 40 165 201 134 121 42 80 91 157 208 67 +180 27 219 133 231 54 99 213 190 33 197 36 2 82 6 47 231 154 205 127 155 195 +156 50 206 52 184 90 232 179 172 169 66 20 81 116 124 17 43 5 120 52 51 196 146 +79 101 128 80 224 65 ^ +503 1 55 102 9 3 202 159 19 103 56 206 165 60 152 54 171 157 164 185 27 59 45 +171 217 80 123 203 203 23 169 66 193 103 116 122 156 7 32 169 6 41 165 176 31 +125 2 211 155 189 93 69 32 109 90 50 225 85 53 127 153 45 175 40 121 172 201 +168 15 37 99 166 44 4 182 188 53 71 7 148 48 130 108 166 220 35 8 12 198 93 9 +63 171 97 195 194 87 204 14 173 132 203 143 54 231 126 102 125 118 37 43 20 94 +60 36 175 47 90 110 141 23 229 35 184 43 24 153 154 85 173 12 82 214 174 232 +117 106 191 128 77 164 76 117 162 101 25 204 74 142 123 143 234 32 229 211 215 +105 31 9 123 87 88 135 102 65 202 99 50 165 116 62 187 62 67 177 191 8 192 52 +196 118 206 105 91 214 114 27 179 166 100 150 79 79 199 84 13 182 128 137 133 +67 57 17 132 23 53 187 122 36 115 131 152 170 50 45 231 186 18 63 111 181 21 18 +179 226 16 88 19 223 230 82 98 59 161 50 105 200 124 11 207 89 179 106 131 212 +139 224 221 86 164 16 148 224 161 170 226 76 57 10 163 85 113 96 144 38 30 18 +119 21 78 148 164 9 232 50 221 26 12 78 208 80 183 172 141 199 24 44 191 188 46 +155 69 208 140 99 110 81 54 55 42 40 65 26 68 41 105 24 93 185 147 180 157 104 +216 89 119 137 193 219 231 10 223 1 51 36 235 16 28 103 49 1 227 120 61 76 173 +72 51 152 114 87 148 104 40 5 57 77 48 14 229 95 100 34 200 8 132 83 22 178 62 +127 93 129 1 47 30 194 203 83 138 4 186 11 147 120 5 113 40 181 141 139 108 106 +15 97 15 157 220 95 160 186 138 184 223 61 20 27 175 107 6 101 81 114 207 33 33 +209 4 66 73 218 4 6 157 44 11 98 179 46 215 221 146 133 7 88 79 139 168 75 189 +37 159 135 218 180 37 219 51 156 120 181 197 49 5 233 161 110 21 138 64 102 185 +87 28 219 111 125 58 121 52 80 3 82 38 90 170 110 197 169 126 162 41 109 30 134 +234 92 145 149 155 13 62 7 208 200 68 48 21 198 33 40 125 178 6 217 196 2 91 34 +24 213 70 23 113 161 ^ +470 0 58 210 15 107 144 15 159 21 142 152 151 130 48 14 34 140 92 231 190 106 +112 54 142 7 116 208 193 187 159 73 19 41 144 67 36 148 135 44 184 71 104 156 +126 218 6 43 204 225 21 90 230 24 182 156 26 138 39 188 139 112 147 62 40 216 +143 35 75 131 121 18 2 68 161 29 185 203 145 95 40 71 63 113 220 66 8 144 212 +116 115 228 109 59 138 177 108 172 19 82 187 211 188 191 34 36 55 215 11 39 136 +24 223 199 170 52 82 42 131 28 53 162 161 226 142 14 231 97 141 79 192 207 120 +183 236 145 233 198 149 208 48 107 237 173 192 166 77 39 84 102 96 206 40 64 +186 224 227 174 213 10 111 212 23 150 195 9 124 13 6 136 124 65 121 25 117 195 +109 204 218 99 201 44 132 149 215 163 234 230 110 225 62 133 181 176 180 10 18 +9 183 50 22 122 191 41 196 182 163 141 27 32 80 127 8 10 204 132 56 57 130 89 +57 223 54 90 85 227 215 18 154 25 210 115 187 66 108 224 134 209 180 103 176 87 +90 223 147 10 163 89 150 143 87 235 20 69 148 228 202 217 171 39 43 59 190 54 +235 165 149 70 83 29 92 67 233 105 229 130 141 172 112 2 27 118 123 33 160 8 +103 169 210 201 230 17 22 29 33 8 51 9 38 208 55 222 126 166 129 154 211 95 226 +194 174 120 90 78 67 88 25 24 37 76 59 45 212 30 72 84 195 16 1 140 237 28 157 +199 222 167 209 35 68 16 232 25 65 80 220 211 43 111 67 181 228 57 137 11 184 +216 184 78 26 45 119 110 232 177 22 129 68 168 189 74 196 37 128 174 172 205 +205 60 218 58 158 93 218 151 123 171 125 86 10 59 52 134 202 20 214 228 195 102 +44 46 106 71 11 236 93 73 71 156 33 15 211 136 31 100 88 163 182 70 221 232 170 +145 2 120 38 156 178 95 133 36 96 20 155 191 134 116 22 70 76 152 203 52 175 7 +209 128 226 49 94 198 190 13 192 21 235 72 229 37 221 139 205 112 140 185 151 +30 206 47 179 75 217 101 ^ +502 0 158 148 66 13 60 95 103 3 15 5 113 38 23 182 125 65 94 107 73 224 37 47 +102 237 3 198 155 7 95 56 198 165 52 148 46 163 157 152 173 19 55 29 167 217 76 +115 203 191 11 165 62 193 99 116 122 144 236 7 28 161 2 29 157 172 23 125 238 +199 151 177 89 61 24 101 78 50 213 73 41 127 153 45 167 24 121 168 193 156 3 25 +87 166 28 228 174 188 53 67 239 148 36 118 104 162 208 27 232 4 194 85 1 63 159 +97 191 194 75 196 10 169 132 199 131 50 223 118 94 117 118 37 27 12 94 60 28 +171 47 82 110 137 15 225 23 172 43 12 141 142 81 161 12 74 210 162 228 117 98 +187 124 69 164 76 105 158 101 21 200 70 130 111 143 230 32 221 203 211 101 31 5 +123 83 76 135 90 57 194 95 46 153 112 62 183 54 63 169 179 4 184 40 188 110 194 +105 91 206 102 27 175 154 88 142 71 79 199 84 5 170 128 129 125 55 49 17 120 19 +45 187 114 24 111 123 140 166 38 33 227 178 18 59 99 173 9 10 179 214 12 84 15 +215 218 82 90 47 149 42 93 188 120 239 195 81 171 94 127 200 127 220 217 86 160 +16 144 216 157 162 218 72 45 234 159 77 101 88 132 26 26 6 119 13 70 140 156 +233 220 34 213 26 236 74 200 80 175 164 133 195 24 44 191 184 30 143 57 204 140 +99 106 77 54 43 42 36 61 14 56 25 97 8 81 181 139 180 153 92 212 77 111 133 185 +219 231 238 219 1 43 32 231 8 24 91 33 237 223 108 49 64 165 72 35 152 106 87 +136 96 32 1 53 77 44 238 229 83 96 22 196 124 79 6 166 58 123 93 121 225 43 22 +186 195 71 126 4 174 235 135 120 229 113 28 181 129 135 100 102 7 85 11 145 212 +87 156 186 138 184 223 61 4 11 175 107 6 89 81 114 207 21 17 197 236 54 73 214 +232 234 149 32 11 98 167 34 203 221 146 121 235 88 75 139 160 63 189 29 147 127 +210 172 33 207 51 152 116 169 189 49 237 233 153 102 17 130 64 98 177 79 16 211 +111 113 58 113 48 68 235 78 30 86 170 98 197 169 122 154 41 97 18 126 234 92 +145 145 155 237 50 209 ^ +481 1 208 200 56 48 21 186 21 40 119 178 236 205 196 226 73 22 12 195 64 23 101 +144 54 206 241 103 132 7 151 13 138 140 151 130 40 2 34 132 80 223 186 94 112 +50 134 237 104 200 181 175 159 61 19 29 140 55 32 144 127 36 172 59 104 148 126 +210 240 35 200 225 5 90 230 20 170 144 10 134 39 176 131 108 147 58 36 216 131 +35 75 127 109 2 232 60 149 25 185 195 137 95 32 71 55 105 216 58 234 144 200 +108 103 228 105 47 130 165 100 172 7 78 183 207 184 179 18 36 47 203 237 31 128 +8 219 187 162 44 74 38 131 12 49 162 161 218 142 14 227 89 141 71 180 203 112 +175 232 133 221 198 141 196 36 99 229 173 192 154 69 23 80 98 88 198 24 52 174 +216 227 162 213 2 107 204 11 150 187 235 116 5 236 132 124 53 117 21 113 191 +109 192 206 95 201 28 124 149 215 159 230 218 98 213 54 133 169 172 176 6 10 9 +183 38 14 110 187 37 188 178 163 133 23 28 72 123 8 240 204 128 52 49 118 89 45 +215 42 86 85 215 211 14 154 17 210 115 179 62 108 220 130 209 172 103 176 79 82 +211 139 10 155 85 142 139 83 227 16 69 140 224 202 213 171 35 31 55 178 46 231 +161 145 70 83 29 88 67 225 101 217 126 137 168 104 2 11 106 115 33 160 4 95 157 +198 193 222 1 18 13 21 238 47 5 38 204 55 222 118 162 117 146 211 87 226 190 +166 116 78 66 63 80 25 16 25 68 51 33 212 30 60 76 195 12 239 136 225 28 145 +195 210 167 205 27 56 4 220 13 65 68 220 203 39 103 59 177 220 57 137 241 176 +204 180 78 14 37 115 106 232 177 22 129 68 168 177 74 184 33 116 174 164 201 +197 52 218 46 158 89 214 143 111 159 113 74 236 59 52 122 190 20 214 216 183 90 +40 46 106 63 7 224 85 69 67 152 29 15 199 136 27 100 76 151 182 66 209 224 158 +141 240 108 30 156 174 91 129 24 96 4 147 183 134 112 6 62 64 148 199 40 171 +233 201 124 222 45 90 186 190 239 188 9 235 64 221 29 213 127 178 ^ +508 1 94 122 173 145 6 206 41 173 57 199 146 150 136 66 9 48 83 91 239 243 5 +109 30 7 174 113 57 90 95 69 224 29 39 102 229 3 194 151 239 87 56 190 165 44 +144 38 155 157 140 161 11 51 13 163 217 72 107 203 179 243 161 58 193 95 116 +122 132 236 7 24 153 242 17 149 168 15 125 238 187 147 165 85 53 16 93 66 50 +201 61 29 127 153 45 159 8 121 164 185 144 235 13 75 166 12 216 166 188 53 63 +235 148 24 106 100 158 196 19 220 240 190 77 237 63 147 97 187 194 63 188 6 165 +132 195 119 46 215 110 86 109 118 37 11 4 94 60 20 167 47 74 110 133 7 221 11 +160 43 129 130 77 149 12 66 206 150 224 117 90 183 120 61 164 76 93 154 101 17 +196 66 118 99 143 226 32 213 195 207 97 31 1 123 79 64 135 78 49 186 91 42 141 +108 62 179 46 59 161 167 176 28 180 102 182 105 91 198 90 27 171 142 76 134 63 +79 199 84 241 158 128 121 117 43 41 17 108 15 37 187 106 12 107 115 128 162 26 +21 223 170 18 55 87 165 241 2 179 202 8 80 11 207 206 82 82 35 137 34 81 176 +116 231 183 73 163 82 123 188 115 216 213 86 156 16 140 208 153 154 210 68 33 +222 155 69 89 80 120 14 22 238 119 5 62 132 148 221 208 18 205 26 224 70 192 80 +167 156 125 191 24 44 191 180 14 131 45 200 140 99 102 73 54 31 42 32 57 2 44 9 +89 236 69 177 131 180 149 80 208 65 103 129 177 219 231 230 215 1 35 28 227 20 +79 17 237 219 96 37 52 157 72 19 152 98 87 124 88 24 241 49 77 40 226 229 71 92 +10 192 236 116 75 234 154 54 119 93 113 213 39 14 178 187 59 114 4 162 223 123 +120 217 113 16 181 117 131 92 98 243 73 7 133 204 79 152 186 138 184 223 61 232 +239 175 107 6 77 81 114 207 9 1 185 232 42 73 210 224 226 141 20 11 98 155 22 +191 221 146 109 227 88 71 139 152 51 189 21 135 119 202 164 29 195 51 148 112 +157 181 49 233 233 145 94 13 122 64 94 169 71 4 203 111 101 58 105 44 56 231 74 +22 82 170 86 197 169 118 146 41 85 6 118 234 92 145 141 149 ^ +484 1 219 32 243 208 200 48 48 21 178 13 40 115 178 232 197 196 218 61 14 4 183 +60 23 93 136 50 202 229 99 120 245 143 5 134 128 151 130 32 236 34 124 68 215 +182 82 112 46 126 229 92 192 169 163 159 49 19 17 136 43 28 140 119 28 160 47 +104 140 126 202 236 27 196 225 235 90 230 16 158 132 240 130 39 164 123 104 147 +54 32 216 119 35 75 123 97 232 224 52 137 21 185 187 129 95 24 71 47 97 212 50 +222 144 188 100 91 228 101 35 122 153 92 172 241 74 179 203 180 167 2 36 39 191 +225 23 120 238 215 175 154 36 66 34 131 242 45 162 161 210 142 14 223 81 141 63 +168 199 104 167 228 121 209 198 133 184 24 91 221 173 192 142 61 7 76 94 80 190 +8 40 162 208 227 150 213 240 103 196 245 150 179 223 108 243 228 128 124 41 113 +17 109 187 109 180 194 91 201 12 116 149 215 155 226 206 86 201 46 133 157 168 +172 2 2 9 183 26 6 98 183 33 180 174 163 125 19 24 64 119 8 232 204 124 48 41 +106 89 33 207 30 82 85 203 207 10 154 9 210 115 171 58 108 216 126 209 164 103 +176 71 74 199 131 10 147 81 134 135 79 219 12 69 132 220 202 209 171 31 19 51 +166 38 227 157 141 70 83 29 84 67 217 97 205 122 133 164 96 2 241 94 107 33 160 +87 145 186 185 214 231 14 243 9 230 43 1 38 200 55 222 110 158 105 138 211 79 +226 186 158 112 66 54 59 72 25 8 13 60 43 21 212 30 48 68 195 8 239 132 213 28 +133 191 198 167 201 19 44 238 208 1 65 56 220 195 35 95 51 173 212 57 137 233 +168 192 176 78 2 29 111 102 232 177 22 129 68 168 165 74 172 29 104 174 156 197 +189 44 218 34 158 85 210 135 99 147 101 62 224 59 52 110 178 20 214 204 171 78 +36 46 106 55 3 212 77 65 63 148 25 15 187 136 23 100 64 139 182 62 197 216 146 +137 240 96 22 156 170 87 125 12 96 234 139 175 134 108 236 54 52 144 195 28 167 +221 193 120 218 41 86 174 190 227 184 243 235 56 213 21 205 115 205 71 ^ +506 0 110 165 141 238 206 37 169 45 187 134 142 124 66 5 36 71 79 235 231 5 105 +22 239 166 101 49 86 83 65 224 21 31 102 221 3 190 147 231 79 56 182 165 36 140 +30 147 157 128 149 3 47 245 159 217 68 99 203 167 235 157 54 193 91 116 122 120 +236 7 20 145 242 5 141 164 7 125 238 175 143 153 81 45 8 85 54 50 189 49 17 127 +153 45 151 240 121 160 177 132 227 1 63 166 244 204 158 188 53 59 231 148 12 94 +96 154 184 11 208 236 186 69 233 63 135 97 183 194 51 180 2 161 132 191 107 42 +207 102 78 101 118 37 243 244 94 60 12 163 47 66 110 129 247 217 247 148 43 236 +117 118 73 137 12 58 202 138 220 117 82 179 116 53 164 76 81 150 101 13 192 62 +106 87 143 222 32 205 187 203 93 31 245 123 75 52 135 66 41 178 87 38 129 104 +62 175 38 55 153 155 244 168 16 172 94 170 105 91 190 78 27 167 130 64 126 55 +79 199 84 237 146 128 113 109 31 33 17 96 11 29 187 98 103 107 116 158 14 9 219 +162 18 51 75 157 233 242 179 190 4 76 7 199 194 82 74 23 125 26 69 164 112 223 +171 65 155 70 119 176 103 212 209 86 152 16 136 200 149 146 202 64 21 210 151 +61 77 72 108 2 18 230 119 245 54 124 140 209 196 2 197 26 212 66 184 80 159 148 +117 187 24 44 191 176 246 119 33 196 140 99 98 69 54 19 42 28 53 238 32 241 81 +224 57 173 123 180 145 68 204 53 95 125 169 219 231 222 211 1 27 24 223 240 16 +67 1 237 215 84 25 40 149 72 3 152 90 87 112 80 16 241 45 77 36 214 229 59 88 +246 188 232 108 71 222 142 50 115 93 105 201 35 6 170 179 47 102 4 150 211 111 +120 205 113 4 181 105 127 84 94 239 61 3 121 196 71 148 186 138 184 223 61 220 +227 175 107 6 65 81 114 207 245 233 173 228 30 73 206 216 218 133 8 11 98 143 +10 179 221 146 97 219 88 67 139 144 39 189 13 123 111 194 156 25 183 51 144 108 +145 173 49 229 233 137 86 9 114 64 90 161 63 240 195 111 89 58 97 40 44 227 70 +14 78 170 74 197 169 114 138 41 73 242 110 234 177 ^ +491 0 145 135 155 207 20 243 208 200 40 48 21 170 5 40 111 178 228 189 196 210 +49 6 246 171 56 23 85 128 46 198 217 95 108 241 135 247 130 116 151 130 24 228 +34 116 56 207 178 70 112 42 118 221 80 184 157 151 159 37 19 5 132 31 24 136 +111 20 148 35 104 132 126 194 232 19 192 225 223 90 230 12 146 120 228 126 39 +152 115 100 147 50 28 216 107 35 75 119 85 220 216 44 125 17 185 179 121 95 16 +71 39 89 208 42 210 144 176 92 79 228 97 23 114 141 84 172 233 70 175 199 176 +155 236 36 31 179 213 15 112 226 211 163 146 28 58 30 131 230 41 162 161 202 +142 14 219 73 141 55 156 195 96 159 224 109 197 198 125 172 12 83 213 173 192 +130 53 241 72 90 72 182 242 28 150 200 227 138 213 236 99 188 237 150 171 211 +100 239 220 124 124 29 109 13 105 183 109 168 182 87 201 246 108 149 215 151 +222 194 74 189 38 133 145 164 168 248 244 9 183 14 248 86 179 29 172 170 163 +117 15 20 56 115 8 224 204 120 44 33 94 89 21 199 18 78 85 191 203 6 154 1 210 +115 163 54 108 212 122 209 156 103 176 63 66 187 123 10 139 77 126 131 75 211 8 +69 124 216 202 205 171 27 7 47 154 30 223 153 137 70 83 29 80 67 209 93 193 118 +129 160 88 2 229 82 99 33 160 246 79 133 174 177 206 219 10 231 247 222 39 247 +38 196 55 222 102 154 93 130 211 71 226 182 150 108 54 42 55 64 25 1 52 35 9 +212 30 36 60 195 4 239 128 201 28 121 187 186 167 197 11 32 230 196 239 65 44 +220 187 31 87 43 169 204 57 137 225 160 180 172 78 240 21 107 98 232 177 22 129 +68 168 153 74 160 25 92 174 148 193 181 36 218 22 158 81 206 127 87 135 89 50 +212 59 52 98 166 20 214 192 159 66 32 46 106 47 249 200 69 61 59 144 21 15 175 +136 19 100 52 127 182 58 185 208 134 133 240 84 14 156 166 83 121 96 222 131 +167 134 104 224 46 40 140 191 16 163 209 185 116 214 37 82 162 190 215 180 235 +235 48 205 13 197 103 205 76 104 161 139 232 146 ^ +516 0 33 165 33 175 122 134 112 66 1 24 59 67 231 219 5 101 14 227 158 89 41 82 +71 61 224 13 23 102 213 3 186 143 223 71 56 174 165 28 136 22 139 157 116 137 +247 43 233 155 217 64 91 203 155 227 153 50 193 87 116 122 108 236 7 16 137 242 +245 133 160 251 125 238 163 139 141 77 37 77 42 50 177 37 5 127 153 45 143 228 +121 156 169 120 219 241 51 166 232 192 150 188 53 55 227 148 82 92 150 172 3 +196 232 182 61 229 63 123 97 179 194 39 172 250 157 132 187 95 38 199 94 70 93 +118 37 231 240 94 60 4 159 47 58 110 125 243 213 239 136 43 228 105 106 69 125 +12 50 198 126 216 117 74 175 112 45 164 76 69 146 101 9 188 58 94 75 143 218 32 +197 179 199 89 31 245 123 71 40 135 54 33 170 83 34 117 100 62 171 30 51 145 +143 244 160 4 164 86 158 105 91 182 66 27 163 118 52 118 47 79 199 84 233 134 +128 105 101 19 25 17 84 7 21 187 90 240 99 99 104 154 2 249 215 154 18 47 63 +149 225 238 179 178 72 3 191 182 82 66 11 113 18 57 152 108 215 159 57 147 58 +115 164 91 208 205 86 148 16 132 192 145 138 194 60 9 198 147 53 65 64 96 242 +14 222 119 241 46 116 132 197 184 238 189 26 200 62 176 80 151 140 109 183 24 +44 191 172 234 107 21 192 140 99 94 65 54 7 42 24 49 230 20 229 73 212 45 169 +115 180 141 56 200 41 87 121 161 219 231 214 207 1 19 20 219 236 12 55 237 237 +211 72 13 28 141 72 239 152 82 87 100 72 8 241 41 77 32 202 229 47 84 238 184 +228 100 67 210 130 46 111 93 97 189 31 250 162 171 35 90 4 138 199 99 120 193 +113 244 181 93 123 76 90 235 49 251 109 188 63 144 186 138 184 223 61 208 215 +175 107 6 53 81 114 207 237 221 161 224 18 73 202 208 210 125 248 11 98 131 250 +167 221 146 85 211 88 63 139 136 27 189 5 111 103 186 148 21 171 51 140 104 133 +165 49 225 233 129 78 5 106 64 86 153 55 232 187 111 77 58 89 36 32 223 66 6 74 +170 62 197 169 110 130 41 61 234 102 234 92 145 133 155 201 14 243 208 200 36 +48 21 166 1 40 109 178 147 ^ +522 0 179 196 200 34 251 241 156 51 23 75 118 41 193 202 90 93 236 125 242 125 +101 151 130 14 218 34 106 41 197 173 55 112 37 108 211 65 174 142 136 159 22 19 +245 127 16 19 131 101 10 133 20 104 122 126 184 227 9 187 225 208 90 230 7 131 +105 213 121 39 137 105 95 147 45 23 216 92 35 75 114 70 205 206 34 110 12 185 +169 111 95 6 71 29 79 203 32 195 144 161 82 64 228 92 8 104 126 74 172 223 65 +170 194 171 140 221 36 21 164 198 5 102 211 206 148 136 18 48 25 131 215 36 162 +161 192 142 14 214 63 141 45 141 190 86 149 219 94 182 198 115 157 252 73 203 +173 192 115 43 226 67 85 62 172 227 13 135 190 227 123 213 231 94 178 227 150 +161 196 90 234 210 119 124 14 104 8 100 178 109 153 167 82 201 231 98 149 215 +146 217 179 59 174 28 133 130 159 163 248 239 9 183 254 243 71 174 24 162 165 +163 107 10 15 46 110 8 214 204 115 39 23 79 89 6 189 3 73 85 176 198 1 154 246 +210 115 153 49 108 207 117 209 146 103 176 53 56 172 113 10 129 72 116 126 70 +201 3 69 114 211 202 200 171 22 247 42 139 20 218 148 132 70 83 29 75 67 199 88 +178 113 124 155 78 2 214 67 89 33 160 246 69 118 159 167 196 204 5 216 237 212 +34 247 38 191 55 222 92 149 78 120 211 61 226 177 140 103 39 27 50 54 25 245 +241 42 25 249 212 30 21 50 195 254 239 123 186 28 106 182 171 167 192 1 17 220 +181 229 65 29 220 177 26 77 33 164 194 57 137 215 150 165 167 78 230 11 102 93 +232 177 22 129 68 168 138 74 145 20 77 174 138 188 171 26 218 7 158 76 201 117 +72 120 74 35 197 59 52 83 151 20 214 177 144 51 27 46 106 37 249 185 59 56 54 +139 16 15 160 136 14 100 37 112 182 53 170 198 119 128 240 69 4 156 161 78 116 +240 96 207 121 157 134 99 209 36 25 135 186 1 158 194 175 111 209 32 77 147 190 +200 175 225 235 38 195 3 187 88 205 61 89 151 134 217 206 30 162 24 166 113 128 +103 66 253 15 50 58 228 210 5 98 8 218 152 80 35 79 62 58 224 7 17 102 207 3 +183 140 217 65 56 168 165 22 133 16 133 157 107 128 244 12 ^ +517 1 218 150 217 59 81 203 140 217 148 45 193 82 116 122 93 236 7 11 127 242 +235 123 155 246 125 238 148 134 126 72 27 247 67 27 50 162 22 247 127 153 45 +133 213 121 151 159 105 209 231 36 166 217 177 140 188 53 50 222 148 242 67 87 +145 157 250 181 227 177 51 224 63 108 97 174 194 24 162 250 152 132 182 80 33 +189 84 60 83 118 37 216 235 94 60 251 154 47 48 110 120 238 208 229 121 43 218 +90 91 64 110 12 40 193 111 211 117 64 170 107 35 164 76 54 141 101 4 183 53 79 +60 143 213 32 187 169 194 84 31 245 123 66 25 135 39 23 160 78 29 102 95 62 166 +20 46 135 128 244 150 246 154 76 143 105 91 172 51 27 158 103 37 108 37 79 199 +84 228 119 128 95 91 4 15 17 69 2 11 187 80 230 94 89 89 149 244 239 210 144 18 +42 48 139 215 233 179 163 252 67 255 181 167 82 56 253 98 8 42 137 103 205 144 +47 137 43 110 149 76 203 200 86 143 16 127 182 140 128 184 55 251 183 142 43 50 +54 81 232 9 212 119 236 36 106 122 182 169 223 179 26 185 57 166 80 141 130 99 +178 24 44 191 167 219 92 6 187 140 99 89 60 54 249 42 19 44 220 5 214 63 197 30 +164 105 180 136 41 195 26 77 116 151 219 231 204 202 1 9 15 214 231 7 40 222 +237 206 57 255 13 131 72 224 152 72 87 85 62 255 241 36 77 27 187 229 32 79 228 +179 223 90 62 195 115 41 106 93 87 174 26 245 152 161 20 75 4 123 184 84 120 +178 113 234 181 78 118 66 85 230 34 251 94 178 53 139 186 138 184 223 61 193 +200 175 107 6 38 81 114 207 227 206 146 219 3 73 197 198 200 115 238 11 98 116 +240 152 221 146 70 201 88 58 139 126 12 189 252 96 93 176 138 16 156 51 135 99 +118 155 49 220 233 119 68 96 64 81 143 45 222 177 111 62 58 79 31 17 218 61 253 +69 170 47 197 169 105 120 41 46 224 92 234 92 145 128 155 186 256 243 208 200 +26 48 21 156 248 40 104 178 221 175 196 196 28 249 239 150 49 23 71 114 39 191 +196 88 87 234 121 240 123 95 151 130 10 214 34 102 35 193 171 49 112 35 104 207 +59 170 136 130 159 16 19 241 125 213 ^ +529 1 15 127 93 2 121 8 104 114 126 176 223 1 183 225 196 90 230 3 119 93 201 +117 39 125 97 91 147 41 19 216 80 35 75 110 58 193 198 26 98 8 185 161 103 95 +257 71 21 71 199 24 183 144 149 74 52 228 88 255 96 114 66 172 215 61 166 190 +167 128 209 36 13 152 186 256 94 199 202 136 128 10 40 21 131 203 32 162 161 +184 142 14 210 55 141 37 129 186 78 141 215 82 170 198 107 145 244 65 195 173 +192 103 35 214 63 81 54 164 215 1 123 182 227 111 213 227 90 170 219 150 153 +184 82 230 202 115 124 2 100 4 96 174 109 141 155 78 201 219 90 149 215 142 213 +167 47 162 20 133 118 155 159 248 235 9 183 246 239 59 170 20 154 161 163 99 6 +11 38 106 8 206 204 111 35 15 67 89 253 181 250 69 85 164 194 256 154 242 210 +115 145 45 108 203 113 209 138 103 176 45 48 160 105 10 121 68 108 122 66 193 +258 69 106 207 202 196 171 18 239 38 127 12 214 144 128 70 83 29 71 67 191 84 +166 109 120 151 70 2 202 55 81 33 160 246 61 106 147 159 188 192 1 204 229 204 +30 247 38 187 55 222 84 145 66 112 211 53 226 173 132 99 27 15 46 46 25 241 233 +34 17 241 212 30 9 42 195 254 239 119 174 28 94 178 159 167 188 252 5 212 169 +221 65 17 220 169 22 69 25 160 186 57 137 207 142 153 163 78 222 3 98 89 232 +177 22 129 68 168 126 74 133 16 65 174 130 184 163 18 218 254 158 72 197 109 60 +108 62 23 185 59 52 71 139 20 214 165 132 39 23 46 106 29 249 173 51 52 50 135 +12 15 148 136 10 100 25 100 182 49 158 190 107 124 240 57 255 156 157 74 112 +232 96 195 113 149 134 95 197 28 13 131 182 248 154 182 167 107 205 28 73 135 +190 188 171 217 235 30 187 254 179 76 205 49 77 143 130 205 206 26 158 12 154 +101 120 91 66 253 3 38 46 224 198 5 94 206 144 68 27 75 50 54 224 258 9 102 199 +3 179 136 209 57 56 160 165 14 129 8 125 157 95 116 240 36 212 148 217 57 77 +203 134 213 146 43 193 80 116 122 87 236 7 9 123 242 231 119 153 244 125 238 +142 132 120 70 23 245 63 21 50 156 16 243 127 153 45 129 207 121 149 155 99 205 +227 30 166 211 57 ^ +548 0 134 188 53 47 219 148 236 58 84 142 148 247 172 224 174 45 221 63 99 97 +171 194 15 156 250 149 132 179 71 30 183 78 54 77 118 37 207 232 94 60 248 151 +47 42 110 117 235 205 223 112 43 212 81 82 61 101 12 34 190 102 208 117 58 167 +104 29 164 76 45 138 101 1 180 50 70 51 143 210 32 181 163 191 81 31 245 123 63 +16 135 30 17 154 75 26 93 92 62 163 14 43 129 119 244 144 240 148 70 134 105 91 +166 42 27 155 94 28 102 31 79 199 84 225 110 128 89 85 255 9 17 60 259 5 187 74 +224 91 83 80 146 238 233 207 138 18 39 39 133 209 230 179 154 252 64 255 175 +158 82 50 247 89 2 33 128 100 199 135 41 131 34 107 140 67 200 197 86 140 16 +124 176 137 122 178 52 245 174 139 37 41 48 72 226 6 206 119 233 30 100 116 173 +160 214 173 26 176 54 160 80 135 124 93 175 24 44 191 164 210 83 257 184 140 99 +86 57 54 243 42 16 41 214 256 205 57 188 21 161 99 180 133 32 192 17 71 113 145 +219 231 198 199 1 3 12 211 228 4 31 213 237 203 48 249 4 125 72 215 152 66 87 +76 56 252 241 33 77 24 178 229 23 76 222 176 220 84 59 186 106 38 103 93 81 165 +23 242 146 155 11 66 4 114 175 75 120 169 113 228 181 69 115 60 82 227 25 251 +85 172 47 136 186 138 184 223 61 184 191 175 107 6 29 81 114 207 221 197 137 +216 254 73 194 192 194 109 232 11 98 107 234 143 221 146 61 195 88 55 139 120 3 +189 249 87 87 170 132 13 147 51 132 96 109 149 49 217 233 113 62 257 90 64 78 +137 39 216 171 111 53 58 73 28 8 215 58 250 66 170 38 197 169 102 114 41 37 218 +86 234 92 145 125 155 177 250 243 208 200 20 48 21 150 245 40 101 178 218 169 +196 190 19 246 236 141 46 23 65 108 36 188 187 85 78 231 115 237 120 86 151 130 +4 208 34 96 26 187 168 40 112 32 98 201 50 164 127 121 159 7 19 235 122 1 14 +126 91 118 5 104 112 126 174 222 259 182 225 193 90 230 2 116 90 198 116 39 122 +95 90 147 40 18 216 77 35 75 109 55 190 196 24 95 7 185 159 101 95 256 71 19 69 +198 22 180 144 146 72 49 228 87 253 94 111 64 172 213 60 165 189 166 125 206 36 +11 149 183 255 92 196 201 133 126 8 38 20 131 213 ^ +547 0 29 162 161 178 142 14 207 49 141 31 120 183 72 135 212 73 161 198 101 136 +238 59 189 173 192 94 29 205 60 78 48 158 206 254 114 176 227 102 213 224 87 +164 213 150 147 175 76 227 196 112 124 255 97 1 93 171 109 132 146 75 201 210 +84 149 215 139 210 158 38 153 14 133 109 152 156 248 232 9 183 240 236 50 167 +17 148 158 163 93 3 8 32 103 8 200 204 108 32 9 58 89 247 175 244 66 85 155 191 +256 154 239 210 115 139 42 108 200 110 209 132 103 176 39 42 151 99 10 115 65 +102 119 63 187 258 69 100 204 202 193 171 15 233 35 118 6 211 141 125 70 83 29 +68 67 185 81 157 106 117 148 64 2 193 46 75 33 160 246 55 97 138 153 182 183 +260 195 223 198 27 247 38 184 55 222 78 142 57 106 211 47 226 170 126 96 18 6 +43 40 25 238 227 28 11 235 212 30 36 195 254 239 116 165 28 85 175 150 167 185 +249 258 206 160 215 65 8 220 163 19 63 19 157 180 57 137 201 136 144 160 78 216 +259 95 86 232 177 22 129 68 168 117 74 124 13 56 174 124 181 157 12 218 248 158 +69 194 103 51 99 53 14 176 59 52 62 130 20 214 156 123 30 20 46 106 23 249 164 +45 49 47 132 9 15 139 136 7 100 16 91 182 46 149 184 98 121 240 48 252 156 154 +71 109 226 96 186 107 143 134 92 188 22 4 128 179 242 151 173 161 104 202 25 70 +126 190 179 168 211 235 24 181 251 173 67 205 40 68 137 127 196 206 23 155 3 +145 92 114 82 66 253 256 29 37 221 189 5 91 256 197 138 59 21 72 41 51 224 255 +3 102 193 3 176 133 203 51 56 154 165 8 126 2 119 157 86 107 237 33 203 145 217 +54 71 203 125 207 143 40 193 77 116 122 78 236 7 6 117 242 225 113 150 241 125 +238 133 129 111 67 17 242 57 12 50 147 7 237 127 153 45 123 198 121 146 149 90 +199 221 21 166 202 162 130 188 53 45 217 148 232 52 82 140 142 245 166 222 172 +41 219 63 93 97 169 194 9 152 250 147 132 177 65 28 179 74 50 73 118 37 201 230 +94 60 246 149 47 38 110 115 233 203 219 106 43 208 75 76 59 95 12 30 188 96 206 +117 54 165 102 25 164 76 39 136 101 261 178 48 64 45 143 208 32 177 159 189 79 +31 245 123 61 10 135 24 13 150 73 24 87 90 62 161 10 41 125 209 ^ +542 1 244 136 232 140 62 122 105 91 158 30 27 151 82 16 94 23 79 199 84 221 98 +128 81 77 247 1 17 48 259 261 187 66 216 87 75 68 142 230 225 203 130 18 35 27 +125 201 226 179 142 252 60 255 167 146 82 42 239 77 258 21 116 96 191 123 33 +123 22 103 128 55 196 193 86 136 16 120 168 133 114 170 48 237 162 135 29 29 40 +60 218 2 198 119 229 22 92 108 161 148 202 165 26 164 50 152 80 127 116 85 171 +24 44 191 160 198 71 249 180 140 99 82 53 54 235 42 12 37 206 248 193 49 176 9 +157 91 180 129 20 188 5 63 109 137 219 231 190 195 1 259 8 207 224 19 201 237 +199 36 241 256 117 72 203 152 58 87 64 48 248 241 29 77 20 166 229 11 72 214 +172 216 76 55 174 94 34 99 93 73 153 19 238 138 147 263 54 4 102 163 63 120 157 +113 220 181 57 111 52 78 223 13 251 73 164 39 132 186 138 184 223 61 172 179 +175 107 6 17 81 114 207 213 185 125 212 246 73 190 184 186 101 224 11 98 95 226 +131 221 146 49 187 88 51 139 112 255 189 245 75 79 162 124 9 135 51 128 92 97 +141 49 213 233 105 54 257 82 64 74 129 31 208 163 111 41 58 65 24 260 211 54 +246 62 170 26 197 169 98 106 41 25 210 78 234 92 145 121 155 165 242 243 208 +200 12 48 21 142 241 40 97 178 214 161 196 182 7 242 232 129 42 23 57 100 32 +184 175 81 66 227 107 233 116 74 151 130 260 200 34 88 14 179 164 28 112 28 90 +193 38 156 115 109 159 259 19 227 118 253 10 122 83 256 106 257 104 104 126 166 +218 255 178 225 181 90 230 262 104 78 186 112 39 110 87 86 147 36 14 216 65 35 +75 105 43 178 188 16 83 3 185 151 93 95 252 71 11 61 194 14 168 144 134 64 37 +228 83 245 86 99 56 172 205 56 161 185 162 113 194 36 3 137 171 251 84 184 197 +121 118 30 16 131 188 27 162 161 174 142 14 205 45 141 27 114 181 68 131 210 67 +155 198 97 130 234 55 185 173 192 88 25 199 58 76 44 154 200 250 108 172 227 96 +213 222 85 160 209 150 143 169 72 225 192 110 124 251 95 263 91 169 109 126 140 +73 201 204 80 149 215 137 208 152 32 147 10 133 103 150 154 248 230 9 183 236 +234 44 165 15 144 156 163 89 1 6 28 101 8 196 204 106 164 ^ +567 0 1 46 89 239 167 236 62 85 143 187 256 154 235 210 115 131 38 108 196 106 +209 124 103 176 31 34 139 91 10 107 61 94 115 59 179 258 69 92 200 202 189 171 +11 225 31 106 264 207 137 121 70 83 29 64 67 177 77 145 102 113 144 56 2 181 34 +67 33 160 246 47 85 126 145 174 171 260 183 215 190 23 247 38 180 55 222 70 138 +45 98 211 39 226 166 118 92 6 260 39 32 25 234 219 20 3 227 212 30 254 28 195 +254 239 112 153 28 73 171 138 167 181 245 250 198 148 207 65 262 220 155 15 55 +11 153 172 57 137 193 128 132 156 78 208 255 91 82 232 177 22 129 68 168 105 74 +112 9 44 174 116 177 149 4 218 240 158 65 190 95 39 87 41 2 164 59 52 50 118 20 +214 144 111 18 16 46 106 15 249 152 37 45 43 128 5 15 127 136 3 100 4 79 182 42 +137 176 86 117 240 36 248 156 150 67 105 218 96 174 99 135 134 88 176 14 258 +124 175 234 147 161 153 100 198 21 66 114 190 167 164 203 235 16 173 247 165 55 +205 28 56 129 123 184 206 19 151 257 133 80 106 70 66 253 248 17 25 217 177 5 +87 252 185 130 47 13 68 29 47 224 251 261 102 185 3 172 129 195 43 56 146 165 +122 260 111 157 74 95 233 29 191 141 217 50 63 203 113 199 139 36 193 73 116 +122 66 236 7 2 109 242 217 105 146 237 125 238 121 125 99 63 9 238 49 50 135 +261 229 127 153 45 115 186 121 142 141 78 191 213 9 166 190 150 122 188 53 41 +213 148 224 40 78 136 130 241 154 218 168 33 215 63 81 97 165 194 263 144 250 +143 132 173 53 24 171 66 42 65 118 37 189 226 94 60 242 145 47 30 110 111 229 +199 211 94 43 200 63 64 55 83 12 22 184 84 202 117 46 161 98 17 164 76 27 132 +101 261 174 44 52 33 143 204 32 169 151 185 75 31 245 123 57 264 135 12 5 142 +69 20 75 86 62 157 2 37 117 101 244 132 228 136 58 116 105 91 154 24 27 149 76 +10 90 19 79 199 84 219 92 128 77 73 243 263 17 42 259 259 187 62 212 85 71 62 +140 226 221 201 126 18 33 21 121 197 224 179 136 252 58 255 163 140 82 38 235 +71 256 15 110 94 187 117 29 119 16 101 122 49 194 191 86 134 16 118 164 131 110 +166 46 233 156 133 25 23 36 54 214 194 119 227 18 88 104 155 142 196 161 26 158 +48 148 80 123 112 81 169 24 44 191 158 192 65 245 178 140 223 ^ +551 1 78 49 54 227 42 8 33 198 240 181 41 164 265 153 83 180 125 8 184 261 55 +105 129 219 231 182 191 1 255 4 203 220 264 7 189 237 195 24 233 248 109 72 191 +152 50 87 52 40 244 241 25 77 16 154 229 267 68 206 168 212 68 51 162 82 30 95 +93 65 141 15 234 130 139 255 42 4 90 151 51 120 145 113 212 181 45 107 44 74 +219 1 251 61 156 31 128 186 138 184 223 61 160 167 175 107 6 5 81 114 207 205 +173 113 208 238 73 186 176 178 93 216 11 98 83 218 119 221 146 37 179 88 47 139 +104 247 189 241 63 71 154 116 5 123 51 124 88 85 133 49 209 233 97 46 257 74 64 +70 121 23 200 155 111 29 58 57 20 252 207 50 242 58 170 14 197 169 94 98 41 13 +202 70 234 92 145 117 155 153 234 243 208 200 4 48 21 134 237 40 93 178 210 153 +196 174 263 238 228 117 38 23 49 92 28 180 163 77 54 223 99 229 112 62 151 130 +256 192 34 80 2 171 160 16 112 24 82 185 26 148 103 97 159 251 19 219 114 245 6 +118 75 252 94 249 104 96 126 158 214 251 174 225 169 90 230 262 92 66 174 108 +39 98 79 82 147 32 10 216 53 35 75 101 31 166 180 8 71 267 185 143 85 95 248 71 +3 53 190 6 156 144 122 56 25 228 79 237 78 87 48 172 197 52 157 181 158 101 182 +36 263 125 159 247 76 172 193 109 110 260 22 12 131 176 23 162 161 166 142 14 +201 37 141 19 102 177 60 123 206 55 143 198 89 118 226 47 177 173 192 76 17 187 +54 72 36 146 188 242 96 164 227 84 213 218 81 152 201 150 135 157 64 221 184 +106 124 243 91 263 87 165 109 114 128 69 201 192 72 149 215 133 204 140 20 135 +2 133 91 146 150 248 226 9 183 228 230 32 161 11 136 152 163 81 265 2 20 97 8 +188 204 102 26 265 40 89 235 163 232 60 85 137 185 256 154 233 210 115 127 36 +108 194 104 209 120 103 176 27 30 133 87 10 103 59 90 113 57 175 258 69 88 198 +202 187 171 9 221 29 100 262 205 135 119 70 83 29 62 67 173 75 139 100 111 142 +52 2 175 28 63 33 160 246 43 79 120 141 170 165 260 177 211 186 21 247 38 178 +55 222 66 136 39 94 211 35 226 164 114 90 256 37 28 25 232 215 16 267 223 212 +30 250 24 195 254 239 110 147 28 67 169 132 167 179 243 246 194 142 203 65 263 ^ +578 0 220 147 11 47 3 149 164 57 137 185 120 120 152 78 200 251 87 78 232 177 +22 129 68 168 93 74 100 5 32 174 108 173 141 266 218 232 158 61 186 87 27 75 29 +260 152 59 52 38 106 20 214 132 99 6 12 46 106 7 249 140 29 41 39 124 1 15 115 +136 269 100 262 67 182 38 125 168 74 113 240 24 244 156 146 63 101 210 96 162 +91 127 134 84 164 6 250 120 171 226 143 149 145 96 194 17 62 102 190 155 160 +195 235 8 165 243 157 43 205 16 44 121 119 172 206 15 147 249 121 68 98 58 66 +253 240 5 13 213 165 5 83 248 173 122 35 5 64 17 43 224 247 257 102 177 3 168 +125 187 35 56 138 165 262 118 256 103 157 62 83 229 25 179 137 217 46 55 203 +101 191 135 32 193 69 116 122 54 236 7 268 101 242 209 97 142 233 125 238 109 +121 87 59 1 234 41 258 50 123 253 221 127 153 45 107 174 121 138 133 66 183 205 +267 166 178 138 114 188 53 37 209 148 216 28 74 132 118 237 142 214 164 25 211 +63 69 97 161 194 255 136 250 139 132 169 41 20 163 58 34 57 118 37 177 222 94 +60 238 141 47 22 110 107 225 195 203 82 43 192 51 52 51 71 12 14 180 72 198 117 +38 157 94 9 164 76 15 128 101 261 170 40 40 21 143 200 32 161 143 181 71 31 245 +123 53 256 135 267 134 65 16 63 82 62 153 264 33 109 89 244 124 220 128 50 104 +105 91 146 12 27 145 64 268 82 11 79 199 84 215 80 128 69 65 235 259 17 30 259 +255 187 54 204 81 63 50 136 218 213 197 118 18 29 9 113 189 220 179 124 252 54 +255 155 128 82 30 227 59 252 3 98 90 179 105 21 111 4 97 110 37 190 187 86 130 +16 114 156 127 102 158 42 225 144 129 17 11 28 42 206 266 186 119 223 10 80 96 +143 130 184 153 26 146 44 140 80 115 104 73 165 24 44 191 154 180 53 237 174 +140 99 76 47 54 223 42 6 31 194 236 175 37 158 261 151 79 180 123 2 182 257 51 +103 125 219 231 178 189 1 253 2 201 218 264 1 183 237 193 18 229 244 105 72 185 +152 46 87 46 36 242 241 23 77 14 148 229 263 66 202 166 210 64 49 156 76 28 93 +93 61 135 13 232 126 135 251 36 4 84 145 45 120 139 113 208 181 39 105 40 72 +217 265 251 55 152 27 126 186 138 184 223 61 154 161 175 107 6 269 81 114 207 +201 167 107 206 234 73 184 172 174 89 212 11 98 77 214 113 221 146 31 175 88 45 +139 100 243 189 213 ^ +578 1 51 63 146 108 1 111 51 120 84 73 125 49 205 233 89 38 257 66 64 66 113 15 +192 147 111 17 58 49 16 244 203 46 238 54 170 2 197 169 90 90 41 1 194 62 234 +92 145 113 155 141 226 243 208 200 268 48 21 126 233 40 89 178 206 145 196 166 +255 234 224 105 34 23 41 84 24 176 151 73 42 219 91 225 108 50 151 130 252 184 +34 72 262 163 156 4 112 20 74 177 14 140 91 85 159 243 19 211 110 237 2 114 67 +248 82 241 104 88 126 150 210 247 170 225 157 90 230 262 80 54 162 104 39 86 71 +78 147 28 6 216 41 35 75 97 19 154 172 59 267 185 135 77 95 244 71 267 45 186 +270 144 144 110 48 13 228 75 229 70 75 40 172 189 48 153 177 154 89 170 36 259 +113 147 243 68 160 189 97 102 256 14 8 131 164 19 162 161 158 142 14 197 29 141 +11 90 173 52 115 202 43 131 198 81 106 218 39 169 173 192 64 9 175 50 68 28 138 +176 234 84 156 227 72 213 214 77 144 193 150 127 145 56 217 176 102 124 235 87 +263 83 161 109 102 116 65 201 180 64 149 215 129 200 128 8 123 266 133 79 142 +146 248 222 9 183 220 226 20 157 7 128 148 163 73 265 270 12 93 8 180 204 98 22 +261 28 89 227 155 224 56 85 125 181 256 154 229 210 115 119 32 108 190 100 209 +112 103 176 19 22 121 79 10 95 55 82 109 53 167 258 69 80 194 202 183 171 5 213 +25 88 258 201 131 115 70 83 29 58 67 165 71 127 96 107 138 44 2 163 16 55 33 +160 246 35 67 108 133 162 153 260 165 203 178 17 247 38 174 55 222 58 132 27 86 +211 27 226 160 106 86 260 248 33 20 25 228 207 8 263 215 212 30 242 16 195 254 +239 106 135 28 55 165 120 167 175 239 238 186 130 195 65 250 220 143 9 43 271 +147 160 57 137 181 116 114 150 78 196 249 85 76 232 177 22 129 68 168 87 74 94 +3 26 174 104 171 137 264 218 228 158 59 184 83 21 69 23 256 146 59 52 32 100 20 +214 126 93 10 46 106 3 249 134 25 39 37 122 271 15 109 136 269 100 258 61 182 +36 119 164 68 111 240 18 242 156 144 61 99 206 96 156 87 123 134 82 158 2 246 +118 169 222 141 143 141 94 192 15 60 96 190 149 158 191 235 4 161 241 153 37 +205 10 38 117 117 166 206 13 145 245 115 62 94 52 66 253 236 271 7 211 159 5 81 +246 167 118 29 1 62 11 41 224 245 255 102 173 3 166 123 183 31 56 134 165 260 +116 254 81 ^ +583 1 157 50 71 225 21 167 133 217 42 47 203 89 183 131 28 193 65 116 122 42 +236 7 268 93 242 201 89 138 229 125 238 97 117 75 55 267 230 33 250 50 111 245 +213 127 153 45 99 162 121 134 125 54 175 197 259 166 166 126 106 188 53 33 205 +148 208 16 70 128 106 233 130 210 160 17 207 63 57 97 157 194 247 128 250 135 +132 165 29 16 155 50 26 49 118 37 165 218 94 60 234 137 47 14 110 103 221 191 +195 70 43 184 39 40 47 59 12 6 176 60 194 117 30 153 90 1 164 76 3 124 101 261 +166 36 28 9 143 196 32 153 135 177 67 31 245 123 49 248 135 262 263 126 61 12 +51 78 62 149 260 29 101 77 244 116 212 120 42 92 105 91 138 27 141 52 260 74 3 +79 199 84 211 68 128 61 57 227 255 17 18 259 251 187 46 196 77 55 38 132 210 +205 193 110 18 25 271 105 181 216 179 112 252 50 255 147 116 82 22 219 47 248 +265 86 86 171 93 13 103 266 93 98 25 186 183 86 126 16 110 148 123 94 150 38 +217 132 125 9 273 20 30 198 266 178 119 219 2 72 88 131 118 172 145 26 134 40 +132 80 107 96 65 161 24 44 191 150 168 41 229 170 140 99 72 43 54 215 42 2 27 +186 228 163 29 146 253 147 71 180 119 264 178 249 43 99 117 219 231 170 185 1 +249 272 197 214 264 263 171 237 189 6 221 236 97 72 173 152 38 87 34 28 238 241 +19 77 10 136 229 255 62 194 162 206 56 45 144 64 24 89 93 53 123 9 228 118 127 +243 24 4 72 133 33 120 127 113 200 181 27 101 32 68 213 257 251 43 144 19 122 +186 138 184 223 61 142 149 175 107 6 261 81 114 207 193 155 95 202 226 73 180 +164 166 81 204 11 98 65 206 101 221 146 19 167 88 41 139 92 235 189 235 45 59 +142 104 273 105 51 118 82 67 121 49 203 233 85 34 257 62 64 64 109 11 188 143 +111 11 58 45 14 240 201 44 236 52 170 270 197 169 88 86 41 269 190 58 234 92 +145 111 155 135 222 243 208 200 266 48 21 122 231 40 87 178 204 141 196 162 251 +232 222 99 32 23 37 80 22 174 145 71 36 217 87 223 106 44 151 130 250 180 34 68 +258 159 154 272 112 18 70 173 8 136 85 79 159 239 19 207 108 233 112 63 246 76 +237 104 84 126 146 208 245 168 225 151 90 230 262 74 48 156 102 39 80 67 76 147 +26 4 216 35 35 75 95 13 148 168 270 53 267 185 131 73 95 242 71 265 41 184 268 +138 144 104 44 7 228 73 225 66 69 36 272 ^ +588 0 181 44 149 173 150 77 158 36 255 101 135 239 60 148 185 85 94 252 6 4 131 +152 15 162 161 150 142 14 193 21 141 3 78 169 44 107 198 31 119 198 73 94 210 +31 161 173 192 52 1 163 46 64 20 130 164 226 72 148 227 60 213 210 73 136 185 +150 119 133 48 213 168 98 124 227 83 263 79 157 109 90 104 61 201 168 56 149 +215 125 196 116 272 111 262 133 67 138 142 248 218 9 183 212 222 8 153 3 120 +144 163 65 265 270 4 89 8 172 204 94 18 257 16 89 219 147 216 52 85 113 177 256 +154 225 210 115 111 28 108 186 96 209 104 103 176 11 14 109 71 10 87 51 74 105 +49 159 258 69 72 190 202 179 171 1 205 21 76 254 197 127 111 70 83 29 54 67 157 +67 115 92 103 134 36 2 151 4 47 33 160 246 27 55 96 125 154 141 260 153 195 170 +13 247 38 170 55 222 50 128 15 78 211 19 226 156 98 82 252 240 29 12 25 224 199 +259 207 212 30 234 8 195 254 239 102 123 28 43 161 108 167 171 235 230 178 118 +187 65 242 220 135 5 35 267 143 152 57 137 173 108 102 146 78 188 245 81 72 232 +177 22 129 68 168 75 74 82 275 14 174 96 167 129 260 218 220 158 55 180 75 9 57 +11 248 134 59 52 20 88 20 214 114 81 264 6 46 106 271 249 122 17 35 33 118 271 +15 97 136 269 100 250 49 182 32 107 156 56 107 240 6 238 156 140 57 95 198 96 +144 79 115 134 78 146 270 238 114 165 214 137 131 133 90 188 11 56 84 190 137 +154 183 235 272 153 237 145 25 205 274 26 109 113 154 206 9 141 237 103 50 86 +40 66 253 228 263 271 207 147 5 77 242 155 110 17 269 58 275 37 224 241 251 102 +165 3 162 119 175 23 56 126 165 256 112 250 91 157 44 65 223 19 161 131 217 40 +43 203 83 179 129 26 193 63 116 122 36 236 7 268 89 242 197 85 136 227 125 238 +91 115 69 53 265 228 29 246 50 105 241 209 127 153 45 95 156 121 132 121 48 171 +193 255 166 160 120 102 188 53 31 203 148 204 10 68 126 100 231 124 208 158 13 +205 63 51 97 155 194 243 124 250 133 132 163 23 14 151 46 22 45 118 37 159 216 +94 60 232 135 47 10 110 101 219 189 191 64 43 180 33 34 45 53 12 2 174 54 192 +117 26 151 88 273 164 76 273 122 101 261 164 34 22 3 143 194 32 149 131 175 65 +31 245 123 47 244 135 258 261 122 59 10 45 76 62 147 258 27 97 71 244 112 208 +116 38 86 105 91 134 270 27 139 46 256 70 275 79 199 160 ^ +594 0 207 56 128 53 49 219 251 17 6 259 247 187 38 188 73 47 26 128 202 197 189 +102 18 21 263 97 173 212 179 100 252 46 255 139 104 82 14 211 35 244 257 74 82 +163 81 5 95 258 89 86 13 182 179 86 122 16 106 140 119 86 142 34 209 120 121 1 +265 12 18 190 266 170 119 215 272 64 80 119 106 160 137 26 122 36 124 80 99 88 +57 157 24 44 191 146 156 29 221 166 140 99 68 39 54 207 42 276 23 178 220 151 +21 134 245 143 63 180 115 256 174 241 35 95 109 219 231 162 181 1 245 272 193 +210 264 255 159 237 185 272 213 228 89 72 161 152 30 87 22 20 234 241 15 77 6 +124 229 247 58 186 158 202 48 41 132 52 20 85 93 45 111 5 224 110 119 235 12 4 +60 121 21 120 115 113 192 181 15 97 24 64 209 249 251 31 136 11 118 186 138 184 +223 61 130 137 175 107 6 253 81 114 207 185 143 83 198 218 73 176 156 158 73 +196 11 98 53 198 89 221 146 7 159 88 37 139 84 227 189 231 33 51 134 96 273 93 +51 114 78 55 113 49 199 233 77 26 257 54 64 60 101 3 180 135 111 277 58 37 10 +232 197 40 232 48 170 262 197 169 84 78 41 261 182 50 234 92 145 107 155 123 +214 243 208 200 262 48 21 114 227 40 83 178 200 133 196 154 243 228 218 87 28 +23 29 72 18 170 133 67 24 213 79 219 102 32 151 130 246 172 34 60 250 151 150 +264 112 14 62 165 274 128 73 67 159 231 19 199 104 225 274 108 55 242 64 229 +104 76 126 138 204 241 164 225 139 90 230 262 62 36 144 98 39 68 59 72 147 22 +216 23 35 75 91 1 136 160 266 41 267 185 123 65 95 238 71 261 33 180 264 126 +144 92 36 273 228 69 217 58 57 28 172 177 42 147 171 148 71 152 36 253 95 129 +237 56 142 183 79 90 250 2 2 131 146 13 162 161 146 142 14 191 17 141 277 72 +167 40 103 196 25 113 198 69 88 206 27 157 173 192 46 275 157 44 62 16 126 158 +222 66 144 227 54 213 208 71 132 181 150 115 127 44 211 164 96 124 223 81 263 +77 155 109 84 98 59 201 162 52 149 215 123 194 110 268 105 260 133 61 136 140 +248 216 9 183 208 220 2 151 1 116 142 163 61 265 270 87 8 168 204 92 16 255 10 +89 215 143 212 50 85 107 175 256 154 223 210 115 107 26 108 184 94 209 100 103 +176 7 10 103 67 10 83 49 70 103 47 155 258 69 68 188 202 177 171 277 201 19 70 +252 195 125 109 70 83 29 52 67 153 65 109 90 101 132 32 2 145 276 43 33 160 246 +23 259 ^ +600 1 87 119 148 132 260 144 189 164 10 247 38 167 55 222 44 125 6 72 211 13 +226 153 92 79 246 234 26 6 25 221 193 273 256 201 212 30 228 2 195 254 239 99 +114 28 34 158 99 167 168 232 224 172 109 181 65 236 220 129 2 29 264 140 146 57 +137 167 102 93 143 78 182 242 78 69 232 177 22 129 68 168 66 74 73 275 5 174 90 +164 123 257 218 214 158 52 177 69 48 2 242 125 59 52 11 79 20 214 105 72 258 3 +46 106 268 249 113 11 32 30 115 271 15 88 136 269 100 244 40 182 29 98 150 47 +104 240 276 235 156 137 54 92 192 96 135 73 109 134 75 137 267 232 111 162 208 +134 122 127 87 185 8 53 75 190 128 151 177 235 269 147 234 139 16 205 268 17 +103 110 145 206 6 138 231 94 41 80 31 66 253 222 257 265 204 138 5 74 239 146 +104 8 266 55 269 34 224 238 248 102 159 3 159 116 169 17 56 120 165 253 109 247 +85 157 35 56 220 16 152 128 217 37 37 203 74 173 126 23 193 60 116 122 27 236 7 +268 83 242 191 79 133 224 125 238 82 112 60 50 262 225 23 240 50 96 235 203 127 +153 45 89 147 121 129 115 39 165 187 249 166 151 111 96 188 53 28 200 148 198 1 +65 123 91 228 115 205 155 7 202 63 42 97 152 194 237 118 250 130 132 160 14 11 +145 40 16 39 118 37 150 213 94 60 229 132 47 4 110 98 216 186 185 55 43 174 24 +25 42 44 12 275 171 45 189 117 20 148 85 270 164 76 267 119 101 261 161 31 13 +273 143 191 32 143 125 172 62 31 245 123 44 238 135 252 258 116 56 7 36 73 62 +144 255 24 91 62 244 106 202 110 32 77 105 91 128 264 27 136 37 250 64 272 79 +199 84 206 53 128 51 47 217 250 17 3 259 246 187 36 186 72 45 23 127 200 195 +188 100 18 20 261 95 171 211 179 97 252 45 255 137 101 82 12 209 32 243 255 71 +81 161 78 3 93 256 88 83 10 181 178 86 121 16 105 138 118 84 140 33 207 117 120 +278 263 10 15 188 266 168 119 214 271 62 78 116 103 157 135 26 119 35 122 80 97 +86 55 156 24 44 191 145 153 26 219 165 140 99 67 38 54 205 42 276 22 176 218 +148 19 131 243 142 61 180 114 254 173 239 33 94 107 219 231 160 180 1 244 272 +192 209 264 253 156 237 184 270 211 226 87 72 158 152 28 87 19 18 233 241 14 77 +5 121 229 245 57 184 157 201 46 40 129 49 19 84 93 43 108 4 223 108 117 233 9 4 +57 118 18 120 112 113 190 181 12 96 22 63 208 247 251 28 134 9 117 186 138 184 +223 61 127 216 ^ +590 1 175 107 6 247 81 114 207 179 134 74 195 212 73 173 150 152 67 190 11 98 +44 192 80 221 146 279 153 88 34 139 78 221 189 228 24 45 128 90 273 84 51 111 +75 46 107 49 196 233 71 20 257 48 64 57 95 278 174 129 111 271 58 31 7 226 194 +37 229 45 170 256 197 169 81 72 41 255 176 44 234 92 145 104 155 114 208 243 +208 200 259 48 21 108 224 40 80 178 197 127 196 148 237 225 215 78 25 23 23 66 +15 167 124 64 15 210 73 216 99 23 151 130 243 166 34 54 244 145 147 258 112 11 +56 159 268 122 64 58 159 225 19 193 101 219 274 105 49 239 55 223 104 70 126 +132 201 238 161 225 130 90 230 262 53 27 135 95 39 59 53 69 147 19 278 216 14 +35 75 88 273 127 154 263 32 267 185 117 59 95 235 71 258 27 177 261 117 144 83 +30 267 228 66 211 52 48 22 172 171 39 144 168 145 62 143 36 250 86 120 234 50 +133 180 70 84 247 277 280 131 137 10 162 161 140 142 14 188 11 141 274 63 164 +34 97 193 16 104 198 63 79 200 21 151 173 192 37 272 148 41 59 10 120 149 216 +57 138 227 45 213 205 68 126 175 150 109 118 38 208 158 93 124 217 78 263 74 +152 109 75 89 56 201 153 46 149 215 120 191 101 262 96 257 133 52 133 137 248 +213 9 183 202 217 274 148 279 110 139 163 55 265 270 275 84 8 162 204 89 13 252 +1 89 209 137 206 47 85 98 172 256 154 220 210 115 101 23 108 181 91 209 94 103 +176 1 4 94 61 10 77 46 64 100 44 149 258 69 62 185 202 174 171 277 195 16 61 +249 192 122 106 70 83 29 49 67 147 62 100 87 98 129 26 2 136 270 37 33 160 246 +17 40 81 115 144 126 260 138 185 160 8 247 38 165 55 222 40 123 68 211 9 226 +151 88 77 242 230 24 2 25 219 189 271 254 197 212 30 224 279 195 254 239 97 108 +28 28 156 93 167 166 230 220 168 103 177 65 232 220 125 25 262 138 142 57 137 +163 98 87 141 78 178 240 76 67 232 177 22 129 68 168 60 74 67 275 280 174 86 +162 119 255 218 210 158 50 175 65 275 42 277 238 119 59 52 5 73 20 214 99 66 +254 1 46 106 266 249 107 7 30 28 113 271 15 82 136 269 100 240 34 182 27 92 146 +41 102 240 272 233 156 135 52 90 188 96 129 69 105 134 73 131 265 228 109 160 +204 132 116 123 85 183 6 51 69 190 122 149 173 235 267 143 232 135 10 205 264 +11 99 108 139 206 4 136 227 88 35 76 25 66 253 218 253 261 202 132 5 72 237 140 +203 ^ +620 0 279 262 51 261 30 224 234 244 102 151 3 155 112 161 9 56 112 165 249 105 +243 77 157 23 44 216 12 140 124 217 33 29 203 62 165 122 19 193 56 116 122 15 +236 7 268 75 242 183 71 129 220 125 238 70 108 48 46 258 221 15 232 50 84 227 +195 127 153 45 81 135 121 125 107 27 157 179 241 166 139 99 88 188 53 24 196 +148 190 272 61 119 79 224 103 201 151 282 198 63 30 97 148 194 229 110 250 126 +132 156 2 7 137 32 8 31 118 37 138 209 94 60 225 128 47 279 110 94 212 182 177 +43 43 166 12 13 38 32 12 271 167 33 185 117 12 144 81 266 164 76 259 115 101 +261 157 27 1 265 143 187 32 135 117 168 58 31 245 123 40 230 135 244 254 108 52 +3 24 69 62 140 251 20 83 50 244 98 194 102 24 65 105 91 120 256 27 132 25 242 +56 268 79 199 84 202 41 128 43 39 209 246 17 274 259 242 187 28 178 68 37 11 +123 192 187 184 92 18 16 253 87 163 207 179 85 252 41 255 129 89 82 4 201 20 +239 247 59 77 153 66 278 85 248 84 71 281 177 174 86 117 16 101 130 114 76 132 +29 199 105 116 274 255 2 3 180 266 160 119 210 267 54 70 104 91 145 127 26 107 +31 114 80 89 78 47 152 24 44 191 141 141 14 211 161 140 99 63 34 54 197 42 276 +18 168 210 136 11 119 235 138 53 180 110 246 169 231 25 90 99 219 231 152 176 1 +240 272 188 205 264 245 144 237 180 262 203 218 79 72 146 152 20 87 7 10 229 +241 10 77 1 109 229 237 53 176 153 197 38 36 117 37 15 80 93 35 96 219 100 109 +225 280 4 45 106 6 120 100 113 182 181 92 14 59 204 239 251 16 126 1 113 186 +138 184 223 61 115 122 175 107 6 243 81 114 207 175 128 68 193 208 73 171 146 +148 63 186 11 98 38 188 74 221 146 275 149 88 32 139 74 217 189 226 18 41 124 +86 273 78 51 109 73 40 103 49 194 233 67 16 257 44 64 55 91 276 170 125 111 267 +58 27 5 222 192 35 227 43 170 252 197 169 79 68 41 251 172 40 234 92 145 102 +155 108 204 243 208 200 257 48 21 104 222 40 78 178 195 123 196 144 233 223 213 +72 23 23 19 62 13 165 118 62 9 208 69 214 97 17 151 130 241 162 34 50 240 141 +145 254 112 9 52 155 264 118 58 52 159 221 19 189 99 215 274 103 45 237 49 219 +104 66 126 128 199 236 159 225 124 90 230 262 47 21 129 93 39 53 49 67 147 17 +278 216 8 35 75 86 269 121 150 261 26 267 185 113 55 95 233 71 256 23 175 259 +111 144 77 26 263 228 64 207 48 42 18 172 167 37 142 166 143 56 137 36 248 80 +114 232 46 127 257 ^ +605 1 58 76 243 273 280 131 125 6 162 161 132 142 14 184 3 141 270 51 160 26 89 +189 4 92 198 55 67 192 13 143 173 192 25 268 136 37 55 2 112 137 208 45 130 227 +33 213 201 64 118 167 150 101 106 30 204 150 89 124 209 74 263 70 148 109 63 77 +52 201 141 38 149 215 116 187 89 254 84 253 133 40 129 133 248 209 9 183 194 +213 266 144 279 102 135 163 47 265 270 271 80 8 154 204 85 9 248 274 89 201 129 +198 43 85 86 168 256 154 216 210 115 93 19 108 177 87 209 86 103 176 278 281 82 +53 10 69 42 56 96 40 141 258 69 54 181 202 170 171 277 187 12 49 245 188 118 +102 70 83 29 45 67 139 58 88 83 94 125 18 2 124 262 29 33 160 246 9 28 69 107 +136 114 260 126 177 152 4 247 38 161 55 222 32 119 273 60 211 1 226 147 80 73 +234 222 20 279 25 215 181 267 250 189 212 30 216 275 195 254 239 93 96 28 16 +152 81 167 162 226 212 160 91 169 65 224 220 117 281 17 258 134 134 57 137 155 +90 75 137 78 170 236 72 63 232 177 22 129 68 168 48 74 55 275 272 174 78 158 +111 251 218 202 158 46 171 57 267 30 269 230 107 59 52 278 61 20 214 87 54 246 +282 46 106 262 249 95 284 26 24 109 271 15 70 136 269 100 232 22 182 23 80 138 +29 98 240 264 229 156 131 48 86 180 96 117 61 97 134 69 119 261 220 105 156 196 +128 104 115 81 179 2 47 57 190 110 145 165 235 263 135 228 127 283 205 256 284 +91 104 127 206 132 219 76 23 68 13 66 253 210 245 253 198 120 5 68 233 128 92 +275 260 49 257 28 224 232 242 102 147 3 153 110 157 5 56 108 165 247 103 241 73 +157 17 38 214 10 134 122 217 31 25 203 56 161 120 17 193 54 116 122 9 236 7 268 +71 242 179 67 127 218 125 238 64 106 42 44 256 219 11 228 50 78 223 191 127 153 +45 77 129 121 123 103 21 153 175 237 166 133 93 84 188 53 22 194 148 186 268 59 +117 73 222 97 199 149 280 196 63 24 97 146 194 225 106 250 124 132 154 281 5 +133 28 4 27 118 37 132 207 94 60 223 126 47 277 110 92 210 180 173 37 43 162 6 +7 36 26 12 269 165 27 183 117 8 142 79 264 164 76 255 113 101 261 155 25 280 +261 143 185 32 131 113 166 56 31 245 123 38 226 135 240 252 104 50 1 18 67 62 +138 249 18 79 44 244 94 190 98 20 59 105 91 116 252 27 130 19 238 52 266 79 199 +84 200 35 128 39 35 205 244 17 270 259 240 187 24 174 66 33 5 121 188 183 182 +88 18 14 249 83 159 205 179 79 252 186 ^ +615 0 255 121 77 82 283 193 8 235 239 47 73 145 54 274 77 240 80 59 273 173 170 +86 113 16 97 122 110 68 124 25 191 93 112 270 247 281 278 172 266 152 119 206 +263 46 62 92 79 133 119 26 95 27 106 80 81 70 39 148 24 44 191 137 129 2 203 +157 140 99 59 30 54 189 42 276 14 160 202 124 3 107 227 134 45 180 106 238 165 +223 17 86 91 219 231 144 172 1 236 272 184 201 264 237 132 237 176 254 195 210 +71 72 134 152 12 87 282 2 225 241 6 77 284 97 229 229 49 168 149 193 30 32 105 +25 11 76 93 27 84 283 215 92 101 217 272 4 33 94 281 120 88 113 174 181 275 88 +6 55 200 231 251 4 118 280 109 186 138 184 223 61 103 110 175 107 6 235 81 114 +207 167 116 56 189 200 73 167 138 140 55 178 11 98 26 180 62 221 146 267 141 88 +28 139 66 209 189 222 6 33 116 78 273 66 51 105 69 28 95 49 190 233 59 8 257 36 +64 51 83 272 162 117 111 259 58 19 1 214 188 31 223 39 170 244 197 169 75 60 41 +243 164 32 234 92 145 98 155 96 196 243 208 200 253 48 21 96 218 40 74 178 191 +115 196 136 225 219 209 60 19 23 11 54 9 161 106 58 284 204 61 210 93 5 151 130 +237 154 34 42 232 133 141 246 112 5 44 147 256 110 46 40 159 213 19 181 95 207 +274 99 37 233 37 211 104 58 126 120 195 232 155 225 112 90 230 262 35 9 117 89 +39 41 41 63 147 13 278 216 283 35 75 82 261 109 142 257 14 267 185 105 47 95 +229 71 252 15 171 255 99 144 65 18 255 228 60 199 40 30 10 172 159 33 138 162 +139 44 125 36 244 68 102 228 38 115 174 52 72 241 271 280 131 119 4 162 161 128 +142 14 182 286 141 268 45 158 22 85 187 285 86 198 51 61 188 9 139 173 192 19 +266 130 35 53 285 108 131 204 39 126 227 27 213 199 62 114 163 150 97 100 26 +202 146 87 124 205 72 263 68 146 109 57 71 50 201 135 34 149 215 114 185 83 250 +78 251 133 34 127 131 248 207 9 183 190 211 262 142 279 98 133 163 43 265 270 +269 78 8 150 204 83 7 246 270 89 197 125 194 41 85 80 166 256 154 214 210 115 +89 17 108 175 85 209 82 103 176 276 279 76 49 10 65 40 52 94 38 137 258 69 50 +179 202 168 171 277 183 10 43 243 186 116 100 70 83 29 43 67 135 56 82 81 92 +123 14 2 118 258 25 33 160 246 5 22 63 103 132 108 260 120 173 148 2 247 38 159 +55 222 28 117 269 56 211 284 226 145 76 71 230 218 18 277 25 213 177 265 248 +185 212 30 212 273 195 254 239 91 90 28 10 150 75 167 160 224 175 ^ +613 0 152 79 161 65 216 220 109 281 9 254 130 126 57 137 147 82 63 133 78 162 +232 68 59 232 177 22 129 68 168 36 74 43 275 264 174 70 154 103 247 218 194 158 +42 167 49 259 18 261 222 95 59 52 270 49 20 214 75 42 238 282 46 106 258 249 83 +280 22 20 105 271 15 58 136 269 100 224 10 182 19 68 130 17 94 240 256 225 156 +127 44 82 172 96 105 53 89 134 65 107 257 212 101 152 188 124 92 107 77 175 287 +43 45 190 98 141 157 235 259 127 224 119 275 205 248 276 83 100 115 206 285 128 +211 64 11 60 1 66 253 202 237 245 194 108 5 64 229 116 84 267 256 45 249 24 224 +228 238 102 139 3 149 106 149 286 56 100 165 243 99 237 65 157 5 26 210 6 122 +118 217 27 17 203 44 153 116 13 193 50 116 122 286 236 7 268 63 242 171 59 123 +214 125 238 52 102 30 40 252 215 3 220 50 66 215 183 127 153 45 69 117 121 119 +95 9 145 167 229 166 121 81 76 188 53 18 190 148 178 260 55 113 61 218 85 195 +145 276 192 63 12 97 142 194 217 98 250 120 132 150 273 1 125 20 285 19 118 37 +120 203 94 60 219 122 47 273 110 88 206 176 165 25 43 154 283 284 32 14 12 265 +161 15 179 117 138 75 260 164 76 247 109 101 261 151 21 272 253 143 181 32 123 +105 162 52 31 245 123 34 218 135 232 248 96 46 286 6 63 62 134 245 14 71 32 244 +86 182 90 12 47 105 91 108 244 27 126 7 230 44 262 79 199 84 196 23 128 31 27 +197 240 17 262 259 236 187 16 166 62 25 282 117 180 175 178 80 18 10 241 75 151 +201 179 67 252 35 255 117 71 82 281 189 2 233 235 41 71 141 48 272 73 236 78 53 +269 171 168 86 111 16 95 118 108 64 120 23 187 87 110 268 243 279 274 168 266 +148 119 204 261 42 58 86 73 127 115 26 89 25 102 80 77 66 35 146 24 44 191 135 +123 285 199 155 140 99 57 28 54 185 42 276 12 156 198 118 288 101 223 132 41 +180 104 234 163 219 13 84 87 219 231 140 170 1 234 272 182 199 264 233 126 237 +174 250 191 206 67 72 128 152 8 87 278 287 223 241 4 77 284 91 229 225 47 164 +147 191 26 30 99 19 9 74 93 23 78 283 213 88 97 213 268 4 27 88 277 120 82 113 +170 181 271 86 2 53 198 227 251 287 114 278 107 186 138 184 223 61 97 104 175 +107 6 231 81 114 207 163 110 50 187 196 73 165 134 136 51 174 11 98 20 176 56 +221 146 263 137 88 26 139 62 205 189 220 29 112 74 273 60 51 103 67 22 91 49 +188 233 55 4 257 32 64 49 79 270 158 113 111 255 58 15 288 210 213 ^ +624 1 28 220 36 170 238 197 169 72 54 41 237 158 26 234 92 145 95 155 87 190 +243 208 200 250 48 21 90 215 40 71 178 188 109 196 130 219 216 206 51 16 23 5 +48 6 158 97 55 278 201 55 207 90 286 151 130 234 148 34 36 226 127 138 240 112 +2 38 141 250 104 37 31 159 207 19 175 92 201 274 96 31 230 28 205 104 52 126 +114 192 229 152 225 103 90 230 262 26 108 86 39 32 35 60 147 10 278 216 277 35 +75 79 255 100 136 254 5 267 185 99 41 95 226 71 249 9 168 252 90 144 56 12 249 +228 57 193 34 21 4 172 153 30 135 159 136 35 116 36 241 59 93 225 32 106 171 43 +66 238 268 280 131 110 1 162 161 122 142 14 179 283 141 265 36 155 16 79 184 +279 77 198 45 52 182 3 133 173 192 10 263 121 32 50 282 102 122 198 30 120 227 +18 213 196 59 108 157 150 91 91 20 199 140 84 124 199 69 263 65 143 109 48 62 +47 201 126 28 149 215 111 182 74 244 69 248 133 25 124 128 248 204 9 183 184 +208 256 139 279 92 130 163 37 265 270 266 75 8 144 204 80 4 243 264 89 191 119 +188 38 85 71 163 256 154 211 210 115 83 14 108 172 82 209 76 103 176 273 276 67 +43 10 59 37 46 91 35 131 258 69 44 176 202 165 171 277 177 7 34 240 183 113 97 +70 83 29 40 67 129 53 73 78 89 120 8 2 109 252 19 33 160 246 289 13 54 97 126 +99 260 111 167 142 289 247 38 156 55 222 22 114 263 50 211 281 226 142 70 68 +224 212 15 274 25 210 171 262 245 179 212 30 206 270 195 254 239 88 81 28 1 147 +66 167 157 221 202 150 76 159 65 214 220 107 281 7 253 129 124 57 137 145 80 60 +132 78 160 231 67 58 232 177 22 129 68 168 33 74 40 275 262 174 68 153 101 246 +218 192 158 41 166 47 257 15 259 220 92 59 52 268 46 20 214 72 39 236 282 46 +106 257 249 80 279 21 19 104 271 15 55 136 269 100 222 7 182 18 65 128 14 93 +240 254 224 156 126 43 81 170 96 102 51 87 134 64 104 256 210 100 151 186 123 +89 105 76 174 287 42 42 190 95 140 155 235 258 125 223 117 273 205 246 274 81 +99 112 206 285 127 209 61 8 58 288 66 253 200 235 243 193 105 5 63 228 113 82 +265 255 44 247 23 224 227 237 102 137 3 148 105 147 285 56 98 165 242 98 236 63 +157 2 23 209 5 119 117 217 26 15 203 41 151 115 12 193 49 116 122 284 236 7 268 +61 242 169 57 122 213 125 238 49 101 27 39 251 214 1 218 50 63 213 181 127 153 +45 67 114 121 118 93 6 143 165 227 166 118 78 74 188 53 17 189 148 176 258 54 +112 58 217 82 194 144 275 191 141 ^ +628 1 3 97 139 194 211 92 250 117 132 147 267 290 119 14 282 13 118 37 111 200 +94 60 216 119 47 270 110 85 203 173 159 16 43 148 277 278 29 5 12 262 158 6 176 +117 286 135 72 257 164 76 241 106 101 261 148 18 266 247 143 178 32 117 99 159 +49 31 245 123 31 212 135 226 245 90 43 286 289 60 62 131 242 11 65 23 244 80 +176 84 6 38 105 91 102 238 27 123 290 224 38 259 79 199 84 193 14 128 25 21 191 +237 17 256 259 233 187 10 160 59 19 276 114 174 169 175 74 18 7 235 69 145 198 +179 58 252 32 255 111 62 82 278 183 285 230 229 32 68 135 39 269 67 230 75 44 +263 168 165 86 108 16 92 112 105 58 114 20 181 78 107 265 237 276 268 162 266 +142 119 201 258 36 52 77 64 118 109 26 80 22 96 80 71 60 29 143 24 44 191 132 +114 279 193 152 140 99 54 25 54 179 42 276 9 150 192 109 285 92 217 129 35 180 +101 228 160 213 7 81 81 219 231 134 167 1 231 272 179 196 264 227 117 237 171 +244 185 200 61 72 119 152 2 87 272 284 220 241 1 77 284 82 229 219 44 158 144 +188 20 27 90 10 6 71 93 17 69 283 210 82 91 207 262 4 18 79 271 120 73 113 164 +181 265 83 288 50 195 221 251 281 108 275 104 186 138 184 223 61 88 95 175 107 +6 225 81 114 207 157 101 41 184 190 73 162 128 130 45 168 11 98 11 170 47 221 +146 257 131 88 23 139 56 199 189 217 283 23 106 68 273 51 51 100 64 13 85 49 +185 233 49 290 257 26 64 46 73 267 152 107 111 249 58 9 288 204 183 26 218 34 +170 234 197 169 70 50 41 233 154 22 234 92 145 93 155 81 186 243 208 200 248 48 +21 86 213 40 69 178 186 105 196 126 215 214 204 45 14 23 1 44 4 156 91 53 274 +199 51 205 88 282 151 130 232 144 34 32 222 123 136 236 112 34 137 246 100 31 +25 159 203 19 171 90 197 274 94 27 228 22 201 104 48 126 110 190 227 150 225 97 +90 230 262 20 286 102 84 39 26 31 58 147 8 278 216 273 35 75 77 251 94 132 252 +291 267 185 95 37 95 224 71 247 5 166 250 84 144 50 8 245 228 55 189 30 15 172 +149 28 133 157 134 29 110 36 239 53 87 223 28 100 169 37 62 236 266 280 131 104 +291 162 161 118 142 14 177 281 141 263 30 153 12 75 182 275 71 198 41 46 178 +291 129 173 192 4 261 115 30 48 280 98 116 194 24 116 227 12 213 194 57 104 153 +150 87 85 16 197 136 82 124 195 67 263 63 141 109 42 56 45 201 120 24 149 215 +109 180 68 240 63 246 133 19 122 126 248 202 9 183 180 206 252 137 279 88 128 +163 33 265 270 264 73 8 140 204 78 2 241 76 ^ +622 0 89 183 111 180 34 85 59 159 256 154 207 210 115 75 10 108 168 78 209 68 +103 176 269 272 55 35 10 51 33 38 87 31 123 258 69 36 172 202 161 171 277 169 3 +22 236 179 109 93 70 83 29 36 67 121 49 61 74 85 116 2 97 244 11 33 160 246 285 +1 42 89 118 87 260 99 159 134 289 247 38 152 55 222 14 110 255 42 211 277 226 +138 62 64 216 204 11 270 25 206 163 258 241 171 212 30 198 266 195 254 239 84 +69 28 283 143 54 167 153 217 194 142 64 151 65 206 220 99 281 293 249 125 116 +57 137 137 72 48 128 78 152 227 63 54 232 177 22 129 68 168 21 74 28 275 254 +174 60 149 93 242 218 184 158 37 162 39 249 3 251 212 80 59 52 260 34 20 214 60 +27 228 282 46 106 253 249 68 275 17 15 100 271 15 43 136 269 100 214 289 182 14 +53 120 2 89 240 246 220 156 122 39 77 162 96 90 43 79 134 60 92 252 202 96 147 +178 119 77 97 72 170 287 38 30 190 83 136 147 235 254 117 219 109 265 205 238 +266 73 95 100 206 285 123 201 49 290 50 280 66 253 192 227 235 189 93 5 59 224 +101 74 257 251 40 239 19 224 223 233 102 129 3 144 101 139 281 56 90 165 238 94 +232 55 157 284 11 205 1 107 113 217 22 7 203 29 143 111 8 193 45 116 122 276 +236 7 268 53 242 161 49 118 209 125 238 37 97 15 35 247 210 287 210 50 51 205 +173 127 153 45 59 102 121 114 85 288 135 157 219 166 106 66 66 188 53 13 185 +148 168 250 50 108 46 213 70 190 140 271 187 63 291 97 137 194 207 88 250 115 +132 145 263 290 115 10 280 9 118 37 105 198 94 60 214 117 47 268 110 83 201 171 +155 10 43 144 273 274 27 293 12 260 156 174 117 284 133 70 255 164 76 237 104 +101 261 146 16 262 243 143 176 32 113 95 157 47 31 245 123 29 208 135 222 243 +86 41 286 285 58 62 129 240 9 61 17 244 76 172 80 2 32 105 91 98 234 27 121 286 +220 34 257 79 199 84 191 8 128 21 17 187 235 17 252 259 231 187 6 156 57 15 272 +112 170 165 173 70 18 5 231 65 141 196 179 52 252 30 255 107 56 82 276 179 281 +228 225 26 66 131 33 267 63 226 73 38 259 166 163 86 106 16 90 108 103 54 110 +18 177 72 105 263 233 274 264 158 266 138 119 199 256 32 48 71 58 112 105 26 74 +20 92 80 67 56 25 141 24 44 191 130 108 275 189 150 140 99 52 23 54 175 42 276 +7 146 188 103 283 86 213 127 31 180 99 224 158 209 3 79 77 219 231 130 165 1 +229 272 177 194 264 223 111 237 169 240 181 196 57 72 113 152 292 87 268 282 +218 241 293 77 284 76 229 80 ^ +635 1 40 150 140 184 12 23 78 294 2 67 93 9 57 283 206 74 83 199 254 4 6 67 263 +120 61 113 156 181 257 79 284 46 191 213 251 273 100 271 100 186 138 184 223 61 +76 83 175 107 6 217 81 114 207 149 89 29 180 182 73 158 120 122 37 160 11 98 +295 162 35 221 146 249 123 88 19 139 48 191 189 213 275 15 98 60 273 39 51 96 +60 1 77 49 181 233 41 286 257 18 64 42 65 263 144 99 111 241 58 1 288 196 179 +22 214 30 170 226 197 169 66 42 41 225 146 14 234 92 145 89 155 69 178 243 208 +200 244 48 21 78 209 40 65 178 182 97 196 118 207 210 200 33 10 23 289 36 152 +79 49 266 195 43 201 84 274 151 130 228 136 34 24 214 115 132 228 112 292 26 +129 238 92 19 13 159 195 19 163 86 189 274 90 19 224 10 193 104 40 126 102 186 +223 146 225 85 90 230 262 8 278 90 80 39 14 23 54 147 4 278 216 265 35 75 73 +243 82 124 248 283 267 185 87 29 95 220 71 243 293 162 246 72 144 38 237 228 51 +181 22 3 288 172 141 24 129 153 130 17 98 36 235 41 75 219 20 88 165 25 54 232 +262 280 131 92 291 162 161 110 142 14 173 277 141 259 18 149 4 67 178 267 59 +198 33 34 170 287 121 173 192 288 257 103 26 44 276 90 104 186 12 108 227 213 +190 53 96 145 150 79 73 8 193 128 78 124 187 63 263 59 137 109 30 44 41 201 108 +16 149 215 105 176 56 232 51 242 133 7 118 122 248 198 9 183 172 202 244 133 +279 80 124 163 25 265 270 260 69 8 132 204 74 294 237 252 89 179 107 176 32 85 +53 157 256 154 205 210 115 71 8 108 166 76 209 64 103 176 267 270 49 31 10 47 +31 34 85 29 119 258 69 32 170 202 159 171 277 165 1 16 234 177 107 91 70 83 29 +34 67 117 47 55 72 83 114 292 2 91 240 7 33 160 246 283 291 36 85 114 81 260 93 +155 130 289 247 38 150 55 222 10 108 251 38 211 275 226 136 58 62 212 200 9 268 +25 204 159 256 239 167 212 30 194 264 195 254 239 82 63 28 279 141 48 167 151 +215 190 138 58 147 65 202 220 95 281 291 247 123 112 57 137 133 68 42 126 78 +148 225 61 52 232 177 22 129 68 168 15 74 22 275 250 174 56 147 89 240 218 180 +158 35 160 35 245 293 247 208 74 59 52 256 28 20 214 54 21 224 282 46 106 251 +249 62 273 15 13 98 271 15 37 136 269 100 210 285 182 12 47 116 292 87 240 242 +218 156 120 37 75 158 96 84 39 75 134 58 86 250 198 94 145 174 117 71 93 70 168 +287 36 24 190 77 134 143 235 252 113 217 105 261 205 234 262 69 93 94 206 285 +121 197 43 286 46 276 66 253 188 223 231 187 87 5 57 222 95 285 ^ +636 0 251 248 37 233 16 224 220 230 102 123 3 141 98 133 278 56 84 165 235 91 +229 49 157 278 2 202 295 98 110 217 19 1 203 20 137 108 5 193 42 116 122 270 +236 7 268 47 242 155 43 115 206 125 238 28 94 6 32 244 207 284 204 50 42 199 +167 127 153 45 53 93 121 111 79 282 129 151 213 166 97 57 60 188 53 10 182 148 +162 244 47 105 37 210 61 187 137 268 184 63 285 97 134 194 201 82 250 112 132 +142 257 290 109 4 277 3 118 37 96 195 94 60 211 114 47 265 110 80 198 168 149 1 +43 138 267 268 24 287 12 257 153 288 171 117 281 130 67 252 164 76 231 101 101 +261 143 13 256 237 143 173 32 107 89 154 44 31 245 123 26 202 135 216 240 80 38 +286 279 55 62 126 237 6 55 8 244 70 166 74 293 23 105 91 92 228 27 118 280 214 +28 254 79 199 84 188 296 128 15 11 181 232 17 246 259 228 187 150 54 9 266 109 +164 159 170 64 18 2 225 59 135 193 179 43 252 27 255 101 47 82 273 173 275 225 +219 17 63 125 24 264 57 220 70 29 253 163 160 86 103 16 87 102 100 48 104 15 +171 63 102 260 227 271 258 152 266 132 119 196 253 26 42 62 49 103 99 26 65 17 +86 80 61 50 19 138 24 44 191 127 99 269 183 147 140 99 49 20 54 169 42 276 4 +140 182 94 280 77 207 124 25 180 96 218 155 203 294 76 71 219 231 124 162 1 226 +272 174 191 264 217 102 237 166 234 175 190 51 72 104 152 289 87 262 279 215 +241 293 77 284 67 229 209 39 148 139 183 10 22 75 292 1 66 93 7 54 283 205 72 +81 197 252 4 3 64 261 120 58 113 154 181 255 78 283 45 190 211 251 271 98 270 +99 186 138 184 223 61 73 80 175 107 6 215 81 114 207 147 86 26 179 180 73 157 +118 120 35 158 11 98 293 160 32 221 146 247 121 88 18 139 46 189 189 212 273 13 +96 58 273 36 51 95 59 295 75 49 180 233 39 285 257 16 64 41 63 262 142 97 111 +239 58 296 288 194 178 21 213 29 170 224 197 169 65 40 41 223 144 12 234 92 145 +88 155 66 176 243 208 200 243 48 21 76 208 40 64 178 181 95 196 116 205 209 199 +30 9 23 288 34 296 151 76 48 264 194 41 200 83 272 151 130 227 134 34 22 212 +113 131 226 112 292 24 127 236 90 16 10 159 193 19 161 85 187 274 89 17 223 7 +191 104 38 126 100 185 222 145 225 82 90 230 262 5 276 87 79 39 11 21 53 147 3 +278 216 263 35 75 72 241 79 122 247 281 267 185 85 27 95 219 71 242 292 161 245 +69 144 35 295 235 228 50 179 20 287 172 139 23 128 152 129 14 95 36 234 38 72 +218 18 85 164 22 52 231 261 280 131 89 291 162 161 108 142 14 172 276 91 ^ +635 1 256 9 146 297 61 175 261 50 198 27 25 164 284 115 173 192 282 254 94 23 +41 273 84 95 180 3 102 227 290 213 187 50 90 139 150 73 64 2 190 122 75 124 181 +60 263 56 134 109 21 35 38 201 99 10 149 215 102 173 47 226 42 239 133 297 115 +119 248 195 9 183 166 199 238 130 279 74 121 163 19 265 270 257 66 8 126 204 71 +294 234 246 89 173 101 170 29 85 44 154 256 154 202 210 115 65 5 108 163 73 209 +58 103 176 264 267 40 25 10 41 28 28 82 26 113 258 69 26 167 202 156 171 277 +159 297 7 231 174 104 88 70 83 29 31 67 111 44 46 69 80 111 289 2 82 234 1 33 +160 246 280 285 27 79 108 72 260 84 149 124 289 247 38 147 55 222 4 105 245 32 +211 272 226 133 52 59 206 194 6 265 25 201 153 253 236 161 212 30 188 261 195 +254 239 79 54 28 273 138 39 167 148 212 184 132 49 141 65 196 220 89 281 288 +244 120 106 57 137 127 62 33 123 78 142 222 58 49 232 177 22 129 68 168 6 74 13 +275 244 174 50 144 83 237 218 174 158 32 157 29 239 287 241 202 65 59 52 250 19 +20 214 45 12 218 282 46 106 248 249 53 270 12 10 95 271 15 28 136 269 100 204 +279 182 9 38 110 286 84 240 236 215 156 117 34 72 152 96 75 33 69 134 55 77 247 +192 91 142 168 114 62 87 67 165 287 33 15 190 68 131 137 235 249 107 214 99 255 +205 228 256 63 90 85 206 285 118 191 34 280 40 270 66 253 182 217 225 184 78 5 +54 219 86 64 247 246 35 229 14 224 218 228 102 119 3 139 96 129 276 56 80 165 +233 89 227 45 157 274 295 200 295 92 108 217 17 296 203 14 133 106 3 193 40 116 +122 266 236 7 268 43 242 151 39 113 204 125 238 22 92 30 242 205 282 200 50 36 +195 163 127 153 45 49 87 121 109 75 278 125 147 209 166 91 51 56 188 53 8 180 +148 158 240 45 103 31 208 55 185 135 266 182 63 281 97 132 194 197 78 250 110 +132 140 253 290 105 275 298 118 37 90 193 94 60 209 112 47 263 110 78 196 166 +145 294 43 134 263 264 22 283 12 255 151 284 169 117 279 128 65 250 164 76 227 +99 101 261 141 11 252 233 143 171 32 103 85 152 42 31 245 123 24 198 135 212 +238 76 36 286 275 53 62 124 235 4 51 2 244 66 162 70 291 17 105 91 88 224 27 +116 276 210 24 252 79 199 84 186 292 128 11 7 177 230 17 242 259 226 187 295 +146 52 5 262 107 160 155 168 60 18 221 55 131 191 179 37 252 25 255 97 41 82 +271 169 271 223 215 11 61 121 18 262 53 216 68 23 249 161 158 86 101 16 85 98 +98 44 100 13 167 57 100 258 223 269 254 148 266 128 119 194 251 22 38 56 43 275 +^ +642 0 91 26 53 13 78 80 53 42 11 134 24 44 191 123 87 261 175 143 140 99 45 16 +54 161 42 276 132 174 82 276 65 199 120 17 180 92 210 151 195 290 72 63 219 231 +116 158 1 222 272 170 187 264 209 90 237 162 226 167 182 43 72 92 152 285 87 +254 275 211 241 293 77 284 55 229 201 35 140 135 179 2 18 63 284 298 62 93 300 +42 283 201 64 73 189 244 4 292 52 253 120 46 113 146 181 247 74 279 41 186 203 +251 263 90 266 95 186 138 184 223 61 61 68 175 107 6 207 81 114 207 139 74 14 +175 172 73 153 110 112 27 150 11 98 285 152 20 221 146 239 113 88 14 139 38 181 +189 208 265 5 88 50 273 24 51 91 55 287 67 49 176 233 31 281 257 8 64 37 55 258 +134 89 111 231 58 292 288 186 174 17 209 25 170 216 197 169 61 32 41 215 136 4 +234 92 145 84 155 54 168 243 208 200 239 48 21 68 204 40 60 178 177 87 196 108 +197 205 195 18 5 23 284 26 296 147 64 44 256 190 33 196 79 264 151 130 223 126 +34 14 204 105 127 218 112 292 16 119 228 82 4 299 159 185 19 153 81 179 274 85 +9 219 296 183 104 30 126 92 181 218 141 225 70 90 230 262 294 268 75 75 39 300 +13 49 147 300 278 216 255 35 75 68 233 67 114 243 273 267 185 77 19 95 215 71 +238 288 157 241 57 144 23 291 227 228 46 171 12 289 283 172 131 19 124 148 125 +2 83 36 230 26 60 214 10 73 160 10 44 227 257 280 131 77 291 162 161 100 142 14 +168 272 141 254 3 144 295 57 173 257 44 198 23 19 160 282 111 173 192 278 252 +88 21 39 271 80 89 176 298 98 227 286 213 185 48 86 135 150 69 58 299 188 118 +73 124 177 58 263 54 132 109 15 29 36 201 93 6 149 215 100 171 41 222 36 237 +133 293 113 117 248 193 9 183 162 197 234 128 279 70 119 163 15 265 270 255 64 +8 122 204 69 294 232 242 89 169 97 166 27 85 38 152 256 154 200 210 115 61 3 +108 161 71 209 54 103 176 262 265 34 21 10 37 26 24 80 24 109 258 69 22 165 202 +154 171 277 155 297 1 229 172 102 86 70 83 29 29 67 107 42 40 67 78 109 287 2 +76 230 298 33 160 246 278 281 21 75 104 66 260 78 145 120 289 247 38 145 55 222 +103 241 28 211 270 226 131 48 57 202 190 4 263 25 199 149 251 234 157 212 30 +184 259 195 254 239 77 48 28 269 136 33 167 146 210 180 128 43 137 65 192 220 +85 281 286 242 118 102 57 137 123 58 27 121 78 138 220 56 47 232 177 22 129 68 +168 74 7 275 240 174 46 142 79 235 218 170 158 30 155 25 235 283 237 198 59 59 +52 246 13 20 214 39 6 214 282 46 106 246 249 47 268 10 8 93 271 15 22 136 269 +100 200 275 42 ^ +644 0 6 29 104 280 81 240 230 212 156 114 31 69 146 96 66 27 63 134 52 68 244 +186 88 139 162 111 53 81 64 162 287 30 6 190 59 128 131 235 246 101 211 93 249 +205 222 250 57 87 76 206 285 115 185 25 274 34 264 66 253 176 211 219 181 69 5 +51 216 77 58 241 243 32 223 11 224 215 225 102 113 3 136 93 123 273 56 74 165 +230 86 224 39 157 268 289 197 295 83 105 217 14 293 203 5 127 103 193 37 116 +122 260 236 7 268 37 242 145 33 110 201 125 238 13 89 293 27 239 202 279 194 50 +27 189 157 127 153 45 43 78 121 106 69 272 119 141 203 166 82 42 50 188 53 5 +177 148 152 234 42 100 22 205 46 182 132 263 179 63 275 97 129 194 191 72 250 +107 132 137 247 290 99 296 272 295 118 37 81 190 94 60 206 109 47 260 110 75 +193 163 139 288 43 128 257 258 19 277 12 252 148 278 166 117 276 125 62 247 164 +76 221 96 101 261 138 8 246 227 143 168 32 97 79 149 39 31 245 123 21 192 135 +206 235 70 33 286 269 50 62 121 232 1 45 295 244 60 156 64 288 8 105 91 82 218 +27 113 270 204 18 249 79 199 84 183 286 128 5 1 171 227 17 236 259 223 187 292 +140 49 301 256 104 154 149 165 54 18 299 215 49 125 188 179 28 252 22 255 91 32 +82 268 163 265 220 209 2 58 115 9 259 47 210 65 14 243 158 155 86 98 16 82 92 +95 38 94 10 161 48 97 255 217 266 248 142 266 122 119 191 248 16 32 47 34 88 89 +26 50 12 76 80 51 40 9 133 24 44 191 122 84 259 173 142 140 99 44 15 54 159 42 +276 301 130 172 79 275 62 197 119 15 180 91 208 150 193 289 71 61 219 231 114 +157 1 221 272 169 186 264 207 87 237 161 224 165 180 41 72 89 152 284 87 252 +274 210 241 293 77 284 52 229 199 34 138 134 178 17 60 282 298 61 93 299 39 283 +200 62 71 187 242 4 290 49 251 120 43 113 144 181 245 73 278 40 185 201 251 261 +88 265 94 186 138 184 223 61 58 65 175 107 6 205 81 114 207 137 71 11 174 170 +73 152 108 110 25 148 11 98 283 150 17 221 146 237 111 88 13 139 36 179 189 207 +263 3 86 48 273 21 51 90 54 285 65 49 175 233 29 280 257 6 64 36 53 257 132 87 +111 229 58 291 288 184 173 16 208 24 170 214 197 169 60 30 41 213 134 2 234 92 +145 83 155 51 166 243 208 200 238 48 21 66 203 40 59 178 176 85 196 106 195 204 +194 15 4 23 283 24 296 146 61 43 254 189 31 195 78 262 151 130 222 124 34 12 +202 103 126 216 112 292 14 117 226 80 1 297 159 183 19 151 80 177 274 84 7 218 +294 181 104 28 126 90 180 217 140 225 67 90 230 262 292 266 72 74 39 298 11 48 +147 300 278 216 253 265 ^ +638 1 75 65 227 58 108 240 267 267 185 71 13 95 212 71 235 285 154 238 48 144 +14 288 221 228 43 165 6 283 280 172 125 16 121 145 122 297 74 36 227 17 51 211 +4 64 157 1 38 224 254 280 131 68 291 162 161 94 142 14 165 269 141 251 298 141 +292 51 170 251 35 198 17 10 154 279 105 173 192 272 249 79 18 36 268 74 80 170 +292 92 227 280 213 182 45 80 129 150 63 49 296 185 112 70 124 171 55 263 51 129 +109 6 20 33 201 84 149 215 97 168 32 216 27 234 133 287 110 114 248 190 9 183 +156 194 228 125 279 64 116 163 9 265 270 252 61 8 116 204 66 294 229 236 89 163 +91 160 24 85 29 149 256 154 197 210 115 55 108 158 68 209 48 103 176 259 262 25 +15 10 31 23 18 77 21 103 258 69 16 162 202 151 171 277 149 297 296 226 169 99 +83 70 83 29 26 67 101 39 31 64 75 106 284 2 67 224 295 33 160 246 275 275 12 69 +98 57 260 69 139 114 289 247 38 142 55 222 298 100 235 22 211 267 226 128 42 54 +196 184 1 260 25 196 143 248 231 151 212 30 178 256 195 254 239 74 39 28 263 +133 24 167 143 207 174 122 34 131 65 186 220 79 281 283 239 115 96 57 137 117 +52 18 118 78 132 217 53 44 232 177 22 129 68 168 295 74 302 275 234 174 40 139 +73 232 218 164 158 27 152 19 229 277 231 192 50 59 52 240 4 20 214 30 301 208 +282 46 106 243 249 38 265 7 5 90 271 15 13 136 269 100 194 269 182 4 23 100 276 +79 240 226 210 156 112 29 67 142 96 60 23 59 134 50 62 242 182 86 137 158 109 +47 77 62 160 287 28 190 53 126 127 235 244 97 209 89 245 205 218 246 53 85 70 +206 285 113 181 19 270 30 260 66 253 172 207 215 179 63 5 49 214 71 54 237 241 +30 219 9 224 213 223 102 109 3 134 91 119 271 56 70 165 228 84 222 35 157 264 +285 195 295 77 103 217 12 291 203 303 123 101 302 193 35 116 122 256 236 7 268 +33 242 141 29 108 199 125 238 7 87 289 25 237 200 277 190 50 21 185 153 127 153 +45 39 72 121 104 65 268 115 137 199 166 76 36 46 188 53 3 175 148 148 230 40 98 +16 203 40 180 130 261 177 63 271 97 127 194 187 68 250 105 132 135 243 290 95 +294 270 293 118 37 75 188 94 60 204 107 47 258 110 73 191 161 135 284 43 124 +253 254 17 273 12 250 146 274 164 117 274 123 60 245 164 76 217 94 101 261 136 +6 242 223 143 166 32 93 75 147 37 31 245 123 19 188 135 202 233 66 31 286 265 +48 62 119 230 303 41 291 244 56 152 60 286 2 105 91 78 214 27 111 266 200 14 +247 79 199 84 181 282 128 1 301 167 225 17 232 259 221 187 290 136 47 299 252 +102 150 145 163 157 ^ +653 0 18 299 207 41 117 184 179 16 252 18 255 83 20 82 264 155 257 216 201 296 +54 107 303 255 39 202 61 2 235 154 151 86 94 16 78 84 91 30 86 6 153 36 93 251 +209 262 240 134 266 114 119 187 244 8 24 35 22 76 81 26 38 8 68 80 43 32 1 129 +24 44 191 118 72 251 165 138 140 99 40 11 54 151 42 276 301 122 164 67 271 50 +189 115 7 180 87 200 146 185 285 67 53 219 231 106 153 1 217 272 165 182 264 +199 75 237 157 216 157 172 33 72 77 152 280 87 244 270 206 241 293 77 284 40 +229 191 30 130 130 174 298 13 48 274 298 57 93 295 27 283 196 54 63 179 234 4 +282 37 243 120 31 113 136 181 237 69 274 36 181 193 251 253 80 261 90 186 138 +184 223 61 46 53 175 107 6 197 81 114 207 129 59 305 170 162 73 148 100 102 17 +140 11 98 275 142 5 221 146 229 103 88 9 139 28 171 189 203 255 301 78 40 273 9 +51 86 50 277 57 49 171 233 21 276 257 304 64 32 45 253 124 79 111 221 58 287 +288 176 169 12 204 20 170 206 197 169 56 22 41 205 126 300 234 92 145 79 155 39 +158 243 208 200 234 48 21 58 199 40 55 178 172 77 196 98 187 200 190 3 23 279 +16 296 142 49 39 246 185 23 191 74 254 151 130 218 116 34 4 194 95 122 208 112 +292 6 109 218 72 295 289 159 175 19 143 76 169 274 80 305 214 286 173 104 20 +126 82 176 213 136 225 55 90 230 262 284 258 60 70 39 290 3 44 147 300 278 216 +245 35 75 63 223 52 104 238 263 267 185 67 9 95 210 71 233 283 152 236 42 144 8 +286 217 228 41 161 2 279 278 172 121 14 119 143 120 293 68 36 225 11 45 209 58 +155 301 34 222 252 280 131 62 291 162 161 90 142 14 163 267 141 249 294 139 290 +47 168 247 29 198 13 4 150 277 101 173 192 268 247 73 16 34 266 70 74 166 288 +88 227 276 213 180 43 76 125 150 59 43 294 183 108 68 124 167 53 263 49 127 109 +14 31 201 78 302 149 215 95 166 26 212 21 232 133 283 108 112 248 188 9 183 152 +192 224 123 279 60 114 163 5 265 270 250 59 8 112 204 64 294 227 232 89 159 87 +156 22 85 23 147 256 154 195 210 115 51 304 108 156 66 209 44 103 176 257 260 +19 11 10 27 21 14 75 19 99 258 69 12 160 202 149 171 277 145 297 292 224 167 97 +81 70 83 29 24 67 97 37 25 62 73 104 282 2 61 220 293 33 160 246 273 271 6 65 +94 51 260 63 135 110 289 247 38 140 55 222 296 98 231 18 211 265 226 126 38 52 +192 180 305 258 25 194 139 246 229 147 212 30 174 254 195 254 239 72 33 28 259 +131 18 167 141 205 170 118 28 127 65 182 220 75 281 281 237 113 92 57 137 113 +48 12 116 78 128 215 51 42 232 177 22 129 68 168 291 161 ^ +653 0 296 275 228 174 34 136 67 229 218 158 158 24 149 13 223 271 225 186 41 59 +52 234 302 20 214 21 295 202 282 46 106 240 249 29 262 4 2 87 271 15 4 136 269 +100 188 263 182 1 14 94 270 76 240 220 207 156 109 26 64 136 96 51 17 53 134 47 +53 239 176 83 134 152 106 38 71 59 157 287 25 298 190 44 123 121 235 241 91 206 +83 239 205 212 240 47 82 61 206 285 110 175 10 264 24 254 66 253 166 201 209 +176 54 5 46 211 62 48 231 238 27 213 6 224 210 220 102 103 3 131 88 113 268 56 +64 165 225 81 219 29 157 258 279 192 295 68 100 217 9 288 203 297 117 98 302 +193 32 116 122 250 236 7 268 27 242 135 23 105 196 125 238 305 84 283 22 234 +197 274 184 50 12 179 147 127 153 45 33 63 121 101 59 262 109 131 193 166 67 27 +40 188 53 172 148 142 224 37 95 7 200 31 177 127 258 174 63 265 97 124 194 181 +62 250 102 132 132 237 290 89 291 267 290 118 37 66 185 94 60 201 104 47 255 +110 70 188 158 129 278 43 118 247 248 14 267 12 247 143 268 161 117 271 120 57 +242 164 76 211 91 101 261 133 3 236 217 143 163 32 87 69 144 34 31 245 123 16 +182 135 196 230 60 28 286 259 45 62 116 227 303 35 285 244 50 146 54 283 300 +105 91 72 208 27 108 260 194 8 244 79 199 84 178 276 128 302 298 161 222 17 226 +259 218 187 287 130 44 296 246 99 144 139 160 44 18 299 205 39 115 183 179 13 +252 17 255 81 17 82 263 153 255 215 199 294 53 105 301 254 37 200 60 306 233 +153 150 86 93 16 77 82 90 28 84 5 151 33 92 250 207 261 238 132 266 112 119 186 +243 6 22 32 19 73 79 26 35 7 66 80 41 30 306 128 24 44 191 117 69 249 163 137 +140 99 39 10 54 149 42 276 301 120 162 64 270 47 187 114 5 180 86 198 145 183 +284 66 51 219 231 104 152 1 216 272 164 181 264 197 72 237 156 214 155 170 31 +72 74 152 279 87 242 269 205 241 293 77 284 37 229 189 29 128 129 173 297 12 45 +272 298 56 93 294 24 283 195 52 61 177 232 4 280 34 241 120 28 113 134 181 235 +68 273 35 180 191 251 251 78 260 89 186 138 184 223 61 43 50 175 107 6 195 81 +114 207 127 56 303 169 160 73 147 98 100 15 138 11 98 273 140 2 221 146 227 101 +88 8 139 26 169 189 202 253 300 76 38 273 6 51 85 49 275 55 49 170 233 19 275 +257 303 64 31 43 252 122 77 111 219 58 286 288 174 168 11 203 19 170 204 197 +169 55 20 41 203 124 299 234 92 145 78 155 36 156 243 208 200 233 48 21 56 198 +40 54 178 171 75 196 96 185 199 189 306 23 278 14 296 141 46 38 244 184 21 190 +73 252 151 130 217 114 34 2 192 93 121 206 112 292 4 107 216 70 293 112 ^ +646 1 159 169 19 137 73 163 274 77 302 211 280 167 104 14 126 76 173 210 133 +225 46 90 230 262 278 252 51 67 39 284 306 41 147 300 278 216 239 35 75 60 217 +43 98 235 257 267 185 61 3 95 207 71 230 280 149 233 33 144 308 283 211 228 38 +155 305 273 275 172 115 11 116 140 117 287 59 36 222 2 36 206 303 49 152 295 28 +219 249 280 131 53 291 162 161 84 142 14 160 264 141 246 288 136 287 41 165 241 +20 198 7 304 144 274 95 173 192 262 244 64 13 31 263 64 65 160 282 82 227 270 +213 177 40 70 119 150 53 34 291 180 102 65 124 161 50 263 46 124 109 300 5 28 +201 69 299 149 215 92 163 17 206 12 229 133 277 105 109 248 185 9 183 146 189 +218 120 279 54 111 163 308 265 270 247 56 8 106 204 61 294 224 226 89 153 81 +150 19 85 14 144 256 154 192 210 115 45 304 108 153 63 209 38 103 176 254 257 +10 5 10 21 18 8 72 16 93 258 69 6 157 202 146 171 277 139 297 286 221 164 94 78 +70 83 29 21 67 91 34 16 59 70 101 279 2 52 214 290 33 160 246 270 265 306 59 88 +42 260 54 129 104 289 247 38 137 55 222 293 95 225 12 211 262 226 123 32 49 186 +174 305 255 25 191 133 243 226 141 212 30 168 251 195 254 239 69 24 28 253 128 +9 167 138 202 164 112 19 121 65 176 220 69 281 278 234 110 86 57 137 107 42 3 +113 78 122 212 48 39 232 177 22 129 68 168 285 74 292 275 224 174 30 134 63 227 +218 154 158 22 147 9 219 267 221 182 35 59 52 230 298 20 214 15 291 198 282 46 +106 238 249 23 260 2 85 271 15 307 136 269 100 184 259 182 308 8 90 266 74 240 +216 205 156 107 24 62 132 96 45 13 49 134 45 47 237 172 81 132 148 104 32 67 57 +155 287 23 294 190 38 121 117 235 239 87 204 79 235 205 208 236 43 80 55 206 +285 108 171 4 260 20 250 66 253 162 197 205 174 48 5 44 209 56 44 227 236 25 +209 4 224 208 218 102 99 3 129 86 109 266 56 60 165 223 79 217 25 157 254 275 +190 295 62 98 217 7 286 203 293 113 96 302 193 30 116 122 246 236 7 268 23 242 +131 19 103 194 125 238 301 82 279 20 232 195 272 180 50 6 175 143 127 153 45 29 +57 121 99 55 258 105 127 189 166 61 21 36 188 53 307 170 148 138 220 35 93 1 +198 25 175 125 256 172 63 261 97 122 194 177 58 250 100 132 130 233 290 85 289 +265 288 118 37 60 183 94 60 199 102 47 253 110 68 186 156 125 274 43 114 243 +244 12 263 12 245 141 264 159 117 269 118 55 240 164 76 207 89 101 261 131 1 +232 213 143 161 32 83 65 142 32 31 245 123 14 178 135 192 228 56 26 286 255 43 +62 114 225 303 31 281 244 46 142 50 281 296 105 91 238 ^ +647 0 200 27 104 252 186 240 79 199 84 174 268 128 298 294 153 218 17 218 259 +214 187 283 122 40 292 238 95 136 131 156 36 18 299 197 31 107 179 179 1 252 13 +255 73 5 82 259 145 247 211 191 286 49 97 293 250 29 192 56 298 225 149 146 86 +89 16 73 74 86 20 76 1 143 21 88 246 199 257 230 124 266 104 119 182 239 309 14 +20 7 61 71 26 23 3 58 80 33 22 302 124 24 44 191 113 57 241 155 133 140 99 35 6 +54 141 42 276 301 112 154 52 266 35 179 110 308 180 82 190 141 175 280 62 43 +219 231 96 148 1 212 272 160 177 264 189 60 237 152 206 147 162 23 72 62 152 +275 87 234 265 201 241 293 77 284 25 229 181 25 120 125 169 293 8 33 264 298 52 +93 290 12 283 191 44 53 169 224 4 272 22 233 120 16 113 126 181 227 64 269 31 +176 183 251 243 70 256 85 186 138 184 223 61 31 38 175 107 6 187 81 114 207 119 +44 295 165 152 73 143 90 92 7 130 11 98 265 132 301 221 146 219 93 88 4 139 18 +161 189 198 245 296 68 30 273 305 51 81 45 267 47 49 166 233 11 271 257 299 64 +27 35 248 114 69 111 211 58 282 288 166 164 7 199 15 170 196 197 169 51 12 41 +195 116 295 234 92 145 74 155 24 148 243 208 200 229 48 21 48 194 40 50 178 167 +67 196 88 177 195 185 299 306 23 274 6 296 137 34 34 236 180 13 186 69 244 151 +130 213 106 34 305 184 85 117 198 112 292 307 99 208 62 285 279 159 165 19 133 +71 159 274 75 300 209 276 163 104 10 126 72 171 208 131 225 40 90 230 262 274 +248 45 65 39 280 304 39 147 300 278 216 235 35 75 58 213 37 94 233 253 267 185 +57 310 95 205 71 228 278 147 231 27 144 304 281 207 228 36 151 303 269 273 172 +111 9 114 138 115 283 53 36 220 307 30 204 301 43 150 291 24 217 247 280 131 47 +291 162 161 80 142 14 158 262 141 244 284 134 285 37 163 237 14 198 3 300 140 +272 91 173 192 258 242 58 11 29 261 60 59 156 278 78 227 266 213 175 38 66 115 +150 49 28 289 178 98 63 124 157 48 263 44 122 109 296 310 26 201 63 297 149 215 +90 161 11 202 6 227 133 273 103 107 248 183 9 183 142 187 214 118 279 50 109 +163 306 265 270 245 54 8 102 204 59 294 222 222 89 149 77 146 17 85 8 142 256 +154 190 210 115 41 304 108 151 61 209 34 103 176 252 255 4 1 10 17 16 4 70 14 +89 258 69 2 155 202 144 171 277 135 297 282 219 162 92 76 70 83 29 19 67 87 32 +10 57 68 99 277 2 46 210 288 33 160 246 268 261 302 55 84 36 260 48 125 100 289 +247 38 135 55 222 291 93 221 8 211 260 226 121 28 47 182 170 305 253 25 189 129 +241 224 137 212 30 164 249 195 254 239 86 ^ +665 0 15 28 247 125 167 135 199 158 106 10 115 65 170 220 63 281 275 231 107 80 +57 137 101 36 306 110 78 116 209 45 36 232 177 22 129 68 168 279 74 286 275 218 +174 24 131 57 224 218 148 158 19 144 3 213 261 215 176 26 59 52 224 292 20 214 +6 285 192 282 46 106 235 249 14 257 311 309 82 271 15 301 136 269 100 178 253 +182 308 311 84 260 71 240 210 202 156 104 21 59 126 96 36 7 43 134 42 38 234 +166 78 129 142 101 23 61 54 152 287 20 288 190 29 118 111 235 236 81 201 73 229 +205 202 230 37 77 46 206 285 105 165 307 254 14 244 66 253 156 191 199 171 39 5 +41 206 47 38 221 233 22 203 1 224 205 215 102 93 3 126 83 103 263 56 54 165 220 +76 214 19 157 248 269 187 295 53 95 217 4 283 203 287 107 93 302 193 27 116 122 +240 236 7 268 17 242 125 13 100 191 125 238 295 79 273 17 229 192 269 174 50 +309 169 137 127 153 45 23 48 121 96 49 252 99 121 183 166 52 12 30 188 53 307 +167 148 132 214 32 90 304 195 16 172 122 253 169 63 255 97 119 194 171 52 250 +97 132 127 227 290 79 286 262 285 118 37 51 180 94 60 196 99 47 250 110 65 183 +153 119 268 43 108 237 238 9 257 12 242 138 258 156 117 266 115 52 237 164 76 +201 86 101 261 128 310 226 207 143 158 32 77 59 139 29 31 245 123 11 172 135 +186 225 50 23 286 249 40 62 111 222 303 25 275 244 40 136 44 278 290 105 91 62 +198 27 103 250 184 310 239 79 199 84 173 266 128 297 293 151 217 17 216 259 213 +187 282 120 39 291 236 94 134 129 155 34 18 299 195 29 105 178 179 310 252 12 +255 71 2 82 258 143 245 210 189 284 48 95 291 249 27 190 55 296 223 148 145 86 +88 16 72 72 85 18 74 141 18 87 245 197 256 228 122 266 102 119 181 238 308 12 +17 4 58 69 26 20 2 56 80 31 20 301 123 24 44 191 112 54 239 153 132 140 99 34 5 +54 139 42 276 301 110 152 49 265 32 177 109 307 180 81 188 140 173 279 61 41 +219 231 94 147 1 211 272 159 176 264 187 57 237 151 204 145 160 21 72 59 152 +274 87 232 264 200 241 293 77 284 22 229 179 24 118 124 168 292 7 30 262 298 51 +93 289 9 283 190 42 51 167 222 4 270 19 231 120 13 113 124 181 225 63 268 30 +175 181 251 241 68 255 84 186 138 184 223 61 28 35 175 107 6 185 81 114 207 117 +41 293 164 150 73 142 88 90 5 128 11 98 263 130 299 221 146 217 91 88 3 139 16 +159 189 197 243 295 66 28 273 303 51 80 44 265 45 49 165 233 9 270 257 298 64 +26 33 247 112 67 111 209 58 281 288 164 163 6 198 14 170 194 197 169 50 10 41 +193 114 294 234 92 145 73 155 21 146 243 208 200 228 48 21 46 193 40 49 178 166 +65 196 86 175 194 184 297 306 23 273 206 ^ +641 0 296 134 25 31 230 177 7 183 66 238 151 130 210 100 34 302 178 79 114 192 +112 292 304 93 202 56 279 273 159 159 19 127 68 153 274 72 297 206 270 157 104 +4 126 66 168 205 128 225 31 90 230 262 268 242 36 62 39 274 301 36 147 300 278 +216 229 35 75 55 207 28 88 230 247 267 185 51 307 95 202 71 225 275 144 228 18 +144 298 278 201 228 33 145 300 263 270 172 105 6 111 135 112 277 44 36 217 301 +21 201 298 34 147 285 18 214 244 280 131 38 291 162 161 74 142 14 155 259 141 +241 278 131 282 31 160 231 5 198 311 294 134 269 85 173 192 252 239 49 8 26 258 +54 50 150 272 72 227 260 213 172 35 60 109 150 43 19 286 175 92 60 124 151 45 +263 41 119 109 290 304 23 201 54 294 149 215 87 158 2 196 311 224 133 267 100 +104 248 180 9 183 136 184 208 115 279 44 106 163 303 265 270 242 51 8 96 204 56 +294 219 216 89 143 71 140 14 85 313 139 256 154 187 210 115 35 304 108 148 58 +209 28 103 176 249 252 309 309 10 11 13 312 67 11 83 258 69 310 152 202 141 171 +277 129 297 276 216 159 89 73 70 83 29 16 67 81 29 1 54 65 96 274 2 37 204 285 +33 160 246 265 255 296 49 78 27 260 39 119 94 289 247 38 132 55 222 288 90 215 +2 211 257 226 118 22 44 176 164 305 250 25 186 123 238 221 131 212 30 158 246 +195 254 239 64 9 28 243 123 308 167 133 197 154 102 4 111 65 166 220 59 281 273 +229 105 76 57 137 97 32 302 108 78 112 207 43 34 232 177 22 129 68 168 275 74 +282 275 214 174 20 129 53 222 218 144 158 17 142 313 209 257 211 172 20 59 52 +220 288 20 214 281 188 282 46 106 233 249 8 255 311 309 80 271 15 297 136 269 +100 174 249 182 308 307 80 256 69 240 206 200 156 102 19 57 122 96 30 3 39 134 +40 32 232 162 76 127 138 99 17 57 52 150 287 18 284 190 23 116 107 235 234 77 +199 69 225 205 198 226 33 75 40 206 285 103 161 303 250 10 240 66 253 152 187 +195 169 33 5 39 204 41 34 217 231 20 199 313 224 203 213 102 89 3 124 81 99 261 +56 50 165 218 74 212 15 157 244 265 185 295 47 93 217 2 281 203 283 103 91 302 +193 25 116 122 236 236 7 268 13 242 121 9 98 189 125 238 291 77 269 15 227 190 +267 170 50 305 165 133 127 153 45 19 42 121 94 45 248 95 117 179 166 46 6 26 +188 53 307 165 148 128 210 30 88 300 193 10 170 120 251 167 63 251 97 117 194 +167 48 250 95 132 125 223 290 75 284 260 283 118 37 45 178 94 60 194 97 47 248 +110 63 181 151 115 264 43 104 233 234 7 253 12 240 136 254 154 117 264 113 50 +235 164 76 197 84 101 261 126 310 222 203 143 276 ^ +656 0 32 69 51 135 25 31 245 123 7 164 135 178 221 42 19 286 241 36 62 107 218 +303 17 267 244 32 128 36 274 282 105 91 54 190 27 99 242 176 306 235 79 199 84 +169 258 128 293 289 143 213 17 208 259 209 187 278 112 35 287 228 90 126 121 +151 26 18 299 187 21 97 174 179 302 252 8 255 63 306 82 254 135 237 206 181 276 +44 87 283 245 19 182 51 288 215 144 141 86 84 16 68 64 81 10 66 312 133 6 83 +241 189 252 220 114 266 94 119 177 234 304 4 5 308 46 61 26 8 314 48 80 23 12 +297 119 24 44 191 108 42 231 145 128 140 99 30 1 54 131 42 276 301 102 144 37 +261 20 169 105 303 180 77 180 136 165 275 57 33 219 231 86 143 1 207 272 155 +172 264 179 45 237 147 196 137 152 13 72 47 152 270 87 224 260 196 241 293 77 +284 10 229 171 20 110 120 164 288 3 18 254 298 47 93 285 313 283 186 34 43 159 +214 4 262 7 223 120 1 113 116 181 217 59 264 26 171 173 251 233 60 251 80 186 +138 184 223 61 16 23 175 107 6 177 81 114 207 109 29 285 160 142 73 138 80 82 +313 120 11 98 255 122 291 221 146 209 83 88 315 139 8 151 189 193 235 291 58 20 +273 295 51 76 40 257 37 49 161 233 1 266 257 294 64 22 25 243 104 59 111 201 58 +277 288 156 159 2 194 10 170 186 197 169 46 2 41 185 106 290 234 92 145 69 155 +9 138 243 208 200 224 48 21 38 189 40 45 178 162 57 196 78 167 190 180 289 306 +23 269 312 296 132 19 29 226 175 3 181 64 234 151 130 208 96 34 300 174 75 112 +188 112 292 302 89 198 52 275 269 159 155 19 123 66 149 274 70 295 204 266 153 +104 126 62 166 203 126 225 25 90 230 262 264 238 30 60 39 270 299 34 147 300 +278 216 225 35 75 53 203 22 84 228 243 267 185 47 305 95 200 71 223 273 142 226 +12 144 294 276 197 228 31 141 298 259 268 172 101 4 109 133 110 273 38 36 215 +297 15 199 296 28 145 281 14 212 242 280 131 32 291 162 161 70 142 14 153 257 +141 239 274 129 280 27 158 227 315 198 309 290 130 267 81 173 192 248 237 43 6 +24 256 50 44 146 268 68 227 256 213 170 33 56 105 150 39 13 284 173 88 58 124 +147 43 263 39 117 109 286 300 21 201 48 292 149 215 85 156 312 192 307 222 133 +263 98 102 248 178 9 183 132 182 204 113 279 40 104 163 301 265 270 240 49 8 92 +204 54 294 217 212 89 139 67 136 12 85 309 137 256 154 185 210 115 31 304 108 +146 56 209 24 103 176 247 250 305 307 10 7 11 310 65 9 79 258 69 308 150 202 +139 171 277 125 297 272 214 157 87 71 70 83 29 14 67 77 27 311 52 63 94 272 2 +31 200 283 33 160 246 263 251 292 45 74 21 260 33 115 90 289 247 38 130 55 222 +286 88 211 227 ^ +668 0 211 254 226 115 16 41 170 158 305 247 25 183 117 235 218 125 212 30 152 +243 195 254 239 61 28 237 120 302 167 130 194 148 96 312 105 65 160 220 53 281 +270 226 102 70 57 137 91 26 296 105 78 106 204 40 31 232 177 22 129 68 168 269 +74 276 275 208 174 14 126 47 219 218 138 158 14 139 310 203 251 205 166 11 59 +52 214 282 20 214 308 275 182 282 46 106 230 249 316 252 311 309 77 271 15 291 +136 269 100 168 243 182 308 301 74 250 66 240 200 197 156 99 16 54 116 96 21 +314 33 134 37 23 229 156 73 124 132 96 8 51 49 147 287 15 278 190 14 113 101 +235 231 71 196 63 219 205 192 220 27 72 31 206 285 100 155 297 244 4 234 66 253 +146 181 189 166 24 5 36 201 32 28 211 228 17 193 313 224 200 210 102 83 3 121 +78 93 258 56 44 165 215 71 209 9 157 238 259 182 295 38 90 217 316 278 203 277 +97 88 302 193 22 116 122 230 236 7 268 7 242 115 3 95 186 125 238 285 74 263 12 +224 187 264 164 50 299 159 127 127 153 45 13 33 121 91 39 242 89 111 173 166 37 +314 20 188 53 307 162 148 122 204 27 85 294 190 1 167 117 248 164 63 245 97 114 +194 161 42 250 92 132 122 217 290 69 281 257 280 118 37 36 175 94 60 191 94 47 +245 110 60 178 148 109 258 43 98 227 228 4 247 12 237 133 248 151 117 261 110 +47 232 164 76 191 81 101 261 123 310 216 197 143 153 32 67 49 134 24 31 245 123 +6 162 135 176 220 40 18 286 239 35 62 106 217 303 15 265 244 30 126 34 273 280 +105 91 52 188 27 98 240 174 305 234 79 199 84 168 256 128 292 288 141 212 17 +206 259 208 187 277 110 34 286 226 89 124 119 150 24 18 299 185 19 95 173 179 +300 252 7 255 61 304 82 253 133 235 205 179 274 43 85 281 244 17 180 50 286 213 +143 140 86 83 16 67 62 80 8 64 312 131 3 82 240 187 251 218 112 266 92 119 176 +233 303 2 2 306 43 59 26 5 314 46 80 21 10 296 118 24 44 191 107 39 229 143 127 +140 99 29 54 129 42 276 301 100 142 34 260 17 167 104 302 180 76 178 135 163 +274 56 31 219 231 84 142 1 206 272 154 171 264 177 42 237 146 194 135 150 11 72 +44 152 269 87 222 259 195 241 293 77 284 7 229 169 19 108 119 163 287 2 15 252 +298 46 93 284 311 283 185 32 41 157 212 4 260 4 221 120 315 113 114 181 215 58 +263 25 170 171 251 231 58 250 79 186 138 184 223 61 13 20 175 107 6 175 81 114 +207 107 26 283 159 140 73 137 78 80 312 118 11 98 253 120 289 221 146 207 81 88 +315 139 6 149 189 192 233 290 56 18 273 293 51 75 39 255 35 49 160 233 316 265 +257 293 64 21 23 242 102 57 111 199 58 276 288 154 158 1 193 9 170 184 197 169 +45 41 183 104 289 234 92 145 68 155 6 136 243 208 203 ^ +656 0 221 48 21 32 186 40 42 178 159 51 196 72 161 187 177 283 306 23 266 309 +296 129 10 26 220 172 316 178 61 228 151 130 205 90 34 297 168 69 109 182 112 +292 299 83 192 46 269 263 159 149 19 117 63 143 274 67 292 201 260 147 104 313 +126 56 163 200 123 225 16 90 230 262 258 232 21 57 39 264 296 31 147 300 278 +216 219 35 75 50 197 13 78 225 237 267 185 41 302 95 197 71 220 270 139 223 3 +144 288 273 191 228 28 135 295 253 265 172 95 1 106 130 107 267 29 36 212 291 6 +196 293 19 142 275 8 209 239 280 131 23 291 162 161 64 142 14 150 254 141 236 +268 126 277 21 155 221 309 198 306 284 124 264 75 173 192 242 234 34 3 21 253 +44 35 140 262 62 227 250 213 167 30 50 99 150 33 4 281 170 82 55 124 141 40 263 +36 114 109 280 294 18 201 39 289 149 215 82 153 306 186 301 219 133 257 95 99 +248 175 9 183 126 179 198 110 279 34 101 163 298 265 270 237 46 8 86 204 51 294 +214 206 89 133 61 130 9 85 303 134 256 154 182 210 115 25 304 108 143 53 209 18 +103 176 244 247 299 304 10 1 8 307 62 6 73 258 69 305 147 202 136 171 277 119 +297 266 211 154 84 68 70 83 29 11 67 71 24 305 49 60 91 269 2 22 194 280 33 160 +246 260 245 286 39 68 12 260 24 109 84 289 247 38 127 55 222 283 85 205 311 211 +252 226 113 12 39 166 154 305 245 25 181 113 233 216 121 212 30 148 241 195 254 +239 59 313 28 233 118 298 167 128 192 144 92 308 101 65 156 220 49 281 268 224 +100 66 57 137 87 22 292 103 78 102 202 38 29 232 177 22 129 68 168 265 74 272 +275 204 174 10 124 43 217 218 134 158 12 137 308 199 247 201 162 5 59 52 210 +278 20 214 304 271 178 282 46 106 228 249 312 250 311 309 75 271 15 287 136 269 +100 164 239 182 308 297 70 246 64 240 196 195 156 97 14 52 112 96 15 312 29 134 +35 17 227 152 71 122 128 94 2 47 47 145 287 13 274 190 8 111 97 235 229 67 194 +59 215 205 188 216 23 70 25 206 285 98 151 293 240 230 66 253 142 177 185 164 +18 5 34 199 26 24 207 226 15 189 313 224 198 208 102 79 3 119 76 89 256 56 40 +165 213 69 207 5 157 234 255 180 295 32 88 217 316 276 203 273 93 86 302 193 20 +116 122 226 236 7 268 3 242 111 318 93 184 125 238 281 72 259 10 222 185 262 +160 50 295 155 123 127 153 45 9 27 121 89 35 238 85 107 169 166 31 310 16 188 +53 307 160 148 118 200 25 83 290 188 314 165 115 246 162 63 241 97 112 194 157 +38 250 90 132 120 213 290 65 279 255 278 118 37 30 173 94 60 189 92 47 243 110 +58 176 146 105 254 43 94 223 224 2 243 12 235 131 244 149 117 259 108 45 230 +164 76 187 79 101 261 109 ^ +656 0 310 208 189 143 149 32 59 41 130 20 31 245 123 2 154 135 168 216 32 14 +286 231 31 62 102 213 303 7 257 244 22 118 26 269 272 105 91 44 180 27 94 232 +166 301 230 79 199 84 164 248 128 288 284 133 208 17 198 259 204 187 273 102 30 +282 218 85 116 111 146 16 18 299 177 11 87 169 179 292 252 3 255 53 296 82 249 +125 227 201 171 266 39 77 273 240 9 172 46 278 205 139 136 86 79 16 63 54 76 56 +312 123 312 78 236 179 247 210 104 266 84 119 172 229 299 315 311 298 31 51 26 +314 314 38 80 13 2 292 114 24 44 191 103 27 221 135 123 140 99 25 317 54 121 42 +276 301 92 134 22 256 5 159 100 298 180 72 170 131 155 270 52 23 219 231 76 138 +1 202 272 150 167 264 169 30 237 142 186 127 142 3 72 32 152 265 87 214 255 191 +241 293 77 284 316 229 161 15 100 115 159 283 319 3 244 298 42 93 280 303 283 +181 24 33 149 204 4 252 313 213 120 307 113 106 181 207 54 259 21 166 163 251 +223 50 246 75 186 138 184 223 61 1 8 175 107 6 167 81 114 207 99 14 275 155 132 +73 133 70 72 308 110 11 98 245 112 281 221 146 199 73 88 315 139 319 141 189 +188 225 286 48 10 273 285 51 71 35 247 27 49 156 233 312 261 257 289 64 17 15 +238 94 49 111 191 58 272 288 146 154 318 189 5 170 176 197 169 41 313 41 175 96 +285 234 92 145 64 155 315 128 243 208 200 219 48 21 28 184 40 40 178 157 47 196 +68 157 185 175 279 306 23 264 307 296 127 4 24 216 170 314 176 59 224 151 130 +203 86 34 295 164 65 107 178 112 292 297 79 188 42 265 259 159 145 19 113 61 +139 274 65 290 199 256 143 104 311 126 52 161 198 121 225 10 90 230 262 254 228 +15 55 39 260 294 29 147 300 278 216 215 35 75 48 193 7 74 223 233 267 185 37 +300 95 195 71 218 268 137 221 318 144 284 271 187 228 26 131 293 249 263 172 91 +320 104 128 105 263 23 36 210 287 194 291 13 140 271 4 207 237 280 131 17 291 +162 161 60 142 14 148 252 141 234 264 124 275 17 153 217 305 198 304 280 120 +262 71 173 192 238 232 28 1 19 251 40 29 136 258 58 227 246 213 165 28 46 95 +150 29 319 279 168 78 53 124 137 38 263 34 112 109 276 290 16 201 33 287 149 +215 80 151 302 182 297 217 133 253 93 97 248 173 9 183 122 177 194 108 279 30 +99 163 296 265 270 235 44 8 82 204 49 294 212 202 89 129 57 126 7 85 299 132 +256 154 180 210 115 21 304 108 141 51 209 14 103 176 242 245 295 302 10 318 6 +305 60 4 69 258 69 303 145 202 134 171 277 115 297 262 209 152 82 66 70 83 29 9 +67 67 22 301 47 58 89 267 2 16 190 278 33 160 246 258 241 282 35 64 6 260 18 +105 80 289 247 38 125 55 292 ^ +SHS Type 3 Strings +45 0 14 5 3 1 4 16 12 20 1 6 15 11 18 4 17 16 6 10 3 2 9 9 14 6 2 8 6 7 10 17 +12 20 6 7 5 16 1 4 2 17 10 15 8 20 1 ^ +MINFO -rem perl util\mk1mf.pl VC-MSDOS no-sock >ms\msdos.mak -rem perl util\mk1mf.pl VC-W31-32 >ms\w31.mak -perl util\mk1mf.pl dll VC-W31-32 >ms\w31dll.mak -perl util\mk1mf.pl VC-WIN32 >ms\nt.mak -perl util\mk1mf.pl dll VC-WIN32 >ms\ntdll.mak - -perl util\mkdef.pl 16 libeay > ms\libeay16.def -perl util\mkdef.pl 32 libeay > ms\libeay32.def -perl util\mkdef.pl 16 ssleay > ms\ssleay16.def -perl util\mkdef.pl 32 ssleay > ms\ssleay32.def +rem perl util\mk1mf.pl no-sock %1 VC-MSDOS >ms\msdos.mak +rem perl util\mk1mf.pl %1 VC-W31-32 >ms\w31.mak +perl util\mk1mf.pl dll %1 VC-W31-32 >ms\w31dll.mak +perl util\mk1mf.pl %1 VC-WIN32 >ms\nt.mak +perl util\mk1mf.pl dll %1 VC-WIN32 >ms\ntdll.mak + +perl util\mkdef.pl 16 libeay %1 > ms\libeay16.def +perl util\mkdef.pl 32 libeay %1 > ms\libeay32.def +perl util\mkdef.pl 16 ssleay %1 > ms\ssleay16.def +perl util\mkdef.pl 32 ssleay %1 > ms\ssleay32.def diff --git a/ms/do_ms.bat b/ms/do_ms.bat index a8cf515bac..72179708bf 100755 --- a/ms/do_ms.bat +++ b/ms/do_ms.bat @@ -1,14 +1,14 @@ perl util\mkfiles.pl >MINFO -rem perl util\mk1mf.pl VC-MSDOS no-sock >ms\msdos.mak -rem perl util\mk1mf.pl VC-W31-32 >ms\w31.mak -perl util\mk1mf.pl dll VC-W31-32 >ms\w31dll.mak -perl util\mk1mf.pl no-asm VC-WIN32 >ms\nt.mak -perl util\mk1mf.pl dll no-asm VC-WIN32 >ms\ntdll.mak -perl util\mk1mf.pl no-asm VC-CE >ms\ce.mak -perl util\mk1mf.pl dll no-asm VC-CE >ms\cedll.mak +rem perl util\mk1mf.pl no-sock %1 VC-MSDOS >ms\msdos.mak +rem perl util\mk1mf.pl %1 VC-W31-32 >ms\w31.mak +perl util\mk1mf.pl dll %1 VC-W31-32 >ms\w31dll.mak +perl util\mk1mf.pl no-asm %1 VC-WIN32 >ms\nt.mak +perl util\mk1mf.pl dll no-asm %1 VC-WIN32 >ms\ntdll.mak +perl util\mk1mf.pl no-asm %1 VC-CE >ms\ce.mak +perl util\mk1mf.pl dll no-asm %1 VC-CE >ms\cedll.mak -perl util\mkdef.pl 16 libeay > ms\libeay16.def -perl util\mkdef.pl 32 libeay > ms\libeay32.def -perl util\mkdef.pl 16 ssleay > ms\ssleay16.def -perl util\mkdef.pl 32 ssleay > ms\ssleay32.def +perl util\mkdef.pl 16 libeay %1 > ms\libeay16.def +perl util\mkdef.pl 32 libeay %1 > ms\libeay32.def +perl util\mkdef.pl 16 ssleay %1 > ms\ssleay16.def +perl util\mkdef.pl 32 ssleay %1 > ms\ssleay32.def diff --git a/ms/do_nasm.bat b/ms/do_nasm.bat index 557f8a66d7..270dab0058 100755 --- a/ms/do_nasm.bat +++ b/ms/do_nasm.bat @@ -1,3 +1,4 @@ +rem use "fips" as the first argument to make a proper FIPS build. @echo off echo Generating x86 for NASM assember @@ -57,14 +58,14 @@ cd ..\..\.. echo on perl util\mkfiles.pl >MINFO -rem perl util\mk1mf.pl VC-MSDOS no-sock >ms\msdos.mak -rem perl util\mk1mf.pl VC-W31-32 >ms\w31.mak -perl util\mk1mf.pl dll VC-W31-32 >ms\w31dll.mak -perl util\mk1mf.pl nasm VC-WIN32 >ms\nt.mak -perl util\mk1mf.pl dll nasm VC-WIN32 >ms\ntdll.mak -perl util\mk1mf.pl nasm BC-NT >ms\bcb.mak - -perl util\mkdef.pl 16 libeay > ms\libeay16.def -perl util\mkdef.pl 32 libeay > ms\libeay32.def -perl util\mkdef.pl 16 ssleay > ms\ssleay16.def -perl util\mkdef.pl 32 ssleay > ms\ssleay32.def +rem perl util\mk1mf.pl no-sock %1 VC-MSDOS >ms\msdos.mak +rem perl util\mk1mf.pl %1 VC-W31-32 >ms\w31.mak +perl util\mk1mf.pl dll %1 VC-W31-32 >ms\w31dll.mak +perl util\mk1mf.pl nasm %1 VC-WIN32 >ms\nt.mak +perl util\mk1mf.pl dll nasm %1 VC-WIN32 >ms\ntdll.mak +perl util\mk1mf.pl nasm %1 BC-NT >ms\bcb.mak + +perl util\mkdef.pl 16 libeay %1 > ms\libeay16.def +perl util\mkdef.pl 32 libeay %1 > ms\libeay32.def +perl util\mkdef.pl 16 ssleay %1 > ms\ssleay16.def +perl util\mkdef.pl 32 ssleay %1 > ms\ssleay32.def diff --git a/ms/do_nt.bat b/ms/do_nt.bat index 9c06c27caa..66b408b283 100755 --- a/ms/do_nt.bat +++ b/ms/do_nt.bat @@ -1,7 +1,7 @@ perl util\mkfiles.pl >MINFO -perl util\mk1mf.pl no-asm VC-NT >ms\nt.mak -perl util\mk1mf.pl dll no-asm VC-NT >ms\ntdll.mak +perl util\mk1mf.pl no-asm %1 VC-NT >ms\nt.mak +perl util\mk1mf.pl dll no-asm %1 VC-NT >ms\ntdll.mak -perl util\mkdef.pl libeay NT > ms\libeay32.def -perl util\mkdef.pl ssleay NT > ms\ssleay32.def +perl util\mkdef.pl libeay NT %1 > ms\libeay32.def +perl util\mkdef.pl ssleay NT %1 > ms\ssleay32.def diff --git a/shlib/hpux10-cc.sh b/shlib/hpux10-cc.sh index 81eb9d4cab..fcadda827d 100644 --- a/shlib/hpux10-cc.sh +++ b/shlib/hpux10-cc.sh @@ -74,9 +74,9 @@ make clean # Hack the Makefiles to pick up the dynamic libraries during linking # -sed 's/^PEX_LIBS=.*$/PEX_LIBS=-L\/usr\/local\/ssl\/lib/' Makefile.ssl >xxx; mv xxx Makefile.ssl -sed 's/-L\.\.//' apps/Makefile.ssl >xxx; mv xxx apps/Makefile.ssl -sed 's/-L\.\.//' test/Makefile.ssl >xxx; mv xxx test/Makefile.ssl +sed 's/^PEX_LIBS=.*$/PEX_LIBS=-L\/usr\/local\/ssl\/lib/' Makefile >xxx; mv xxx Makefile.ssl +sed 's/-L\.\.//' apps/Makefile >xxx; mv xxx apps/Makefile +sed 's/-L\.\.//' test/Makefile >xxx; mv xxx test/Makefile # Build the static libs and the executables in one make. make # Install everything diff --git a/ssl/Makefile.ssl b/ssl/Makefile similarity index 90% rename from ssl/Makefile.ssl rename to ssl/Makefile index 3ae3561ac1..db182f3d3f 100644 --- a/ssl/Makefile.ssl +++ b/ssl/Makefile @@ -10,10 +10,9 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile AR= ar r # KRB5 stuff KRB5_INCLUDES= @@ -68,10 +67,9 @@ shared: lib fi files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile @$(PERL) $(TOP)/util/mklink.pl ../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../apps $(APPS) @@ -466,24 +464,24 @@ s3_clnt.o: ../include/openssl/crypto.h ../include/openssl/des.h s3_clnt.o: ../include/openssl/des_old.h ../include/openssl/dh.h s3_clnt.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h s3_clnt.o: ../include/openssl/err.h ../include/openssl/evp.h -s3_clnt.o: ../include/openssl/idea.h ../include/openssl/kssl.h -s3_clnt.o: ../include/openssl/lhash.h ../include/openssl/md2.h -s3_clnt.o: ../include/openssl/md4.h ../include/openssl/md5.h -s3_clnt.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h -s3_clnt.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h -s3_clnt.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h -s3_clnt.o: ../include/openssl/pem.h ../include/openssl/pem2.h -s3_clnt.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h -s3_clnt.o: ../include/openssl/rc2.h ../include/openssl/rc4.h -s3_clnt.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h -s3_clnt.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -s3_clnt.o: ../include/openssl/sha.h ../include/openssl/ssl.h -s3_clnt.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h -s3_clnt.o: ../include/openssl/ssl3.h ../include/openssl/stack.h -s3_clnt.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h -s3_clnt.o: ../include/openssl/ui.h ../include/openssl/ui_compat.h -s3_clnt.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h kssl_lcl.h -s3_clnt.o: s3_clnt.c ssl_locl.h +s3_clnt.o: ../include/openssl/fips.h ../include/openssl/idea.h +s3_clnt.o: ../include/openssl/kssl.h ../include/openssl/lhash.h +s3_clnt.o: ../include/openssl/md2.h ../include/openssl/md4.h +s3_clnt.o: ../include/openssl/md5.h ../include/openssl/mdc2.h +s3_clnt.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h +s3_clnt.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h +s3_clnt.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h +s3_clnt.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h +s3_clnt.o: ../include/openssl/rand.h ../include/openssl/rc2.h +s3_clnt.o: ../include/openssl/rc4.h ../include/openssl/rc5.h +s3_clnt.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h +s3_clnt.o: ../include/openssl/safestack.h ../include/openssl/sha.h +s3_clnt.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h +s3_clnt.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h +s3_clnt.o: ../include/openssl/stack.h ../include/openssl/symhacks.h +s3_clnt.o: ../include/openssl/tls1.h ../include/openssl/ui.h +s3_clnt.o: ../include/openssl/ui_compat.h ../include/openssl/x509.h +s3_clnt.o: ../include/openssl/x509_vfy.h kssl_lcl.h s3_clnt.c ssl_locl.h s3_enc.o: ../e_os.h ../include/openssl/aes.h ../include/openssl/asn1.h s3_enc.o: ../include/openssl/bio.h ../include/openssl/blowfish.h s3_enc.o: ../include/openssl/bn.h ../include/openssl/buffer.h @@ -592,24 +590,24 @@ s3_srvr.o: ../include/openssl/crypto.h ../include/openssl/des.h s3_srvr.o: ../include/openssl/des_old.h ../include/openssl/dh.h s3_srvr.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h s3_srvr.o: ../include/openssl/err.h ../include/openssl/evp.h -s3_srvr.o: ../include/openssl/idea.h ../include/openssl/kssl.h -s3_srvr.o: ../include/openssl/lhash.h ../include/openssl/md2.h -s3_srvr.o: ../include/openssl/md4.h ../include/openssl/md5.h -s3_srvr.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h -s3_srvr.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h -s3_srvr.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h -s3_srvr.o: ../include/openssl/pem.h ../include/openssl/pem2.h -s3_srvr.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h -s3_srvr.o: ../include/openssl/rc2.h ../include/openssl/rc4.h -s3_srvr.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h -s3_srvr.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -s3_srvr.o: ../include/openssl/sha.h ../include/openssl/ssl.h -s3_srvr.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h -s3_srvr.o: ../include/openssl/ssl3.h ../include/openssl/stack.h -s3_srvr.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h -s3_srvr.o: ../include/openssl/ui.h ../include/openssl/ui_compat.h -s3_srvr.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h kssl_lcl.h -s3_srvr.o: s3_srvr.c ssl_locl.h +s3_srvr.o: ../include/openssl/fips.h ../include/openssl/idea.h +s3_srvr.o: ../include/openssl/kssl.h ../include/openssl/lhash.h +s3_srvr.o: ../include/openssl/md2.h ../include/openssl/md4.h +s3_srvr.o: ../include/openssl/md5.h ../include/openssl/mdc2.h +s3_srvr.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h +s3_srvr.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h +s3_srvr.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h +s3_srvr.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h +s3_srvr.o: ../include/openssl/rand.h ../include/openssl/rc2.h +s3_srvr.o: ../include/openssl/rc4.h ../include/openssl/rc5.h +s3_srvr.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h +s3_srvr.o: ../include/openssl/safestack.h ../include/openssl/sha.h +s3_srvr.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h +s3_srvr.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h +s3_srvr.o: ../include/openssl/stack.h ../include/openssl/symhacks.h +s3_srvr.o: ../include/openssl/tls1.h ../include/openssl/ui.h +s3_srvr.o: ../include/openssl/ui_compat.h ../include/openssl/x509.h +s3_srvr.o: ../include/openssl/x509_vfy.h kssl_lcl.h s3_srvr.c ssl_locl.h ssl_algs.o: ../e_os.h ../include/openssl/aes.h ../include/openssl/asn1.h ssl_algs.o: ../include/openssl/bio.h ../include/openssl/blowfish.h ssl_algs.o: ../include/openssl/bn.h ../include/openssl/buffer.h @@ -669,24 +667,25 @@ ssl_cert.o: ../include/openssl/conf.h ../include/openssl/crypto.h ssl_cert.o: ../include/openssl/des.h ../include/openssl/des_old.h ssl_cert.o: ../include/openssl/dh.h ../include/openssl/dsa.h ssl_cert.o: ../include/openssl/e_os2.h ../include/openssl/err.h -ssl_cert.o: ../include/openssl/evp.h ../include/openssl/idea.h -ssl_cert.o: ../include/openssl/kssl.h ../include/openssl/lhash.h -ssl_cert.o: ../include/openssl/md2.h ../include/openssl/md4.h -ssl_cert.o: ../include/openssl/md5.h ../include/openssl/mdc2.h -ssl_cert.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -ssl_cert.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -ssl_cert.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -ssl_cert.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -ssl_cert.o: ../include/openssl/rc2.h ../include/openssl/rc4.h -ssl_cert.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h -ssl_cert.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -ssl_cert.o: ../include/openssl/sha.h ../include/openssl/ssl.h -ssl_cert.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h -ssl_cert.o: ../include/openssl/ssl3.h ../include/openssl/stack.h -ssl_cert.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h -ssl_cert.o: ../include/openssl/ui.h ../include/openssl/ui_compat.h -ssl_cert.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h -ssl_cert.o: ../include/openssl/x509v3.h ssl_cert.c ssl_locl.h +ssl_cert.o: ../include/openssl/evp.h ../include/openssl/fips.h +ssl_cert.o: ../include/openssl/idea.h ../include/openssl/kssl.h +ssl_cert.o: ../include/openssl/lhash.h ../include/openssl/md2.h +ssl_cert.o: ../include/openssl/md4.h ../include/openssl/md5.h +ssl_cert.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h +ssl_cert.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h +ssl_cert.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h +ssl_cert.o: ../include/openssl/pem.h ../include/openssl/pem2.h +ssl_cert.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h +ssl_cert.o: ../include/openssl/rc4.h ../include/openssl/rc5.h +ssl_cert.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h +ssl_cert.o: ../include/openssl/safestack.h ../include/openssl/sha.h +ssl_cert.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h +ssl_cert.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h +ssl_cert.o: ../include/openssl/stack.h ../include/openssl/symhacks.h +ssl_cert.o: ../include/openssl/tls1.h ../include/openssl/ui.h +ssl_cert.o: ../include/openssl/ui_compat.h ../include/openssl/x509.h +ssl_cert.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h +ssl_cert.o: ssl_cert.c ssl_locl.h ssl_ciph.o: ../e_os.h ../include/openssl/aes.h ../include/openssl/asn1.h ssl_ciph.o: ../include/openssl/bio.h ../include/openssl/blowfish.h ssl_ciph.o: ../include/openssl/bn.h ../include/openssl/buffer.h @@ -770,24 +769,25 @@ ssl_lib.o: ../include/openssl/conf.h ../include/openssl/crypto.h ssl_lib.o: ../include/openssl/des.h ../include/openssl/des_old.h ssl_lib.o: ../include/openssl/dh.h ../include/openssl/dsa.h ssl_lib.o: ../include/openssl/e_os2.h ../include/openssl/err.h -ssl_lib.o: ../include/openssl/evp.h ../include/openssl/idea.h -ssl_lib.o: ../include/openssl/kssl.h ../include/openssl/lhash.h -ssl_lib.o: ../include/openssl/md2.h ../include/openssl/md4.h -ssl_lib.o: ../include/openssl/md5.h ../include/openssl/mdc2.h -ssl_lib.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -ssl_lib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -ssl_lib.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -ssl_lib.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -ssl_lib.o: ../include/openssl/rc2.h ../include/openssl/rc4.h -ssl_lib.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h -ssl_lib.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -ssl_lib.o: ../include/openssl/sha.h ../include/openssl/ssl.h -ssl_lib.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h -ssl_lib.o: ../include/openssl/ssl3.h ../include/openssl/stack.h -ssl_lib.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h -ssl_lib.o: ../include/openssl/ui.h ../include/openssl/ui_compat.h -ssl_lib.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h -ssl_lib.o: ../include/openssl/x509v3.h kssl_lcl.h ssl_lib.c ssl_locl.h +ssl_lib.o: ../include/openssl/evp.h ../include/openssl/fips.h +ssl_lib.o: ../include/openssl/idea.h ../include/openssl/kssl.h +ssl_lib.o: ../include/openssl/lhash.h ../include/openssl/md2.h +ssl_lib.o: ../include/openssl/md4.h ../include/openssl/md5.h +ssl_lib.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h +ssl_lib.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h +ssl_lib.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h +ssl_lib.o: ../include/openssl/pem.h ../include/openssl/pem2.h +ssl_lib.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h +ssl_lib.o: ../include/openssl/rc4.h ../include/openssl/rc5.h +ssl_lib.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h +ssl_lib.o: ../include/openssl/safestack.h ../include/openssl/sha.h +ssl_lib.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h +ssl_lib.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h +ssl_lib.o: ../include/openssl/stack.h ../include/openssl/symhacks.h +ssl_lib.o: ../include/openssl/tls1.h ../include/openssl/ui.h +ssl_lib.o: ../include/openssl/ui_compat.h ../include/openssl/x509.h +ssl_lib.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h kssl_lcl.h +ssl_lib.o: ssl_lib.c ssl_locl.h ssl_rsa.o: ../e_os.h ../include/openssl/aes.h ../include/openssl/asn1.h ssl_rsa.o: ../include/openssl/bio.h ../include/openssl/blowfish.h ssl_rsa.o: ../include/openssl/bn.h ../include/openssl/buffer.h @@ -923,24 +923,24 @@ t1_enc.o: ../include/openssl/crypto.h ../include/openssl/des.h t1_enc.o: ../include/openssl/des_old.h ../include/openssl/dh.h t1_enc.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h t1_enc.o: ../include/openssl/err.h ../include/openssl/evp.h -t1_enc.o: ../include/openssl/hmac.h ../include/openssl/idea.h -t1_enc.o: ../include/openssl/kssl.h ../include/openssl/lhash.h -t1_enc.o: ../include/openssl/md2.h ../include/openssl/md4.h -t1_enc.o: ../include/openssl/md5.h ../include/openssl/mdc2.h -t1_enc.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -t1_enc.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -t1_enc.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -t1_enc.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -t1_enc.o: ../include/openssl/rc2.h ../include/openssl/rc4.h -t1_enc.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h -t1_enc.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -t1_enc.o: ../include/openssl/sha.h ../include/openssl/ssl.h -t1_enc.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h -t1_enc.o: ../include/openssl/ssl3.h ../include/openssl/stack.h -t1_enc.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h -t1_enc.o: ../include/openssl/ui.h ../include/openssl/ui_compat.h -t1_enc.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h -t1_enc.o: t1_enc.c +t1_enc.o: ../include/openssl/fips.h ../include/openssl/hmac.h +t1_enc.o: ../include/openssl/idea.h ../include/openssl/kssl.h +t1_enc.o: ../include/openssl/lhash.h ../include/openssl/md2.h +t1_enc.o: ../include/openssl/md4.h ../include/openssl/md5.h +t1_enc.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h +t1_enc.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h +t1_enc.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h +t1_enc.o: ../include/openssl/pem.h ../include/openssl/pem2.h +t1_enc.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h +t1_enc.o: ../include/openssl/rc4.h ../include/openssl/rc5.h +t1_enc.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h +t1_enc.o: ../include/openssl/safestack.h ../include/openssl/sha.h +t1_enc.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h +t1_enc.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h +t1_enc.o: ../include/openssl/stack.h ../include/openssl/symhacks.h +t1_enc.o: ../include/openssl/tls1.h ../include/openssl/ui.h +t1_enc.o: ../include/openssl/ui_compat.h ../include/openssl/x509.h +t1_enc.o: ../include/openssl/x509_vfy.h ssl_locl.h t1_enc.c t1_lib.o: ../e_os.h ../include/openssl/aes.h ../include/openssl/asn1.h t1_lib.o: ../include/openssl/bio.h ../include/openssl/blowfish.h t1_lib.o: ../include/openssl/bn.h ../include/openssl/buffer.h diff --git a/ssl/s3_clnt.c b/ssl/s3_clnt.c index 26ce0cb963..472b6d7c22 100644 --- a/ssl/s3_clnt.c +++ b/ssl/s3_clnt.c @@ -117,6 +117,7 @@ #include #include #include +#include static SSL_METHOD *ssl3_get_client_method(int ver); static int ssl3_client_hello(SSL *s); @@ -1165,7 +1166,16 @@ static int ssl3_get_key_exchange(SSL *s) EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); EVP_DigestUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); EVP_DigestUpdate(&md_ctx,param,param_len); +#ifdef OPENSSL_FIPS + if(s->version == TLS1_VERSION && num == 2) + FIPS_allow_md5(1); +#endif + EVP_DigestFinal_ex(&md_ctx,q,(unsigned int *)&i); +#ifdef OPENSSL_FIPS + if(s->version == TLS1_VERSION && num == 2) + FIPS_allow_md5(1); +#endif q+=i; j+=i; } diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c index deb3cffabe..37789e5c7d 100644 --- a/ssl/s3_srvr.c +++ b/ssl/s3_srvr.c @@ -125,6 +125,7 @@ #include #endif #include +#include static SSL_METHOD *ssl3_get_server_method(int ver); static int ssl3_get_client_hello(SSL *s); @@ -1216,8 +1217,16 @@ static int ssl3_send_server_key_exchange(SSL *s) EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); EVP_DigestUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); EVP_DigestUpdate(&md_ctx,&(d[4]),n); +#ifdef OPENSSL_FIPS + if(s->version == TLS1_VERSION && num == 2) + FIPS_allow_md5(1); +#endif EVP_DigestFinal_ex(&md_ctx,q, (unsigned int *)&i); +#ifdef OPENSSL_FIPS + if(s->version == TLS1_VERSION && num == 2) + FIPS_allow_md5(0); +#endif q+=i; j+=i; } diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c index 2cfb615878..5c7b3a3418 100644 --- a/ssl/ssl_cert.c +++ b/ssl/ssl_cert.c @@ -129,6 +129,7 @@ #include #include #include "ssl_locl.h" +#include int SSL_get_ex_data_X509_STORE_CTX_idx(void) { @@ -491,7 +492,15 @@ int ssl_verify_cert_chain(SSL *s,STACK_OF(X509) *sk) else { #ifndef OPENSSL_NO_X509_VERIFY +# ifdef OPENSSL_FIPS + if(s->version == TLS1_VERSION) + FIPS_allow_md5(1); +# endif i=X509_verify_cert(&ctx); +# ifdef OPENSSL_FIPS + if(s->version == TLS1_VERSION) + FIPS_allow_md5(0); +# endif #else i=0; ctx.error=X509_V_ERR_APPLICATION_VERIFICATION; diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index ee9a82d586..f5705af0f6 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -121,6 +121,7 @@ #include #include #include +#include const char *SSL_version_str=OPENSSL_VERSION_TEXT; @@ -2156,7 +2157,18 @@ int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx) int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, const char *CApath) { - return(X509_STORE_load_locations(ctx->cert_store,CAfile,CApath)); + int r; + +#ifdef OPENSSL_FIPS + if(ctx->method->version == TLS1_VERSION) + FIPS_allow_md5(1); +#endif + r=X509_STORE_load_locations(ctx->cert_store,CAfile,CApath); +#ifdef OPENSSL_FIPS + if(ctx->method->version == TLS1_VERSION) + FIPS_allow_md5(0); +#endif + return r; } #endif diff --git a/ssl/ssltest.c b/ssl/ssltest.c index 28095148e7..c7f33d9a7f 100644 --- a/ssl/ssltest.c +++ b/ssl/ssltest.c @@ -133,6 +133,7 @@ #endif #include #include +#include #define _XOPEN_SOURCE_EXTENDED 1 /* Or gethostname won't be declared properly on Compaq platforms (at least with DEC C). @@ -198,6 +199,9 @@ static void sv_usage(void) { fprintf(stderr,"usage: ssltest [args ...]\n"); fprintf(stderr,"\n"); +#ifdef OPENSSL_FIPS + fprintf(stderr,"-F - run test in FIPS mode\n"); +#endif fprintf(stderr," -server_auth - check server certificate\n"); fprintf(stderr," -client_auth - do client authentication\n"); fprintf(stderr," -v - more output\n"); @@ -369,6 +373,10 @@ int main(int argc, char *argv[]) clock_t s_time = 0, c_time = 0; int comp = 0; COMP_METHOD *cm = NULL; +#ifdef OPENSSL_FIPS + int fips_mode=0; + const char *path=argv[0]; +#endif verbose = 0; debug = 0; @@ -400,7 +408,16 @@ int main(int argc, char *argv[]) while (argc >= 1) { - if (strcmp(*argv,"-server_auth") == 0) + if(!strcmp(*argv,"-F")) + { +#ifdef OPENSSL_FIPS + fips_mode=1; +#else + fprintf(stderr,"not compiled with FIPS support, so exitting without running.\n"); + exit(0); +#endif + } + else if (strcmp(*argv,"-server_auth") == 0) server_auth=1; else if (strcmp(*argv,"-client_auth") == 0) client_auth=1; @@ -534,6 +551,7 @@ bad: goto end; } + if (!ssl2 && !ssl3 && !tls1 && number > 1 && !reuse && !force) { fprintf(stderr, "This case cannot work. Use -f to perform " @@ -543,6 +561,20 @@ bad: EXIT(1); } +#ifdef OPENSSL_FIPS + if(fips_mode) + { + if(!FIPS_mode_set(1,path)) + { + ERR_load_crypto_strings(); + ERR_print_errors(BIO_new_fp(stderr,BIO_NOCLOSE)); + exit(1); + } + else + fprintf(stderr,"*** IN FIPS MODE ***\n"); + } +#endif + if (print_time) { if (!bio_pair) diff --git a/ssl/t1_enc.c b/ssl/t1_enc.c index 271e247eea..ac224ddfa1 100644 --- a/ssl/t1_enc.c +++ b/ssl/t1_enc.c @@ -115,6 +115,7 @@ #include #include #include +#include static void tls1_P_hash(const EVP_MD *md, const unsigned char *sec, int sec_len, unsigned char *seed, int seed_len, @@ -177,8 +178,13 @@ static void tls1_PRF(const EVP_MD *md5, const EVP_MD *sha1, S2= &(sec[len]); len+=(slen&1); /* add for odd, make longer */ - +#ifdef OPENSSL_FIPS + FIPS_allow_md5(1); +#endif tls1_P_hash(md5 ,S1,len,label,label_len,out1,olen); +#ifdef OPENSSL_FIPS + FIPS_allow_md5(0); +#endif tls1_P_hash(sha1,S2,len,label,label_len,out2,olen); for (i=0; i> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile generate: $(SRC) $(SRC): @@ -136,6 +139,14 @@ alltests: \ test_rand test_bn test_ec test_enc test_x509 test_rsa test_crl test_sid \ test_gen test_req test_pkcs7 test_verify test_dh test_dsa \ test_ss test_ca test_engine test_evp test_ssl +# temporarily removed +# fips_test_aes + +fips_test_aes: + if egrep 'define OPENSSL_FIPS' $(TOP)/include/openssl/opensslconf.h > /dev/null; then \ + mkdir -p fips_aes_data/rsp; \ + $(SET_SO_PATHS); ./$(FIPS_AESTEST) -d fips_aes_data/list; \ + fi test_evp: $(SET_SO_PATHS); ./$(EVPTEST) evptests.txt @@ -149,6 +160,9 @@ test_idea: test_sha: $(SET_SO_PATHS); ./$(SHATEST) $(SET_SO_PATHS); ./$(SHA1TEST) + if egrep 'define OPENSSL_FIPS' $(TOP)/include/openssl/opensslconf.h > /dev/null; then \ + $(SET_SO_PATHS); ./$(FIPS_SHA1TEST) sha1vectors.txt | sed s/Strings/Hashes/ | cmp sha1hashes.txt - ; \ + fi test_mdc2: $(SET_SO_PATHS); ./$(MDC2TEST) @@ -185,6 +199,9 @@ test_rc5: test_rand: $(SET_SO_PATHS); ./$(RANDTEST) + if egrep 'define OPENSSL_FIPS' $(TOP)/include/openssl/opensslconf.h > /dev/null; then \ + $(SET_SO_PATHS); ./$(FIPS_RANDTEST); \ + fi test_enc: @$(SET_SO_PATHS); sh ./testenc @@ -241,6 +258,10 @@ test_dsa: @echo "Generate a set of DSA parameters" $(SET_SO_PATHS); ./$(DSATEST) $(SET_SO_PATHS); ./$(DSATEST) -app2_1 + if egrep 'define OPENSSL_FIPS' $(TOP)/include/openssl/opensslconf.h > /dev/null; then \ + $(SET_SO_PATHS); ./$(FIPS_DSATEST); \ + $(SET_SO_PATHS); ./$(FIPS_DSATEST) -app2_1; \ + fi test_gen: @echo "Generate and verify a certificate request" @@ -256,6 +277,9 @@ test_engine: test_ssl: keyU.ss certU.ss certCA.ss @echo "test SSL protocol" + @if egrep 'define OPENSSL_FIPS' $(TOP)/include/openssl/opensslconf.h > /dev/null; then \ + $(SET_SO_PATHS); sh ./testfipsssl keyU.ss certU.ss certCA.ss; \ + fi @$(SET_SO_PATHS); sh ./testssl keyU.ss certU.ss certCA.ss test_ca: @@ -264,7 +288,7 @@ test_ca: else \ echo "Generate and certify a test certificate via the 'ca' program"; \ sh ./testca; \ - fi + fi test_aes: #$(AESTEST) # @echo "test Rijndael" @@ -289,6 +313,16 @@ $(DLIBSSL): $(DLIBCRYPTO): (cd ..; $(MAKE) DIRS=crypto all) +$(FIPS_AESTEST): $(FIPS_AESTEST).o $(DLIBCRYPTO) + if [ "$(SHLIB_TARGET)" = "hpux-shared" -o "$(SHLIB_TARGET)" = "darwin-shared" ] ; then \ + $(CC) -o $(FIPS_AESTEST) $(CFLAGS) $(FIPS_AESTEST).o $(PEX_LIBS) $(DLIBCRYPTO) $(EX_LIBS) ; \ + else \ + $(CC) -o $(FIPS_AESTEST) $(CFLAGS) $(FIPS_AESTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) ; \ + fi + if egrep 'define OPENSSL_FIPS' $(TOP)/include/openssl/opensslconf.h > /dev/null; then \ + TOP=$(TOP) $(TOP)/fips/openssl_fips_fingerprint $(TOP)/libcrypto.a $(FIPS_AESTEST); \ + fi + $(RSATEST): $(RSATEST).o $(DLIBCRYPTO) if [ "$(SHLIB_TARGET)" = "hpux-shared" -o "$(SHLIB_TARGET)" = "darwin-shared" ] ; then \ $(CC) -o $(RSATEST) $(CFLAGS) $(RSATEST).o $(PEX_LIBS) $(DLIBCRYPTO) $(EX_LIBS) ; \ @@ -353,6 +387,16 @@ $(SHA1TEST): $(SHA1TEST).o $(DLIBCRYPTO) $(CC) -o $(SHA1TEST) $(CFLAGS) $(SHA1TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) ; \ fi +$(FIPS_SHA1TEST): $(FIPS_SHA1TEST).o $(DLIBCRYPTO) + if [ "$(SHLIB_TARGET)" = "hpux-shared" -o "$(SHLIB_TARGET)" = "darwin-shared" ] ; then \ + $(CC) -o $(FIPS_SHA1TEST) $(CFLAGS) $(FIPS_SHA1TEST).o $(PEX_LIBS) $(DLIBCRYPTO) $(EX_LIBS) ; \ + else \ + $(CC) -o $(FIPS_SHA1TEST) $(CFLAGS) $(FIPS_SHA1TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) ; \ + fi + if egrep 'define OPENSSL_FIPS' $(TOP)/include/openssl/opensslconf.h > /dev/null; then \ + TOP=$(TOP) $(TOP)/fips/openssl_fips_fingerprint $(TOP)/libcrypto.a $(FIPS_SHA1TEST); \ + fi + $(RMDTEST): $(RMDTEST).o $(DLIBCRYPTO) if [ "$(SHLIB_TARGET)" = "hpux-shared" -o "$(SHLIB_TARGET)" = "darwin-shared" ] ; then \ $(CC) -o $(RMDTEST) $(CFLAGS) $(RMDTEST).o $(PEX_LIBS) $(DLIBCRYPTO) $(EX_LIBS) ; \ @@ -441,6 +485,17 @@ $(DESTEST): $(DESTEST).o $(DLIBCRYPTO) $(CC) -o $(DESTEST) $(CFLAGS) $(DESTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) ; \ fi +$(FIPS_DESTEST): $(FIPS_DESTEST).o $(DLIBCRYPTO) + if [ "$(SHLIB_TARGET)" = "hpux-shared" -o "$(SHLIB_TARGET)" = "darwin-shared" ] ; then \ + $(CC) -o $(FIPS_DESTEST) $(CFLAGS) $(FIPS_DESTEST).o $(PEX_LIBS) $(DLIBCRYPTO) $(EX_LIBS) ; \ + else \ + LD_LIBRARY_PATH=..:$$LD_LIBRARY_PATH \ + $(CC) -o $(FIPS_DESTEST) $(CFLAGS) $(FIPS_DESTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) ; \ + fi + if egrep 'define OPENSSL_FIPS' $(TOP)/include/openssl/opensslconf.h > /dev/null; then \ + TOP=$(TOP) $(TOP)/fips/openssl_fips_fingerprint $(TOP)/libcrypto.a $(FIPS_DESTEST); \ + fi + $(RANDTEST): $(RANDTEST).o $(DLIBCRYPTO) if [ "$(SHLIB_TARGET)" = "hpux-shared" -o "$(SHLIB_TARGET)" = "darwin-shared" ] ; then \ $(CC) -o $(RANDTEST) $(CFLAGS) $(RANDTEST).o $(PEX_LIBS) $(DLIBCRYPTO) $(EX_LIBS) ; \ @@ -449,6 +504,16 @@ $(RANDTEST): $(RANDTEST).o $(DLIBCRYPTO) $(CC) -o $(RANDTEST) $(CFLAGS) $(RANDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) ; \ fi +$(FIPS_RANDTEST): $(FIPS_RANDTEST).o $(DLIBCRYPTO) + if [ "$(SHLIB_TARGET)" = "hpux-shared" -o "$(SHLIB_TARGET)" = "darwin-shared" ] ; then \ + $(CC) -o $(FIPS_RANDTEST) $(CFLAGS) $(FIPS_RANDTEST).o $(PEX_LIBS) $(DLIBCRYPTO) $(EX_LIBS) ; \ + else \ + $(CC) -o $(FIPS_RANDTEST) $(CFLAGS) $(FIPS_RANDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) ; \ + fi + if egrep 'define OPENSSL_FIPS' $(TOP)/include/openssl/opensslconf.h > /dev/null; then \ + TOP=$(TOP) $(TOP)/fips/openssl_fips_fingerprint $(TOP)/libcrypto.a $(FIPS_RANDTEST); \ + fi + $(DHTEST): $(DHTEST).o $(DLIBCRYPTO) if [ "$(SHLIB_TARGET)" = "hpux-shared" -o "$(SHLIB_TARGET)" = "darwin-shared" ] ; then \ $(CC) -o $(DHTEST) $(CFLAGS) $(DHTEST).o $(PEX_LIBS) $(DLIBCRYPTO) $(EX_LIBS) ; \ @@ -465,6 +530,16 @@ $(DSATEST): $(DSATEST).o $(DLIBCRYPTO) $(CC) -o $(DSATEST) $(CFLAGS) $(DSATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) ; \ fi +$(FIPS_DSATEST): $(FIPS_DSATEST).o $(DLIBCRYPTO) + if [ "$(SHLIB_TARGET)" = "hpux-shared" -o "$(SHLIB_TARGET)" = "darwin-shared" ] ; then \ + $(CC) -o $(FIPS_DSATEST) $(CFLAGS) $(FIPS_DSATEST).o $(PEX_LIBS) $(DLIBCRYPTO) $(EX_LIBS) ; \ + else \ + $(CC) -o $(FIPS_DSATEST) $(CFLAGS) $(FIPS_DSATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) ; \ + fi + if egrep 'define OPENSSL_FIPS' $(TOP)/include/openssl/opensslconf.h > /dev/null; then \ + TOP=$(TOP) $(TOP)/fips/openssl_fips_fingerprint $(TOP)/libcrypto.a $(FIPS_DSATEST); \ + fi + $(METHTEST): $(METHTEST).o $(DLIBCRYPTO) if [ "$(SHLIB_TARGET)" = "hpux-shared" -o "$(SHLIB_TARGET)" = "darwin-shared" ] ; then \ $(CC) -o $(METHTEST) $(CFLAGS) $(METHTEST).o $(PEX_LIBS) $(DLIBCRYPTO) $(EX_LIBS) ; \ @@ -480,6 +555,9 @@ $(SSLTEST): $(SSLTEST).o $(DLIBSSL) $(DLIBCRYPTO) LD_LIBRARY_PATH=..:$$LD_LIBRARY_PATH \ $(CC) -o $(SSLTEST) $(CFLAGS) $(SSLTEST).o $(PEX_LIBS) $(LIBSSL) $(LIBKRB5) $(LIBCRYPTO) $(EX_LIBS) ; \ fi + if egrep 'define OPENSSL_FIPS' $(TOP)/include/openssl/opensslconf.h > /dev/null; then \ + TOP=$(TOP) $(TOP)/fips/openssl_fips_fingerprint $(TOP)/libcrypto.a $(SSLTEST); \ + fi $(ENGINETEST): $(ENGINETEST).o $(DLIBCRYPTO) if [ "$(SHLIB_TARGET)" = "hpux-shared" -o "$(SHLIB_TARGET)" = "darwin-shared" ] ; then \ @@ -496,7 +574,7 @@ $(EVPTEST): $(EVPTEST).o $(DLIBCRYPTO) LD_LIBRARY_PATH=..:$$LD_LIBRARY_PATH \ $(CC) -o $(EVPTEST) $(CFLAGS) $(EVPTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) ; \ fi - + #$(AESTEST).o: $(AESTEST).c # $(CC) -c $(CFLAGS) -DINTERMEDIATE_VALUE_KAT -DTRACE_KAT_MCT $(AESTEST).c @@ -612,6 +690,73 @@ exptest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h exptest.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h exptest.o: ../include/openssl/safestack.h ../include/openssl/stack.h exptest.o: ../include/openssl/symhacks.h exptest.c +fips_aesavs.o: ../e_os.h ../include/openssl/aes.h ../include/openssl/asn1.h +fips_aesavs.o: ../include/openssl/bio.h ../include/openssl/blowfish.h +fips_aesavs.o: ../include/openssl/bn.h ../include/openssl/cast.h +fips_aesavs.o: ../include/openssl/crypto.h ../include/openssl/des.h +fips_aesavs.o: ../include/openssl/des_old.h ../include/openssl/dh.h +fips_aesavs.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h +fips_aesavs.o: ../include/openssl/err.h ../include/openssl/evp.h +fips_aesavs.o: ../include/openssl/fips.h ../include/openssl/idea.h +fips_aesavs.o: ../include/openssl/lhash.h ../include/openssl/md2.h +fips_aesavs.o: ../include/openssl/md4.h ../include/openssl/md5.h +fips_aesavs.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h +fips_aesavs.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h +fips_aesavs.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h +fips_aesavs.o: ../include/openssl/rc2.h ../include/openssl/rc4.h +fips_aesavs.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h +fips_aesavs.o: ../include/openssl/rsa.h ../include/openssl/safestack.h +fips_aesavs.o: ../include/openssl/sha.h ../include/openssl/stack.h +fips_aesavs.o: ../include/openssl/symhacks.h ../include/openssl/ui.h +fips_aesavs.o: ../include/openssl/ui_compat.h fips_aesavs.c +fips_desmovs.o: ../e_os.h ../include/openssl/aes.h ../include/openssl/asn1.h +fips_desmovs.o: ../include/openssl/bio.h ../include/openssl/blowfish.h +fips_desmovs.o: ../include/openssl/bn.h ../include/openssl/cast.h +fips_desmovs.o: ../include/openssl/crypto.h ../include/openssl/des.h +fips_desmovs.o: ../include/openssl/des_old.h ../include/openssl/dh.h +fips_desmovs.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h +fips_desmovs.o: ../include/openssl/err.h ../include/openssl/evp.h +fips_desmovs.o: ../include/openssl/fips.h ../include/openssl/idea.h +fips_desmovs.o: ../include/openssl/lhash.h ../include/openssl/md2.h +fips_desmovs.o: ../include/openssl/md4.h ../include/openssl/md5.h +fips_desmovs.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h +fips_desmovs.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h +fips_desmovs.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h +fips_desmovs.o: ../include/openssl/rc2.h ../include/openssl/rc4.h +fips_desmovs.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h +fips_desmovs.o: ../include/openssl/rsa.h ../include/openssl/safestack.h +fips_desmovs.o: ../include/openssl/sha.h ../include/openssl/stack.h +fips_desmovs.o: ../include/openssl/symhacks.h ../include/openssl/ui.h +fips_desmovs.o: ../include/openssl/ui_compat.h fips_desmovs.c +fips_dsatest.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h +fips_dsatest.o: ../include/openssl/bn.h ../include/openssl/crypto.h +fips_dsatest.o: ../include/openssl/des.h ../include/openssl/des_old.h +fips_dsatest.o: ../include/openssl/dh.h ../include/openssl/dsa.h +fips_dsatest.o: ../include/openssl/e_os2.h ../include/openssl/engine.h +fips_dsatest.o: ../include/openssl/err.h ../include/openssl/fips.h +fips_dsatest.o: ../include/openssl/fips_rand.h ../include/openssl/lhash.h +fips_dsatest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h +fips_dsatest.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h +fips_dsatest.o: ../include/openssl/rsa.h ../include/openssl/safestack.h +fips_dsatest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h +fips_dsatest.o: ../include/openssl/ui.h ../include/openssl/ui_compat.h +fips_dsatest.o: fips_dsatest.c +fips_randtest.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/crypto.h +fips_randtest.o: ../include/openssl/des.h ../include/openssl/des_old.h +fips_randtest.o: ../include/openssl/e_os2.h ../include/openssl/err.h +fips_randtest.o: ../include/openssl/fips_rand.h ../include/openssl/lhash.h +fips_randtest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h +fips_randtest.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h +fips_randtest.o: ../include/openssl/safestack.h ../include/openssl/stack.h +fips_randtest.o: ../include/openssl/symhacks.h ../include/openssl/ui.h +fips_randtest.o: ../include/openssl/ui_compat.h fips_randtest.c +fips_sha1test.o: ../include/openssl/bio.h ../include/openssl/crypto.h +fips_sha1test.o: ../include/openssl/e_os2.h ../include/openssl/err.h +fips_sha1test.o: ../include/openssl/fips.h ../include/openssl/lhash.h +fips_sha1test.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h +fips_sha1test.o: ../include/openssl/safestack.h ../include/openssl/sha.h +fips_sha1test.o: ../include/openssl/stack.h ../include/openssl/symhacks.h +fips_sha1test.o: fips_sha1test.c hmactest.o: ../e_os.h ../include/openssl/aes.h ../include/openssl/asn1.h hmactest.o: ../include/openssl/bio.h ../include/openssl/blowfish.h hmactest.o: ../include/openssl/bn.h ../include/openssl/cast.h @@ -776,21 +921,21 @@ ssltest.o: ../include/openssl/crypto.h ../include/openssl/des.h ssltest.o: ../include/openssl/des_old.h ../include/openssl/dh.h ssltest.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h ssltest.o: ../include/openssl/engine.h ../include/openssl/err.h -ssltest.o: ../include/openssl/evp.h ../include/openssl/idea.h -ssltest.o: ../include/openssl/kssl.h ../include/openssl/lhash.h -ssltest.o: ../include/openssl/md2.h ../include/openssl/md4.h -ssltest.o: ../include/openssl/md5.h ../include/openssl/mdc2.h -ssltest.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -ssltest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -ssltest.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -ssltest.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -ssltest.o: ../include/openssl/rand.h ../include/openssl/rc2.h -ssltest.o: ../include/openssl/rc4.h ../include/openssl/rc5.h -ssltest.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h -ssltest.o: ../include/openssl/safestack.h ../include/openssl/sha.h -ssltest.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h -ssltest.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h -ssltest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h -ssltest.o: ../include/openssl/tls1.h ../include/openssl/ui.h -ssltest.o: ../include/openssl/ui_compat.h ../include/openssl/x509.h -ssltest.o: ../include/openssl/x509_vfy.h ssltest.c +ssltest.o: ../include/openssl/evp.h ../include/openssl/fips.h +ssltest.o: ../include/openssl/idea.h ../include/openssl/kssl.h +ssltest.o: ../include/openssl/lhash.h ../include/openssl/md2.h +ssltest.o: ../include/openssl/md4.h ../include/openssl/md5.h +ssltest.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h +ssltest.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h +ssltest.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h +ssltest.o: ../include/openssl/pem.h ../include/openssl/pem2.h +ssltest.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h +ssltest.o: ../include/openssl/rc2.h ../include/openssl/rc4.h +ssltest.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h +ssltest.o: ../include/openssl/rsa.h ../include/openssl/safestack.h +ssltest.o: ../include/openssl/sha.h ../include/openssl/ssl.h +ssltest.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h +ssltest.o: ../include/openssl/ssl3.h ../include/openssl/stack.h +ssltest.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h +ssltest.o: ../include/openssl/ui.h ../include/openssl/ui_compat.h +ssltest.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssltest.c diff --git a/test/bctest b/test/bctest index bdb3218f7a..e81fc0733a 100755 --- a/test/bctest +++ b/test/bctest @@ -1,6 +1,6 @@ #!/bin/sh -# This script is used by test/Makefile.ssl to check whether a sane 'bc' +# This script is used by test/Makefile to check whether a sane 'bc' # is installed. # ('make test_bn' should not try to run 'bc' if it does not exist or if # it is a broken 'bc' version that is known to cause trouble.) diff --git a/test/testenc b/test/testenc index 0656c7f525..70505f0222 100644 --- a/test/testenc +++ b/test/testenc @@ -1,6 +1,6 @@ #!/bin/sh -testsrc=Makefile.ssl +testsrc=Makefile test=./p cmd=../apps/openssl diff --git a/test/testfipsssl b/test/testfipsssl new file mode 100644 index 0000000000..da5e5987ab --- /dev/null +++ b/test/testfipsssl @@ -0,0 +1,113 @@ +#!/bin/sh + +if [ "$1" = "" ]; then + key=../apps/server.pem +else + key="$1" +fi +if [ "$2" = "" ]; then + cert=../apps/server.pem +else + cert="$2" +fi + +ciphers="DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:AES256-SHA:EDH-RSA-DES-CBC3-SHA:EDH-DSS-DES-CBC3-SHA:DES-CBC3-SHA:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA:AES128-SHA:EXP1024-DHE-DSS-DES-CBC-SHA:EXP1024-DES-CBC-SHA:EDH-RSA-DES-CBC-SHA:EDH-DSS-DES-CBC-SHA:DES-CBC-SHA:EXP-EDH-RSA-DES-CBC-SHA:EXP-EDH-DSS-DES-CBC-SHA:EXP-DES-CBC-SHA" + +ssltest="./ssltest -F -key $key -cert $cert -c_key $key -c_cert $cert -cipher $ciphers" + +if ../apps/openssl x509 -in $cert -text -noout | fgrep 'DSA Public Key' >/dev/null; then + dsa_cert=YES +else + dsa_cert=NO +fi + +if [ "$3" = "" ]; then + CA="-CApath ../certs" +else + CA="-CAfile $3" +fi + +if [ "$4" = "" ]; then + extra="" +else + extra="$4" +fi + +############################################################################# + +echo test ssl3 is forbidden in FIPS mode +$ssltest -ssl3 $extra && exit 1 + +echo test ssl2 is forbidden in FIPS mode +$ssltest -ssl2 $extra && exit 1 + +echo test tls1 +$ssltest -tls1 $extra || exit 1 + +echo test tls1 with server authentication +$ssltest -tls1 -server_auth $CA $extra || exit 1 + +echo test tls1 with client authentication +$ssltest -tls1 -client_auth $CA $extra || exit 1 + +echo test tls1 with both client and server authentication +$ssltest -tls1 -server_auth -client_auth $CA $extra || exit 1 + +echo test tls1 via BIO pair +$ssltest -bio_pair -tls1 $extra || exit 1 + +echo test tls1 with server authentication via BIO pair +$ssltest -bio_pair -tls1 -server_auth $CA $extra || exit 1 + +echo test tls1 with client authentication via BIO pair +$ssltest -bio_pair -tls1 -client_auth $CA $extra || exit 1 + +echo test tls1 with both client and server authentication via BIO pair +$ssltest -bio_pair -tls1 -server_auth -client_auth $CA $extra || exit 1 + +# note that all the below actually choose TLS... + +if [ $dsa_cert = NO ]; then + echo test sslv2/sslv3 w/o DHE via BIO pair + $ssltest -bio_pair -no_dhe $extra || exit 1 +fi + +echo test sslv2/sslv3 with 1024bit DHE via BIO pair +$ssltest -bio_pair -dhe1024dsa -v $extra || exit 1 + +echo test sslv2/sslv3 with server authentication +$ssltest -bio_pair -server_auth $CA $extra || exit 1 + +echo test sslv2/sslv3 with client authentication via BIO pair +$ssltest -bio_pair -client_auth $CA $extra || exit 1 + +echo test sslv2/sslv3 with both client and server authentication via BIO pair +$ssltest -bio_pair -server_auth -client_auth $CA $extra || exit 1 + +echo test sslv2/sslv3 with both client and server authentication via BIO pair and app verify +$ssltest -bio_pair -server_auth -client_auth -app_verify $CA $extra || exit 1 + +############################################################################# + +if ../apps/openssl no-dh; then + echo skipping anonymous DH tests +else + echo test tls1 with 1024bit anonymous DH, multiple handshakes + $ssltest -v -bio_pair -tls1 -cipher ADH -dhe1024dsa -num 10 -f -time $extra || exit 1 +fi + +if ../apps/openssl no-rsa; then + echo skipping RSA tests +else + echo test tls1 with 1024bit RSA, no DHE, multiple handshakes + ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -no_dhe -num 10 -f -time $extra || exit 1 + + if ../apps/openssl no-dh; then + echo skipping RSA+DHE tests + else + echo test tls1 with 1024bit RSA, 1024bit DHE, multiple handshakes + ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -dhe1024dsa -num 10 -f -time $extra || exit 1 + fi +fi + +exit 0 diff --git a/tools/Makefile.ssl b/tools/Makefile similarity index 86% rename from tools/Makefile.ssl rename to tools/Makefile index cb33d4a41e..52a7970455 100644 --- a/tools/Makefile.ssl +++ b/tools/Makefile @@ -10,14 +10,12 @@ CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl MAKEDEPPROG= makedepend MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl +MAKEFILE= Makefile CFLAGS= $(INCLUDES) $(CFLAG) -GENERAL=Makefile.ssl TEST= APPS= c_rehash MISC_APPS= c_hash c_info c_issuer c_name @@ -39,10 +37,9 @@ install: done; files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile lint: diff --git a/util/cygwin.sh b/util/cygwin.sh index 930f766b4f..f93b2a0db6 100755 --- a/util/cygwin.sh +++ b/util/cygwin.sh @@ -21,11 +21,11 @@ function cleanup() function get_openssl_version() { - eval `grep '^VERSION=' Makefile.ssl` + eval `grep '^VERSION=' Makefile` if [ -z "${VERSION}" ] then - echo "Error: Couldn't retrieve OpenSSL version from Makefile.ssl." - echo " Check value of variable VERSION in Makefile.ssl." + echo "Error: Couldn't retrieve OpenSSL version from Makefile." + echo " Check value of variable VERSION in Makefile." exit 1 fi } diff --git a/util/domd b/util/domd index 49310bbdd1..5610521f0b 100755 --- a/util/domd +++ b/util/domd @@ -11,7 +11,7 @@ if [ "$1" = "-MD" ]; then fi if [ "$MAKEDEPEND" = "" ]; then MAKEDEPEND=makedepend; fi -cp Makefile.ssl Makefile.save +cp Makefile Makefile.save # fake the presence of Kerberos touch $TOP/krb5.h if [ "$MAKEDEPEND" = "gcc" ]; then @@ -20,15 +20,15 @@ if [ "$MAKEDEPEND" = "gcc" ]; then if [ "$1" != "--" ]; then args="$args $1"; fi shift done - sed -e '/^# DO NOT DELETE.*/,$d' < Makefile.ssl > Makefile.tmp + sed -e '/^# DO NOT DELETE.*/,$d' < Makefile > Makefile.tmp echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' >> Makefile.tmp gcc -D OPENSSL_DOING_MAKEDEPEND -M $args >> Makefile.tmp ${PERL} $TOP/util/clean-depend.pl < Makefile.tmp > Makefile.new rm -f Makefile.tmp else - ${MAKEDEPEND} -D OPENSSL_DOING_MAKEDEPEND -f Makefile.ssl $@ - ${PERL} $TOP/util/clean-depend.pl < Makefile.ssl > Makefile.new + ${MAKEDEPEND} -D OPENSSL_DOING_MAKEDEPEND -f Makefile $@ + ${PERL} $TOP/util/clean-depend.pl < Makefile > Makefile.new fi -mv Makefile.new Makefile.ssl +mv Makefile.new Makefile # unfake the presence of Kerberos rm $TOP/krb5.h diff --git a/util/fixNT.sh b/util/fixNT.sh index ce4f19299b..ab9e766b86 100755 --- a/util/fixNT.sh +++ b/util/fixNT.sh @@ -3,12 +3,12 @@ # clean up the mess that NT makes of my source tree # -if [ -f makefile.ssl -a ! -f Makefile.ssl ]; then - /bin/mv makefile.ssl Makefile.ssl +if [ -f makefile -a ! -f Makefile ]; then + /bin/mv makefile Makefile fi chmod +x Configure util/* echo cleaning /bin/rm -f `find . -name '*.$$$' -print` 2>/dev/null >/dev/null echo 'removing those damn ^M' perl -pi -e 's/\015//' `find . -type 'f' -print |grep -v '.obj$' |grep -v '.der$' |grep -v '.gz'` -make -f Makefile.ssl links +make -f Makefile links diff --git a/util/libeay.num b/util/libeay.num index 203c7713e7..6a3e1d3059 100755 --- a/util/libeay.num +++ b/util/libeay.num @@ -284,20 +284,20 @@ EVP_add_alias 291 NOEXIST::FUNCTION: EVP_add_cipher 292 EXIST::FUNCTION: EVP_add_digest 293 EXIST::FUNCTION: EVP_bf_cbc 294 EXIST::FUNCTION:BF -EVP_bf_cfb 295 EXIST::FUNCTION:BF +EVP_bf_cfb 295 NOEXIST::FUNCTION: EVP_bf_ecb 296 EXIST::FUNCTION:BF EVP_bf_ofb 297 EXIST::FUNCTION:BF EVP_cleanup 298 EXIST::FUNCTION: EVP_des_cbc 299 EXIST::FUNCTION:DES -EVP_des_cfb 300 EXIST::FUNCTION:DES +EVP_des_cfb 300 NOEXIST::FUNCTION: EVP_des_ecb 301 EXIST::FUNCTION:DES EVP_des_ede 302 EXIST::FUNCTION:DES EVP_des_ede3 303 EXIST::FUNCTION:DES EVP_des_ede3_cbc 304 EXIST::FUNCTION:DES -EVP_des_ede3_cfb 305 EXIST::FUNCTION:DES +EVP_des_ede3_cfb 305 NOEXIST::FUNCTION: EVP_des_ede3_ofb 306 EXIST::FUNCTION:DES EVP_des_ede_cbc 307 EXIST::FUNCTION:DES -EVP_des_ede_cfb 308 EXIST::FUNCTION:DES +EVP_des_ede_cfb 308 NOEXIST::FUNCTION: EVP_des_ede_ofb 309 EXIST::FUNCTION:DES EVP_des_ofb 310 EXIST::FUNCTION:DES EVP_desx_cbc 311 EXIST::FUNCTION:DES @@ -308,14 +308,14 @@ EVP_get_cipherbyname 315 EXIST::FUNCTION: EVP_get_digestbyname 316 EXIST::FUNCTION: EVP_get_pw_prompt 317 EXIST::FUNCTION: EVP_idea_cbc 318 EXIST::FUNCTION:IDEA -EVP_idea_cfb 319 EXIST::FUNCTION:IDEA +EVP_idea_cfb 319 NOEXIST::FUNCTION: EVP_idea_ecb 320 EXIST::FUNCTION:IDEA EVP_idea_ofb 321 EXIST::FUNCTION:IDEA EVP_md2 322 EXIST::FUNCTION:MD2 EVP_md5 323 EXIST::FUNCTION:MD5 EVP_md_null 324 EXIST::FUNCTION: EVP_rc2_cbc 325 EXIST::FUNCTION:RC2 -EVP_rc2_cfb 326 EXIST::FUNCTION:RC2 +EVP_rc2_cfb 326 NOEXIST::FUNCTION: EVP_rc2_ecb 327 EXIST::FUNCTION:RC2 EVP_rc2_ofb 328 EXIST::FUNCTION:RC2 EVP_rc4 329 EXIST::FUNCTION:RC4 @@ -962,7 +962,7 @@ i2t_ASN1_OBJECT 979 EXIST::FUNCTION: BN_BLINDING_new 980 EXIST::FUNCTION: BN_BLINDING_free 981 EXIST::FUNCTION: EVP_cast5_cbc 983 EXIST::FUNCTION:CAST -EVP_cast5_cfb 984 EXIST::FUNCTION:CAST +EVP_cast5_cfb 984 NOEXIST::FUNCTION: EVP_cast5_ecb 985 EXIST::FUNCTION:CAST EVP_cast5_ofb 986 EXIST::FUNCTION:CAST BF_decrypt 987 EXIST::FUNCTION:BF @@ -1057,7 +1057,7 @@ EVP_CIPHER_param_to_asn1 1084 EXIST::FUNCTION: EVP_CIPHER_get_asn1_iv 1085 EXIST::FUNCTION: EVP_CIPHER_set_asn1_iv 1086 EXIST::FUNCTION: EVP_rc5_32_12_16_cbc 1087 EXIST::FUNCTION:RC5 -EVP_rc5_32_12_16_cfb 1088 EXIST::FUNCTION:RC5 +EVP_rc5_32_12_16_cfb 1088 NOEXIST::FUNCTION: EVP_rc5_32_12_16_ecb 1089 EXIST::FUNCTION:RC5 EVP_rc5_32_12_16_ofb 1090 EXIST::FUNCTION:RC5 asn1_add_error 1091 EXIST::FUNCTION: @@ -2776,10 +2776,10 @@ ENGINE_load_4758cca 3218 EXIST::FUNCTION:ENGINE _ossl_096_des_random_seed 3219 EXIST::FUNCTION:DES EVP_aes_256_ofb 3220 EXIST::FUNCTION:AES EVP_aes_192_ofb 3221 EXIST::FUNCTION:AES -EVP_aes_128_cfb 3222 EXIST::FUNCTION:AES -EVP_aes_256_cfb 3223 EXIST::FUNCTION:AES +EVP_aes_128_cfb 3222 NOEXIST::FUNCTION: +EVP_aes_256_cfb 3223 NOEXIST::FUNCTION: EVP_aes_128_ofb 3224 EXIST::FUNCTION:AES -EVP_aes_192_cfb 3225 EXIST::FUNCTION:AES +EVP_aes_192_cfb 3225 NOEXIST::FUNCTION: CONF_modules_free 3226 EXIST::FUNCTION: NCONF_default 3227 EXIST::FUNCTION: OPENSSL_no_config 3228 EXIST::FUNCTION: @@ -2803,3 +2803,47 @@ OpenSSLDie 3244 EXIST::FUNCTION: OPENSSL_cleanse 3245 EXIST::FUNCTION: ENGINE_setup_bsd_cryptodev 3246 EXIST:__FreeBSD__:FUNCTION:ENGINE ERR_release_err_state_table 3247 EXIST::FUNCTION:LHASH +EVP_cast5_cfb64 3248 EXIST::FUNCTION:CAST +EVP_aes_128_cfb8 3249 EXIST::FUNCTION:AES +EVP_aes_256_cfb128 3250 EXIST::FUNCTION:AES +EVP_des_ede3_cfb64 3251 EXIST::FUNCTION:DES +EVP_aes_128_cfb1 3252 EXIST::FUNCTION:AES +EVP_aes_192_cfb8 3253 EXIST::FUNCTION:AES +EVP_des_cfb64 3254 EXIST::FUNCTION:DES +EVP_rc2_cfb64 3255 EXIST::FUNCTION:RC2 +EVP_aes_256_cfb8 3256 EXIST::FUNCTION:AES +DES_ede3_cfb_encrypt 3257 EXIST::FUNCTION:DES +EVP_aes_128_cfb128 3258 EXIST::FUNCTION:AES +EVP_bf_cfb64 3259 EXIST::FUNCTION:BF +EVP_des_ede3_cfb8 3260 EXIST::FUNCTION:DES +AES_cfbr_encrypt_block 3261 EXIST::FUNCTION:AES +AES_cfb8_encrypt 3262 EXIST::FUNCTION:AES +EVP_des_ede_cfb64 3263 EXIST::FUNCTION:DES +EVP_aes_192_cfb128 3264 EXIST::FUNCTION:AES +EVP_aes_192_cfb1 3265 EXIST::FUNCTION:AES +EVP_des_cfb8 3266 EXIST::FUNCTION:DES +EVP_aes_256_cfb1 3267 EXIST::FUNCTION:AES +EVP_idea_cfb64 3268 EXIST::FUNCTION:IDEA +EVP_rc5_32_12_16_cfb64 3269 EXIST::FUNCTION:RC5 +EVP_des_cfb1 3270 EXIST::FUNCTION:DES +AES_cfb1_encrypt 3271 EXIST::FUNCTION:AES +EVP_des_ede3_cfb1 3272 EXIST::FUNCTION:DES +FIPS_corrupt_rsa 3273 EXIST:OPENSSL_FIPS:FUNCTION: +FIPS_selftest_des 3274 EXIST:OPENSSL_FIPS:FUNCTION: +FIPS_mode_set 3275 EXIST:OPENSSL_FIPS:FUNCTION: +FIPS_selftest_dsa 3276 EXIST:OPENSSL_FIPS:FUNCTION: +FIPS_allow_md5 3277 EXIST:OPENSSL_FIPS:FUNCTION: +FIPS_corrupt_des 3278 EXIST:OPENSSL_FIPS:FUNCTION: +FIPS_selftest_aes 3279 EXIST:OPENSSL_FIPS:FUNCTION: +FIPS_corrupt_dsa 3280 EXIST:OPENSSL_FIPS:FUNCTION: +ERR_load_FIPS_strings 3281 EXIST:OPENSSL_FIPS:FUNCTION: +FIPS_corrupt_aes 3282 EXIST:OPENSSL_FIPS:FUNCTION: +FIPS_selftest_sha1 3283 EXIST:OPENSSL_FIPS:FUNCTION: +FIPS_selftest_rsa 3284 EXIST:OPENSSL_FIPS:FUNCTION: +FIPS_corrupt_sha1 3285 EXIST:OPENSSL_FIPS:FUNCTION: +FIPS_dsa_check 3286 EXIST:OPENSSL_FIPS:FUNCTION: +FIPS_rand_seeded 3287 EXIST:OPENSSL_FIPS:FUNCTION: +FIPS_rand_seed 3288 EXIST:OPENSSL_FIPS:FUNCTION: +FIPS_set_prng_key 3289 EXIST:OPENSSL_FIPS:FUNCTION: +FIPS_test_mode 3290 EXIST:OPENSSL_FIPS:FUNCTION: +FIPS_rand_method 3291 EXIST:OPENSSL_FIPS:FUNCTION: diff --git a/util/mk1mf.pl b/util/mk1mf.pl index b4bc0457e5..ea585d8042 100755 --- a/util/mk1mf.pl +++ b/util/mk1mf.pl @@ -10,7 +10,7 @@ $OPTIONS=""; $ssl_version=""; $banner="\t\@echo Building OpenSSL"; -open(IN,") { $ssl_version=$1 if (/^VERSION=(.*)$/); $OPTIONS=$1 if (/^OPTIONS=(.*)$/); @@ -18,7 +18,7 @@ while() { } close(IN); -die "Makefile.ssl is not the toplevel Makefile!\n" if $ssl_version eq ""; +die "Makefile is not the toplevel Makefile!\n" if $ssl_version eq ""; $infile="MINFO"; @@ -222,7 +222,7 @@ $cflags.=" -DOPENSSL_NO_SHA" if $no_sha; $cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1; $cflags.=" -DOPENSSL_NO_RIPEMD" if $no_ripemd; $cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2; -$cflags.=" -DOPENSSL_NO_BF" if $no_bf; +$cflags.=" -DOPENSSL_NO_BF" if $no_bf; $cflags.=" -DOPENSSL_NO_CAST" if $no_cast; $cflags.=" -DOPENSSL_NO_DES" if $no_des; $cflags.=" -DOPENSSL_NO_RSA" if $no_rsa; @@ -236,6 +236,7 @@ $cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5; $cflags.=" -DOPENSSL_NO_EC" if $no_ec; $cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine; $cflags.=" -DOPENSSL_NO_HW" if $no_hw; +$cflags.=" -DOPENSSL_FIPS" if $fips; #$cflags.=" -DRSAref" if $rsaref ne ""; ## if ($unix) @@ -639,7 +640,7 @@ if ($platform eq "linux-elf") { print <<"EOF"; # Generate perlasm output files %.cpp: - (cd \$(\@D)/..; PERL=perl make -f Makefile.ssl asm/\$(\@F)) + (cd \$(\@D)/..; PERL=perl make -f Makefile asm/\$(\@F)) EOF } print "###################################################################\n"; @@ -921,6 +922,7 @@ sub read_options $no_aes=1; } elsif (/^rsaref$/) { } + elsif (/^fips$/) { $fips=1; } elsif (/^gcc$/) { $gcc=1; } elsif (/^debug$/) { $debug=1; } elsif (/^profile$/) { $profile=1; } diff --git a/util/mkdef.pl b/util/mkdef.pl index 01a1bfda19..443d74d448 100755 --- a/util/mkdef.pl +++ b/util/mkdef.pl @@ -79,7 +79,7 @@ my $OS2=0; my $safe_stack_def = 0; my @known_platforms = ( "__FreeBSD__", "PERL5", "NeXT", - "EXPORT_VAR_AS_FUNCTION" ); + "EXPORT_VAR_AS_FUNCTION", "OPENSSL_FIPS" ); my @known_ossl_platforms = ( "VMS", "WIN16", "WIN32", "WINNT", "OS2" ); my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF", "CAST", "MD2", "MD4", "MD5", "SHA", "SHA0", "SHA1", @@ -94,7 +94,7 @@ my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF", "FP_API", "STDIO", "SOCK", "KRB5", "ENGINE", "HW" ); my $options=""; -open(IN,") { $options=$1 if (/^OPTIONS=(.*)$/); } @@ -109,6 +109,7 @@ my $no_md2; my $no_md4; my $no_md5; my $no_sha; my $no_ripemd; my $no_mdc2; my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0; my $no_aes; my $no_krb5; my $no_ec; my $no_engine; my $no_hw; my $no_fp_api; +my $fips; foreach (@ARGV, split(/ /, $options)) { @@ -129,6 +130,7 @@ foreach (@ARGV, split(/ /, $options)) } $VMS=1 if $_ eq "VMS"; $OS2=1 if $_ eq "OS2"; + $fips=1 if $_ eq "fips"; $do_ssl=1 if $_ eq "ssleay"; if ($_ eq "ssl") { @@ -265,6 +267,7 @@ $crypto.=" crypto/ocsp/ocsp.h"; $crypto.=" crypto/ui/ui.h crypto/ui/ui_compat.h"; $crypto.=" crypto/krb5/krb5_asn.h"; $crypto.=" crypto/tmdiff.h"; +$crypto.=" fips/fips.h fips/rand/fips_rand.h"; my $symhacks="crypto/symhacks.h"; @@ -794,7 +797,7 @@ sub do_defs } close(IN); - my $algs; + my $algs = ''; my $plays; print STDERR "DEBUG: postprocessing ----------\n" if $debug; @@ -864,6 +867,7 @@ sub do_defs $platform{$s} = &reduce_platforms((defined($platform{$s})?$platform{$s}.',':"").$p); + $algorithm{$s} = '' if !defined $algorithm{$s}; $algorithm{$s} .= ','.$a; if (defined($variant{$s})) { @@ -1028,6 +1032,9 @@ sub is_valid if ($keyword eq "EXPORT_VAR_AS_FUNCTION" && ($VMSVAX || $W32 || $W16)) { return 1; } + if ($keyword eq "OPENSSL_FIPS" && $fips) { + return 1; + } return 0; } else { # algorithms @@ -1119,7 +1126,7 @@ sub print_test_file sub get_version { local *MF; my $v = '?'; - open MF, 'Makefile.ssl' or return $v; + open MF, 'Makefile' or return $v; while () { $v = $1, last if /^VERSION=(.*?)\s*$/; } diff --git a/util/mkerr.pl b/util/mkerr.pl index 1b2915c767..e3215e27a3 100644 --- a/util/mkerr.pl +++ b/util/mkerr.pl @@ -41,7 +41,8 @@ while (@ARGV) { } if($recurse) { - @source = (, , ); + @source = (, , , , + ); } else { @source = @ARGV; } diff --git a/util/mkfiles.pl b/util/mkfiles.pl index 29e1404c69..7c9d9d58e6 100755 --- a/util/mkfiles.pl +++ b/util/mkfiles.pl @@ -51,6 +51,13 @@ my @dirs = ( "crypto/ocsp", "crypto/ui", "crypto/krb5", +"fips", +"fips/aes", +"fips/des", +"fips/dsa", +"fips/rand", +"fips/rsa", +"fips/sha1", "ssl", "apps", "test", @@ -58,7 +65,7 @@ my @dirs = ( ); foreach (@dirs) { - &files_dir ($_, "Makefile.ssl"); + &files_dir ($_, "Makefile"); } exit(0); diff --git a/util/pl/BC-16.pl b/util/pl/BC-16.pl index 2033f524ca..7f4e0e7d5e 100644 --- a/util/pl/BC-16.pl +++ b/util/pl/BC-16.pl @@ -64,7 +64,7 @@ $lfile=''; $asm='bcc -c -B -Tml'; $afile='/o'; -if ($no_asm) +if ($no_asm || $fips) { $bn_asm_obj=''; $bn_asm_src=''; diff --git a/util/pl/BC-32.pl b/util/pl/BC-32.pl index e83b336190..fe9f4ca9e7 100644 --- a/util/pl/BC-32.pl +++ b/util/pl/BC-32.pl @@ -62,7 +62,7 @@ $des_enc_src=''; $bf_enc_obj=''; $bf_enc_src=''; -if (!$no_asm) +if (!$no_asm && !$fips) { $bn_mulw_obj='crypto\bn\asm\bn_win32.obj'; $bn_mulw_src='crypto\bn\asm\bn_win32.asm'; diff --git a/util/pl/Mingw32.pl b/util/pl/Mingw32.pl index 4bee638c4a..bfbcb58bf6 100644 --- a/util/pl/Mingw32.pl +++ b/util/pl/Mingw32.pl @@ -21,7 +21,7 @@ if ($debug) else { $cflags="-DL_ENDIAN -DDSO_WIN32 -fomit-frame-pointer -O3 -mcpu=i486 -Wall"; } -if ($gaswin and !$no_asm) +if ($gaswin and !$no_asm and !$fips) { $bn_asm_obj='$(OBJ_D)\bn-win32.o'; $bn_asm_src='crypto/bn/asm/bn-win32.s'; diff --git a/util/pl/OS2-EMX.pl b/util/pl/OS2-EMX.pl index ddb3524210..009417acc7 100644 --- a/util/pl/OS2-EMX.pl +++ b/util/pl/OS2-EMX.pl @@ -48,7 +48,7 @@ $des_enc_src=""; $bf_enc_obj=""; $bf_enc_src=""; -if (!$no_asm) +if (!$no_asm && !$fips) { $bn_asm_obj="crypto/bn/asm/bn-os2$obj crypto/bn/asm/co-os2$obj"; $bn_asm_src="crypto/bn/asm/bn-os2.asm crypto/bn/asm/co-os2.asm"; diff --git a/util/pl/VC-16.pl b/util/pl/VC-16.pl index 7cda5e67a9..af348fa134 100644 --- a/util/pl/VC-16.pl +++ b/util/pl/VC-16.pl @@ -61,7 +61,7 @@ if ($shlib) else { $mlflags=''; } -$app_ex_obj="setargv.obj"; +$app_ex_obj=""; $obj='.obj'; $ofile="/Fo"; @@ -90,7 +90,7 @@ $des_enc_src=''; $bf_enc_obj=''; $bf_enc_src=''; -if (!$no_asm) +if (!$no_asm && !$fips) { if ($asmbits == 32) { diff --git a/util/pl/VC-32.pl b/util/pl/VC-32.pl index 285990c589..85e3d8da50 100644 --- a/util/pl/VC-32.pl +++ b/util/pl/VC-32.pl @@ -47,7 +47,7 @@ $shlibp=($shlib)?".dll":".lib"; $lfile='/out:'; $shlib_ex_obj=""; -$app_ex_obj="setargv.obj"; +$app_ex_obj=""; if ($nasm) { $asm='nasmw -f win32'; $afile='-o '; @@ -64,7 +64,7 @@ $des_enc_src=''; $bf_enc_obj=''; $bf_enc_src=''; -if (!$no_asm) +if (!$no_asm && !$fips) { $bn_asm_obj='crypto\bn\asm\bn_win32.obj'; $bn_asm_src='crypto\bn\asm\bn_win32.asm'; diff --git a/util/pl/VC-CE.pl b/util/pl/VC-CE.pl index 1805ef9d97..062c6a4395 100644 --- a/util/pl/VC-CE.pl +++ b/util/pl/VC-CE.pl @@ -47,7 +47,7 @@ $shlibp=($shlib)?".dll":".lib"; $lfile='/out:'; $shlib_ex_obj=""; -#$app_ex_obj="setargv.obj"; +$app_ex_obj=""; $app_ex_obj=""; $bn_asm_obj=''; diff --git a/util/pl/ultrix.pl b/util/pl/ultrix.pl index ea370c71f9..d88e8b9827 100644 --- a/util/pl/ultrix.pl +++ b/util/pl/ultrix.pl @@ -17,7 +17,7 @@ else $cflags.=" -std1 -DL_ENDIAN"; -if (!$no_asm) +if (!$no_asm && !$fips) { $bn_asm_obj='$(OBJ_D)/mips1.o'; $bn_asm_src='crypto/bn/asm/mips1.s'; diff --git a/util/pod2mantest b/util/pod2mantest index 412ca8d6d8..384e683df4 100755 --- a/util/pod2mantest +++ b/util/pod2mantest @@ -1,6 +1,6 @@ #!/bin/sh -# This script is used by test/Makefile.ssl to check whether a sane 'pod2man' +# This script is used by test/Makefile to check whether a sane 'pod2man' # is installed. # ('make install' should not try to run 'pod2man' if it does not exist or if # it is a broken 'pod2man' version that is known to cause trouble. if we find diff --git a/util/selftest.pl b/util/selftest.pl index 276b81183d..e9d5aa8938 100644 --- a/util/selftest.pl +++ b/util/selftest.pl @@ -34,9 +34,9 @@ foreach $_ (split("\n",$c)) { $platform0=$1 if (/Configuring for (.*)$/); } -system "sh config" if (! -f "Makefile.ssl"); +system "sh config" if (! -f "Makefile"); -if (open(IN,") { $version=$1 if (/^VERSION=(.*)$/); $platform=$1 if (/^PLATFORM=(.*)$/); -- 2.25.1