From 5d49bf7cb0db572caf91dd38693dfeb5585c7d27 Mon Sep 17 00:00:00 2001 From: Todd A Ouska Date: Wed, 24 Aug 2011 15:54:58 -0700 Subject: [PATCH] Brian Aker commits plus some minor changes like AM_CFLAGS getting AC_SUBST and --enable-xxx #ifdef to new header layout --- .gitignore | 12 +- Makefile.am | 103 +++--- README | 16 + autogen.sh | 8 +- certs/include.am | 38 +++ {ctaocrypt/benchmark => certs}/rsa1024.der | Bin configure.ac | 227 +++++++------ ctaocrypt/benchmark/benchmark.c | 43 +-- ctaocrypt/benchmark/dh1024.der | Bin 138 -> 0 bytes ctaocrypt/benchmark/include.am | 9 +- ctaocrypt/src/aes.c | 9 +- ctaocrypt/src/arc4.c | 3 +- ctaocrypt/src/asn.c | 20 +- ctaocrypt/src/coding.c | 7 +- ctaocrypt/src/ctc_asm.c | 1 + ctaocrypt/src/ctc_misc.c | 3 +- ctaocrypt/src/cyassl_memory.c | 7 +- ctaocrypt/src/des3.c | 6 +- ctaocrypt/src/dh.c | 5 +- ctaocrypt/src/dsa.c | 9 +- ctaocrypt/src/hc128.c | 9 +- ctaocrypt/src/hmac.c | 5 +- ctaocrypt/src/include.am | 39 +++ ctaocrypt/src/integer.c | 6 +- ctaocrypt/src/logging.c | 7 +- ctaocrypt/src/md4.c | 6 +- ctaocrypt/src/md5.c | 7 +- ctaocrypt/src/pwdbased.c | 9 +- ctaocrypt/src/rabbit.c | 5 +- ctaocrypt/src/random.c | 5 +- ctaocrypt/src/ripemd.c | 4 +- ctaocrypt/src/rsa.c | 10 +- ctaocrypt/src/sha.c | 5 +- ctaocrypt/src/sha256.c | 5 +- ctaocrypt/src/sha512.c | 2 + ctaocrypt/src/tfm.c | 9 +- ctaocrypt/test/include.am | 14 +- ctaocrypt/test/test.c | 102 +++--- .../include => cyassl/ctaocrypt}/ctc_aes.h | 0 .../include => cyassl/ctaocrypt}/ctc_arc4.h | 0 .../include => cyassl/ctaocrypt}/ctc_asn.h | 0 .../ctaocrypt}/ctc_asn_public.h | 0 .../include => cyassl/ctaocrypt}/ctc_coding.h | 0 .../include => cyassl/ctaocrypt}/ctc_des3.h | 0 .../include => cyassl/ctaocrypt}/ctc_dh.h | 0 .../include => cyassl/ctaocrypt}/ctc_dsa.h | 0 .../include => cyassl/ctaocrypt}/ctc_ecc.h | 0 .../include => cyassl/ctaocrypt}/ctc_error.h | 0 .../include => cyassl/ctaocrypt}/ctc_hc128.h | 4 +- .../include => cyassl/ctaocrypt}/ctc_hmac.h | 0 .../ctaocrypt}/ctc_integer.h | 0 .../include => cyassl/ctaocrypt}/ctc_md4.h | 0 .../include => cyassl/ctaocrypt}/ctc_md5.h | 0 .../include => cyassl/ctaocrypt}/ctc_misc.h | 0 .../ctaocrypt}/ctc_pwdbased.h | 0 .../include => cyassl/ctaocrypt}/ctc_rabbit.h | 0 .../include => cyassl/ctaocrypt}/ctc_random.h | 0 .../include => cyassl/ctaocrypt}/ctc_ripemd.h | 0 .../include => cyassl/ctaocrypt}/ctc_rsa.h | 0 .../ctaocrypt}/ctc_settings.h | 6 +- .../include => cyassl/ctaocrypt}/ctc_sha.h | 3 +- .../include => cyassl/ctaocrypt}/ctc_sha256.h | 0 .../include => cyassl/ctaocrypt}/ctc_sha512.h | 0 .../include => cyassl/ctaocrypt}/ctc_tfm.h | 0 .../include => cyassl/ctaocrypt}/ctc_types.h | 6 +- .../ctaocrypt}/ctc_visibility.h | 0 .../ctaocrypt}/cyassl_logging.h | 0 .../ctaocrypt}/cyassl_memory.h | 0 cyassl/ctaocrypt/include.am | 36 +++ .../include => cyassl/ctaocrypt}/mpi_class.h | 0 .../ctaocrypt}/mpi_superclass.h | 0 {include => cyassl}/cyassl_error.h | 2 +- {include => cyassl}/cyassl_int.h | 24 +- cyassl/include.am | 15 + {include => cyassl}/openssl/asn1.h | 0 {include => cyassl}/openssl/bio.h | 0 {include => cyassl}/openssl/bn.h | 0 {include => cyassl}/openssl/conf.h | 0 {include => cyassl}/openssl/crypto.h | 0 .../openssl/cyassl_callbacks.h | 0 {include => cyassl}/openssl/cyassl_test.h | 48 ++- {include => cyassl}/openssl/des.h | 0 {include => cyassl}/openssl/dh.h | 0 {include => cyassl}/openssl/dsa.h | 0 {include => cyassl}/openssl/ec.h | 0 {include => cyassl}/openssl/ecdsa.h | 0 {include => cyassl}/openssl/engine.h | 0 {include => cyassl}/openssl/err.h | 0 {include => cyassl}/openssl/evp.h | 0 {include => cyassl}/openssl/hmac.h | 0 cyassl/openssl/include.am | 37 +++ {include => cyassl}/openssl/lhash.h | 0 {include => cyassl}/openssl/md4.h | 0 {include => cyassl}/openssl/md5.h | 0 {include => cyassl}/openssl/ocsp.h | 0 {include => cyassl}/openssl/opensslconf.h | 0 {include => cyassl}/openssl/opensslv.h | 0 {include => cyassl}/openssl/ossl_typ.h | 0 {include => cyassl}/openssl/pem.h | 0 {include => cyassl}/openssl/pkcs12.h | 0 cyassl/openssl/rand.h | 4 + {include => cyassl}/openssl/rsa.h | 0 {include => cyassl}/openssl/sha.h | 0 {include => cyassl}/openssl/ssl.h | 5 +- {include => cyassl}/openssl/stack.h | 0 {include => cyassl}/openssl/ui.h | 0 cyassl/openssl/x509.h | 3 + {include => cyassl}/openssl/x509v3.h | 0 {include => cyassl}/sniffer.h | 0 {include => cyassl}/sniffer_error.h | 0 {include => cyassl}/sniffer_error.rc | 0 cyassl/version.h.in | 35 ++ doc/include.am | 5 + examples/client/client.c | 16 +- examples/client/include.am | 11 +- examples/echoclient/echoclient.c | 9 +- examples/echoclient/include.am | 12 +- examples/echoserver/echoserver.c | 23 +- examples/echoserver/include.am | 11 +- examples/server/include.am | 9 +- examples/server/server.c | 25 +- include/openssl/rand.h | 4 - include/openssl/x509.h | 3 - examples/echoclient/input => input | 0 m4/acx_pthread.m4 | 242 -------------- m4/ax_pthread.m4 | 302 ++++++++++++++++++ m4/hexversion.m4 | 6 + m4/{pandora_visibility.m4 => visibility.m4} | 38 ++- testsuite/quit => quit | 0 src/cyassl_int.c | 12 +- src/cyassl_io.c | 3 +- src/include.am | 46 +-- src/keys.c | 8 +- src/sniffer.c | 23 +- src/ssl.c | 39 +-- src/tls.c | 9 +- sslSniffer/sslSnifferTest/include.am | 10 +- sslSniffer/sslSnifferTest/snifftest.c | 6 +- stamp-h.in | 0 support/include.am | 8 + support/libcyassl.pc.in | 10 + swig/cyassl_adds.c | 7 +- swig/include.am | 12 + testsuite/include.am | 25 +- testsuite/input | 87 ----- testsuite/testsuite.c | 28 +- 146 files changed, 1199 insertions(+), 853 deletions(-) create mode 100644 certs/include.am rename {ctaocrypt/benchmark => certs}/rsa1024.der (100%) delete mode 100644 ctaocrypt/benchmark/dh1024.der create mode 100644 ctaocrypt/src/include.am rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_aes.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_arc4.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_asn.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_asn_public.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_coding.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_des3.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_dh.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_dsa.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_ecc.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_error.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_hc128.h (97%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_hmac.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_integer.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_md4.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_md5.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_misc.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_pwdbased.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_rabbit.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_random.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_ripemd.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_rsa.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_settings.h (97%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_sha.h (96%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_sha256.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_sha512.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_tfm.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_types.h (98%) rename {ctaocrypt/include => cyassl/ctaocrypt}/ctc_visibility.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/cyassl_logging.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/cyassl_memory.h (100%) create mode 100644 cyassl/ctaocrypt/include.am rename {ctaocrypt/include => cyassl/ctaocrypt}/mpi_class.h (100%) rename {ctaocrypt/include => cyassl/ctaocrypt}/mpi_superclass.h (100%) rename {include => cyassl}/cyassl_error.h (98%) rename {include => cyassl}/cyassl_int.h (98%) create mode 100644 cyassl/include.am rename {include => cyassl}/openssl/asn1.h (100%) rename {include => cyassl}/openssl/bio.h (100%) rename {include => cyassl}/openssl/bn.h (100%) rename {include => cyassl}/openssl/conf.h (100%) rename {include => cyassl}/openssl/crypto.h (100%) rename {include => cyassl}/openssl/cyassl_callbacks.h (100%) rename {include => cyassl}/openssl/cyassl_test.h (92%) rename {include => cyassl}/openssl/des.h (100%) rename {include => cyassl}/openssl/dh.h (100%) rename {include => cyassl}/openssl/dsa.h (100%) rename {include => cyassl}/openssl/ec.h (100%) rename {include => cyassl}/openssl/ecdsa.h (100%) rename {include => cyassl}/openssl/engine.h (100%) rename {include => cyassl}/openssl/err.h (100%) rename {include => cyassl}/openssl/evp.h (100%) rename {include => cyassl}/openssl/hmac.h (100%) create mode 100644 cyassl/openssl/include.am rename {include => cyassl}/openssl/lhash.h (100%) rename {include => cyassl}/openssl/md4.h (100%) rename {include => cyassl}/openssl/md5.h (100%) rename {include => cyassl}/openssl/ocsp.h (100%) rename {include => cyassl}/openssl/opensslconf.h (100%) rename {include => cyassl}/openssl/opensslv.h (100%) rename {include => cyassl}/openssl/ossl_typ.h (100%) rename {include => cyassl}/openssl/pem.h (100%) rename {include => cyassl}/openssl/pkcs12.h (100%) create mode 100644 cyassl/openssl/rand.h rename {include => cyassl}/openssl/rsa.h (100%) rename {include => cyassl}/openssl/sha.h (100%) rename {include => cyassl}/openssl/ssl.h (99%) rename {include => cyassl}/openssl/stack.h (100%) rename {include => cyassl}/openssl/ui.h (100%) create mode 100644 cyassl/openssl/x509.h rename {include => cyassl}/openssl/x509v3.h (100%) rename {include => cyassl}/sniffer.h (100%) rename {include => cyassl}/sniffer_error.h (100%) rename {include => cyassl}/sniffer_error.rc (100%) create mode 100644 cyassl/version.h.in create mode 100644 doc/include.am delete mode 100644 include/openssl/rand.h delete mode 100644 include/openssl/x509.h rename examples/echoclient/input => input (100%) delete mode 100644 m4/acx_pthread.m4 create mode 100644 m4/ax_pthread.m4 create mode 100644 m4/hexversion.m4 rename m4/{pandora_visibility.m4 => visibility.m4} (60%) rename testsuite/quit => quit (100%) create mode 100644 stamp-h.in create mode 100644 support/include.am create mode 100644 support/libcyassl.pc.in create mode 100644 swig/include.am delete mode 100644 testsuite/input diff --git a/.gitignore b/.gitignore index 41a639a161..ab634e7b88 100644 --- a/.gitignore +++ b/.gitignore @@ -8,8 +8,7 @@ *.user config* *Debug/ -ctc_config* -stamp* +stamp-h libtool.m4 aclocal.m4 lt*.m4 @@ -21,7 +20,7 @@ missing libtool tags ctaocrypt/benchmark/benchmark -ctaocrypt/test +ctaocrypt/test/testctaocrypt examples/client/client examples/echoclient/echoclient examples/echoserver/echoserver @@ -43,3 +42,10 @@ NTRU_algorithm/ build-test/ build/ cyassl.xcodeproj/ +cyassl*rc* +autoscan.log +TAGS +support/libcyassl.pc +cyassl/version.h +cyassl/ctaocrypt/stamp-h1 +stamp-h1 diff --git a/Makefile.am b/Makefile.am index 582c462cb9..13054b598f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,13 +1,51 @@ -EXTRA_DIST = certs/*.pem certs/*.der certs/*.txt certs/*.raw \ - lib/dummy *.sln *.vcproj cyassl-iphone.xcodeproj/project.pbxproj \ - doc/*.txt swig/README swig/*.i swig/cyassl_adds.c swig/*.sh swig/runme.* \ - swig/python_cyassl.vcproj swig/rsasign.py +# includes append to these: +SUFFIXES = +TESTS = +CLEANFILES = +DISTCLEANFILES = +bin_PROGRAMS = +noinst_HEADERS = +lib_LTLIBRARIES = +man_MANS = +noinst_LTLIBRARIES = +noinst_PROGRAMS = +include_HEADERS = +nobase_include_HEADERS = +check_PROGRAMS = +EXTRA_HEADERS = +BUILT_SOURCES= +EXTRA_DIST= +doc_DATA= -ACLOCAL_AMFLAGS = -I m4 +exampledir = $(docdir)/@PACKAGE@/example +example_DATA= +EXTRA_DIST+= $(example_DATA) + +certsdir = $(sysconfdir)/ssl/certs +certs_DATA= +EXTRA_DIST+= $(certs_DATA) + +EXTRA_DIST+= $(doc_DATA) + +ACLOCAL_AMFLAGS= -I m4 --install + +EXTRA_DIST+= lib/dummy + +EXTRA_DIST+= cyassl-ntru.vcproj +EXTRA_DIST+= cyassl.vcproj +EXTRA_DIST+= cyassl-iphone.xcodeproj/project.pbxproj +EXTRA_DIST+= cyassl-ntru.sln +EXTRA_DIST+= cyassl.sln + +include cyassl/include.am +include certs/include.am +include doc/include.am +include swig/include.am include src/include.am -include ctaocrypt/test/include.am include ctaocrypt/benchmark/include.am +include ctaocrypt/src/include.am +include ctaocrypt/test/include.am include examples/client/include.am include examples/server/include.am include examples/echoclient/include.am @@ -15,44 +53,19 @@ include examples/echoserver/include.am include testsuite/include.am include sslSniffer/sslSnifferTest/include.am +TESTS += $(check_PROGRAMS) +test: check # !!!! first line of rule has to start with a hard (real) tab, not spaces -basic: - $(MAKE) src/libcyassl.la; \ - $(MAKE) testsuite/testsuite; \ - cd testsuite; \ - ./testsuite; \ - cd ../; - -egs: - $(MAKE) examples/client/client; \ - $(MAKE) examples/echoclient/echoclient;\ - $(MAKE) examples/server/server; \ - $(MAKE) examples/echoserver/echoserver; - -ctc: - $(MAKE) ctaocrypt/test/test; \ - $(MAKE) ctaocrypt/benchmark/benchmark; - -openssl-links: - cd lib; ln -s ../src/.libs/libcyassl.a libcrypto.a; \ - ln -s ../src/.libs/libcyassl.a libssl.a; \ - ln -s ../src/.libs/libcyassl.a libcyassl.a; cd ../ - -# !!! test -e with a .name like .libs then a * like *dylib fails so just -# look for the .dylib on OS X, and .so otherwise but copy all parts -install: - $(mkinstalldirs) $(DESTDIR)$(includedir)/openssl $(DESTDIR)$(libdir); \ - cp -fpR include/openssl/* $(DESTDIR)$(includedir)/openssl; \ - cp -fpR ctaocrypt/include/*.h $(DESTDIR)$(includedir); \ - rm $(DESTDIR)$(includedir)/ctc_asn.h; \ - rm $(DESTDIR)$(includedir)/ctc_coding.h; \ - rm $(DESTDIR)$(includedir)/ctc_error.h; \ - rm $(DESTDIR)$(includedir)/ctc_misc.h; \ - cp -fpR src/libcyassl.la $(DESTDIR)$(libdir); \ - if test -e src/.libs/libcyassl.a; then \ - cp -fp src/.libs/libcyassl.a $(DESTDIR)$(libdir); fi; \ - if test -e src/.libs/libcyassl.so; then \ - cp -fpR src/.libs/libcyassl.so* $(DESTDIR)$(libdir); fi; \ - if test -e src/.libs/libcyassl.dylib; then \ - cp -fpR src/.libs/libcyassl.*dylib $(DESTDIR)$(libdir); fi; + +merge-clean: + @find ./ | $(GREP) \.gcda | xargs rm -f + @find ./ | $(GREP) \.gcno | xargs rm -f + @find ./ | $(GREP) \.gz | xargs rm -f + @find ./ | $(GREP) \.orig | xargs rm -f + @find ./ | $(GREP) \.rej | xargs rm -f + @find ./ | $(GREP) \.rpm | xargs rm -f + @find ./ | $(GREP) \.THIS | xargs rm -f + @find ./ | $(GREP) \.OTHER | xargs rm -f + @find ./ | $(GREP) \.BASE | xargs rm -f + @find ./ | $(GREP) \~$$ | xargs rm -f diff --git a/README b/README index 54a4410d5b..9fe79e3724 100644 --- a/README +++ b/README @@ -1,5 +1,21 @@ *** Note, Please read *** +Note 1) +CyaSSL now needs all examples and tests to be run from the CyaSSL home +directory. This is because it finds certs and keys from ./certs/. Trying to +maintain the ability to run each program from its own directory, the testsuite +directory, the main directory (for make check/test), and for the various +different project layouts (with or without config) was becoming harder and +harder. Now to run testsuite just do: + +./testsuite/testsuite + +or + +make test (when using autoconf) + + +Note 2) CyaSSL takes a different approach to certificate verification than OpenSSL does. The default policy for the client is to verify the server, this means that if you don't load CAs to verify the server you'll get a connect error, unable to diff --git a/autogen.sh b/autogen.sh index aba826916a..09f9a6dae9 100755 --- a/autogen.sh +++ b/autogen.sh @@ -3,10 +3,4 @@ # Create configure and makefile stuff... # -set -e - -autoreconf -ivf -aclocal -I m4 -autoheader -autoconf -automake --add-missing --copy +autoreconf -ivf -Wall diff --git a/certs/include.am b/certs/include.am new file mode 100644 index 0000000000..c21a643aca --- /dev/null +++ b/certs/include.am @@ -0,0 +1,38 @@ +# vim:ft=automake +# All paths should be given relative to the root +# + +certs_DATA+= \ + certs/ca-cert.pem \ + certs/ca-key.pem \ + certs/client-cert.pem \ + certs/client-keyEnc.pem \ + certs/client-key.pem \ + certs/dsa512.pem \ + certs/dsa-cert.pem \ + certs/ecc-key.pem \ + certs/ntru-cert.pem \ + certs/server-cert.pem \ + certs/server-ecc.pem \ + certs/server-keyEnc.pem \ + certs/server-key.pem \ + certs/server-keyPkcs8Enc12.pem \ + certs/server-keyPkcs8Enc2.pem \ + certs/server-keyPkcs8Enc.pem \ + certs/server-keyPkcs8.pem + +certs_DATA+= \ + certs/ca-key.der \ + certs/client-cert.der \ + certs/client-key.der \ + certs/dh1024.der \ + certs/rsa1024.der \ + certs/dsa512.der \ + certs/ecc-key.der + +EXTRA_DIST+= ${certs_DATA} + +doc_DATA+= certs/taoCert.txt + +EXTRA_DIST+= certs/ntru-key.raw + diff --git a/ctaocrypt/benchmark/rsa1024.der b/certs/rsa1024.der similarity index 100% rename from ctaocrypt/benchmark/rsa1024.der rename to certs/rsa1024.der diff --git a/configure.ac b/configure.ac index 26f0e24a65..f3b52afce6 100644 --- a/configure.ac +++ b/configure.ac @@ -6,13 +6,23 @@ # # -AC_INIT(cyassl,2.0.0rc2,http://www.yassl.com) # !!! also change in ssl.h !!! +AC_INIT([cyassl],[2.0.0rc2],[http://www.yassl.com]) + AC_CONFIG_AUX_DIR(config) -AM_CONFIG_HEADER(ctaocrypt/include/ctc_config.h) -AC_CONFIG_MACRO_DIR([m4]) -AC_CANONICAL_SYSTEM -AM_INIT_AUTOMAKE(subdir-objects) +AC_CANONICAL_TARGET + +AM_INIT_AUTOMAKE(-Wall -Werror -Wno-portability foreign tar-ustar subdir-objects) + +AC_CANONICAL_HOST +AC_CANONICAL_BUILD + +AC_PREREQ([2.61]) + +AC_CONFIG_MACRO_DIR(m4) + +AC_CONFIG_HEADERS([config.h:config.in])dnl Keep filename to 8.3 for MS-DOS. + #shared library versioning CYASSL_LIBRARY_VERSION=2:1:0 @@ -29,31 +39,48 @@ CYASSL_LIBRARY_VERSION=2:1:0 # +- increment if interfaces have been added, removed or changed AC_SUBST(CYASSL_LIBRARY_VERSION) - -# make sure configure doesn't add to CFLAGS -CFLAGS="$CFLAGS $C_EXTRA_FLAGS" +LT_INIT([win32-dll]) +LT_LANG([C++]) +LT_LANG([C]) +gl_VISIBILITY + +m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) + +AC_CHECK_FUNCS([gethostbyname]) +AC_CHECK_FUNCS([gettimeofday]) +AC_CHECK_FUNCS([inet_ntoa]) +AC_CHECK_FUNCS([memset]) +AC_CHECK_FUNCS([socket]) +AC_CHECK_HEADERS([arpa/inet.h]) +AC_CHECK_HEADERS([fcntl.h]) +AC_CHECK_HEADERS([limits.h]) +AC_CHECK_HEADERS([netdb.h]) +AC_CHECK_HEADERS([netinet/in.h]) +AC_CHECK_HEADERS([stddef.h]) +AC_CHECK_HEADERS([sys/ioctl.h]) +AC_CHECK_HEADERS([sys/socket.h]) +AC_CHECK_HEADERS([sys/time.h]) +AC_CHECK_HEADERS(errno.h) +AC_CHECK_LIB(network,socket) +AC_CHECK_SIZEOF(long long, 8) +AC_CHECK_SIZEOF(long, 4) +AC_C_BIGENDIAN +AC_DISABLE_STATIC +AC_DISABLE_STATIC +AC_FUNC_MALLOC +AC_FUNC_MKTIME +AC_FUNC_REALLOC AC_PROG_CC -AM_PROG_CC_C_O AC_PROG_CC_C_O -AM_PROG_AS +AC_PROG_CXX AC_PROG_INSTALL -AC_LIBTOOL_WIN32_DLL -AC_DISABLE_STATIC -AC_PROG_LIBTOOL - -AC_PREFIX_DEFAULT(/usr/local/cyassl) - -AC_C_BIGENDIAN - -AC_CHECK_SIZEOF(long, 4) -AC_CHECK_SIZEOF(long long, 8) - -AC_CHECK_LIB(network,socket) -AC_CHECK_LIBM - -AC_CHECK_HEADERS(errno.h) - +LT_INIT +AC_TYPE_SIZE_T +AC_TYPE_UINT8_T +AM_PROG_AS +AM_PROG_CC_C_O +LT_LIB_M OPTIMIZE_CFLAGS="-Os -fomit-frame-pointer" OPTIMIZE_FAST_CFLAGS="-O3 -fomit-frame-pointer" @@ -70,10 +97,10 @@ AC_ARG_ENABLE(debug, if test "$ENABLED_DEBUG" = "yes" then # Full debug. Very slow in some cases - CFLAGS="$DEBUG_CFLAGS $CFLAGS" + AM_CFLAGS="$DEBUG_CFLAGS $AM_CFLAGS" else # Optimized version. No debug - CFLAGS="$CFLAGS -DNDEBUG" + AM_CFLAGS="$AM_CFLAGS -DNDEBUG" fi @@ -89,7 +116,7 @@ then # if you only want server or client you can define NO_CYASSL_SERVER or # NO_CYASSL_CLIENT but then some of the examples and testsuite won't build # note that TLS needs HMAC - CFLAGS="-DNO_TLS -DNO_HMAC -DNO_AES -DNO_DES3 -DNO_SHA256 -DNO_ERROR_STRINGS -DNO_HC128 -DNO_RABBIT -DNO_PSK -DNO_DSA -DNO_DH -DNO_PWDBASED $CFLAGS" + AM_CFLAGS="-DNO_TLS -DNO_HMAC -DNO_AES -DNO_DES3 -DNO_SHA256 -DNO_ERROR_STRINGS -DNO_RABBIT -DNO_PSK -DNO_DSA -DNO_DH -DNO_PWDBASED $AM_CFLAGS" fi @@ -101,7 +128,7 @@ AC_ARG_ENABLE(singleThreaded, ) if test "$ENABLED_SINGLETHREADED" = "yes" then - CFLAGS="-DSINGLE_THREADED $CFLAGS" + AM_CFLAGS="-DSINGLE_THREADED $AM_CFLAGS" fi @@ -113,7 +140,7 @@ AC_ARG_ENABLE(dtls, ) if test "$ENABLED_DTLS" = "yes" then - CFLAGS="-DCYASSL_DTLS $CFLAGS" + AM_CFLAGS="-DCYASSL_DTLS $AM_CFLAGS" fi @@ -125,7 +152,7 @@ AC_ARG_ENABLE(opensslExtra, ) if test "$ENABLED_OPENSSLEXTRA" = "yes" then - CFLAGS="-DOPENSSL_EXTRA $CFLAGS" + AM_CFLAGS="-DOPENSSL_EXTRA $AM_CFLAGS" fi if test "$ENABLED_OPENSSLEXTRA" = "yes" && test "$ENABLED_SMALL" = "yes" @@ -143,7 +170,7 @@ AC_ARG_ENABLE(ipv6, if test "$ENABLED_IPV6" = "yes" then - CFLAGS="$CFLAGS -DTEST_IPV6" + AM_CFLAGS="$AM_CFLAGS -DTEST_IPV6" fi @@ -154,9 +181,9 @@ AC_ARG_ENABLE(fastmath, [ ENABLED_FASTMATH=no ] ) -if test "$ENABLED_FASTMATH" = "yes" +if test "x$ENABLED_FASTMATH" = "xyes" then - CFLAGS="$CFLAGS -DUSE_FAST_MATH" + AM_CFLAGS="$AM_CFLAGS -DUSE_FAST_MATH" fi @@ -170,7 +197,7 @@ AC_ARG_ENABLE(fasthugemath, if test "$ENABLED_FASTHUGEMATH" = "yes" then ENABLED_FASTMATH="yes" - CFLAGS="$CFLAGS -DUSE_FAST_MATH" + AM_CFLAGS="$AM_CFLAGS -DUSE_FAST_MATH" fi AM_CONDITIONAL([BUILD_FASTMATH], [test "x$ENABLED_FASTMATH" = "xyes"]) @@ -185,7 +212,7 @@ AC_ARG_ENABLE(bigcache, if test "$ENABLED_BIGCACHE" = "yes" then - CFLAGS="$CFLAGS -DBIG_SESSION_CACHE" + AM_CFLAGS="$AM_CFLAGS -DBIG_SESSION_CACHE" fi @@ -198,7 +225,7 @@ AC_ARG_ENABLE(hugecache, if test "$ENABLED_HUGECACHE" = "yes" then - CFLAGS="$CFLAGS -DHUGE_SESSION_CACHE" + AM_CFLAGS="$AM_CFLAGS -DHUGE_SESSION_CACHE" fi @@ -211,7 +238,7 @@ AC_ARG_ENABLE(sniffer, if test "$ENABLED_SNIFFER" = "yes" then - CFLAGS="$CFLAGS -DCYASSL_SNIFFER -DOPENSSL_EXTRA" + AM_CFLAGS="$AM_CFLAGS -DCYASSL_SNIFFER -DOPENSSL_EXTRA" fi AM_CONDITIONAL([BUILD_SNIFFER], [test "x$ENABLED_SNIFFER" = "xyes"]) @@ -225,11 +252,11 @@ AC_ARG_ENABLE(aesni, if test "$ENABLED_AESNI" = "yes" then - CFLAGS="$CFLAGS -DCYASSL_AESNI" + AM_CFLAGS="$AM_CFLAGS -DCYASSL_AESNI" if test "$GCC" = "yes" then # GCC needs these flags, icc doesn't - CFLAGS="$CFLAGS -maes -msse4" + AM_CFLAGS="$AM_CFLAGS -maes -msse4" fi fi @@ -245,7 +272,7 @@ AC_ARG_ENABLE(ripemd, if test "$ENABLED_RIPEMD" = "yes" then - CFLAGS="$CFLAGS -DCYASSL_RIPEMD" + AM_CFLAGS="$AM_CFLAGS -DCYASSL_RIPEMD" fi AM_CONDITIONAL([BUILD_RIPEMD], [test "x$ENABLED_RIPEMD" = "xyes"]) @@ -260,7 +287,7 @@ AC_ARG_ENABLE(sha512, if test "$ENABLED_SHA512" = "yes" then - CFLAGS="$CFLAGS -DCYASSL_SHA512" + AM_CFLAGS="$AM_CFLAGS -DCYASSL_SHA512" fi AM_CONDITIONAL([BUILD_SHA512], [test "x$ENABLED_SHA512" = "xyes"]) @@ -275,7 +302,7 @@ AC_ARG_ENABLE(sessioncerts, if test "$ENABLED_SESSIONCERTS" = "yes" then - CFLAGS="$CFLAGS -DSESSION_CERTS" + AM_CFLAGS="$AM_CFLAGS -DSESSION_CERTS" fi @@ -288,7 +315,7 @@ AC_ARG_ENABLE(keygen, if test "$ENABLED_KEYGEN" = "yes" then - CFLAGS="$CFLAGS -DCYASSL_KEY_GEN" + AM_CFLAGS="$AM_CFLAGS -DCYASSL_KEY_GEN" fi @@ -301,23 +328,22 @@ AC_ARG_ENABLE(certgen, if test "$ENABLED_CERTGEN" = "yes" then - CFLAGS="$CFLAGS -DCYASSL_CERT_GEN" + AM_CFLAGS="$AM_CFLAGS -DCYASSL_CERT_GEN" fi # HC128 -AC_ARG_ENABLE(hc128, - [ --enable-hc128 Enable HC-128 (default: disabled)], - [ ENABLED_HC128=$enableval ], - [ ENABLED_HC128=no ] - ) - -if test "$ENABLED_HC128" = "no" -then - CFLAGS="$CFLAGS -DNO_HC128" -fi - -AM_CONDITIONAL([BUILD_HC128], [test "x$ENABLED_HC128" = "xyes"]) +AC_ARG_ENABLE([hc128], + [ --enable-hc128 Enable HC-128 (default: disabled)], + [case "${enableval}" in + yes) BUILD_HC128=true ;; + no) BUILD_HC128=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-hc128]) ;; + esac],[BUILD_HC128=false]) +AM_CONDITIONAL([BUILD_HC128], [test x$BUILD_HC128 = xtrue]) +AS_IF([test "x$BUILD_HC128" = "xyes"], + [ AC_DEFINE([HAVE_HC128], [1], [Have hc128])], + [ AC_DEFINE([HAVE_HC128], [0], [Have hc128])]) # PSK @@ -329,7 +355,7 @@ AC_ARG_ENABLE(psk, if test "$ENABLED_PSK" = "no" then - CFLAGS="$CFLAGS -DNO_PSK" + AM_CFLAGS="$AM_CFLAGS -DNO_PSK" fi @@ -342,7 +368,7 @@ AC_ARG_ENABLE(webServer, if test "$ENABLED_WEBSERVER" = "yes" then - CFLAGS="$CFLAGS -DHAVE_WEBSERVER" + AM_CFLAGS="$AM_CFLAGS -DHAVE_WEBSERVER" fi @@ -355,7 +381,7 @@ AC_ARG_ENABLE(noFilesystem, if test "$ENABLED_NOFILESYSTEM" = "yes" then - CFLAGS="$CFLAGS -DNO_FILESYSTEM" + AM_CFLAGS="$AM_CFLAGS -DNO_FILESYSTEM" fi @@ -383,7 +409,7 @@ AC_ARG_ENABLE(ecc, if test "$ENABLED_ECC" = "yes" then - CFLAGS="$CFLAGS -DHAVE_ECC" + AM_CFLAGS="$AM_CFLAGS -DHAVE_ECC" fi AM_CONDITIONAL([BUILD_ECC], [test "x$ENABLED_ECC" = "xyes"]) @@ -407,8 +433,8 @@ AC_ARG_ENABLE(ntru, if test "$ENABLED_NTRU" = "yes" then - CFLAGS="$CFLAGS -DHAVE_NTRU -I$ntruInclude" - LDFLAGS="$LDFLAGS -L$ntruLib" + AM_CFLAGS="$AM_CFLAGS -DHAVE_NTRU -I$ntruInclude" + AM_LDFLAGS="$AM_LDFLAGS -L$ntruLib" LIBS="$LIBS -lntru_encrypt" fi @@ -429,7 +455,7 @@ AC_ARG_ENABLE(testcert, if test "$ENABLED_TESTCERT" = "yes" then - CFLAGS="$CFLAGS -DCYASSL_TEST_CERT" + AM_CFLAGS="$AM_CFLAGS -DCYASSL_TEST_CERT" fi @@ -442,8 +468,7 @@ AC_ARG_WITH(libz, CPPFLAGS="$CPPFLAGS -DHAVE_LIBZ" LIBS="$LIBS -lz" - AC_TRY_LINK([#include ], [ deflateInit(0, 8); ], - [ libz_linked=yes ], [ libz_linked=no ]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ deflateInit(0, 8); ]])],[ libz_linked=yes ],[ libz_linked=no ]) if test "x$libz_linked" == "xno" ; then if test "x$withval" != "xno" ; then @@ -453,11 +478,10 @@ AC_ARG_WITH(libz, trylibzdir="/usr" fi - LDFLAGS="$LDFLAGS -L$trylibzdir/lib" + AM_LDFLAGS="$AM_LDFLAGS -L$trylibzdir/lib" CPPFLAGS="$CPPFLAGS -I$trylibzdir/include" - AC_TRY_LINK([#include ], [ deflateInit(0, 8); ], - [ libz_linked=yes ], [ libz_linked=no ]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ deflateInit(0, 8); ]])],[ libz_linked=yes ],[ libz_linked=no ]) if test "x$libz_linked" == "xno" ; then AC_MSG_ERROR([libz isn't found. @@ -475,56 +499,55 @@ AC_ARG_WITH(libz, # OPTIMIZE FLAGS if test "$GCC" = "yes" then - CFLAGS="$CFLAGS -Wall -Wno-unused" + AM_CFLAGS="$AM_CFLAGS -Wall -Wno-unused" if test "$ENABLED_DEBUG" = "no" then if test "$ENABLED_FASTMATH" = "yes" then - CFLAGS="$CFLAGS $OPTIMIZE_FAST_CFLAGS" + AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_FAST_CFLAGS" if test "$ENABLED_FASTHUGEMATH" = "yes" then - CFLAGS="$CFLAGS $OPTIMIZE_HUGE_CFLAGS" + AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_HUGE_CFLAGS" fi else - CFLAGS="$CFLAGS $OPTIMIZE_CFLAGS" + AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_CFLAGS" fi fi fi - - - -ACX_PTHREAD - -LIBS="$PTHREAD_LIBS $LIBM $LIBS" -CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +AX_PTHREAD([ + AC_DEFINE([HAVE_PTHREAD], [1], [Define if you have POSIX threads libraries and header files.]) + ], + [ + AC_DEFINE([HAVE_PTHREAD], [0], [Define if you have POSIX threads libraries and header files.]) + ]) LIB_SOCKET_NSL dnl Various GCC warnings that should never fire for release quality code GCCWARNINGS="-Wall -fno-strict-aliasing -W -Wfloat-equal -Wundef \ --Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \ --Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment \ --Wformat=2 -Wwrite-strings -Wmissing-declarations -Wredundant-decls \ --Wnested-externs -Wbad-function-cast -Wswitch-enum -Winit-self \ --Wmissing-field-initializers -Wdeclaration-after-statement \ --Wold-style-definition -Waddress -Wmissing-noreturn -Wnormalized=id \ --Woverride-init -Wstrict-overflow=1 -Wextra -Warray-bounds \ --Wstack-protector -Wformat -Wformat-security -Wpointer-sign -Wshadow \ --Wswitch-default" + -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \ + -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment \ + -Wformat=2 -Wwrite-strings -Wmissing-declarations -Wredundant-decls \ + -Wnested-externs -Wbad-function-cast -Wswitch-enum -Winit-self \ + -Wmissing-field-initializers -Wdeclaration-after-statement \ + -Wold-style-definition -Waddress -Wmissing-noreturn -Wnormalized=id \ + -Woverride-init -Wstrict-overflow=1 -Wextra -Warray-bounds \ + -Wstack-protector -Wformat -Wformat-security -Wpointer-sign -Wshadow \ + -Wswitch-default" AC_ARG_ENABLE(gcc-lots-o-warnings, AS_HELP_STRING(--enable-gcc-lots-o-warnings, Enable lots of gcc warnings (default: disabled)), [if test x$enableval = xyes; then - CFLAGS="$CFLAGS $GCCWARNINGS" + AM_CFLAGS="$AM_CFLAGS $GCCWARNINGS" fi]) AC_ARG_ENABLE(gcc-hardening, AS_HELP_STRING(--enable-gcc-hardening, Enable compiler security checks (default: disabled)), [if test x$enableval = xyes; then - CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector-all" - CFLAGS="$CFLAGS -fwrapv -fPIE -Wstack-protector" - CFLAGS="$CFLAGS --param ssp-buffer-size=1" + AM_CFLAGS="$AM_CFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector-all" + AM_CFLAGS="$AM_CFLAGS -fwrapv -fPIE -Wstack-protector" + AM_CFLAGS="$AM_CFLAGS --param ssp-buffer-size=1" LDFLAGS="$LDFLAGS -pie" fi]) @@ -536,16 +559,16 @@ AS_HELP_STRING(--enable-linker-hardening, Enable linker security fixups (default LDFLAGS="$LDFLAGS -z relro -z now" fi]) - -PANDORA_VISIBILITY -CFLAGS="$CFLAGS $CFLAG_VISIBILITY" - -AC_SUBST(CFLAGS) -AC_SUBST(LIBS) - - +CREATE_HEX_VERSION +AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY" +AC_SUBST(AM_CFLAGS) +AC_SUBST(AM_LDFLAGS) # FINAL +AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([cyassl/version.h]) +AC_CONFIG_FILES([support/libcyassl.pc]) + AC_OUTPUT diff --git a/ctaocrypt/benchmark/benchmark.c b/ctaocrypt/benchmark/benchmark.c index d98c4fce2f..61c066d616 100644 --- a/ctaocrypt/benchmark/benchmark.c +++ b/ctaocrypt/benchmark/benchmark.c @@ -21,24 +21,25 @@ /* CTaoCrypt benchmark */ +#include #include #include -#include "ctc_des3.h" -#include "ctc_arc4.h" -#include "ctc_hc128.h" -#include "ctc_rabbit.h" -#include "ctc_aes.h" -#include "ctc_md5.h" -#include "ctc_sha.h" -#include "ctc_sha256.h" -#include "ctc_sha512.h" -#include "ctc_rsa.h" -#include "ctc_asn.h" -#include "ctc_ripemd.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "ctc_dh.h" +#include #ifdef _MSC_VER @@ -73,7 +74,7 @@ int main(int argc, char** argv) bench_aes(1); #endif bench_arc4(); -#ifndef NO_HC128 +#if HAVE_HC128 bench_hc128(); #endif #ifndef NO_RABBIT @@ -202,7 +203,7 @@ void bench_arc4() } -#ifndef NO_HC128 +#if HAVE_HC128 void bench_hc128() { HC128 enc; @@ -221,7 +222,7 @@ void bench_hc128() printf("HC128 %d megs took %5.3f seconds, %6.2f MB/s\n", megs, total, persec); } -#endif /* NO_HC128 */ +#endif /* HAVE_HC128 */ #ifndef NO_RABBIT @@ -381,10 +382,11 @@ void bench_rsa() double start, total, each, milliEach; RsaKey key; - FILE* file = fopen("./rsa1024.der", "rb"); + FILE* file = fopen("./certs/rsa1024.der", "rb"); if (!file) { - printf("can't find ./rsa1024.der\n"); + printf("can't find ./certs/rsa1024.der, " + "Please run from CyaSSL home dir\n"); return; } @@ -438,10 +440,11 @@ void bench_dh() double start, total, each, milliEach; DhKey key; - FILE* file = fopen("./dh1024.der", "rb"); + FILE* file = fopen("./certs/dh1024.der", "rb"); if (!file) { - printf("can't find ./dh1024.der\n"); + printf("can't find ./certs/dh1024.der, " + "Please run from CyaSSL home dir\n"); return; } diff --git a/ctaocrypt/benchmark/dh1024.der b/ctaocrypt/benchmark/dh1024.der deleted file mode 100644 index 09f81ee14c1433f2976ecbd6f005f08bab148fc9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 138 zcmV;50CoQ`frkQtfdJzSP$YVrg24|O8KaTE_~w4Yl;};FUoGsR9lw0C(6T;r s7lz80Qg_hFWcwke)}*PMa1+xurq+{@w?<}rUFSuFc-iKdchdp^0(h}S$^ZZW diff --git a/ctaocrypt/benchmark/include.am b/ctaocrypt/benchmark/include.am index df03f6e644..8d4895bcb5 100644 --- a/ctaocrypt/benchmark/include.am +++ b/ctaocrypt/benchmark/include.am @@ -1,12 +1,9 @@ # vim:ft=automake -# included from Top Level Makefile.am # All paths should be given relative to the root - -bin_PROGRAMS += ctaocrypt/benchmark/benchmark +noinst_PROGRAMS += ctaocrypt/benchmark/benchmark ctaocrypt_benchmark_benchmark_SOURCES = ctaocrypt/benchmark/benchmark.c -ctaocrypt_benchmark_benchmark_LDFLAGS = -Lsrc ctaocrypt_benchmark_benchmark_LDADD = src/libcyassl.la ctaocrypt_benchmark_benchmark_DEPENDENCIES = src/libcyassl.la -EXTRA_DIST += ctaocrypt/benchmark/*.der \ - ctaocrypt/benchmark/benchmark.sln ctaocrypt/benchmark/benchmark.vcproj +EXTRA_DIST += ctaocrypt/benchmark/benchmark.sln +EXTRA_DIST += ctaocrypt/benchmark/benchmark.vcproj diff --git a/ctaocrypt/src/aes.c b/ctaocrypt/src/aes.c index 4c15706add..bb533b537d 100644 --- a/ctaocrypt/src/aes.c +++ b/ctaocrypt/src/aes.c @@ -19,14 +19,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include #ifndef NO_AES -#include "ctc_aes.h" -#include "ctc_error.h" -#include "cyassl_logging.h" +#include +#include +#include #ifdef NO_INLINE - #include "ctc_misc.h" + #include #else #include "ctc_misc.c" #endif diff --git a/ctaocrypt/src/arc4.c b/ctaocrypt/src/arc4.c index cc31de275c..0924579bf0 100644 --- a/ctaocrypt/src/arc4.c +++ b/ctaocrypt/src/arc4.c @@ -19,8 +19,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include -#include "ctc_arc4.h" +#include void Arc4SetKey(Arc4* arc4, const byte* key, word32 length) diff --git a/ctaocrypt/src/asn.c b/ctaocrypt/src/asn.c index db045270b7..75782ed812 100644 --- a/ctaocrypt/src/asn.c +++ b/ctaocrypt/src/asn.c @@ -19,20 +19,22 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include #ifdef THREADX #include "os.h" /* dc_rtc_api needs */ #include "dc_rtc_api.h" /* to get current time */ #endif -#include "ctc_asn.h" -#include "ctc_coding.h" -#include "ctc_sha.h" -#include "ctc_md5.h" -#include "ctc_error.h" -#include "ctc_pwdbased.h" -#include "ctc_des3.h" -#include "ctc_sha256.h" -#include "cyassl_logging.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef HAVE_NTRU #include "crypto_ntru.h" diff --git a/ctaocrypt/src/coding.c b/ctaocrypt/src/coding.c index 38dc3be8f3..38854cfa94 100644 --- a/ctaocrypt/src/coding.c +++ b/ctaocrypt/src/coding.c @@ -19,10 +19,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include -#include "ctc_coding.h" -#include "ctc_error.h" -#include "cyassl_logging.h" +#include +#include +#include enum { diff --git a/ctaocrypt/src/ctc_asm.c b/ctaocrypt/src/ctc_asm.c index c45ee3142c..8e06cfb90d 100644 --- a/ctaocrypt/src/ctc_asm.c +++ b/ctaocrypt/src/ctc_asm.c @@ -19,6 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include /* * Based on public domain TomsFastMath 0.10 by Tom St Denis, tomstdenis@iahu.ca, diff --git a/ctaocrypt/src/ctc_misc.c b/ctaocrypt/src/ctc_misc.c index f726143d50..0c3bd6c329 100644 --- a/ctaocrypt/src/ctc_misc.c +++ b/ctaocrypt/src/ctc_misc.c @@ -19,8 +19,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include -#include "ctc_misc.h" +#include /* inlining these functions is a huge speed increase and a small size decrease, because the functions are smaller than function call setup/cleanup, e.g., diff --git a/ctaocrypt/src/cyassl_memory.c b/ctaocrypt/src/cyassl_memory.c index 8684bfa672..260ef172e1 100644 --- a/ctaocrypt/src/cyassl_memory.c +++ b/ctaocrypt/src/cyassl_memory.c @@ -19,16 +19,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include /* submitted by eof */ -#include "ctc_settings.h" +#include #ifdef USE_CYASSL_MEMORY -#include "cyassl_memory.h" -#include "ctc_error.h" +#include +#include /* Set these to default values initially. */ diff --git a/ctaocrypt/src/des3.c b/ctaocrypt/src/des3.c index a7ef3c7873..10011e8530 100644 --- a/ctaocrypt/src/des3.c +++ b/ctaocrypt/src/des3.c @@ -19,12 +19,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include #ifndef NO_DES3 -#include "ctc_des3.h" +#include + #ifdef NO_INLINE - #include "ctc_misc.h" + #include #else #include "ctc_misc.c" #endif diff --git a/ctaocrypt/src/dh.c b/ctaocrypt/src/dh.c index 522b7e3c71..31e6f446a9 100644 --- a/ctaocrypt/src/dh.c +++ b/ctaocrypt/src/dh.c @@ -19,11 +19,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include #ifndef NO_DH -#include "ctc_dh.h" -#include "ctc_error.h" +#include +#include #ifndef USER_MATH_LIB #include diff --git a/ctaocrypt/src/dsa.c b/ctaocrypt/src/dsa.c index e13eea8e06..06aab4cd17 100644 --- a/ctaocrypt/src/dsa.c +++ b/ctaocrypt/src/dsa.c @@ -19,13 +19,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include #ifndef NO_DSA -#include "ctc_dsa.h" -#include "ctc_sha.h" -#include "ctc_random.h" -#include "ctc_error.h" +#include +#include +#include +#include enum { diff --git a/ctaocrypt/src/hc128.c b/ctaocrypt/src/hc128.c index 97c924f7cf..bd1172808b 100644 --- a/ctaocrypt/src/hc128.c +++ b/ctaocrypt/src/hc128.c @@ -19,14 +19,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include -#ifndef NO_HC128 +#if HAVE_HC128 -#include "ctc_hc128.h" +#include #ifdef NO_INLINE - #include "ctc_misc.h" + #include #else - #include "ctc_misc.c" + #include "ctaocrypt/src/ctc_misc.c" #endif diff --git a/ctaocrypt/src/hmac.c b/ctaocrypt/src/hmac.c index da1581523e..ae1fc32d22 100644 --- a/ctaocrypt/src/hmac.c +++ b/ctaocrypt/src/hmac.c @@ -19,11 +19,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include #ifndef NO_HMAC -#include "ctc_hmac.h" -#include "ctc_error.h" +#include +#include static int InitHmac(Hmac* hmac, int type) diff --git a/ctaocrypt/src/include.am b/ctaocrypt/src/include.am new file mode 100644 index 0000000000..e274ddb701 --- /dev/null +++ b/ctaocrypt/src/include.am @@ -0,0 +1,39 @@ +# vim:ft=automake +# All paths should be given relative to the root + +EXTRA_DIST += ctaocrypt/src/ctc_misc.c +EXTRA_DIST += ctaocrypt/src/ctc_asm.c + +EXTRA_DIST += \ + ctaocrypt/src/ecc_fp.c \ + ctaocrypt/src/fp_mont_small.i \ + ctaocrypt/src/fp_mul_comba_12.i \ + ctaocrypt/src/fp_mul_comba_17.i \ + ctaocrypt/src/fp_mul_comba_20.i \ + ctaocrypt/src/fp_mul_comba_24.i \ + ctaocrypt/src/fp_mul_comba_28.i \ + ctaocrypt/src/fp_mul_comba_32.i \ + ctaocrypt/src/fp_mul_comba_3.i \ + ctaocrypt/src/fp_mul_comba_48.i \ + ctaocrypt/src/fp_mul_comba_4.i \ + ctaocrypt/src/fp_mul_comba_64.i \ + ctaocrypt/src/fp_mul_comba_6.i \ + ctaocrypt/src/fp_mul_comba_7.i \ + ctaocrypt/src/fp_mul_comba_8.i \ + ctaocrypt/src/fp_mul_comba_9.i \ + ctaocrypt/src/fp_mul_comba_small_set.i \ + ctaocrypt/src/fp_sqr_comba_12.i \ + ctaocrypt/src/fp_sqr_comba_17.i \ + ctaocrypt/src/fp_sqr_comba_20.i \ + ctaocrypt/src/fp_sqr_comba_24.i \ + ctaocrypt/src/fp_sqr_comba_28.i \ + ctaocrypt/src/fp_sqr_comba_32.i \ + ctaocrypt/src/fp_sqr_comba_3.i \ + ctaocrypt/src/fp_sqr_comba_48.i \ + ctaocrypt/src/fp_sqr_comba_4.i \ + ctaocrypt/src/fp_sqr_comba_64.i \ + ctaocrypt/src/fp_sqr_comba_6.i \ + ctaocrypt/src/fp_sqr_comba_7.i \ + ctaocrypt/src/fp_sqr_comba_8.i \ + ctaocrypt/src/fp_sqr_comba_9.i \ + ctaocrypt/src/fp_sqr_comba_small_set.i diff --git a/ctaocrypt/src/integer.c b/ctaocrypt/src/integer.c index 10275475de..a9381a0509 100644 --- a/ctaocrypt/src/integer.c +++ b/ctaocrypt/src/integer.c @@ -26,11 +26,13 @@ */ -#include "ctc_settings.h" /* in case user set USE_FAST_MATH there */ +#include +/* in case user set USE_FAST_MATH there */ +#include #ifndef USE_FAST_MATH -#include "ctc_integer.h" +#include /* handle up to 6 inits */ diff --git a/ctaocrypt/src/logging.c b/ctaocrypt/src/logging.c index c48105c4a5..05ce6e1da7 100644 --- a/ctaocrypt/src/logging.c +++ b/ctaocrypt/src/logging.c @@ -19,12 +19,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include /* submitted by eof */ -#include "ctc_settings.h" -#include "cyassl_logging.h" -#include "ctc_error.h" +#include +#include +#include CYASSL_API int CyaSSL_Debugging_ON(void); diff --git a/ctaocrypt/src/md4.c b/ctaocrypt/src/md4.c index 69bc957156..46e1e97098 100644 --- a/ctaocrypt/src/md4.c +++ b/ctaocrypt/src/md4.c @@ -19,12 +19,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include + #ifndef NO_MD4 -#include "ctc_md4.h" +#include #ifdef NO_INLINE - #include "ctc_misc.h" + #include #else #include "ctc_misc.c" #endif diff --git a/ctaocrypt/src/md5.c b/ctaocrypt/src/md5.c index 73d2980729..3642050d27 100644 --- a/ctaocrypt/src/md5.c +++ b/ctaocrypt/src/md5.c @@ -20,9 +20,12 @@ */ -#include "ctc_md5.h" +#include + +#include + #ifdef NO_INLINE - #include "ctc_misc.h" + #include #else #include "ctc_misc.c" #endif diff --git a/ctaocrypt/src/pwdbased.c b/ctaocrypt/src/pwdbased.c index af9cf52081..4d94eb8913 100644 --- a/ctaocrypt/src/pwdbased.c +++ b/ctaocrypt/src/pwdbased.c @@ -19,13 +19,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include #ifndef NO_PWDBASED -#include "ctc_pwdbased.h" -#include "ctc_hmac.h" -#include "ctc_integer.h" -#include "ctc_error.h" +#include +#include +#include +#include #ifdef CYASSL_SHA512 #include "ctc_sha512.h" #endif diff --git a/ctaocrypt/src/rabbit.c b/ctaocrypt/src/rabbit.c index 2d85136d30..ddfbdb5c57 100644 --- a/ctaocrypt/src/rabbit.c +++ b/ctaocrypt/src/rabbit.c @@ -19,12 +19,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include #ifndef NO_RABBIT -#include "ctc_rabbit.h" +#include #ifdef NO_INLINE - #include "ctc_misc.h" + #include #else #include "ctc_misc.c" #endif diff --git a/ctaocrypt/src/random.c b/ctaocrypt/src/random.c index a76333eefd..393d5c4616 100644 --- a/ctaocrypt/src/random.c +++ b/ctaocrypt/src/random.c @@ -19,14 +19,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include /* on HPUX 11 you may need to install /dev/random see http://h20293.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=KRNG11I */ -#include "ctc_random.h" -#include "ctc_error.h" +#include +#include #if defined(USE_WINDOWS_API) diff --git a/ctaocrypt/src/ripemd.c b/ctaocrypt/src/ripemd.c index 2f73805013..fdfaf19d9d 100644 --- a/ctaocrypt/src/ripemd.c +++ b/ctaocrypt/src/ripemd.c @@ -20,11 +20,13 @@ */ +#include + #ifdef CYASSL_RIPEMD #include "ctc_ripemd.h" #ifdef NO_INLINE - #include "ctc_misc.h" + #include #else #include "ctc_misc.c" #endif diff --git a/ctaocrypt/src/rsa.c b/ctaocrypt/src/rsa.c index cfc95a81dd..37b970bfbe 100644 --- a/ctaocrypt/src/rsa.c +++ b/ctaocrypt/src/rsa.c @@ -20,10 +20,12 @@ */ -#include "ctc_rsa.h" -#include "ctc_random.h" -#include "ctc_error.h" -#include "cyassl_logging.h" +#include + +#include +#include +#include +#include #ifdef SHOW_GEN #include diff --git a/ctaocrypt/src/sha.c b/ctaocrypt/src/sha.c index 9f70652dbd..993eb45b85 100644 --- a/ctaocrypt/src/sha.c +++ b/ctaocrypt/src/sha.c @@ -19,10 +19,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include -#include "ctc_sha.h" +#include #ifdef NO_INLINE - #include "ctc_misc.h" + #include #else #include "ctc_misc.c" #endif diff --git a/ctaocrypt/src/sha256.c b/ctaocrypt/src/sha256.c index 65ab591ff9..69ec0f044e 100644 --- a/ctaocrypt/src/sha256.c +++ b/ctaocrypt/src/sha256.c @@ -22,12 +22,13 @@ /* code submitted by raphael.huck@efixo.com */ +#include #ifndef NO_SHA256 -#include "ctc_sha256.h" +#include #ifdef NO_INLINE - #include "ctc_misc.h" + #include #else #include "ctc_misc.c" #endif diff --git a/ctaocrypt/src/sha512.c b/ctaocrypt/src/sha512.c index 5986fc1ff0..8f95592a42 100644 --- a/ctaocrypt/src/sha512.c +++ b/ctaocrypt/src/sha512.c @@ -19,6 +19,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include + #ifdef CYASSL_SHA512 diff --git a/ctaocrypt/src/tfm.c b/ctaocrypt/src/tfm.c index ffc3a55df1..321a4e64b7 100644 --- a/ctaocrypt/src/tfm.c +++ b/ctaocrypt/src/tfm.c @@ -30,12 +30,15 @@ * to fit CyaSSL's needs. */ -#include "ctc_settings.h" /* in case user set USE_FAST_MATH there */ +#include + +/* in case user set USE_FAST_MATH there */ +#include #ifdef USE_FAST_MATH -#include "ctc_tfm.h" -#include "ctc_asm.c" /* will define asm MACROS or C ones */ +#include +#include /* will define asm MACROS or C ones */ diff --git a/ctaocrypt/test/include.am b/ctaocrypt/test/include.am index e42f111d7d..9c876c939f 100644 --- a/ctaocrypt/test/include.am +++ b/ctaocrypt/test/include.am @@ -1,11 +1,9 @@ # vim:ft=automake -# included from Top Level Makefile.am # All paths should be given relative to the root - -bin_PROGRAMS = ctaocrypt/test/test -ctaocrypt_test_test_SOURCES = ctaocrypt/test/test.c -ctaocrypt_test_test_LDFLAGS = -Lsrc -ctaocrypt_test_test_LDADD = src/libcyassl.la -ctaocrypt_test_test_DEPENDENCIES = src/libcyassl.la -EXTRA_DIST += ctaocrypt/test/test.sln ctaocrypt/test/test.vcproj +noinst_PROGRAMS+= ctaocrypt/test/testctaocrypt +ctaocrypt_test_testctaocrypt_SOURCES = ctaocrypt/test/test.c +ctaocrypt_test_testctaocrypt_LDADD = src/libcyassl.la +ctaocrypt_test_testctaocrypt_DEPENDENCIES = src/libcyassl.la +EXTRA_DIST += ctaocrypt/test/test.sln +EXTRA_DIST += ctaocrypt/test/test.vcproj diff --git a/ctaocrypt/test/test.c b/ctaocrypt/test/test.c index eea1dbff1e..4177bb0a91 100644 --- a/ctaocrypt/test/test.c +++ b/ctaocrypt/test/test.c @@ -19,36 +19,37 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include #include #include #include #ifdef CYASSL_TEST_CERT - #include "ctc_asn.h" + #include #else - #include "ctc_asn_public.h" + #include #endif -#include "ctc_md5.h" -#include "ctc_md4.h" -#include "ctc_sha.h" -#include "ctc_sha256.h" -#include "ctc_sha512.h" -#include "ctc_arc4.h" -#include "ctc_random.h" -#include "ctc_coding.h" -#include "ctc_rsa.h" -#include "ctc_des3.h" -#include "ctc_aes.h" -#include "ctc_hmac.h" -#include "ctc_dh.h" -#include "ctc_dsa.h" -#include "ctc_hc128.h" -#include "ctc_rabbit.h" -#include "ctc_pwdbased.h" -#include "ctc_ripemd.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef HAVE_ECC - #include "ctc_ecc.h" + #include #endif #ifdef _MSC_VER @@ -57,10 +58,10 @@ #endif #ifdef OPENSSL_EXTRA - #include "evp.h" - #include "rand.h" - #include "hmac.h" - #include "des.h" + #include + #include + #include + #include #endif #ifdef HAVE_NTRU @@ -181,12 +182,17 @@ void ctaocrypt_test(void* args) else printf( "ARC4 test passed!\n"); -#ifndef NO_HC128 - if ( (ret = hc128_test()) ) + if (HAVE_HC128) + { + if ( (ret = hc128_test()) ) err_sys("HC-128 test failed!\n", ret); - else + else printf( "HC-128 test passed!\n"); -#endif + } + else + { + printf( "HC-128 test skipped!\n"); + } #ifndef NO_RABBIT if ( (ret = rabbit_test()) ) @@ -744,9 +750,9 @@ int arc4_test() } -#ifndef NO_HC128 int hc128_test() { +#if defined(HAVE_HC128) && HAVE_HC128 byte cipher[16]; byte plain[16]; @@ -815,9 +821,9 @@ int hc128_test() return -120 - 5 - i; } +#endif /* HAVE_HC128 */ return 0; } -#endif /* NO_HC128 */ #ifndef NO_RABBIT @@ -1044,20 +1050,11 @@ int random_test() } -#ifndef NO_MAIN_DRIVER - static const char* clientKey = "../../certs/client-key.der"; - static const char* clientCert = "../../certs/client-cert.der"; - #ifdef CYASSL_CERT_GEN - static const char* caKeyFile = "../../certs/ca-key.der"; - static const char* caCertFile = "../../certs/ca-cert.pem"; - #endif -#else - static const char* clientKey = "../certs/client-key.der"; - static const char* clientCert = "../certs/client-cert.der"; - #ifdef CYASSL_CERT_GEN - static const char* caKeyFile = "../certs/ca-key.der"; - static const char* caCertFile = "../certs/ca-cert.pem"; - #endif +static const char* clientKey = "./certs/client-key.der"; +static const char* clientCert = "./certs/client-cert.der"; +#ifdef CYASSL_CERT_GEN + static const char* caKeyFile = "./certs/ca-key.der"; + static const char* caCertFile = "./certs/ca-cert.pem"; #endif @@ -1112,7 +1109,8 @@ int rsa_test() FILE* file = fopen(clientKey, "rb"), * file2; if (!file) - return -40; + err_sys("can't open ./certs/client-key.der, " + "Please run from CyaSSL home dir", -40); bytes = fread(tmp, 1, sizeof(tmp), file); @@ -1447,11 +1445,7 @@ int rsa_test() } -#ifndef NO_MAIN_DRIVER - static const char* dhKey = "../../certs/dh1024.der"; -#else - static const char* dhKey = "../certs/dh1024.der"; -#endif +static const char* dhKey = "./certs/dh1024.der"; #ifndef NO_DH @@ -1515,11 +1509,7 @@ int dh_test() #endif /* NO_DH */ -#ifndef NO_MAIN_DRIVER - static const char* dsaKey = "../../certs/dsa512.der"; -#else - static const char* dsaKey = "../certs/dsa512.der"; -#endif +static const char* dsaKey = "./certs/dsa512.der"; #ifndef NO_DSA diff --git a/ctaocrypt/include/ctc_aes.h b/cyassl/ctaocrypt/ctc_aes.h similarity index 100% rename from ctaocrypt/include/ctc_aes.h rename to cyassl/ctaocrypt/ctc_aes.h diff --git a/ctaocrypt/include/ctc_arc4.h b/cyassl/ctaocrypt/ctc_arc4.h similarity index 100% rename from ctaocrypt/include/ctc_arc4.h rename to cyassl/ctaocrypt/ctc_arc4.h diff --git a/ctaocrypt/include/ctc_asn.h b/cyassl/ctaocrypt/ctc_asn.h similarity index 100% rename from ctaocrypt/include/ctc_asn.h rename to cyassl/ctaocrypt/ctc_asn.h diff --git a/ctaocrypt/include/ctc_asn_public.h b/cyassl/ctaocrypt/ctc_asn_public.h similarity index 100% rename from ctaocrypt/include/ctc_asn_public.h rename to cyassl/ctaocrypt/ctc_asn_public.h diff --git a/ctaocrypt/include/ctc_coding.h b/cyassl/ctaocrypt/ctc_coding.h similarity index 100% rename from ctaocrypt/include/ctc_coding.h rename to cyassl/ctaocrypt/ctc_coding.h diff --git a/ctaocrypt/include/ctc_des3.h b/cyassl/ctaocrypt/ctc_des3.h similarity index 100% rename from ctaocrypt/include/ctc_des3.h rename to cyassl/ctaocrypt/ctc_des3.h diff --git a/ctaocrypt/include/ctc_dh.h b/cyassl/ctaocrypt/ctc_dh.h similarity index 100% rename from ctaocrypt/include/ctc_dh.h rename to cyassl/ctaocrypt/ctc_dh.h diff --git a/ctaocrypt/include/ctc_dsa.h b/cyassl/ctaocrypt/ctc_dsa.h similarity index 100% rename from ctaocrypt/include/ctc_dsa.h rename to cyassl/ctaocrypt/ctc_dsa.h diff --git a/ctaocrypt/include/ctc_ecc.h b/cyassl/ctaocrypt/ctc_ecc.h similarity index 100% rename from ctaocrypt/include/ctc_ecc.h rename to cyassl/ctaocrypt/ctc_ecc.h diff --git a/ctaocrypt/include/ctc_error.h b/cyassl/ctaocrypt/ctc_error.h similarity index 100% rename from ctaocrypt/include/ctc_error.h rename to cyassl/ctaocrypt/ctc_error.h diff --git a/ctaocrypt/include/ctc_hc128.h b/cyassl/ctaocrypt/ctc_hc128.h similarity index 97% rename from ctaocrypt/include/ctc_hc128.h rename to cyassl/ctaocrypt/ctc_hc128.h index 3738bb80c2..ea2e35f959 100644 --- a/ctaocrypt/include/ctc_hc128.h +++ b/cyassl/ctaocrypt/ctc_hc128.h @@ -20,7 +20,7 @@ */ -#ifndef NO_HC128 +#if HAVE_HC128 #ifndef CTAO_CRYPT_HC128_H #define CTAO_CRYPT_HC128_H @@ -53,4 +53,4 @@ CYASSL_API void Hc128_SetKey(HC128*, const byte* key, const byte* iv); #endif /* CTAO_CRYPT_HC128_H */ -#endif /* NO_HC128 */ +#endif /* HAVE_HC128 */ diff --git a/ctaocrypt/include/ctc_hmac.h b/cyassl/ctaocrypt/ctc_hmac.h similarity index 100% rename from ctaocrypt/include/ctc_hmac.h rename to cyassl/ctaocrypt/ctc_hmac.h diff --git a/ctaocrypt/include/ctc_integer.h b/cyassl/ctaocrypt/ctc_integer.h similarity index 100% rename from ctaocrypt/include/ctc_integer.h rename to cyassl/ctaocrypt/ctc_integer.h diff --git a/ctaocrypt/include/ctc_md4.h b/cyassl/ctaocrypt/ctc_md4.h similarity index 100% rename from ctaocrypt/include/ctc_md4.h rename to cyassl/ctaocrypt/ctc_md4.h diff --git a/ctaocrypt/include/ctc_md5.h b/cyassl/ctaocrypt/ctc_md5.h similarity index 100% rename from ctaocrypt/include/ctc_md5.h rename to cyassl/ctaocrypt/ctc_md5.h diff --git a/ctaocrypt/include/ctc_misc.h b/cyassl/ctaocrypt/ctc_misc.h similarity index 100% rename from ctaocrypt/include/ctc_misc.h rename to cyassl/ctaocrypt/ctc_misc.h diff --git a/ctaocrypt/include/ctc_pwdbased.h b/cyassl/ctaocrypt/ctc_pwdbased.h similarity index 100% rename from ctaocrypt/include/ctc_pwdbased.h rename to cyassl/ctaocrypt/ctc_pwdbased.h diff --git a/ctaocrypt/include/ctc_rabbit.h b/cyassl/ctaocrypt/ctc_rabbit.h similarity index 100% rename from ctaocrypt/include/ctc_rabbit.h rename to cyassl/ctaocrypt/ctc_rabbit.h diff --git a/ctaocrypt/include/ctc_random.h b/cyassl/ctaocrypt/ctc_random.h similarity index 100% rename from ctaocrypt/include/ctc_random.h rename to cyassl/ctaocrypt/ctc_random.h diff --git a/ctaocrypt/include/ctc_ripemd.h b/cyassl/ctaocrypt/ctc_ripemd.h similarity index 100% rename from ctaocrypt/include/ctc_ripemd.h rename to cyassl/ctaocrypt/ctc_ripemd.h diff --git a/ctaocrypt/include/ctc_rsa.h b/cyassl/ctaocrypt/ctc_rsa.h similarity index 100% rename from ctaocrypt/include/ctc_rsa.h rename to cyassl/ctaocrypt/ctc_rsa.h diff --git a/ctaocrypt/include/ctc_settings.h b/cyassl/ctaocrypt/ctc_settings.h similarity index 97% rename from ctaocrypt/include/ctc_settings.h rename to cyassl/ctaocrypt/ctc_settings.h index 3497cc1852..56c71b7243 100644 --- a/ctaocrypt/include/ctc_settings.h +++ b/cyassl/ctaocrypt/ctc_settings.h @@ -51,11 +51,7 @@ /* Uncomment next line if building CyaSSL for a game console */ /* #define CYASSL_GAME_BUILD */ -#if defined(USE_CYASSL_CONFIG) || defined(HAVE_CONFIG_H) - #include "ctc_config.h" /* may not want global HAVE_CONFIG_H */ -#endif - -#include "ctc_visibility.h" +#include #ifdef IPHONE #define SIZEOF_LONG_LONG 8 diff --git a/ctaocrypt/include/ctc_sha.h b/cyassl/ctaocrypt/ctc_sha.h similarity index 96% rename from ctaocrypt/include/ctc_sha.h rename to cyassl/ctaocrypt/ctc_sha.h index 4e51602476..acb01c7abb 100644 --- a/ctaocrypt/include/ctc_sha.h +++ b/cyassl/ctaocrypt/ctc_sha.h @@ -20,10 +20,11 @@ */ +#pragma once #ifndef CTAO_CRYPT_SHA_H #define CTAO_CRYPT_SHA_H -#include "ctc_types.h" +#include #ifdef __cplusplus extern "C" { diff --git a/ctaocrypt/include/ctc_sha256.h b/cyassl/ctaocrypt/ctc_sha256.h similarity index 100% rename from ctaocrypt/include/ctc_sha256.h rename to cyassl/ctaocrypt/ctc_sha256.h diff --git a/ctaocrypt/include/ctc_sha512.h b/cyassl/ctaocrypt/ctc_sha512.h similarity index 100% rename from ctaocrypt/include/ctc_sha512.h rename to cyassl/ctaocrypt/ctc_sha512.h diff --git a/ctaocrypt/include/ctc_tfm.h b/cyassl/ctaocrypt/ctc_tfm.h similarity index 100% rename from ctaocrypt/include/ctc_tfm.h rename to cyassl/ctaocrypt/ctc_tfm.h diff --git a/ctaocrypt/include/ctc_types.h b/cyassl/ctaocrypt/ctc_types.h similarity index 98% rename from ctaocrypt/include/ctc_types.h rename to cyassl/ctaocrypt/ctc_types.h index 67a23dadb0..592c6cebe4 100644 --- a/ctaocrypt/include/ctc_types.h +++ b/cyassl/ctaocrypt/ctc_types.h @@ -23,11 +23,7 @@ #ifndef CTAO_CRYPT_TYPES_H #define CTAO_CRYPT_TYPES_H -#include "ctc_settings.h" - -#ifdef HAVE_CONFIG_H - #include "ctc_config.h" -#endif +#include #ifdef __cplusplus extern "C" { diff --git a/ctaocrypt/include/ctc_visibility.h b/cyassl/ctaocrypt/ctc_visibility.h similarity index 100% rename from ctaocrypt/include/ctc_visibility.h rename to cyassl/ctaocrypt/ctc_visibility.h diff --git a/ctaocrypt/include/cyassl_logging.h b/cyassl/ctaocrypt/cyassl_logging.h similarity index 100% rename from ctaocrypt/include/cyassl_logging.h rename to cyassl/ctaocrypt/cyassl_logging.h diff --git a/ctaocrypt/include/cyassl_memory.h b/cyassl/ctaocrypt/cyassl_memory.h similarity index 100% rename from ctaocrypt/include/cyassl_memory.h rename to cyassl/ctaocrypt/cyassl_memory.h diff --git a/cyassl/ctaocrypt/include.am b/cyassl/ctaocrypt/include.am new file mode 100644 index 0000000000..c69faf463d --- /dev/null +++ b/cyassl/ctaocrypt/include.am @@ -0,0 +1,36 @@ +# vim:ft=automake +# All paths should be given relative to the root + +nobase_include_HEADERS+= \ + cyassl/ctaocrypt/ctc_aes.h \ + cyassl/ctaocrypt/ctc_arc4.h \ + cyassl/ctaocrypt/ctc_asn.h \ + cyassl/ctaocrypt/ctc_asn_public.h \ + cyassl/ctaocrypt/ctc_coding.h \ + cyassl/ctaocrypt/ctc_des3.h \ + cyassl/ctaocrypt/ctc_dh.h \ + cyassl/ctaocrypt/ctc_dsa.h \ + cyassl/ctaocrypt/ctc_ecc.h \ + cyassl/ctaocrypt/ctc_error.h \ + cyassl/ctaocrypt/ctc_hc128.h \ + cyassl/ctaocrypt/ctc_hmac.h \ + cyassl/ctaocrypt/ctc_integer.h \ + cyassl/ctaocrypt/ctc_md4.h \ + cyassl/ctaocrypt/ctc_md5.h \ + cyassl/ctaocrypt/ctc_misc.h \ + cyassl/ctaocrypt/ctc_pwdbased.h \ + cyassl/ctaocrypt/ctc_rabbit.h \ + cyassl/ctaocrypt/ctc_random.h \ + cyassl/ctaocrypt/ctc_ripemd.h \ + cyassl/ctaocrypt/ctc_rsa.h \ + cyassl/ctaocrypt/ctc_settings.h \ + cyassl/ctaocrypt/ctc_sha256.h \ + cyassl/ctaocrypt/ctc_sha512.h \ + cyassl/ctaocrypt/ctc_sha.h \ + cyassl/ctaocrypt/ctc_tfm.h \ + cyassl/ctaocrypt/ctc_types.h \ + cyassl/ctaocrypt/ctc_visibility.h \ + cyassl/ctaocrypt/cyassl_logging.h \ + cyassl/ctaocrypt/cyassl_memory.h \ + cyassl/ctaocrypt/mpi_class.h \ + cyassl/ctaocrypt/mpi_superclass.h diff --git a/ctaocrypt/include/mpi_class.h b/cyassl/ctaocrypt/mpi_class.h similarity index 100% rename from ctaocrypt/include/mpi_class.h rename to cyassl/ctaocrypt/mpi_class.h diff --git a/ctaocrypt/include/mpi_superclass.h b/cyassl/ctaocrypt/mpi_superclass.h similarity index 100% rename from ctaocrypt/include/mpi_superclass.h rename to cyassl/ctaocrypt/mpi_superclass.h diff --git a/include/cyassl_error.h b/cyassl/cyassl_error.h similarity index 98% rename from include/cyassl_error.h rename to cyassl/cyassl_error.h index dea82cd994..652959bca6 100644 --- a/include/cyassl_error.h +++ b/cyassl/cyassl_error.h @@ -23,7 +23,7 @@ #ifndef CYASSL_ERROR_H #define CYASSL_ERROR_H -#include "ctc_error.h" /* CTaoCrypt errors */ +#include /* CTaoCrypt errors */ #ifdef __cplusplus extern "C" { diff --git a/include/cyassl_int.h b/cyassl/cyassl_int.h similarity index 98% rename from include/cyassl_int.h rename to cyassl/cyassl_int.h index adce323455..c5959a8012 100644 --- a/include/cyassl_int.h +++ b/cyassl/cyassl_int.h @@ -24,20 +24,20 @@ #define CYASSL_INT_H -#include "ctc_types.h" -#include "ctc_random.h" -#include "ctc_des3.h" -#include "ctc_hc128.h" -#include "ctc_rabbit.h" -#include "ctc_asn.h" -#include "ctc_md5.h" -#include "ctc_aes.h" -#include "cyassl_logging.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef HAVE_ECC - #include "ctc_ecc.h" + #include #endif #ifndef NO_SHA256 - #include "ctc_sha256.h" + #include #endif #ifdef CYASSL_CALLBACKS @@ -784,7 +784,7 @@ typedef union { #ifdef BUILD_AES Aes aes; #endif -#ifdef BUILD_HC128 +#if HAVE_HC128 HC128 hc128; #endif #ifdef BUILD_RABBIT diff --git a/cyassl/include.am b/cyassl/include.am new file mode 100644 index 0000000000..89163d8b03 --- /dev/null +++ b/cyassl/include.am @@ -0,0 +1,15 @@ +# vim:ft=automake +# All paths should be given relative to the root +# + +include cyassl/ctaocrypt/include.am +include cyassl/openssl/include.am + +EXTRA_DIST+= cyassl/sniffer_error.rc + +nobase_include_HEADERS+= \ + cyassl/cyassl_error.h \ + cyassl/cyassl_int.h \ + cyassl/sniffer_error.h \ + cyassl/sniffer.h \ + cyassl/version.h diff --git a/include/openssl/asn1.h b/cyassl/openssl/asn1.h similarity index 100% rename from include/openssl/asn1.h rename to cyassl/openssl/asn1.h diff --git a/include/openssl/bio.h b/cyassl/openssl/bio.h similarity index 100% rename from include/openssl/bio.h rename to cyassl/openssl/bio.h diff --git a/include/openssl/bn.h b/cyassl/openssl/bn.h similarity index 100% rename from include/openssl/bn.h rename to cyassl/openssl/bn.h diff --git a/include/openssl/conf.h b/cyassl/openssl/conf.h similarity index 100% rename from include/openssl/conf.h rename to cyassl/openssl/conf.h diff --git a/include/openssl/crypto.h b/cyassl/openssl/crypto.h similarity index 100% rename from include/openssl/crypto.h rename to cyassl/openssl/crypto.h diff --git a/include/openssl/cyassl_callbacks.h b/cyassl/openssl/cyassl_callbacks.h similarity index 100% rename from include/openssl/cyassl_callbacks.h rename to cyassl/openssl/cyassl_callbacks.h diff --git a/include/openssl/cyassl_test.h b/cyassl/openssl/cyassl_test.h similarity index 92% rename from include/openssl/cyassl_test.h rename to cyassl/openssl/cyassl_test.h index 2cc7a1f3a2..e0820b5069 100644 --- a/include/openssl/cyassl_test.h +++ b/cyassl/openssl/cyassl_test.h @@ -7,7 +7,7 @@ #include #include #include -#include "ctc_types.h" +#include #ifdef USE_WINDOWS_API #include @@ -73,14 +73,16 @@ typedef void* THREAD_TYPE; #define CYASSL_THREAD #else - #ifndef _POSIX_THREADS - typedef unsigned int THREAD_RETURN; - typedef HANDLE THREAD_TYPE; - #define CYASSL_THREAD __stdcall - #else + #ifdef _POSIX_THREADS typedef void* THREAD_RETURN; typedef pthread_t THREAD_TYPE; #define CYASSL_THREAD + #define INFINITE -1 + #define WAIT_OBJECT_0 0L + #else + typedef unsigned int THREAD_RETURN; + typedef HANDLE THREAD_TYPE; + #define CYASSL_THREAD __stdcall #endif #endif @@ -94,27 +96,16 @@ #endif -#ifndef NO_MAIN_DRIVER - const char* caCert = "../../certs/ca-cert.pem"; - const char* eccCert = "../../certs/server-ecc.pem"; - const char* eccKey = "../../certs/ecc-key.pem"; - const char* svrCert = "../../certs/server-cert.pem"; - const char* svrKey = "../../certs/server-key.pem"; - const char* cliCert = "../../certs/client-cert.pem"; - const char* cliKey = "../../certs/client-key.pem"; - const char* ntruCert = "../../certs/ntru-cert.pem"; - const char* ntruKey = "../../certs/ntru-key.raw"; -#else - static const char* caCert = "../certs/ca-cert.pem"; - static const char* eccCert = "../certs/server-ecc.pem"; - static const char* eccKey = "../certs/ecc-key.pem"; - static const char* svrCert = "../certs/server-cert.pem"; - static const char* svrKey = "../certs/server-key.pem"; - static const char* cliCert = "../certs/client-cert.pem"; - static const char* cliKey = "../certs/client-key.pem"; - static const char* ntruCert = "../certs/ntru-cert.pem"; - static const char* ntruKey = "../certs/ntru-key.raw"; -#endif +/* all certs relative to CyaSSL home directory now */ +static const char* caCert = "./certs/ca-cert.pem"; +static const char* eccCert = "./certs/server-ecc.pem"; +static const char* eccKey = "./certs/ecc-key.pem"; +static const char* svrCert = "./certs/server-cert.pem"; +static const char* svrKey = "./certs/server-key.pem"; +static const char* cliCert = "./certs/client-cert.pem"; +static const char* cliKey = "./certs/client-key.pem"; +static const char* ntruCert = "./certs/ntru-cert.pem"; +static const char* ntruKey = "./certs/ntru-key.raw"; typedef struct tcp_ready { int ready; /* predicate */ @@ -520,7 +511,8 @@ static INLINE unsigned int my_psk_server_cb(SSL* ssl, const char* identity, FILE* file = fopen(fname, "rb"); if (!file) - err_sys("can't open file for buffer load"); + err_sys("can't open file for buffer load " + "Please run from CyaSSL home directory if not"); fseek(file, 0, SEEK_END); sz = ftell(file); rewind(file); diff --git a/include/openssl/des.h b/cyassl/openssl/des.h similarity index 100% rename from include/openssl/des.h rename to cyassl/openssl/des.h diff --git a/include/openssl/dh.h b/cyassl/openssl/dh.h similarity index 100% rename from include/openssl/dh.h rename to cyassl/openssl/dh.h diff --git a/include/openssl/dsa.h b/cyassl/openssl/dsa.h similarity index 100% rename from include/openssl/dsa.h rename to cyassl/openssl/dsa.h diff --git a/include/openssl/ec.h b/cyassl/openssl/ec.h similarity index 100% rename from include/openssl/ec.h rename to cyassl/openssl/ec.h diff --git a/include/openssl/ecdsa.h b/cyassl/openssl/ecdsa.h similarity index 100% rename from include/openssl/ecdsa.h rename to cyassl/openssl/ecdsa.h diff --git a/include/openssl/engine.h b/cyassl/openssl/engine.h similarity index 100% rename from include/openssl/engine.h rename to cyassl/openssl/engine.h diff --git a/include/openssl/err.h b/cyassl/openssl/err.h similarity index 100% rename from include/openssl/err.h rename to cyassl/openssl/err.h diff --git a/include/openssl/evp.h b/cyassl/openssl/evp.h similarity index 100% rename from include/openssl/evp.h rename to cyassl/openssl/evp.h diff --git a/include/openssl/hmac.h b/cyassl/openssl/hmac.h similarity index 100% rename from include/openssl/hmac.h rename to cyassl/openssl/hmac.h diff --git a/cyassl/openssl/include.am b/cyassl/openssl/include.am new file mode 100644 index 0000000000..a352683e0a --- /dev/null +++ b/cyassl/openssl/include.am @@ -0,0 +1,37 @@ +# vim:ft=automake +# All paths should be given relative to the root + +nobase_include_HEADERS+= \ + cyassl/openssl/asn1.h \ + cyassl/openssl/bio.h \ + cyassl/openssl/bn.h \ + cyassl/openssl/conf.h \ + cyassl/openssl/crypto.h \ + cyassl/openssl/cyassl_callbacks.h \ + cyassl/openssl/cyassl_test.h \ + cyassl/openssl/des.h \ + cyassl/openssl/dh.h \ + cyassl/openssl/dsa.h \ + cyassl/openssl/ecdsa.h \ + cyassl/openssl/ec.h \ + cyassl/openssl/engine.h \ + cyassl/openssl/err.h \ + cyassl/openssl/evp.h \ + cyassl/openssl/hmac.h \ + cyassl/openssl/lhash.h \ + cyassl/openssl/md4.h \ + cyassl/openssl/md5.h \ + cyassl/openssl/ocsp.h \ + cyassl/openssl/opensslconf.h \ + cyassl/openssl/opensslv.h \ + cyassl/openssl/ossl_typ.h \ + cyassl/openssl/pem.h \ + cyassl/openssl/pkcs12.h \ + cyassl/openssl/rand.h \ + cyassl/openssl/rsa.h \ + cyassl/openssl/sha.h \ + cyassl/openssl/ssl.h \ + cyassl/openssl/stack.h \ + cyassl/openssl/ui.h \ + cyassl/openssl/x509.h \ + cyassl/openssl/x509v3.h diff --git a/include/openssl/lhash.h b/cyassl/openssl/lhash.h similarity index 100% rename from include/openssl/lhash.h rename to cyassl/openssl/lhash.h diff --git a/include/openssl/md4.h b/cyassl/openssl/md4.h similarity index 100% rename from include/openssl/md4.h rename to cyassl/openssl/md4.h diff --git a/include/openssl/md5.h b/cyassl/openssl/md5.h similarity index 100% rename from include/openssl/md5.h rename to cyassl/openssl/md5.h diff --git a/include/openssl/ocsp.h b/cyassl/openssl/ocsp.h similarity index 100% rename from include/openssl/ocsp.h rename to cyassl/openssl/ocsp.h diff --git a/include/openssl/opensslconf.h b/cyassl/openssl/opensslconf.h similarity index 100% rename from include/openssl/opensslconf.h rename to cyassl/openssl/opensslconf.h diff --git a/include/openssl/opensslv.h b/cyassl/openssl/opensslv.h similarity index 100% rename from include/openssl/opensslv.h rename to cyassl/openssl/opensslv.h diff --git a/include/openssl/ossl_typ.h b/cyassl/openssl/ossl_typ.h similarity index 100% rename from include/openssl/ossl_typ.h rename to cyassl/openssl/ossl_typ.h diff --git a/include/openssl/pem.h b/cyassl/openssl/pem.h similarity index 100% rename from include/openssl/pem.h rename to cyassl/openssl/pem.h diff --git a/include/openssl/pkcs12.h b/cyassl/openssl/pkcs12.h similarity index 100% rename from include/openssl/pkcs12.h rename to cyassl/openssl/pkcs12.h diff --git a/cyassl/openssl/rand.h b/cyassl/openssl/rand.h new file mode 100644 index 0000000000..a5534e1a0d --- /dev/null +++ b/cyassl/openssl/rand.h @@ -0,0 +1,4 @@ +/* rand.h for openSSL */ + +#include + diff --git a/include/openssl/rsa.h b/cyassl/openssl/rsa.h similarity index 100% rename from include/openssl/rsa.h rename to cyassl/openssl/rsa.h diff --git a/include/openssl/sha.h b/cyassl/openssl/sha.h similarity index 100% rename from include/openssl/sha.h rename to cyassl/openssl/sha.h diff --git a/include/openssl/ssl.h b/cyassl/openssl/ssl.h similarity index 99% rename from include/openssl/ssl.h rename to cyassl/openssl/ssl.h index cd3dc28584..815b3a8f5b 100644 --- a/include/openssl/ssl.h +++ b/cyassl/openssl/ssl.h @@ -28,7 +28,8 @@ #ifndef CYASSL_OPENSSL_H_ #define CYASSL_OPENSSL_H_ -#include "ctc_settings.h" /* for users not using preprocessor flags */ +#include /* for users not using preprocessor flags */ +#include #ifndef NO_FILESYSTEM #include /* ERR_print fp */ @@ -38,7 +39,7 @@ #include "prefix_ssl.h" #endif -#define CYASSL_VERSION "2.0.0rc2" +#define CYASSL_VERSION LIBCYASSL_VERSION_STRING #ifdef _WIN32 /* wincrypt.h clashes */ diff --git a/include/openssl/stack.h b/cyassl/openssl/stack.h similarity index 100% rename from include/openssl/stack.h rename to cyassl/openssl/stack.h diff --git a/include/openssl/ui.h b/cyassl/openssl/ui.h similarity index 100% rename from include/openssl/ui.h rename to cyassl/openssl/ui.h diff --git a/cyassl/openssl/x509.h b/cyassl/openssl/x509.h new file mode 100644 index 0000000000..645b3b5fb8 --- /dev/null +++ b/cyassl/openssl/x509.h @@ -0,0 +1,3 @@ +/* x509.h for openssl */ + +#include diff --git a/include/openssl/x509v3.h b/cyassl/openssl/x509v3.h similarity index 100% rename from include/openssl/x509v3.h rename to cyassl/openssl/x509v3.h diff --git a/include/sniffer.h b/cyassl/sniffer.h similarity index 100% rename from include/sniffer.h rename to cyassl/sniffer.h diff --git a/include/sniffer_error.h b/cyassl/sniffer_error.h similarity index 100% rename from include/sniffer_error.h rename to cyassl/sniffer_error.h diff --git a/include/sniffer_error.rc b/cyassl/sniffer_error.rc similarity index 100% rename from include/sniffer_error.rc rename to cyassl/sniffer_error.rc diff --git a/cyassl/version.h.in b/cyassl/version.h.in new file mode 100644 index 0000000000..2b3605cc7a --- /dev/null +++ b/cyassl/version.h.in @@ -0,0 +1,35 @@ +/* cyassl_error.h + * + * Copyright (C) 2006-2011 Sawtooth Consulting Ltd. + * + * This file is part of CyaSSL. + * + * CyaSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * CyaSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#define LIBCYASSL_VERSION_STRING "@VERSION@" +#define LIBCYASSL_VERSION_HEX @HEX_VERSION@ + +#ifdef __cplusplus +} +#endif + diff --git a/doc/include.am b/doc/include.am new file mode 100644 index 0000000000..fa44fcf8f0 --- /dev/null +++ b/doc/include.am @@ -0,0 +1,5 @@ +# vim:ft=automake +# included from Top Level Makefile.am +# All paths should be given relative to the root + +doc_DATA+= doc/README.txt diff --git a/examples/client/client.c b/examples/client/client.c index accf0fc0f4..4a5ae2ee0a 100644 --- a/examples/client/client.c +++ b/examples/client/client.c @@ -19,10 +19,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include -#include "ssl.h" -#include "cyassl_test.h" - +#include +#include /* #define TEST_RESUME @@ -117,10 +117,10 @@ void client_test(void* args) #ifndef NO_FILESYSTEM if (SSL_CTX_load_verify_locations(ctx, caCert, 0) != SSL_SUCCESS) - err_sys("can't load ca file"); + err_sys("can't load ca file, Please run from CyaSSL home dir"); #ifdef HAVE_ECC if (SSL_CTX_load_verify_locations(ctx, eccCert, 0) != SSL_SUCCESS) - err_sys("can't load ca file"); + err_sys("can't load ca file, Please run from CyaSSL home dir"); #endif #else load_buffer(ctx, caCert, CYASSL_CA); @@ -142,11 +142,13 @@ void client_test(void* args) #ifndef NO_FILESYSTEM if (SSL_CTX_use_certificate_file(ctx, cliCert, SSL_FILETYPE_PEM) != SSL_SUCCESS) - err_sys("can't load client cert file"); + err_sys("can't load client cert file, " + "Please run from CyaSSL home dir"); if (SSL_CTX_use_PrivateKey_file(ctx, cliKey, SSL_FILETYPE_PEM) != SSL_SUCCESS) - err_sys("can't load client key file"); + err_sys("can't load client key file, " + "Please run from CyaSSL home dir"); #else load_buffer(ctx, cliCert, CYASSL_CERT); load_buffer(ctx, cliKey, CYASSL_KEY); diff --git a/examples/client/include.am b/examples/client/include.am index 17c56d0d70..0b900c221f 100644 --- a/examples/client/include.am +++ b/examples/client/include.am @@ -1,11 +1,12 @@ # vim:ft=automake -# included from Top Level Makefile.am # All paths should be given relative to the root - -bin_PROGRAMS += examples/client/client +noinst_PROGRAMS += examples/client/client examples_client_client_SOURCES = examples/client/client.c -examples_client_client_LDFLAGS = -Lsrc examples_client_client_LDADD = src/libcyassl.la examples_client_client_DEPENDENCIES = src/libcyassl.la -EXTRA_DIST += examples/client/client.sln examples/client/*.vcproj +EXTRA_DIST += examples/client/client.sln +EXTRA_DIST += examples/client/client-ntru.vcproj +EXTRA_DIST += examples/client/client.vcproj + +example_DATA+= examples/client/client.c diff --git a/examples/echoclient/echoclient.c b/examples/echoclient/echoclient.c index c2a0070ece..ac6e7699e0 100644 --- a/examples/echoclient/echoclient.c +++ b/examples/echoclient/echoclient.c @@ -19,9 +19,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include -#include "ssl.h" -#include "cyassl_test.h" +#include +#include void echoclient_test(void* args) @@ -74,10 +75,10 @@ void echoclient_test(void* args) #ifndef NO_FILESYSTEM if (SSL_CTX_load_verify_locations(ctx, caCert, 0) != SSL_SUCCESS) - err_sys("can't load ca file"); + err_sys("can't load ca file, Please run from CyaSSL home dir"); #ifdef HAVE_ECC if (SSL_CTX_load_verify_locations(ctx, eccCert, 0) != SSL_SUCCESS) - err_sys("can't load ca file"); + err_sys("can't load ca file, Please run from CyaSSL home dir"); #endif #else load_buffer(ctx, caCert, CYASSL_CA); diff --git a/examples/echoclient/include.am b/examples/echoclient/include.am index 461e8379a9..8f09c24d3f 100644 --- a/examples/echoclient/include.am +++ b/examples/echoclient/include.am @@ -1,12 +1,14 @@ -vim:ft=automake +# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root -bin_PROGRAMS += examples/echoclient/echoclient +noinst_PROGRAMS += examples/echoclient/echoclient examples_echoclient_echoclient_SOURCES = examples/echoclient/echoclient.c -examples_echoclient_echoclient_LDFLAGS = -Lsrc examples_echoclient_echoclient_LDADD = src/libcyassl.la examples_echoclient_echoclient_DEPENDENCIES = src/libcyassl.la -EXTRA_DIST += examples/echoclient/echoclient.sln examples/echoclient/*.vcproj \ - examples/echoclient/input examples/echoclient/quit +EXTRA_DIST += examples/echoclient/echoclient.sln +EXTRA_DIST += examples/echoclient/echoclient-ntru.vcproj +EXTRA_DIST += examples/echoclient/echoclient.vcproj + +example_DATA+= examples/echoclient/echoclient.c diff --git a/examples/echoserver/echoserver.c b/examples/echoserver/echoserver.c index b2c6942b6b..c8528d88fc 100644 --- a/examples/echoserver/echoserver.c +++ b/examples/echoserver/echoserver.c @@ -19,9 +19,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include -#include "ssl.h" -#include "cyassl_test.h" +#include +#include #ifndef NO_MAIN_DRIVER #define ECHO_OUT @@ -90,29 +91,35 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args) /* ntru */ if (SSL_CTX_use_certificate_file(ctx, ntruCert, SSL_FILETYPE_PEM) != SSL_SUCCESS) - err_sys("can't load ntru cert file"); + err_sys("can't load ntru cert file, " + "Please run from CyaSSL home dir"); if (CyaSSL_CTX_use_NTRUPrivateKey_file(ctx, ntruKey) != SSL_SUCCESS) - err_sys("can't load ntru key file"); + err_sys("can't load ntru key file, " + "Please run from CyaSSL home dir"); #elif HAVE_ECC /* ecc */ if (SSL_CTX_use_certificate_file(ctx, eccCert, SSL_FILETYPE_PEM) != SSL_SUCCESS) - err_sys("can't load server cert file"); + err_sys("can't load server cert file, " + "Please run from CyaSSL home dir"); if (SSL_CTX_use_PrivateKey_file(ctx, eccKey, SSL_FILETYPE_PEM) != SSL_SUCCESS) - err_sys("can't load server key file"); + err_sys("can't load server key file, " + "Please run from CyaSSL home dir"); #else /* normal */ if (SSL_CTX_use_certificate_file(ctx, svrCert, SSL_FILETYPE_PEM) != SSL_SUCCESS) - err_sys("can't load server cert file"); + err_sys("can't load server cert file, " + "Please run from CyaSSL home dir"); if (SSL_CTX_use_PrivateKey_file(ctx, svrKey, SSL_FILETYPE_PEM) != SSL_SUCCESS) - err_sys("can't load server key file"); + err_sys("can't load server key file, " + "Please run from CyaSSL home dir"); #endif #else load_buffer(ctx, svrCert, CYASSL_CERT); diff --git a/examples/echoserver/include.am b/examples/echoserver/include.am index cce3db22dc..c998c56ef1 100644 --- a/examples/echoserver/include.am +++ b/examples/echoserver/include.am @@ -1,11 +1,14 @@ -vim:ft=automake +# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root -bin_PROGRAMS += examples/echoserver/echoserver +noinst_PROGRAMS += examples/echoserver/echoserver examples_echoserver_echoserver_SOURCES = examples/echoserver/echoserver.c -examples_echoserver_echoserver_LDFLAGS = -Lsrc examples_echoserver_echoserver_LDADD = src/libcyassl.la examples_echoserver_echoserver_DEPENDENCIES = src/libcyassl.la -EXTRA_DIST += examples/echoserver/echoserver.sln examples/echoserver/*.vcproj +EXTRA_DIST += examples/echoserver/echoserver.sln +EXTRA_DIST += examples/echoserver/echoserver-ntru.vcproj +EXTRA_DIST += examples/echoserver/echoserver.vcproj + +example_DATA+= examples/echoserver/echoserver.c diff --git a/examples/server/include.am b/examples/server/include.am index 8db00eba63..fab37fd0f0 100644 --- a/examples/server/include.am +++ b/examples/server/include.am @@ -3,9 +3,12 @@ # All paths should be given relative to the root -bin_PROGRAMS += examples/server/server +noinst_PROGRAMS += examples/server/server examples_server_server_SOURCES = examples/server/server.c -examples_server_server_LDFLAGS = -Lsrc examples_server_server_LDADD = src/libcyassl.la examples_server_server_DEPENDENCIES = src/libcyassl.la -EXTRA_DIST += examples/server/server.sln examples/server/*.vcproj +EXTRA_DIST += examples/server/server.sln +EXTRA_DIST += examples/server/server-ntru.vcproj +EXTRA_DIST += examples/server/server.vcproj + +example_DATA+= examples/server/server.c diff --git a/examples/server/server.c b/examples/server/server.c index a4e26079fc..c8c4a39f0e 100644 --- a/examples/server/server.c +++ b/examples/server/server.c @@ -19,9 +19,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include -#include "ssl.h" -#include "cyassl_test.h" +#include +#include #ifdef CYASSL_CALLBACKS @@ -100,32 +101,38 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args) #ifndef NO_FILESYSTEM /* for client auth */ if (SSL_CTX_load_verify_locations(ctx, cliCert, 0) != SSL_SUCCESS) - err_sys("can't load ca file"); + err_sys("can't load ca file, Please run from CyaSSL home dir"); #ifdef HAVE_ECC if (SSL_CTX_use_certificate_file(ctx, eccCert, SSL_FILETYPE_PEM) != SSL_SUCCESS) - err_sys("can't load server ecc cert file"); + err_sys("can't load server ecc cert file, " + "Please run from CyaSSL home dir"); if (SSL_CTX_use_PrivateKey_file(ctx, eccKey, SSL_FILETYPE_PEM) != SSL_SUCCESS) - err_sys("can't load server ecc key file"); + err_sys("can't load server ecc key file, " + "Please run from CyaSSL home dir"); #elif HAVE_NTRU if (SSL_CTX_use_certificate_file(ctx, ntruCert, SSL_FILETYPE_PEM) != SSL_SUCCESS) - err_sys("can't load ntru cert file"); + err_sys("can't load ntru cert file, " + "Please run from CyaSSL home dir"); if (CyaSSL_CTX_use_NTRUPrivateKey_file(ctx, ntruKey) != SSL_SUCCESS) - err_sys("can't load ntru key file"); + err_sys("can't load ntru key file, " + "Please run from CyaSSL home dir"); #else /* normal */ if (SSL_CTX_use_certificate_chain_file(ctx, svrCert) != SSL_SUCCESS) - err_sys("can't load server cert chain file"); + err_sys("can't load server cert chain file, " + "Please run from CyaSSL home dir"); if (SSL_CTX_use_PrivateKey_file(ctx, svrKey, SSL_FILETYPE_PEM) != SSL_SUCCESS) - err_sys("can't load server key file"); + err_sys("can't load server key file, " + "Please run from CyaSSL home dir"); #endif /* NTRU */ #else load_buffer(ctx, cliCert, CYASSL_CA); diff --git a/include/openssl/rand.h b/include/openssl/rand.h deleted file mode 100644 index ba81872997..0000000000 --- a/include/openssl/rand.h +++ /dev/null @@ -1,4 +0,0 @@ -/* rand.h for openSSL */ - -#include "openssl/ssl.h" - diff --git a/include/openssl/x509.h b/include/openssl/x509.h deleted file mode 100644 index 2d1da2487f..0000000000 --- a/include/openssl/x509.h +++ /dev/null @@ -1,3 +0,0 @@ -/* x509.h for openssl */ - -#include "openssl/ssl.h" diff --git a/examples/echoclient/input b/input similarity index 100% rename from examples/echoclient/input rename to input diff --git a/m4/acx_pthread.m4 b/m4/acx_pthread.m4 deleted file mode 100644 index e4e91d3c99..0000000000 --- a/m4/acx_pthread.m4 +++ /dev/null @@ -1,242 +0,0 @@ -dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) -dnl -dnl @summary figure out how to build C programs using POSIX threads -dnl -dnl This macro figures out how to build C programs using POSIX threads. -dnl It sets the PTHREAD_LIBS output variable to the threads library and -dnl linker flags, and the PTHREAD_CFLAGS output variable to any special -dnl C compiler flags that are needed. (The user can also force certain -dnl compiler flags/libs to be tested by setting these environment -dnl variables.) -dnl -dnl Also sets PTHREAD_CC to any special C compiler that is needed for -dnl multi-threaded programs (defaults to the value of CC otherwise). -dnl (This is necessary on AIX to use the special cc_r compiler alias.) -dnl -dnl NOTE: You are assumed to not only compile your program with these -dnl flags, but also link it with them as well. e.g. you should link -dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS -dnl $LIBS -dnl -dnl If you are only building threads programs, you may wish to use -dnl these variables in your default LIBS, CFLAGS, and CC: -dnl -dnl LIBS="$PTHREAD_LIBS $LIBS" -dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS" -dnl CC="$PTHREAD_CC" -dnl -dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute -dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to -dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). -dnl -dnl ACTION-IF-FOUND is a list of shell commands to run if a threads -dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to -dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the -dnl default action will define HAVE_PTHREAD. -dnl -dnl Please let the authors know if this macro fails on any platform, or -dnl if you have any other suggestions or comments. This macro was based -dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with -dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros -dnl posted by Alejandro Forero Cuervo to the autoconf macro repository. -dnl We are also grateful for the helpful feedback of numerous users. -dnl -dnl @category InstalledPackages -dnl @author Steven G. Johnson -dnl @version 2006-05-29 -dnl @license GPLWithACException - -AC_DEFUN([ACX_PTHREAD], [ -AC_REQUIRE([AC_CANONICAL_HOST]) -AC_LANG_SAVE -AC_LANG_C -acx_pthread_ok=no - -# We used to check for pthread.h first, but this fails if pthread.h -# requires special compiler flags (e.g. on True64 or Sequent). -# It gets checked for in the link test anyway. - -# First of all, check if the user has set any of the PTHREAD_LIBS, -# etcetera environment variables, and if threads linking works using -# them: -if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - save_LIBS="$LIBS" - LIBS="$PTHREAD_LIBS $LIBS" - AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) - AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) - AC_MSG_RESULT($acx_pthread_ok) - if test x"$acx_pthread_ok" = xno; then - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" - fi - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" -fi - -# We must check for the threads library under a number of different -# names; the ordering is very important because some systems -# (e.g. DEC) have both -lpthread and -lpthreads, where one of the -# libraries is broken (non-POSIX). - -# Create a list of thread flags to try. Items starting with a "-" are -# C compiler flags, and other items are library names, except for "none" -# which indicates that we try without any flags at all, and "pthread-config" -# which is a program returning the flags for the Pth emulation library. - -acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" - -# The ordering *is* (sometimes) important. Some notes on the -# individual items follow: - -# pthreads: AIX (must check this before -lpthread) -# none: in case threads are in libc; should be tried before -Kthread and -# other compiler flags to prevent continual compiler warnings -# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) -# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) -# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) -# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) -# -pthreads: Solaris/gcc -# -mthreads: Mingw32/gcc, Lynx/gcc -# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it -# doesn't hurt to check since this sometimes defines pthreads too; -# also defines -D_REENTRANT) -# ... -mt is also the pthreads flag for HP/aCC -# pthread: Linux, etcetera -# --thread-safe: KAI C++ -# pthread-config: use pthread-config program (for GNU Pth library) - -case "${host_cpu}-${host_os}" in - *solaris*) - - # On Solaris (at least, for some versions), libc contains stubbed - # (non-functional) versions of the pthreads routines, so link-based - # tests will erroneously succeed. (We need to link with -pthreads/-mt/ - # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather - # a function called by this macro, so we could check for that, but - # who knows whether they'll stub that too in a future libc.) So, - # we'll just look for -pthreads and -lpthread first: - - acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags" - ;; -esac - -if test x"$acx_pthread_ok" = xno; then -for flag in $acx_pthread_flags; do - - case $flag in - none) - AC_MSG_CHECKING([whether pthreads work without any flags]) - ;; - - -*) - AC_MSG_CHECKING([whether pthreads work with $flag]) - PTHREAD_CFLAGS="$flag" - ;; - - pthread-config) - AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no) - if test x"$acx_pthread_config" = xno; then continue; fi - PTHREAD_CFLAGS="`pthread-config --cflags`" - PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" - ;; - - *) - AC_MSG_CHECKING([for the pthreads library -l$flag]) - PTHREAD_LIBS="-l$flag" - ;; - esac - - save_LIBS="$LIBS" - save_CFLAGS="$CFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - - # Check for various functions. We must include pthread.h, - # since some functions may be macros. (On the Sequent, we - # need a special flag -Kthread to make this header compile.) - # We check for pthread_join because it is in -lpthread on IRIX - # while pthread_create is in libc. We check for pthread_attr_init - # due to DEC craziness with -lpthreads. We check for - # pthread_cleanup_push because it is one of the few pthread - # functions on Solaris that doesn't have a non-functional libc stub. - # We try pthread_create on general principles. - AC_TRY_LINK([#include ], - [pthread_t th; pthread_join(th, 0); - pthread_attr_init(0); pthread_cleanup_push(0, 0); - pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], - [acx_pthread_ok=yes]) - - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - - AC_MSG_RESULT($acx_pthread_ok) - if test "x$acx_pthread_ok" = xyes; then - break; - fi - - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" -done -fi - -# Various other checks: -if test "x$acx_pthread_ok" = xyes; then - save_LIBS="$LIBS" - LIBS="$PTHREAD_LIBS $LIBS" - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - - # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. - AC_MSG_CHECKING([for joinable pthread attribute]) - attr_name=unknown - for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do - AC_TRY_LINK([#include ], [int attr=$attr; return attr;], - [attr_name=$attr; break]) - done - AC_MSG_RESULT($attr_name) - if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then - AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, - [Define to necessary symbol if this constant - uses a non-standard name on your system.]) - fi - - AC_MSG_CHECKING([if more special flags are required for pthreads]) - flag=no - case "${host_cpu}-${host_os}" in - *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; - *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; - esac - AC_MSG_RESULT(${flag}) - if test "x$flag" != xno; then - PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" - fi - - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - - # More AIX lossage: must compile with xlc_r or cc_r - if test x"$GCC" != xyes; then - AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) - else - PTHREAD_CC=$CC - fi -else - PTHREAD_CC="$CC" -fi - -AC_SUBST(PTHREAD_LIBS) -AC_SUBST(PTHREAD_CFLAGS) -AC_SUBST(PTHREAD_CC) - -# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: -if test x"$acx_pthread_ok" = xyes; then - ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) - : -else - acx_pthread_ok=no - $2 -fi -AC_LANG_RESTORE -])dnl ACX_PTHREAD diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4 new file mode 100644 index 0000000000..a6bf596c32 --- /dev/null +++ b/m4/ax_pthread.m4 @@ -0,0 +1,302 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_pthread.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +# +# DESCRIPTION +# +# This macro figures out how to build C programs using POSIX threads. It +# sets the PTHREAD_LIBS output variable to the threads library and linker +# flags, and the PTHREAD_CFLAGS output variable to any special C compiler +# flags that are needed. (The user can also force certain compiler +# flags/libs to be tested by setting these environment variables.) +# +# Also sets PTHREAD_CC to any special C compiler that is needed for +# multi-threaded programs (defaults to the value of CC otherwise). (This +# is necessary on AIX to use the special cc_r compiler alias.) +# +# NOTE: You are assumed to not only compile your program with these flags, +# but also link it with them as well. e.g. you should link with +# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS +# +# If you are only building threads programs, you may wish to use these +# variables in your default LIBS, CFLAGS, and CC: +# +# LIBS="$PTHREAD_LIBS $LIBS" +# CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +# CC="$PTHREAD_CC" +# +# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant +# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name +# (e.g. PTHREAD_CREATE_UNDETACHED on AIX). +# +# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the +# PTHREAD_PRIO_INHERIT symbol is defined when compiling with +# PTHREAD_CFLAGS. +# +# ACTION-IF-FOUND is a list of shell commands to run if a threads library +# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it +# is not found. If ACTION-IF-FOUND is not specified, the default action +# will define HAVE_PTHREAD. +# +# Please let the authors know if this macro fails on any platform, or if +# you have any other suggestions or comments. This macro was based on work +# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help +# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by +# Alejandro Forero Cuervo to the autoconf macro repository. We are also +# grateful for the helpful feedback of numerous users. +# +# Updated for Autoconf 2.68 by Daniel Richard G. +# +# LICENSE +# +# Copyright (c) 2008 Steven G. Johnson +# Copyright (c) 2011 Daniel Richard G. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 16 + +AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) +AC_DEFUN([AX_PTHREAD], [ +AC_REQUIRE([AC_CANONICAL_HOST]) +AC_LANG_PUSH([C]) +ax_pthread_ok=no + +# We used to check for pthread.h first, but this fails if pthread.h +# requires special compiler flags (e.g. on True64 or Sequent). +# It gets checked for in the link test anyway. + +# First of all, check if the user has set any of the PTHREAD_LIBS, +# etcetera environment variables, and if threads linking works using +# them: +if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) + AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes) + AC_MSG_RESULT($ax_pthread_ok) + if test x"$ax_pthread_ok" = xno; then + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" + fi + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" +fi + +# We must check for the threads library under a number of different +# names; the ordering is very important because some systems +# (e.g. DEC) have both -lpthread and -lpthreads, where one of the +# libraries is broken (non-POSIX). + +# Create a list of thread flags to try. Items starting with a "-" are +# C compiler flags, and other items are library names, except for "none" +# which indicates that we try without any flags at all, and "pthread-config" +# which is a program returning the flags for the Pth emulation library. + +ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" + +# The ordering *is* (sometimes) important. Some notes on the +# individual items follow: + +# pthreads: AIX (must check this before -lpthread) +# none: in case threads are in libc; should be tried before -Kthread and +# other compiler flags to prevent continual compiler warnings +# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) +# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) +# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) +# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) +# -pthreads: Solaris/gcc +# -mthreads: Mingw32/gcc, Lynx/gcc +# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it +# doesn't hurt to check since this sometimes defines pthreads too; +# also defines -D_REENTRANT) +# ... -mt is also the pthreads flag for HP/aCC +# pthread: Linux, etcetera +# --thread-safe: KAI C++ +# pthread-config: use pthread-config program (for GNU Pth library) + +case "${host_cpu}-${host_os}" in + *solaris*) + + # On Solaris (at least, for some versions), libc contains stubbed + # (non-functional) versions of the pthreads routines, so link-based + # tests will erroneously succeed. (We need to link with -pthreads/-mt/ + # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather + # a function called by this macro, so we could check for that, but + # who knows whether they'll stub that too in a future libc.) So, + # we'll just look for -pthreads and -lpthread first: + + ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" + ;; + + *-darwin*) + ax_pthread_flags="-pthread $ax_pthread_flags" + ;; +esac + +if test x"$ax_pthread_ok" = xno; then +for flag in $ax_pthread_flags; do + + case $flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + + -*) + AC_MSG_CHECKING([whether pthreads work with $flag]) + PTHREAD_CFLAGS="$flag" + ;; + + pthread-config) + AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no) + if test x"$ax_pthread_config" = xno; then continue; fi + PTHREAD_CFLAGS="`pthread-config --cflags`" + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" + ;; + + *) + AC_MSG_CHECKING([for the pthreads library -l$flag]) + PTHREAD_LIBS="-l$flag" + ;; + esac + + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we + # need a special flag -Kthread to make this header compile.) + # We check for pthread_join because it is in -lpthread on IRIX + # while pthread_create is in libc. We check for pthread_attr_init + # due to DEC craziness with -lpthreads. We check for + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include + static void routine(void *a) { a = 0; } + static void *start_routine(void *a) { return a; }], + [pthread_t th; pthread_attr_t attr; + pthread_create(&th, 0, start_routine, 0); + pthread_join(th, 0); + pthread_attr_init(&attr); + pthread_cleanup_push(routine, 0); + pthread_cleanup_pop(0) /* ; */])], + [ax_pthread_ok=yes], + []) + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + AC_MSG_RESULT($ax_pthread_ok) + if test "x$ax_pthread_ok" = xyes; then + break; + fi + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi + +# Various other checks: +if test "x$ax_pthread_ok" = xyes; then + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. + AC_MSG_CHECKING([for joinable pthread attribute]) + attr_name=unknown + for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], + [int attr = $attr; return attr /* ; */])], + [attr_name=$attr; break], + []) + done + AC_MSG_RESULT($attr_name) + if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then + AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, + [Define to necessary symbol if this constant + uses a non-standard name on your system.]) + fi + + AC_MSG_CHECKING([if more special flags are required for pthreads]) + flag=no + case "${host_cpu}-${host_os}" in + *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; + *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; + esac + AC_MSG_RESULT(${flag}) + if test "x$flag" != xno; then + PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" + fi + + AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], + ax_cv_PTHREAD_PRIO_INHERIT, [ + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[#include ]], [[int i = PTHREAD_PRIO_INHERIT;]])], + [ax_cv_PTHREAD_PRIO_INHERIT=yes], + [ax_cv_PTHREAD_PRIO_INHERIT=no]) + ]) + AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"], + AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], 1, [Have PTHREAD_PRIO_INHERIT.])) + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + # More AIX lossage: must compile with xlc_r or cc_r + if test x"$GCC" != xyes; then + AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) + else + PTHREAD_CC=$CC + fi +else + PTHREAD_CC="$CC" +fi + +AC_SUBST(PTHREAD_LIBS) +AC_SUBST(PTHREAD_CFLAGS) +AC_SUBST(PTHREAD_CC) + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test x"$ax_pthread_ok" = xyes; then + ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) + : +else + ax_pthread_ok=no + $2 +fi +AC_LANG_POP +])dnl AX_PTHREAD diff --git a/m4/hexversion.m4 b/m4/hexversion.m4 new file mode 100644 index 0000000000..8d26155e59 --- /dev/null +++ b/m4/hexversion.m4 @@ -0,0 +1,6 @@ +AC_DEFUN([CREATE_HEX_VERSION],[ + + HEX_VERSION=`echo $VERSION | sed 's|[\-a-z0-9]*$||' | \ + awk -F. '{printf "0x%0.2d%0.3d%0.3d", $[]1, $[]2, $[]3}'` + AC_SUBST([HEX_VERSION]) +]) diff --git a/m4/pandora_visibility.m4 b/m4/visibility.m4 similarity index 60% rename from m4/pandora_visibility.m4 rename to m4/visibility.m4 index 9c4ab3a369..077c4765ec 100644 --- a/m4/pandora_visibility.m4 +++ b/m4/visibility.m4 @@ -1,5 +1,5 @@ -dnl Copyright (C) 2005, 2008 Free Software Foundation, Inc. -dnl Copyright (C) 2009 Monty Taylor +# visibility.m4 serial 3 (gettext-0.18) +dnl Copyright (C) 2005, 2008-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -20,21 +20,43 @@ dnl "really only recommended for legacy code". dnl Set the variable CFLAG_VISIBILITY. dnl Defines and sets the variable HAVE_VISIBILITY. -AC_DEFUN([PANDORA_VISIBILITY], +AC_DEFUN([gl_VISIBILITY], [ AC_REQUIRE([AC_PROG_CC]) CFLAG_VISIBILITY= HAVE_VISIBILITY=0 - AS_IF([test -n "$GCC"],[ + if test -n "$GCC"; then + dnl First, check whether -Werror can be added to the command line, or + dnl whether it leads to an error because of some other option that the + dnl user has put into $CC $CFLAGS $CPPFLAGS. + AC_MSG_CHECKING([whether the -Werror option is usable]) + AC_CACHE_VAL([gl_cv_cc_vis_werror], [ + gl_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror" + AC_TRY_COMPILE([], [], + [gl_cv_cc_vis_werror=yes], + [gl_cv_cc_vis_werror=no]) + CFLAGS="$gl_save_CFLAGS"]) + AC_MSG_RESULT([$gl_cv_cc_vis_werror]) + dnl Now check whether visibility declarations are supported. AC_MSG_CHECKING([for simple visibility declarations]) AC_CACHE_VAL([gl_cv_cc_visibility], [ gl_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fvisibility=hidden" + dnl We use the option -Werror and a function dummyfunc, because on some + dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning + dnl "visibility attribute not supported in this configuration; ignored" + dnl at the first function definition in every compilation unit, and we + dnl don't want to use the option in this case. + if test $gl_cv_cc_vis_werror = yes; then + CFLAGS="$CFLAGS -Werror" + fi AC_TRY_COMPILE( [extern __attribute__((__visibility__("hidden"))) int hiddenvar; extern __attribute__((__visibility__("default"))) int exportedvar; extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); - extern __attribute__((__visibility__("default"))) int exportedfunc (void);], + extern __attribute__((__visibility__("default"))) int exportedfunc (void); + void dummyfunc (void) {}], [], [gl_cv_cc_visibility=yes], [gl_cv_cc_visibility=no]) @@ -44,11 +66,7 @@ AC_DEFUN([PANDORA_VISIBILITY], CFLAG_VISIBILITY="-fvisibility=hidden" HAVE_VISIBILITY=1 fi - ]) - AS_IF([test "x$SUNCC" = "xyes"],[ - CFLAG_VISIBILITY="-xldscope=hidden" - HAVE_VISIBILITY=1 - ]) + fi AC_SUBST([CFLAG_VISIBILITY]) AC_SUBST([HAVE_VISIBILITY]) AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY], diff --git a/testsuite/quit b/quit similarity index 100% rename from testsuite/quit rename to quit diff --git a/src/cyassl_int.c b/src/cyassl_int.c index cfb52ade77..de807e05c1 100644 --- a/src/cyassl_int.c +++ b/src/cyassl_int.c @@ -20,9 +20,11 @@ */ -#include "cyassl_int.h" -#include "cyassl_error.h" -#include "ctc_asn.h" +#include + +#include +#include +#include #ifdef HAVE_LIBZ #include "zlib.h" @@ -1829,7 +1831,7 @@ static INLINE void Encrypt(SSL* ssl, byte* out, const byte* input, word32 sz) break; #endif - #ifdef BUILD_HC128 + #if HAVE_HC128 case hc128: Hc128_Process(&ssl->encrypt.hc128, out, input, sz); break; @@ -1868,7 +1870,7 @@ static INLINE void Decrypt(SSL* ssl, byte* plain, const byte* input, word32 sz) break; #endif - #ifdef BUILD_HC128 + #if HAVE_HC128 case hc128: Hc128_Process(&ssl->decrypt.hc128, plain, input, sz); break; diff --git a/src/cyassl_io.c b/src/cyassl_io.c index be8d0cb50b..bc4a26cc76 100644 --- a/src/cyassl_io.c +++ b/src/cyassl_io.c @@ -19,13 +19,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include #ifdef _WIN32_WCE /* On WinCE winsock2.h must be included before windows.h for socket stuff */ #include #endif -#include "cyassl_int.h" +#include /* if user writes own I/O callbacks they can define CYASSL_USER_IO to remove automatic setting of default I/O functions EmbedSend() and EmbedReceive() diff --git a/src/include.am b/src/include.am index a9257749f8..c4adc81547 100644 --- a/src/include.am +++ b/src/include.am @@ -2,25 +2,35 @@ # included from Top Level Makefile.am # All paths should be given relative to the root - - -INCLUDES = -Iinclude -Ictaocrypt/include -Iinclude/openssl - -lib_LTLIBRARIES = src/libcyassl.la +lib_LTLIBRARIES+= src/libcyassl.la src_libcyassl_la_SOURCES = \ - src/cyassl_int.c src/cyassl_io.c src/keys.c src/ssl.c src/tls.c \ - ctaocrypt/src/asn.c ctaocrypt/src/coding.c ctaocrypt/src/des3.c \ - ctaocrypt/src/hmac.c ctaocrypt/src/md5.c ctaocrypt/src/md4.c \ - ctaocrypt/src/random.c ctaocrypt/src/rsa.c ctaocrypt/src/sha.c \ - ctaocrypt/src/aes.c ctaocrypt/src/sha256.c ctaocrypt/src/dh.c \ - ctaocrypt/src/dsa.c ctaocrypt/src/arc4.c ctaocrypt/src/rabbit.c \ - ctaocrypt/src/pwdbased.c ctaocrypt/src/logging.c \ - ctaocrypt/src/cyassl_memory.c -src_libcyassl_la_LDFLAGS = -no-undefined -version-info ${CYASSL_LIBRARY_VERSION} -src_libcyassl_la_CFLAGS = -DBUILDING_CYASSL -EXTRA_DIST += include/*.h include/openssl/*.h include/*.rc \ - ctaocrypt/include/*.h ctaocrypt/src/ctc_misc.c \ - ctaocrypt/src/ctc_asm.c ctaocrypt/src/*.i + src/cyassl_int.c \ + src/cyassl_io.c \ + src/keys.c \ + src/ssl.c \ + src/tls.c \ + ctaocrypt/src/asn.c \ + ctaocrypt/src/coding.c \ + ctaocrypt/src/des3.c \ + ctaocrypt/src/hmac.c \ + ctaocrypt/src/md5.c \ + ctaocrypt/src/md4.c \ + ctaocrypt/src/random.c \ + ctaocrypt/src/rsa.c \ + ctaocrypt/src/sha.c \ + ctaocrypt/src/aes.c \ + ctaocrypt/src/sha256.c \ + ctaocrypt/src/dh.c \ + ctaocrypt/src/dsa.c \ + ctaocrypt/src/arc4.c \ + ctaocrypt/src/rabbit.c \ + ctaocrypt/src/pwdbased.c \ + ctaocrypt/src/logging.c \ + ctaocrypt/src/cyassl_memory.c +src_libcyassl_la_LDFLAGS = ${AM_LDFLAGS} -no-undefined -version-info ${CYASSL_LIBRARY_VERSION} +src_libcyassl_la_LIBADD = $(LIBM) +src_libcyassl_la_CFLAGS = -DBUILDING_CYASSL $(AM_CFLAGS) +src_libcyassl_la_CPPFLAGS = -DBUILDING_CYASSL $(AM_CPPFLAGS) if BUILD_AESNI src_libcyassl_la_SOURCES += ctaocrypt/src/aes_asm.s diff --git a/src/keys.c b/src/keys.c index 7252a54eb7..a34bf75e24 100644 --- a/src/keys.c +++ b/src/keys.c @@ -20,8 +20,10 @@ */ -#include "cyassl_int.h" -#include "cyassl_error.h" +#include + +#include +#include #ifdef SHOW_SECRETS #include #endif @@ -561,7 +563,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, } #endif -#ifdef BUILD_HC128 +#if HAVE_HC128 if (specs->bulk_cipher_algorithm == hc128) { if (side == CLIENT_END) { Hc128_SetKey(&enc->hc128, keys->client_write_key, diff --git a/src/sniffer.c b/src/sniffer.c index 50f22020c3..bddfc02ce9 100644 --- a/src/sniffer.c +++ b/src/sniffer.c @@ -19,29 +19,28 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include -#ifdef CYASSL_SNIFFER - -#include "ssl.h" -#include "cyassl_int.h" -#include "cyassl_error.h" -#include "sniffer.h" -#include "sniffer_error.h" +#include #include #ifndef _WIN32 - #include + #include #endif -#include - - #ifdef _WIN32 #define SNPRINTF _snprintf #else #define SNPRINTF snprintf #endif +#ifdef CYASSL_SNIFFER + +#include +#include +#include +#include +#include /* Misc constants */ enum { @@ -1316,7 +1315,7 @@ static void Decrypt(SSL* ssl, byte* output, const byte* input, word32 sz) break; #endif - #ifdef BUILD_HC128 + #ifdef HAVE_HC128 case hc128: Hc128_Process(&ssl->decrypt.hc128, output, input, sz); break; diff --git a/src/ssl.c b/src/ssl.c index bd567688dc..6d7bc19795 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -19,35 +19,36 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include -#include "ssl.h" -#include "cyassl_int.h" -#include "cyassl_error.h" -#include "ctc_coding.h" +#ifdef HAVE_ERRNO_H + #include +#endif + +#define TRUE 1 +#define FALSE 0 + +#include +#include +#include +#include #if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) - #include "evp.h" + #include #endif #ifdef OPENSSL_EXTRA /* openssl headers begin */ - #include "hmac.h" - #include "crypto.h" - #include "des.h" + #include + #include + #include /* openssl headers end, cyassl internal headers next */ - #include "ctc_hmac.h" - #include "ctc_random.h" - #include "ctc_des3.h" - #include "ctc_md4.h" + #include + #include + #include + #include #endif -#ifdef HAVE_ERRNO_H - #include -#endif - -#define TRUE 1 -#define FALSE 0 - #ifndef min diff --git a/src/tls.c b/src/tls.c index 2dced68f9c..a2f71d92f7 100644 --- a/src/tls.c +++ b/src/tls.c @@ -19,11 +19,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include -#include "ssl.h" -#include "cyassl_int.h" -#include "cyassl_error.h" -#include "ctc_hmac.h" +#include +#include +#include +#include diff --git a/sslSniffer/sslSnifferTest/include.am b/sslSniffer/sslSnifferTest/include.am index 480d73360c..cf2ed1c78d 100644 --- a/sslSniffer/sslSnifferTest/include.am +++ b/sslSniffer/sslSnifferTest/include.am @@ -2,13 +2,11 @@ # included from Top Level Makefile.am # All paths should be given relative to the root - -bin_PROGRAMS += sslSniffer/sslSnifferTest/snifftest -sslSniffer_sslSnifferTest_snifftest_SOURCES = \ - sslSniffer/sslSnifferTest/snifftest.c -sslSniffer_sslSnifferTest_snifftest_LDFLAGS = -Lsrc +noinst_PROGRAMS += sslSniffer/sslSnifferTest/snifftest +sslSniffer_sslSnifferTest_snifftest_SOURCES = sslSniffer/sslSnifferTest/snifftest.c if BUILD_SNIFFER sslSniffer_sslSnifferTest_snifftest_LDADD = src/libcyassl.la -lpcap sslSniffer_sslSnifferTest_snifftest_DEPENDENCIES = src/libcyassl.la endif -EXTRA_DIST += sslSniffer/*.vcproj sslSniffer/sslSnifferTest/*.vcproj +EXTRA_DIST += sslSniffer/sslSniffer.vcproj +EXTRA_DIST += sslSniffer/sslSnifferTest/sslSniffTest.vcproj diff --git a/sslSniffer/sslSnifferTest/snifftest.c b/sslSniffer/sslSnifferTest/snifftest.c index ad32c2fb57..ffa9f9ee71 100755 --- a/sslSniffer/sslSnifferTest/snifftest.c +++ b/sslSniffer/sslSnifferTest/snifftest.c @@ -19,6 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include #ifdef _WIN32 #define CYASSL_SNIFFER @@ -28,10 +29,11 @@ /* blank build */ #include +#include int main() { printf("do ./configure --enable-sniffer to enable build support\n"); - return 0; + return EXIT_SUCCESS; } #else @@ -228,7 +230,7 @@ int main(int argc, char** argv) } } - return 0; + return EXIT_SUCCESS; } #endif /* full build */ diff --git a/stamp-h.in b/stamp-h.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/support/include.am b/support/include.am new file mode 100644 index 0000000000..a273632e33 --- /dev/null +++ b/support/include.am @@ -0,0 +1,8 @@ +# vim:ft=automake +# All paths should be given relative to the root +# + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = support/libcyassl.pc + + diff --git a/support/libcyassl.pc.in b/support/libcyassl.pc.in new file mode 100644 index 0000000000..ad469bc485 --- /dev/null +++ b/support/libcyassl.pc.in @@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: cyassl +Description: cyassl C library. +Version: @VERSION@ +Libs: -L${libdir} -lcyassl +Cflags: -I${includedir} diff --git a/swig/cyassl_adds.c b/swig/cyassl_adds.c index 65a7aba6f9..c1d4660f0b 100644 --- a/swig/cyassl_adds.c +++ b/swig/cyassl_adds.c @@ -19,14 +19,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include #ifndef _WIN32 #define HAVE_CONFIG_H #endif -#include "openssl/ssl.h" -#include "ctc_rsa.h" -#include "ctc_asn.h" +#include +#include +#include #include #include diff --git a/swig/include.am b/swig/include.am new file mode 100644 index 0000000000..32adb5b8f9 --- /dev/null +++ b/swig/include.am @@ -0,0 +1,12 @@ +# vim:ft=automake +# All paths should be given relative to the root + +EXTRA_DIST+= \ + swig/PythonBuild.sh \ + swig/README \ + swig/cyassl.i \ + swig/cyassl_adds.c \ + swig/python_cyassl.vcproj \ + swig/rsasign.py \ + swig/runme.py + diff --git a/testsuite/include.am b/testsuite/include.am index 83a92ec0a4..1772ac1241 100644 --- a/testsuite/include.am +++ b/testsuite/include.am @@ -3,13 +3,20 @@ # All paths should be given relative to the root -bin_PROGRAMS += testsuite/testsuite -testsuite_testsuite_SOURCES = testsuite/testsuite.c ctaocrypt/test/test.c \ - examples/client/client.c examples/server/server.c \ - examples/echoclient/echoclient.c examples/echoserver/echoserver.c -testsuite_testsuite_CFLAGS = -DNO_MAIN_DRIVER -testsuite_testsuite_LDFLAGS = -Lsrc -testsuite_testsuite_LDADD = src/libcyassl.la +check_PROGRAMS += testsuite/testsuite +noinst_PROGRAMS += testsuite/testsuite +testsuite_testsuite_SOURCES = \ + ctaocrypt/test/test.c \ + examples/client/client.c \ + examples/echoclient/echoclient.c \ + examples/echoserver/echoserver.c \ + examples/server/server.c \ + testsuite/testsuite.c +testsuite_testsuite_CFLAGS = -DNO_MAIN_DRIVER $(AM_CFLAGS) $(PTHREAD_CFLAGS) +testsuite_testsuite_LDADD = src/libcyassl.la $(PTHREAD_LIBS) testsuite_testsuite_DEPENDENCIES = src/libcyassl.la -EXTRA_DIST += testsuite/testsuite.sln testsuite/*.vcproj testsuite/input \ - testsuite/quit +EXTRA_DIST += testsuite/testsuite.sln +EXTRA_DIST += testsuite/testsuite-ntru.vcproj +EXTRA_DIST += testsuite/testsuite.vcproj +EXTRA_DIST += input +EXTRA_DIST += quit diff --git a/testsuite/input b/testsuite/input deleted file mode 100644 index 06dbbf0764..0000000000 --- a/testsuite/input +++ /dev/null @@ -1,87 +0,0 @@ -/* echoclient.c */ - -#include "openssl/ssl.h" -#include "../test.h" - - -int main(int argc, char** argv) -{ - SOCKET_T sockfd = 0; - - FILE* fin = stdin; - FILE* fout = stdout; - - int inCreated = 0; - int outCreated = 0; - - char send[1024]; - char reply[1024]; - - SSL_METHOD* method = 0; - SSL_CTX* ctx = 0; - SSL* ssl = 0; - -#ifdef _WIN32 - WSADATA wsd; - WSAStartup(0x0002, &wsd); -#endif - - if (argc >= 2) { - fin = fopen(argv[1], "r"); - inCreated = 1; - } - if (argc >= 3) { - fout = fopen(argv[2], "w"); - outCreated = 1; - } - - if (!fin) err_sys("can't open input file"); - if (!fout) err_sys("can't open output file"); - - tcp_connect(&sockfd); - - method = SSLv3_client_method(); - ctx = SSL_CTX_new(method); - - if (SSL_CTX_load_verify_locations(ctx, caCert, 0) != SSL_SUCCESS) - err_sys("can't load ca file"); - - ssl = SSL_new(ctx); - - SSL_set_fd(ssl, sockfd); - if (SSL_connect(ssl) != SSL_SUCCESS) err_sys("SSL_connect failed"); - - while (fgets(send, sizeof(send), fin)) { - - int sendSz = strlen(send) + 1; - - if (SSL_write(ssl, send, sendSz) != sendSz) - err_sys("SSL_write failed"); - - if (strncmp(send, "quit", 4) == 0) { - fputs("sending server shutdown command: quit!\n", fout); - break; - } - - if (SSL_read(ssl, reply, sizeof(reply)) > 0) - fputs(reply, fout); - } - - SSL_shutdown(ssl); - SSL_free(ssl); - SSL_CTX_free(ctx); - - fflush(fout); - if (inCreated) fclose(fin); - if (outCreated) fclose(fout); - -#ifdef _WIN32 - closesocket(sockfd); -#else - close(sockfd); -#endif - - return 0; -} - - diff --git a/testsuite/testsuite.c b/testsuite/testsuite.c index 508c2dd2c1..c3f0511436 100644 --- a/testsuite/testsuite.c +++ b/testsuite/testsuite.c @@ -19,10 +19,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include -#include "ssl.h" -#include "cyassl_test.h" -#include "ctc_md5.h" +#include +#include +#include #ifdef SINGLE_THREADED #error testsuite needs threads to run, please run ctaocrypt/test, \ @@ -126,14 +127,14 @@ int main(int argc, char** argv) file_test("input", input); file_test("output", output); if (memcmp(input, output, sizeof(input)) != 0) - return -1; + return EXIT_FAILURE; } CyaSSL_Cleanup(); FreeTcpReady(&ready); printf("\nAll tests passed!\n"); - return 0; + return EXIT_SUCCESS; } @@ -154,23 +155,24 @@ void wait_tcp_ready(func_args* args) void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread) { -#ifndef _POSIX_THREADS - *thread = (HANDLE)_beginthreadex(0, 0, fun, args, 0, 0); -#else +#ifdef _POSIX_THREADS pthread_create(thread, 0, fun, args); + return; +#else + *thread = (THREAD_TYPE)_beginthreadex(0, 0, fun, args, 0, 0); #endif } void join_thread(THREAD_TYPE thread) { -#ifndef _POSIX_THREADS +#ifdef _POSIX_THREADS + pthread_join(thread, 0); +#else int res = WaitForSingleObject(thread, INFINITE); assert(res == WAIT_OBJECT_0); res = CloseHandle(thread); assert(res); -#else - pthread_join(thread, 0); #endif } @@ -179,8 +181,8 @@ void InitTcpReady(tcp_ready* ready) { ready->ready = 0; #ifdef _POSIX_THREADS - pthread_mutex_init(&ready->mutex, 0); - pthread_cond_init(&ready->cond, 0); + pthread_mutex_init(&ready->mutex, 0); + pthread_cond_init(&ready->cond, 0); #endif }