Merge branch 'master' of github.com:cyassl/cyassl

This commit is contained in:
John Safranek 2013-10-02 15:27:10 -07:00
commit 33bcc76a07
16 changed files with 324 additions and 80 deletions

View File

@ -3,6 +3,15 @@
# Create configure and makefile stuff...
#
# Git hooks should come before autoreconf.
if test -d .git; then
if ! test -d .git/hooks; then
mkdir .git/hooks
fi
ln -s -f ../../pre-commit.sh .git/hooks/pre-commit
fi
# If this is a source checkout then call autoreconf with error as well
if test -d .git; then
WARNINGS="all,error"
else
@ -11,6 +20,3 @@ fi
autoreconf --install --force --verbose
if test -d .git; then
ln -s -f ../../pre-commit.sh .git/hooks/pre-commit
fi

View File

@ -6,25 +6,32 @@
#
#
AC_INIT([cyassl],[2.8.1],[http://www.yassl.com])
AC_INIT([cyassl],[2.8.1],[https://github.com/cyassl/cyassl/issues],[cyassl],[http://www.yassl.com])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
# using $targget_cpu to only turn on fastmath by default on x86_64
AC_CANONICAL_TARGET
AC_USE_SYSTEM_EXTENSIONS
AM_INIT_AUTOMAKE([1.11 -Wall -Werror -Wno-portability foreign tar-ustar subdir-objects])
AC_CANONICAL_HOST
AC_CANONICAL_BUILD
AM_INIT_AUTOMAKE([1.11 -Wall -Werror -Wno-portability foreign tar-ustar subdir-objects no-define color-tests])
AC_PREREQ([2.63])
AC_ARG_PROGRAM
AC_DEFUN([PROTECT_AC_USE_SYSTEM_EXTENSIONS],
[AX_SAVE_FLAGS
AC_LANG_PUSH([C])
AC_USE_SYSTEM_EXTENSIONS
AC_LANG_POP([C])
AX_RESTORE_FLAGS
])
#PROTECT_AC_USE_SYSTEM_EXTENSIONS
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=5:2:0
# | | |
@ -57,8 +64,6 @@ AS_IF([ test -n "$CFLAG_VISIBILITY" ], [
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
AX_CXX_COMPILER_VERSION
AC_CHECK_FUNCS([gethostbyname])
AC_CHECK_FUNCS([getaddrinfo])
AC_CHECK_FUNCS([gettimeofday])

View File

@ -100,6 +100,11 @@
#define XTIME(t1) pic32_time((t1))
#define XGMTIME(c) gmtime((c))
#define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
#elif defined(FREESCALE_MQX)
#include <time.h>
#define XTIME(t1) mqx_time((t1))
#define XGMTIME(c) gmtime((c))
#define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
#elif defined(CYASSL_MDK_ARM)
#include <rtl.h>
#undef RNG
@ -289,6 +294,25 @@ time_t pic32_time(time_t* timer)
#endif /* MICROCHIP_TCPIP */
#ifdef FREESCALE_MQX
time_t mqx_time(time_t* timer)
{
time_t localTime;
TIME_STRUCT time_s;
if (timer == NULL)
timer = &localTime;
_time_get(&time_s);
*timer = (time_t) time_s.SECONDS;
return *timer;
}
#endif /* FREESCALE_MQX */
static INLINE word32 btoi(byte b)
{
return b - 0x30;

View File

@ -487,5 +487,10 @@ static void HmacCaviumSetKey(Hmac* hmac, int type, const byte* key,
#endif /* HAVE_CAVIUM */
int CyaSSL_GetHmacMaxSize(void)
{
return MAX_DIGEST_SIZE;
}
#endif /* NO_HMAC */

View File

@ -3765,7 +3765,7 @@ int mp_sqrmod (mp_int * a, mp_int * b, mp_int * c)
#endif
#if defined(HAVE_ECC) || !defined(NO_PWDBASED)
#if defined(HAVE_ECC) || !defined(NO_PWDBASED) || defined(CYASSL_SNIFFER)
/* single digit addition */
int mp_add_d (mp_int* a, mp_digit b, mp_int* c)

View File

@ -147,6 +147,7 @@ CYASSL_API void HmacFinal(Hmac*, byte*);
CYASSL_API void HmacFreeCavium(Hmac*);
#endif
CYASSL_API int CyaSSL_GetHmacMaxSize(void);
#ifdef __cplusplus
} /* extern "C" */

View File

@ -305,7 +305,7 @@ int mp_init_multi(mp_int* a, mp_int* b, mp_int* c, mp_int* d, mp_int* e,
int mp_lcm (mp_int * a, mp_int * b, mp_int * c);
#endif
#if defined(HAVE_ECC) || !defined(NO_PWDBASED)
#if defined(HAVE_ECC) || !defined(NO_PWDBASED) || defined(CYASSL_SNIFFER)
int mp_sub_d (mp_int * a, mp_digit b, mp_int * c);
#endif

View File

@ -144,6 +144,13 @@
#define NO_HC128
#endif /* MBED */
#ifdef CYASSL_TYTO
#define FREERTOS
#define NO_FILESYSTEM
#define CYASSL_USER_IO
#define NO_DEV_RANDOM
#endif
#ifdef FREERTOS_WINSIM
#define FREERTOS
#define USE_WINDOWS_API

View File

@ -19,9 +19,9 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 7
#serial 8
AC_DEFUN([AX_APPEND_TO_FILE],[
AC_REQUIRE([AX_FILE_ESCAPES])
printf "$2" >> "$1"
printf "$2\n" >> "$1"
])

95
m4/ax_check_library.m4 Normal file
View File

@ -0,0 +1,95 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_library.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_LIBRARY(VARIABLE-PREFIX, HEADER-FILE, LIBRARY-FILE,
# [ACTION-IF-FOUND], [ACTION-IF-NOT_FOUND])
#
# DESCRIPTION
#
# Provides a generic test for a given library, similar in concept to the
# PKG_CHECK_MODULES macro used by pkg-config.
#
# Most simplest libraries can be checked against simply through the
# presence of a header file and a library to link to. This macro allows to
# wrap around the test so that it doesn't have to be recreated each time.
#
# Rather than define --with-$LIBRARY arguments, it uses variables in the
# same way that PKG_CHECK_MODULES does. It doesn't, though, use the same
# names, since you shouldn't provide a value for LIBS or CFLAGS but rather
# for LDFLAGS and CPPFLAGS, to tell the linker and compiler where to find
# libraries and headers respectively.
#
# If the library is find, HAVE_PREFIX is defined, and in all cases
# PREFIX_LDFLAGS and PREFIX_CPPFLAGS are substituted.
#
# Example:
#
# AX_CHECK_LIBRARY([LIBEVENT], [event.h], [event], [],
# [AC_MSG_ERROR([Unable to find libevent])])
#
# LICENSE
#
# Copyright (c) 2012 Brian Aker <brian@tangent.org>
# Copyright (c) 2010 Diego Elio Petteno` <flameeyes@gmail.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
# 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 7
AC_DEFUN([AX_CHECK_LIBRARY],
[AC_ARG_VAR($1[_CPPFLAGS],[C preprocessor flags for ]$1[ headers])
AC_ARG_VAR($1[_LDFLAGS],[linker flags for ]$1[ libraries])
AC_CACHE_VAL(AS_TR_SH([ax_cv_have_]$1),
[AX_SAVE_FLAGS
AS_IF([test "x$]$1[_CPPFLAGS" != "x"],
[CPPFLAGS="$CPPFLAGS $]$1[_CPPFLAGS"])
AS_IF([test "x$]$1[_LDFLAGS" != "x"],
[LDFLAGS="$LDFLAGS $]$1[_LDFLAGS"])
AC_CHECK_HEADER($2, [
AC_CHECK_LIB($3, [main],
[AS_TR_SH([ax_cv_have_]$1)=yes],
[AS_TR_SH([ax_cv_have_]$1)=no])
], [AS_TR_SH([ax_cv_have_]$1)=no])
AX_RESTORE_FLAGS
])
AS_IF([test "$]AS_TR_SH([ax_cv_have_]$1)[" = "yes"],
[AC_DEFINE([HAVE_]$1, [1], [Define to 1 if ]$1[ is found])
AC_SUBST($1[_CPPFLAGS])
AC_SUBST($1[_LDFLAGS])
AC_SUBST($1[_LIB],[-l]$3)
ifelse([$4], , :, [$4])],
[ifelse([$5], , :, [$5])])
])

View File

@ -1,36 +1,100 @@
AC_DEFUN([AX_C_COMPILER_VERSION],[
# ===========================================================================
# https://github.com/BrianAker/ddm4/
# ===========================================================================
#
# SYNOPSIS
#
# AX_COMPILER_VERSION()
#
# DESCRIPTION
#
# Capture version of C/C++ compiler
#
# LICENSE
#
# Copyright (C) 2012 Brian Aker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
#
# * The names of its contributors may not be used to endorse or
# promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dnl Print version of C compiler
AC_MSG_CHECKING("C Compiler version--$GCC")
AS_IF([test "$GCC" = "yes"],[
CC_VERSION=`$CC --version | sed 1q` ],[
test "$SUNCC" = "yes"],[
CC_VERSION=`$CC -V 2>&1 | sed 1q` ],[
test "$CLANG" = "yes"],[
CC_VERSION=`$CC --version 2>&1 | sed 1q` ],[
CC_VERSION=""
])
AC_MSG_RESULT("$CC_VERSION")
AC_SUBST(CC_VERSION)
])
#serial 5
AC_DEFUN([_C_COMPILER_VERSION],
[AC_MSG_CHECKING([C Compiler version])
AS_CASE(["$ax_cv_c_compiler_vendor"],
[sun],[ax_c_compiler_version=`$CC -V 2>&1 | sed 1q`],
[intel],[ax_c_compiler_version=`$CC --version 2>&1 | sed 1q`],
[clang],[ax_c_compiler_version=`$CC --version 2>&1 | sed 1q`],
[gnu],[ax_c_compiler_version=`$CC --version | sed 1q`],
[mingw],[ax_c_compiler_version=`$CC --version | sed 1q`],
[ax_c_compiler_version="unknown: $ax_cv_c_compiler_vendor"])
AC_DEFUN([AX_CXX_COMPILER_VERSION], [
dnl Check C version while at it
AC_REQUIRE([AX_C_COMPILER_VERSION])
dnl Print version of CXX compiler
AC_MSG_CHECKING("C++ Compiler version")
AS_IF([test "$GCC" = "yes"],[
CXX_VERSION=`$CXX --version | sed 1q` ],[
test "$SUNCC" = "yes"],[
CXX_VERSION=`$CXX -V 2>&1 | sed 1q` ],[
test "$CLANG" = "yes"],[
CXX_VERSION=`$CXX --version 2>&1 | sed 1q` ],[
CXX_VERSION=""
])
AC_MSG_RESULT("$CXX_VERSION")
AC_SUBST(CXX_VERSION)
AC_MSG_RESULT(["$ax_c_compiler_version"])
AC_SUBST([CC_VERSION_VENDOR],["$ax_cv_c_compiler_vendor"])
AC_SUBST([CC_VERSION],["$ax_c_compiler_version"])
])
AC_DEFUN([_CXX_COMPILER_VERSION],
[AC_MSG_CHECKING([C++ Compiler version])
AS_CASE(["$ax_cv_c_compiler_vendor"],
[sun],[ax_cxx_compiler_version=`$CXX -V 2>&1 | sed 1q`],
[intel],[ax_cxx_compiler_version=`$CXX --version 2>&1 | sed 1q`],
[clang],[ax_cxx_compiler_version=`$CXX --version 2>&1 | sed 1q`],
[gnu],[ax_cxx_compiler_version=`$CXX --version | sed 1q`],
[mingw],[ax_cxx_compiler_version=`$CXX --version | sed 1q`],
[ax_cxx_compiler_version="unknown: $ax_cv_c_compiler_vendor"])
AC_MSG_RESULT(["$ax_cxx_compiler_version"])
AC_SUBST([CXX_VERSION_VENDOR],["$ax_cv_c_compiler_vendor"])
AC_SUBST([CXX_VERSION],["$ax_cxx_compiler_version"])
])
AC_DEFUN([AX_COMPILER_VERSION],
[AC_REQUIRE([AX_COMPILER_VENDOR])
AC_MSG_CHECKING([MINGW])
AC_CHECK_DECL([__MINGW32__],
[MINGW=yes
ax_c_compiler_version_vendor=mingw],
[MINGW=no])
AC_MSG_RESULT([$MINGW])
AC_REQUIRE([_C_COMPILER_VERSION])
AC_REQUIRE([_CXX_COMPILER_VERSION])
AS_IF([test "x$GCC" = xyes],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if !defined(__GNUC__) || (__GNUC__ < 4) || ((__GNUC__ >= 4) && (__GNUC_MINOR__ < 7))
# error GCC is Too Old!
#endif
]])],
[ac_c_gcc_recent=yes],
[ac_c_gcc_recent=no])
])
])

View File

@ -43,19 +43,22 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#serial 2
#serial 6
AC_DEFUN([AX_DEBUG],[
AC_DEFUN([AX_DEBUG],
[AC_PREREQ([2.63])dnl
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])],[
ax_enable_debug=$enableval
AC_DEFINE(DEBUG, [ 1 ], [Define to 1 to enable debugging code.])
],[
ax_enable_debug=no
AC_DEFINE(DEBUG, [ 0 ], [Define to 1 to enable debugging code.])
])
[Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])],
[ax_enable_debug=yes
AC_DEFINE([DEBUG],[1],[Define to 1 to enable debugging code.])
AX_CHECK_LIBRARY([MCHECK],[mcheck.h],[mcheck],[AX_APPEND_LINK_FLAGS([-lmcheck])])
AX_ADD_AM_MACRO([--debug],[AM_YFLAGS])
AX_ADD_AM_MACRO([-D_GLIBCXX_DEBUG],[AM_CPPFLAGS])],
[ax_enable_debug=no
AC_SUBST([MCHECK])
AC_DEFINE([DEBUG],[0],[Define to 1 to enable debugging code.])])
AC_MSG_CHECKING([for debug])
AC_MSG_RESULT([$ax_enable_debug])
])
AM_CONDITIONAL([DEBUG],[test "x${ax_enable_debug}" = "xyes"])])

