debugging linking error

This commit is contained in:
Jacob Barthelmeh 2014-12-19 15:30:07 -07:00
parent 626a4f318e
commit 5107c6c12b
15 changed files with 938 additions and 37 deletions

View File

@ -60,8 +60,8 @@ EXTRA_DIST+= README.md
EXTRA_DIST+= LICENSING
#-------------------------------------#
include cyassl/include.am
include wolfssl/include.am
include cyassl/include.am
#-------------------------------------#
include certs/include.am
include certs/1024/include.am
@ -72,14 +72,14 @@ include swig/include.am
include src/include.am
include support/include.am
#-------------------------------------#
include ctaocrypt/benchmark/include.am
include wolfcrypt/benchmark/include.am
include ctaocrypt/benchmark/include.am
#-------------------------------------#
include ctaocrypt/src/include.am
include wolfcrypt/src/include.am
include ctaocrypt/src/include.am
#-------------------------------------#
include ctaocrypt/test/include.am
include wolfcrypt/test/include.am
include ctaocrypt/test/include.am
#-------------------------------------#
include examples/client/include.am
include examples/server/include.am

View File

@ -93,6 +93,154 @@
/* 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy */
#pragma warning(disable: 4996)
#endif
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/types.h>
#ifdef HAVE_CAVIUM
static void wc_Arc4CaviumSetKey(Arc4* arc4, const byte* key, word32 length);
static void wc_Arc4CaviumProcess(Arc4* arc4, byte* out, const byte* in,
word32 length);
#endif
void wc_Arc4SetKey(Arc4* arc4, const byte* key, word32 length)
{
word32 i;
word32 keyIndex = 0, stateIndex = 0;
#ifdef HAVE_CAVIUM
if (arc4->magic == WOLFSSL_ARC4_CAVIUM_MAGIC)
return wc_Arc4CaviumSetKey(arc4, key, length);
#endif
arc4->x = 1;
arc4->y = 0;
for (i = 0; i < ARC4_STATE_SIZE; i++)
arc4->state[i] = (byte)i;
for (i = 0; i < ARC4_STATE_SIZE; i++) {
word32 a = arc4->state[i];
stateIndex += key[keyIndex] + a;
stateIndex &= 0xFF;
arc4->state[i] = arc4->state[stateIndex];
arc4->state[stateIndex] = (byte)a;
if (++keyIndex >= length)
keyIndex = 0;
}
}
static INLINE byte MakeByte(word32* x, word32* y, byte* s)
{
word32 a = s[*x], b;
*y = (*y+a) & 0xff;
b = s[*y];
s[*x] = (byte)b;
s[*y] = (byte)a;
*x = (*x+1) & 0xff;
return s[(a+b) & 0xff];
}
void wc_Arc4Process(Arc4* arc4, byte* out, const byte* in, word32 length)
{
word32 x;
word32 y;
#ifdef HAVE_CAVIUM
if (arc4->magic == WOLFSSL_ARC4_CAVIUM_MAGIC)
return wc_Arc4CaviumProcess(arc4, out, in, length);
#endif
x = arc4->x;
y = arc4->y;
while(length--)
*out++ = *in++ ^ MakeByte(&x, &y, arc4->state);
arc4->x = (byte)x;
arc4->y = (byte)y;
}
#ifdef HAVE_CAVIUM
#include <cyassl/ctaocrypt/logging.h>
#include "cavium_common.h"
/* Initiliaze Arc4 for use with Nitrox device */
int wc_Arc4InitCavium(Arc4* arc4, int devId)
{
if (arc4 == NULL)
return -1;
if (CspAllocContext(CONTEXT_SSL, &arc4->contextHandle, devId) != 0)
return -1;
arc4->devId = devId;
arc4->magic = WOLFSSL_ARC4_CAVIUM_MAGIC;
return 0;
}
/* Free Arc4 from use with Nitrox device */
void wc_Arc4FreeCavium(Arc4* arc4)
{
if (arc4 == NULL)
return;
if (arc4->magic != WOLFSSL_ARC4_CAVIUM_MAGIC)
return;
CspFreeContext(CONTEXT_SSL, arc4->contextHandle, arc4->devId);
arc4->magic = 0;
}
static void wc_Arc4CaviumSetKey(Arc4* arc4, const byte* key, word32 length)
{
word32 requestId;
if (CspInitializeRc4(CAVIUM_BLOCKING, arc4->contextHandle, length,
(byte*)key, &requestId, arc4->devId) != 0) {
WOLFSSL_MSG("Bad Cavium Arc4 Init");
}
}
static void wc_Arc4CaviumProcess(Arc4* arc4, byte* out, const byte* in,
word32 length)
{
cyassl_word offset = 0;
word32 requestId;
while (length > WOLFSSL_MAX_16BIT) {
word16 slen = (word16)WOLFSSL_MAX_16BIT;
if (CspEncryptRc4(CAVIUM_BLOCKING, arc4->contextHandle,CAVIUM_UPDATE,
slen, (byte*)in + offset, out + offset, &requestId,
arc4->devId) != 0) {
WOLFSSL_MSG("Bad Cavium Arc4 Encrypt");
}
length -= WOLFSSL_MAX_16BIT;
offset += WOLFSSL_MAX_16BIT;
}
if (length) {
word16 slen = (word16)length;
if (CspEncryptRc4(CAVIUM_BLOCKING, arc4->contextHandle,CAVIUM_UPDATE,
slen, (byte*)in + offset, out + offset, &requestId,
arc4->devId) != 0) {
WOLFSSL_MSG("Bad Cavium Arc4 Encrypt");
}
}
}
#endif /* HAVE_CAVIUM */
void bench_des(void);
void bench_arc4(void);

View File

@ -22,6 +22,8 @@
/* wolfssl_cyassl compatibility layer */
#include <cyassl/ssl.h>
#include <wolfssl/wolfcrypt/arc4.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

View File

@ -386,6 +386,8 @@
#define CYASSL_SMALL_STACK
#endif
#undef WOLFSSL_API
#define WOLFSSL_API CYASSL_API
#define WOLFSSL_ENTER(x) CYASSL_ENTER(x) /* @TODO*/
#define WOLFSSL_BIT_SIZE CYASSL_BIT_SIZE /* @TODO*/
@ -399,7 +401,8 @@
/* for arc4 reverse compatibility */
#ifndef NO_RC4
#define CYASSL_ARC4_CAVIUM_MAGIC WOLFSSL_ARC4_CAVIUM_MAGIC
#include <wolfssl/wolfcrypt/arc4.h>
#define CYASSL_ARC4_CAVIUM_MAGIC WOLFSSL_ARC4_CAVIUM_MAGIC
#define Arc4Process wc_Arc4Process
#define Arc4SetKey wc_Arc4SetKey
#define Arc4InitCavium wc_Arc4InitCavium

View File

@ -24,6 +24,7 @@
#endif
#include <cyassl/ssl.h> /* name change portability layer */
#if defined(CYASSL_MDK_ARM)
#include <stdio.h>
#include <string.h>

210
wolfcrypt/benchmark/benchmark Executable file
View File