View File

@ -67,7 +67,6 @@
AC_REQUIRE([AX_CHECK_LINK_FLAG])
AC_REQUIRE([AX_VCS_CHECKOUT])
AC_REQUIRE([AX_DEBUG])
AC_REQUIRE([AX_CXX_COMPILER_VERSION])
dnl If we are inside of VCS we append -Werror, otherwise we just use it to test other flags
AX_HARDEN_LIB=

View File

@ -82,7 +82,7 @@
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 19
#serial 20
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [
@ -159,12 +159,12 @@ case ${host_os} in
ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
;;
darwin12* | darwin11.4*)
ax_pthread_flags="$ax_pthread_flags"
;;
darwin*)
ax_pthread_flags="-pthreads $ax_pthread_flags"
if test "$CC" = "clang"; then
ax_pthread_flags="$ax_pthread_flags"
else
ax_pthread_flags="-pthread $ax_pthread_flags"
fi
;;
esac
@ -287,16 +287,24 @@ if test "x$ax_pthread_ok" = xyes; then
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
# More AIX lossage: compile with *_r variant
if test "x$GCC" != xyes; then
case $host_os in
aix*)
AS_CASE(["x/$CC"],
[x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
[#handle absolute path differently from PATH based program lookup
AS_CASE(["x$CC"],
[x/*],
[AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
[AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
;;
esac
fi
else
PTHREAD_CC="$CC"
fi
test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
AC_SUBST(PTHREAD_LIBS)
AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_CC)

View File

@ -45,15 +45,31 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#serial 1
AC_DEFUN([AX_VCS_CHECKOUT],[
AC_CACHE_CHECK([for vcs checkout], [ac_cv_vcs_checkout], [
AS_IF([test -d ".bzr"],[ac_cv_vcs_checkout=yes])
AS_IF([test -d ".svn"],[ac_cv_vcs_checkout=yes])
AS_IF([test -d ".hg"], [ac_cv_vcs_checkout=yes])
AS_IF([test -d ".git"],[ac_cv_vcs_checkout=yes])
#serial 6
AC_DEFUN([AX_VCS_SYSTEM],
[AC_PREREQ([2.63])dnl
AC_CACHE_CHECK([for vcs system], [ac_cv_vcs_system],
[ac_cv_vcs_system="none"
AS_IF([test -d ".bzr"],[ac_cv_vcs_system="bazaar"])
AS_IF([test -d ".svn"],[ac_cv_vcs_system="svn"])
AS_IF([test -d ".hg"],[ac_cv_vcs_system="mercurial"])
AS_IF([test -d ".git"],[ac_cv_vcs_system="git"])
])
AC_DEFINE_UNQUOTED([VCS_SYSTEM],["$ac_cv_vcs_system"],[VCS system])
])
AC_DEFUN([AX_VCS_CHECKOUT],
[AC_PREREQ([2.63])dnl
AC_REQUIRE([AX_VCS_SYSTEM])
AC_CACHE_CHECK([for vcs checkout],[ac_cv_vcs_checkout],
[AS_IF([test "x$ac_cv_vcs_system" != "xnone"],
[ac_cv_vcs_checkout=yes],
[ac_cv_vcs_checkout=no])
])
AS_IF([test "$ac_cv_vcs_checkout" = yes], [])
AM_CONDITIONAL([IS_VCS_CHECKOUT],[test "x$ac_cv_vcs_checkout" = "xyes"])
AS_IF([test "x$ac_cv_vcs_checkout" = "xyes"],
[AC_DEFINE([VCS_CHECKOUT],[1],[Define if the code was built from VCS.])],
[AC_DEFINE([VCS_CHECKOUT],[0],[Define if the code was built from VCS.])])
])

View File

@ -2216,6 +2216,17 @@ ProtocolVersion MakeDTLSv1_2(void)
return (word32) SYS_TICK_Get();
}
#elif defined(FREESCALE_MQX)
word32 LowResTimer(void)
{
TIME_STRUCT mqxTime;
_time_get_elapsed(&mqxTime);
return (word32) mqxTime.SECONDS;
}
#elif defined(USER_TICKS)
#if 0