@ -0,0 +1,210 @@
#! /bin/sh
# wolfcrypt/benchmark/benchmark - temporary wrapper script for .libs/benchmark
# Generated by libtool (GNU libtool) 2.4.2
#
# The wolfcrypt/benchmark/benchmark program cannot be directly executed until all the libtool
# libraries that it depends on are installed.
#
# This wrapper script should never be moved out of the build directory.
# If it is, it will not operate correctly.
# Sed substitution that helps us do robust quoting. It backslashifies
# metacharacters that are still active within double-quoted strings.
sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
# Be Bourne compatible
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
fi
BIN_SH=xpg4; export BIN_SH # for Tru64
DUALCASE=1; export DUALCASE # for MKS sh
# The HP-UX ksh and POSIX shell print the target directory to stdout
# if CDPATH is set.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
relink_command=""
# This environment variable determines our operation mode.
if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
# install mode needs the following variables:
generated_by_libtool_version='2.4.2'
notinst_deplibs=' src/libwolfssl.la'
else
# When we are sourced in execute mode, $file and $ECHO are already set.
if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
file="$0"
# A function that is used when there is no print builtin or printf.
func_fallback_echo ()
{
eval 'cat <<_LTECHO_EOF
$1
_LTECHO_EOF'
}
ECHO="printf %s\\n"
fi
# Very basic option parsing. These options are (a) specific to
# the libtool wrapper, (b) are identical between the wrapper
# /script/ and the wrapper /executable/ which is used only on
# windows platforms, and (c) all begin with the string --lt-
# (application programs are unlikely to have options which match
# this pattern).
#
# There are only two supported options: --lt-debug and
# --lt-dump-script. There is, deliberately, no --lt-help.
#
# The first argument to this parsing function should be the
# script's ./libtool value, followed by no.
lt_option_debug=
func_parse_lt_options ()
{
lt_script_arg0=$0
shift
for lt_opt
do
case "$lt_opt" in
--lt-debug) lt_option_debug=1 ;;
--lt-dump-script)
lt_dump_D=`$ECHO "X$lt_script_arg0" | /usr/bin/sed -e 's/^X//' -e 's%/[^/]*$%%'`
test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=.
lt_dump_F=`$ECHO "X$lt_script_arg0" | /usr/bin/sed -e 's/^X//' -e 's%^.*/%%'`
cat "$lt_dump_D/$lt_dump_F"
exit 0
;;
--lt-*)
$ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2
exit 1
;;
esac
done
# Print the debug banner immediately:
if test -n "$lt_option_debug"; then
echo "benchmark:wolfcrypt/benchmark/benchmark:${LINENO}: libtool wrapper (GNU libtool) 2.4.2" 1>&2
fi
}
# Used when --lt-debug. Prints its arguments to stdout
# (redirection is the responsibility of the caller)
func_lt_dump_args ()
{
lt_dump_args_N=1;
for lt_arg
do
$ECHO "benchmark:wolfcrypt/benchmark/benchmark:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg"
lt_dump_args_N=`expr $lt_dump_args_N + 1`
done
}
# Core function for launching the target application
func_exec_program_core ()
{
if test -n "$lt_option_debug"; then
$ECHO "benchmark:wolfcrypt/benchmark/benchmark:${LINENO}: newargv[0]: $progdir/$program" 1>&2
func_lt_dump_args ${1+"$@"} 1>&2
fi
exec "$progdir/$program" ${1+"$@"}
$ECHO "$0: cannot exec $program $*" 1>&2
exit 1
}
# A function to encapsulate launching the target application
# Strips options in the --lt-* namespace from $@ and
# launches target application with the remaining arguments.
func_exec_program ()
{
case " $* " in
*\ --lt-*)
for lt_wr_arg
do
case $lt_wr_arg in
--lt-*) ;;
*) set x "$@" "$lt_wr_arg"; shift;;
esac
shift
done ;;
esac
func_exec_program_core ${1+"$@"}
}
# Parse options
func_parse_lt_options "$0" ${1+"$@"}
# Find the directory that this script lives in.
thisdir=`$ECHO "$file" | /usr/bin/sed 's%/[^/]*$%%'`
test "x$thisdir" = "x$file" && thisdir=.
# Follow symbolic links until we get to the real thisdir.
file=`ls -ld "$file" | /usr/bin/sed -n 's/.*-> //p'`
while test -n "$file"; do
destdir=`$ECHO "$file" | /usr/bin/sed 's%/[^/]*$%%'`
# If there was a directory component, then change thisdir.
if test "x$destdir" != "x$file"; then
case "$destdir" in
[\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;;
*) thisdir="$thisdir/$destdir" ;;
esac
fi
file=`$ECHO "$file" | /usr/bin/sed 's%^.*/%%'`
file=`ls -ld "$thisdir/$file" | /usr/bin/sed -n 's/.*-> //p'`
done
# Usually 'no', except on cygwin/mingw when embedded into
# the cwrapper.
WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no
if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then
# special case for '.'
if test "$thisdir" = "."; then
thisdir=`pwd`
fi
# remove .libs from thisdir
case "$thisdir" in
*[\\/].libs ) thisdir=`$ECHO "$thisdir" | /usr/bin/sed 's%[\\/][^\\/]*$%%'` ;;
.libs ) thisdir=. ;;
esac
fi
# Try to get the absolute directory name.
absdir=`cd "$thisdir" && pwd`
test -n "$absdir" && thisdir="$absdir"
program='benchmark'
progdir="$thisdir/.libs"
if test -f "$progdir/$program"; then
# Add our own library path to DYLD_LIBRARY_PATH
DYLD_LIBRARY_PATH="/Users/sweetness/Documents/cyassl-wolfssl/src/.libs:$DYLD_LIBRARY_PATH"
# Some systems cannot cope with colon-terminated DYLD_LIBRARY_PATH
# The second colon is a workaround for a bug in BeOS R4 sed
DYLD_LIBRARY_PATH=`$ECHO "$DYLD_LIBRARY_PATH" | /usr/bin/sed 's/::*$//'`
export DYLD_LIBRARY_PATH
if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
# Run the actual program with our arguments.
func_exec_program ${1+"$@"}
fi
else
# The program doesn't exist.
$ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2
$ECHO "This script is just a wrapper for $program." 1>&2
$ECHO "See the libtool documentation for more information." 1>&2
exit 1
fi
fi

View File

@ -94,6 +94,158 @@
#pragma warning(disable: 4996)
#endif
//#ifndef NO_RC4
//#include <wolfssl/wolfcrypt/settings.h>
//#include <wolfssl/wolfcrypt/types.h>
//#endif
//
//#ifdef HAVE_CAVIUM
// static void wc_wc_Arc4CaviumSetKey(Arc4* arc4, const byte* key, word32 length);
// static void wc_wc_Arc4CaviumProcess(Arc4* arc4, byte* out, const byte* in,
// word32 length);
//#endif
//
//
//void wc_wc_Arc4SetKey(Arc4* arc4, const byte* key, word32 length)
//{
// word32 i;
// word32 keyIndex = 0, stateIndex = 0;
//
//#ifdef HAVE_CAVIUM
// if (arc4->magic == WOLFSSL_ARC4_CAVIUM_MAGIC)
// return wc_wc_Arc4CaviumSetKey(arc4, key, length);
//#endif
//
// arc4->x = 1;
// arc4->y = 0;
//
// for (i = 0; i < ARC4_STATE_SIZE; i++)
// arc4->state[i] = (byte)i;
//
// for (i = 0; i < ARC4_STATE_SIZE; i++) {
// word32 a = arc4->state[i];
// stateIndex += key[keyIndex] + a;
// stateIndex &= 0xFF;
// arc4->state[i] = arc4->state[stateIndex];
// arc4->state[stateIndex] = (byte)a;
//
// if (++keyIndex >= length)
// keyIndex = 0;
// }
//}
//
//
//static INLINE byte MakeByte(word32* x, word32* y, byte* s)
//{
// word32 a = s[*x], b;
// *y = (*y+a) & 0xff;
//
// b = s[*y];
// s[*x] = (byte)b;
// s[*y] = (byte)a;
// *x = (*x+1) & 0xff;
//
// return s[(a+b) & 0xff];
//}
//
//
//void wc_wc_Arc4Process(Arc4* arc4, byte* out, const byte* in, word32 length)
//{
// word32 x;
// word32 y;
//
//#ifdef HAVE_CAVIUM
// if (arc4->magic == WOLFSSL_ARC4_CAVIUM_MAGIC)
// return wc_wc_Arc4CaviumProcess(arc4, out, in, length);
//#endif
//
// x = arc4->x;
// y = arc4->y;
//
// while(length--)
// *out++ = *in++ ^ MakeByte(&x, &y, arc4->state);
//
// arc4->x = (byte)x;
// arc4->y = (byte)y;
//}
//
//
//#ifdef HAVE_CAVIUM
//
//#include <cyassl/ctaocrypt/logging.h>
//#include "cavium_common.h"
//
///* Initiliaze wc_Arc4 for use with Nitrox device */
//int wc_wc_Arc4InitCavium(Arc4* arc4, int devId)
//{
// if (arc4 == NULL)
// return -1;
//
// if (CspAllocContext(CONTEXT_SSL, &arc4->contextHandle, devId) != 0)
// return -1;
//
// arc4->devId = devId;
// arc4->magic = WOLFSSL_ARC4_CAVIUM_MAGIC;
//
// return 0;
//}
//
//
///* Free wc_Arc4 from use with Nitrox device */
//void wc_wc_Arc4FreeCavium(Arc4* arc4)
//{
// if (arc4 == NULL)
// return;
//
// if (arc4->magic != WOLFSSL_ARC4_CAVIUM_MAGIC)
// return;
//
// CspFreeContext(CONTEXT_SSL, arc4->contextHandle, arc4->devId);
// arc4->magic = 0;
//}
//
//
//static void wc_wc_Arc4CaviumSetKey(Arc4* arc4, const byte* key, word32 length)
//{
// word32 requestId;
//
// if (CspInitializeRc4(CAVIUM_BLOCKING, arc4->contextHandle, length,
// (byte*)key, &requestId, arc4->devId) != 0) {
// WOLFSSL_MSG("Bad Cavium wc_Arc4 Init");
// }
//}
//
//
//static void wc_wc_Arc4CaviumProcess(Arc4* arc4, byte* out, const byte* in,
// word32 length)
//{
// cyassl_word offset = 0;
// word32 requestId;
//
// while (length > WOLFSSL_MAX_16BIT) {
// word16 slen = (word16)WOLFSSL_MAX_16BIT;
// if (CspEncryptRc4(CAVIUM_BLOCKING, arc4->contextHandle,CAVIUM_UPDATE,
// slen, (byte*)in + offset, out + offset, &requestId,
// arc4->devId) != 0) {
// WOLFSSL_MSG("Bad Cavium wc_Arc4 Encrypt");
// }
// length -= WOLFSSL_MAX_16BIT;
// offset += WOLFSSL_MAX_16BIT;
// }
// if (length) {
// word16 slen = (word16)length;
// if (CspEncryptRc4(CAVIUM_BLOCKING, arc4->contextHandle,CAVIUM_UPDATE,
// slen, (byte*)in + offset, out + offset, &requestId,
// arc4->devId) != 0) {
// WOLFSSL_MSG("Bad Cavium wc_Arc4 Encrypt");
// }
// }
//}
//
//#endif /* HAVE_CAVIUM */
void bench_des(void);
void bench_arc4(void);
void bench_hc128(void);
@ -569,15 +721,15 @@ void bench_arc4(void)
int i;
#ifdef HAVE_CAVIUM
if (Arc4InitCavium(&enc, CAVIUM_DEV_ID) != 0)
if (wc_Arc4InitCavium(&enc, CAVIUM_DEV_ID) != 0)
printf("arc4 init cavium failed\n");
#endif
Arc4SetKey(&enc, key, 16);
wc_Arc4SetKey(&enc, key, 16);
start = current_time(1);
for(i = 0; i < numBlocks; i++)
Arc4Process(&enc, cipher, plain, sizeof(plain));
wc_Arc4Process(&enc, cipher, plain, sizeof(plain));
total = current_time(0) - start;
persec = 1 / total * numBlocks;
@ -589,7 +741,7 @@ void bench_arc4(void)
printf("ARC4 %d %s took %5.3f seconds, %7.3f MB/s\n", numBlocks,
blockType, total, persec);
#ifdef HAVE_CAVIUM
Arc4FreeCavium(&enc);
wc_Arc4FreeCavium(&enc);
#endif
}
#endif

View File

@ -23,13 +23,15 @@
#include <config.h>
#endif
#include <cyassl/ctaocrypt/settings.h>
#include <wolfssl/wolfcrypt/settings.h>
//#include <cyassl/ctaocrypt/visibility.h>
//#undef WOLFSSL_API
//#define WOLFSSL_API CYASSL_API
#ifndef NO_RC4
#include <wolfssl/wolfcrypt/arc4.h>
#ifdef HAVE_CAVIUM
static void wc_Arc4CaviumSetKey(Arc4* arc4, const byte* key, word32 length);
static void wc_Arc4CaviumProcess(Arc4* arc4, byte* out, const byte* in,

View File

@ -24,17 +24,17 @@
#include <config.h>
#endif
#include <cyassl/ctaocrypt/settings.h>
#include <wolfssl/wolfcrypt/settings.h>
#ifdef WOLFSSL_MD2
#include <cyassl/ctaocrypt/md2.h>
#include <cyassl/ctaocrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/md2.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
#ifdef NO_INLINE
#include <cyassl/ctaocrypt/misc.h>
#include <wolfssl/wolfcrypt/misc.h>
#else
#include <ctaocrypt/src/misc.c>
#include <wolfcrypt/src/misc.c>
#endif

View File

@ -24,7 +24,7 @@
#include <config.h>
#endif
#include <cyassl/ctaocrypt/settings.h>
#include <wolfssl/wolfcrypt/settings.h>
#if !defined(NO_MD5)
@ -35,12 +35,12 @@
#endif
#include <wolfssl/wolfcrypt/md5.h>
#include <cyassl/ctaocrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
#ifdef NO_INLINE
#include <cyassl/ctaocrypt/misc.h>
#include <wolfssl/wolfcrypt/misc.h>
#else
#include <ctaocrypt/src/misc.c>
#include <wolfcrypt/src/misc.c>
#endif
#ifdef FREESCALE_MMCAU

173
wolfcrypt/src/misc.c Normal file
View File

@ -0,0 +1,173 @@
/* misc.c
*
* Copyright (C) 2006-2014 wolfSSL Inc.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <cyassl/ctaocrypt/settings.h>
#include <cyassl/ctaocrypt/misc.h>
/* 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.,
md5 benchmark is twice as fast with inline. If you don't want it, then
define NO_INLINE and compile this file into cyassl, otherwise it's used as
a source header
*/
#ifdef NO_INLINE
#define STATIC
#else
#define STATIC static
#endif
#ifdef INTEL_INTRINSICS
#include <stdlib.h> /* get intrinsic definitions */
/* for non visual studio probably need no long version, 32 bit only
* i.e., _rotl and _rotr */
#pragma intrinsic(_lrotl, _lrotr)
STATIC INLINE word32 rotlFixed(word32 x, word32 y)
{
return y ? _lrotl(x, y) : x;
}
STATIC INLINE word32 rotrFixed(word32 x, word32 y)
{
return y ? _lrotr(x, y) : x;
}
#else /* generic */
STATIC INLINE word32 rotlFixed(word32 x, word32 y)
{
return (x << y) | (x >> (sizeof(y) * 8 - y));
}
STATIC INLINE word32 rotrFixed(word32 x, word32 y)
{
return (x >> y) | (x << (sizeof(y) * 8 - y));
}
#endif
STATIC INLINE word32 ByteReverseWord32(word32 value)
{
#ifdef PPC_INTRINSICS
/* PPC: load reverse indexed instruction */
return (word32)__lwbrx(&value,0);
#elif defined(KEIL_INTRINSICS)
return (word32)__rev(value);
#elif defined(FAST_ROTATE)
/* 5 instructions with rotate instruction, 9 without */
return (rotrFixed(value, 8U) & 0xff00ff00) |
(rotlFixed(value, 8U) & 0x00ff00ff);
#else
/* 6 instructions with rotate instruction, 8 without */
value = ((value & 0xFF00FF00) >> 8) | ((value & 0x00FF00FF) << 8);
return rotlFixed(value, 16U);
#endif
}
STATIC INLINE void ByteReverseWords(word32* out, const word32* in,
word32 byteCount)
{
word32 count = byteCount/(word32)sizeof(word32), i;
for (i = 0; i < count; i++)
out[i] = ByteReverseWord32(in[i]);
}
#ifdef WORD64_AVAILABLE
STATIC INLINE word64 rotlFixed64(word64 x, word64 y)
{
return (x << y) | (x >> (sizeof(y) * 8 - y));
}
STATIC INLINE word64 rotrFixed64(word64 x, word64 y)
{
return (x >> y) | (x << (sizeof(y) * 8 - y));
}
STATIC INLINE word64 ByteReverseWord64(word64 value)
{
#ifdef CTAOCRYPT_SLOW_WORD64
return (word64)(ByteReverseWord32((word32)value)) << 32 |
ByteReverseWord32((word32)(value>>32));
#else
value = ((value & W64LIT(0xFF00FF00FF00FF00)) >> 8) |
((value & W64LIT(0x00FF00FF00FF00FF)) << 8);
value = ((value & W64LIT(0xFFFF0000FFFF0000)) >> 16) |
((value & W64LIT(0x0000FFFF0000FFFF)) << 16);
return rotlFixed64(value, 32U);
#endif
}
STATIC INLINE void ByteReverseWords64(word64* out, const word64* in,
word32 byteCount)
{
word32 count = byteCount/(word32)sizeof(word64), i;
for (i = 0; i < count; i++)
out[i] = ByteReverseWord64(in[i]);
}
#endif /* WORD64_AVAILABLE */
STATIC INLINE void XorWords(cyassl_word* r, const cyassl_word* a, word32 n)
{
word32 i;
for (i = 0; i < n; i++) r[i] ^= a[i];
}
STATIC INLINE void xorbuf(void* buf, const void* mask, word32 count)
{
if (((cyassl_word)buf | (cyassl_word)mask | count) % CYASSL_WORD_SIZE == 0)
XorWords( (cyassl_word*)buf,
(const cyassl_word*)mask, count / CYASSL_WORD_SIZE);
else {
word32 i;
byte* b = (byte*)buf;
const byte* m = (const byte*)mask;
for (i = 0; i < count; i++) b[i] ^= m[i];
}
}
#undef STATIC

View File

@ -1676,18 +1676,18 @@ int arc4_test(void)
keylen = 4;
#ifdef HAVE_CAVIUM
if (Arc4InitCavium(&enc, CAVIUM_DEV_ID) != 0)
if (wc_Arc4InitCavium(&enc, CAVIUM_DEV_ID) != 0)
return -20001;
if (Arc4InitCavium(&dec, CAVIUM_DEV_ID) != 0)
if (wc_Arc4InitCavium(&dec, CAVIUM_DEV_ID) != 0)
return -20002;
#endif
Arc4SetKey(&enc, (byte*)keys[i], keylen);
Arc4SetKey(&dec, (byte*)keys[i], keylen);
wc_Arc4SetKey(&enc, (byte*)keys[i], keylen);
wc_Arc4SetKey(&dec, (byte*)keys[i], keylen);
Arc4Process(&enc, cipher, (byte*)test_arc4[i].input,
wc_Arc4Process(&enc, cipher, (byte*)test_arc4[i].input,
(word32)test_arc4[i].outLen);
Arc4Process(&dec, plain, cipher, (word32)test_arc4[i].outLen);
wc_Arc4Process(&dec, plain, cipher, (word32)test_arc4[i].outLen);
if (memcmp(plain, test_arc4[i].input, test_arc4[i].outLen))
return -20 - i;
@ -1696,8 +1696,8 @@ int arc4_test(void)
return -20 - 5 - i;
#ifdef HAVE_CAVIUM
Arc4FreeCavium(&enc);
Arc4FreeCavium(&dec);
wc_Arc4FreeCavium(&enc);
wc_Arc4FreeCavium(&dec);
#endif
}

210
wolfcrypt/test/testwolfcrypt Executable file
View File

@ -0,0 +1,210 @@
#! /bin/sh
# wolfcrypt/test/testwolfcrypt - temporary wrapper script for .libs/testwolfcrypt
# Generated by libtool (GNU libtool) 2.4.2
#
# The wolfcrypt/test/testwolfcrypt program cannot be directly executed until all the libtool
# libraries that it depends on are installed.
#
# This wrapper script should never be moved out of the build directory.
# If it is, it will not operate correctly.
# Sed substitution that helps us do robust quoting. It backslashifies
# metacharacters that are still active within double-quoted strings.
sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
# Be Bourne compatible
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
fi
BIN_SH=xpg4; export BIN_SH # for Tru64
DUALCASE=1; export DUALCASE # for MKS sh
# The HP-UX ksh and POSIX shell print the target directory to stdout
# if CDPATH is set.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
relink_command=""
# This environment variable determines our operation mode.
if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
# install mode needs the following variables:
generated_by_libtool_version='2.4.2'
notinst_deplibs=' src/libwolfssl.la'
else
# When we are sourced in execute mode, $file and $ECHO are already set.
if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
file="$0"
# A function that is used when there is no print builtin or printf.
func_fallback_echo ()
{
eval 'cat <<_LTECHO_EOF
$1
_LTECHO_EOF'
}
ECHO="printf %s\\n"
fi
# Very basic option parsing. These options are (a) specific to
# the libtool wrapper, (b) are identical between the wrapper
# /script/ and the wrapper /executable/ which is used only on
# windows platforms, and (c) all begin with the string --lt-
# (application programs are unlikely to have options which match
# this pattern).
#
# There are only two supported options: --lt-debug and
# --lt-dump-script. There is, deliberately, no --lt-help.
#
# The first argument to this parsing function should be the
# script's ./libtool value, followed by no.
lt_option_debug=
func_parse_lt_options ()
{
lt_script_arg0=$0
shift
for lt_opt
do
case "$lt_opt" in
--lt-debug) lt_option_debug=1 ;;
--lt-dump-script)
lt_dump_D=`$ECHO "X$lt_script_arg0" | /usr/bin/sed -e 's/^X//' -e 's%/[^/]*$%%'`
test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=.
lt_dump_F=`$ECHO "X$lt_script_arg0" | /usr/bin/sed -e 's/^X//' -e 's%^.*/%%'`
cat "$lt_dump_D/$lt_dump_F"
exit 0
;;
--lt-*)
$ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2
exit 1
;;
esac
done
# Print the debug banner immediately:
if test -n "$lt_option_debug"; then
echo "testwolfcrypt:wolfcrypt/test/testwolfcrypt:${LINENO}: libtool wrapper (GNU libtool) 2.4.2" 1>&2
fi
}
# Used when --lt-debug. Prints its arguments to stdout
# (redirection is the responsibility of the caller)
func_lt_dump_args ()
{
lt_dump_args_N=1;
for lt_arg
do
$ECHO "testwolfcrypt:wolfcrypt/test/testwolfcrypt:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg"
lt_dump_args_N=`expr $lt_dump_args_N + 1`
done
}
# Core function for launching the target application
func_exec_program_core ()
{
if test -n "$lt_option_debug"; then
$ECHO "testwolfcrypt:wolfcrypt/test/testwolfcrypt:${LINENO}: newargv[0]: $progdir/$program" 1>&2
func_lt_dump_args ${1+"$@"} 1>&2
fi
exec "$progdir/$program" ${1+"$@"}
$ECHO "$0: cannot exec $program $*" 1>&2
exit 1
}
# A function to encapsulate launching the target application
# Strips options in the --lt-* namespace from $@ and
# launches target application with the remaining arguments.
func_exec_program ()
{
case " $* " in
*\ --lt-*)
for lt_wr_arg
do
case $lt_wr_arg in
--lt-*) ;;
*) set x "$@" "$lt_wr_arg"; shift;;
esac
shift
done ;;
esac
func_exec_program_core ${1+"$@"}
}
# Parse options
func_parse_lt_options "$0" ${1+"$@"}
# Find the directory that this script lives in.
thisdir=`$ECHO "$file" | /usr/bin/sed 's%/[^/]*$%%'`
test "x$thisdir" = "x$file" && thisdir=.
# Follow symbolic links until we get to the real thisdir.
file=`ls -ld "$file" | /usr/bin/sed -n 's/.*-> //p'`
while test -n "$file"; do
destdir=`$ECHO "$file" | /usr/bin/sed 's%/[^/]*$%%'`
# If there was a directory component, then change thisdir.
if test "x$destdir" != "x$file"; then
case "$destdir" in
[\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;;
*) thisdir="$thisdir/$destdir" ;;
esac
fi
file=`$ECHO "$file" | /usr/bin/sed 's%^.*/%%'`
file=`ls -ld "$thisdir/$file" | /usr/bin/sed -n 's/.*-> //p'`
done
# Usually 'no', except on cygwin/mingw when embedded into
# the cwrapper.
WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no
if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then
# special case for '.'
if test "$thisdir" = "."; then
thisdir=`pwd`
fi
# remove .libs from thisdir
case "$thisdir" in
*[\\/].libs ) thisdir=`$ECHO "$thisdir" | /usr/bin/sed 's%[\\/][^\\/]*$%%'` ;;
.libs ) thisdir=. ;;
esac
fi
# Try to get the absolute directory name.
absdir=`cd "$thisdir" && pwd`
test -n "$absdir" && thisdir="$absdir"
program='testwolfcrypt'
progdir="$thisdir/.libs"
if test -f "$progdir/$program"; then
# Add our own library path to DYLD_LIBRARY_PATH
DYLD_LIBRARY_PATH="/Users/sweetness/Documents/cyassl-wolfssl/src/.libs:$DYLD_LIBRARY_PATH"
# Some systems cannot cope with colon-terminated DYLD_LIBRARY_PATH
# The second colon is a workaround for a bug in BeOS R4 sed
DYLD_LIBRARY_PATH=`$ECHO "$DYLD_LIBRARY_PATH" | /usr/bin/sed 's/::*$//'`
export DYLD_LIBRARY_PATH
if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
# Run the actual program with our arguments.
func_exec_program ${1+"$@"}
fi
else
# The program doesn't exist.
$ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2
$ECHO "This script is just a wrapper for $program." 1>&2
$ECHO "See the libtool documentation for more information." 1>&2
exit 1
fi
fi

View File

@ -20,12 +20,12 @@
*/
#ifdef CYASSL_MD2
#ifdef WOLFSSL_MD2
#ifndef CTAO_CRYPT_MD2_H
#define CTAO_CRYPT_MD2_H
#ifndef WOLF_CRYPT_MD2_H
#define WOLF_CRYPT_MD2_H
#include <cyassl/ctaocrypt/types.h>
#include <wolfssl/wolfcrypt/types.h>
#ifdef __cplusplus
extern "C" {
@ -51,10 +51,10 @@ typedef struct Md2 {
} Md2;
CYASSL_API void InitMd2(Md2*);
CYASSL_API void Md2Update(Md2*, const byte*, word32);
CYASSL_API void Md2Final(Md2*, byte*);
CYASSL_API int Md2Hash(const byte*, word32, byte*);
WOLFSSL_API void wc_InitMd2(Md2*);
WOLFSSL_API void wc_Md2Update(Md2*, const byte*, word32);
WOLFSSL_API void wc_Md2Final(Md2*, byte*);
WOLFSSL_API int wc_Md2Hash(const byte*, word32, byte*);
#ifdef __cplusplus

View File

@ -24,7 +24,7 @@
#ifndef WOLF_CRYPT_MD5_H
#define WOLF_CRYPT_MD5_H
#include <cyassl/ctaocrypt/types.h>
#include <wolfssl/wolfcrypt/types.h>
#include <cyassl/ctaocrypt/md5.h>