Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,19 @@ fi

AM_CONDITIONAL([BUILD_ARMASM], [test "x$ENABLED_ARMASM" = "xyes"])

# Xilinx hardened crypto
AC_ARG_ENABLE([xilinx],
[AS_HELP_STRING([--enable-xilinx],[Enable wolfSSL support for Xilinx hardened crypto(default: disabled)])],
[ ENABLED_XILINX=$enableval ],
[ ENABLED_XILINX=no ]
)
if test "$ENABLED_XILINX" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_XILINX -DWOLFSSL_XILINX_CRYPT"
fi

AM_CONDITIONAL([BUILD_XILINX], [test "x$ENABLED_XILINX" = "xyes"])

# INTEL AES-NI
AC_ARG_ENABLE([aesni],
[AS_HELP_STRING([--enable-aesni],[Enable wolfSSL AES-NI support (default: disabled)])],
Expand Down Expand Up @@ -3859,6 +3872,7 @@ echo " * ARM ASM: $ENABLED_ARMASM"
echo " * AES Key Wrap: $ENABLED_AESKEYWRAP"
echo " * Write duplicate: $ENABLED_WRITEDUP"
echo " * Intel Quick Assist: $ENABLED_INTEL_QA"
echo " * Xilinx Hardware Acc.: $ENABLED_XILINX"
echo ""
echo "---"

Expand Down
6 changes: 6 additions & 0 deletions src/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/

#if !defined(WOLFSSL_BIO_INCLUDED)
#warning bio.c does not need to be compiled seperatly from ssl.c
#else

/*** TBD ***/
WOLFSSL_API long wolfSSL_BIO_ctrl(WOLFSSL_BIO *bio, int cmd, long larg, void *parg)
{
Expand Down Expand Up @@ -444,3 +448,5 @@ long wolfSSL_BIO_set_mem_eof_return(WOLFSSL_BIO *bio, int v)

return 0;
}
#endif /* WOLFSSL_BIO_INCLUDED */

21 changes: 21 additions & 0 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -5564,6 +5564,27 @@ ProtocolVersion MakeDTLSv1_2(void)
{
return (word32) Seconds_get();
}
#elif defined(WOLFSSL_XILINX)
#include "xrtcpsu.h"

word32 LowResTimer(void)
{
XRtcPsu_Config* con;
XRtcPsu rtc;

con = XRtcPsu_LookupConfig(XPAR_XRTCPSU_0_DEVICE_ID);
if (con != NULL) {
if (XRtcPsu_CfgInitialize(&rtc, con, con->BaseAddr)
== XST_SUCCESS) {
return (word32)XRtcPsu_GetCurrentTime(&rtc);
}
else {
WOLFSSL_MSG("Unable to initialize RTC");
}
}

return 0;
}

#elif defined(WOLFSSL_UTASKER)

Expand Down
2 changes: 2 additions & 0 deletions src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -12525,6 +12525,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md)
return SSL_SUCCESS; /* success */
}

#define WOLFSSL_EVP_INCLUDED
#include "wolfcrypt/src/evp.c"


Expand Down Expand Up @@ -23112,6 +23113,7 @@ WOLFSSL_DSA *wolfSSL_PEM_read_bio_DSAparams(WOLFSSL_BIO *bp, WOLFSSL_DSA **x,
}
#endif /* NO_DSA */

#define WOLFSSL_BIO_INCLUDED
#include "src/bio.c"

#endif /* OPENSSL_EXTRA */
Expand Down
21 changes: 21 additions & 0 deletions wolfcrypt/benchmark/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@
#endif
#include <wolfssl/wolfcrypt/random.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/types.h>

#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif

/* only for stack size check */
#ifdef HAVE_STACK_SIZE
Expand Down Expand Up @@ -837,30 +842,38 @@ static void* benchmarks_do(void* args)
#endif
#endif
#ifdef WOLFSSL_SHA3
#ifndef WOLFSSL_NOSHA3_224
#ifndef NO_SW_BENCH
bench_sha3_224(0);
#endif
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA3)
bench_sha3_224(1);
#endif
#endif /* WOLFSSL_NOSHA3_224 */
#ifndef WOLFSSL_NOSHA3_256
#ifndef NO_SW_BENCH
bench_sha3_256(0);
#endif
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA3)
bench_sha3_256(1);
#endif
#endif /* WOLFSSL_NOSHA3_256 */
#ifndef WOLFSSL_NOSHA3_384
#ifndef NO_SW_BENCH
bench_sha3_384(0);
#endif
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA3)
bench_sha3_384(1);
#endif
#endif /* WOLFSSL_NOSHA3_384 */
#ifndef WOLFSSL_NOSHA3_512
#ifndef NO_SW_BENCH
bench_sha3_512(0);
#endif
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA512)
bench_sha3_512(1);
#endif
#endif /* WOLFSSL_NOSHA3_512 */
#endif
#ifdef WOLFSSL_RIPEMD
bench_ripemd();
Expand Down Expand Up @@ -2131,6 +2144,7 @@ void bench_sha512(int doAsync)


#ifdef WOLFSSL_SHA3
#ifndef WOLFSSL_NOSHA3_224
void bench_sha3_224(int doAsync)
{
Sha3 hash[BENCH_MAX_PENDING];
Expand Down Expand Up @@ -2203,7 +2217,9 @@ void bench_sha3_224(int doAsync)

bench_async_end();
}
#endif /* WOLFSSL_NOSHA3_224 */

#ifndef WOLFSSL_NOSHA3_256
void bench_sha3_256(int doAsync)
{
Sha3 hash[BENCH_MAX_PENDING];
Expand Down Expand Up @@ -2276,7 +2292,9 @@ void bench_sha3_256(int doAsync)

bench_async_end();
}
#endif /* WOLFSSL_NOSHA3_256 */

#ifndef WOLFSSL_NOSHA3_384
void bench_sha3_384(int doAsync)
{
Sha3 hash[BENCH_MAX_PENDING];
Expand Down Expand Up @@ -2349,7 +2367,9 @@ void bench_sha3_384(int doAsync)

bench_async_end();
}
#endif /* WOLFSSL_NOSHA3_384 */

#ifndef WOLFSSL_NOSHA3_512
void bench_sha3_512(int doAsync)
{
Sha3 hash[BENCH_MAX_PENDING];
Expand Down Expand Up @@ -2422,6 +2442,7 @@ void bench_sha3_512(int doAsync)

bench_async_end();
}
#endif /* WOLFSSL_NOSHA3_512 */
#endif


Expand Down
14 changes: 10 additions & 4 deletions wolfcrypt/src/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -3522,6 +3522,10 @@ int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len)
}
#endif /* FREESCALE_LTC_AES_GCM */

#if defined(WOLFSSL_XILINX_CRYPT)
wc_AesGcmSetKey_ex(aes, key, len, XSECURE_CSU_AES_KEY_SRC_KUP);
#endif

return ret;
}

Expand Down Expand Up @@ -3987,7 +3991,7 @@ static void GMULT(byte* X, byte* Y)
}


static void GHASH(Aes* aes, const byte* a, word32 aSz, const byte* c,
void GHASH(Aes* aes, const byte* a, word32 aSz, const byte* c,
word32 cSz, byte* s, word32 sSz)
{
byte x[AES_BLOCK_SIZE];
Expand Down Expand Up @@ -4136,7 +4140,7 @@ static void GMULT(byte *x, byte m[256][AES_BLOCK_SIZE])
}


static void GHASH(Aes* aes, const byte* a, word32 aSz, const byte* c,
void GHASH(Aes* aes, const byte* a, word32 aSz, const byte* c,
word32 cSz, byte* s, word32 sSz)
{
byte x[AES_BLOCK_SIZE];
Expand Down Expand Up @@ -4231,7 +4235,7 @@ static void GMULT(word64* X, word64* Y)
}


static void GHASH(Aes* aes, const byte* a, word32 aSz, const byte* c,
void GHASH(Aes* aes, const byte* a, word32 aSz, const byte* c,
word32 cSz, byte* s, word32 sSz)
{
word64 x[2] = {0,0};
Expand Down Expand Up @@ -4368,7 +4372,7 @@ static void GMULT(word32* X, word32* Y)
}


static void GHASH(Aes* aes, const byte* a, word32 aSz, const byte* c,
void GHASH(Aes* aes, const byte* a, word32 aSz, const byte* c,
word32 cSz, byte* s, word32 sSz)
{
word32 x[4] = {0,0,0,0};
Expand Down Expand Up @@ -4467,6 +4471,7 @@ static void GHASH(Aes* aes, const byte* a, word32 aSz, const byte* c,
#endif /* end GCM_WORD32 */


#if !defined(WOLFSSL_XILINX_CRYPT)
int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
const byte* iv, word32 ivSz,
byte* authTag, word32 authTagSz,
Expand Down Expand Up @@ -4965,6 +4970,7 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
}

#endif /* HAVE_AES_DECRYPT || HAVE_AESGCM_DECRYPT */
#endif /* (WOLFSSL_XILINX_CRYPT) */

WOLFSSL_API int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len)
{
Expand Down
36 changes: 35 additions & 1 deletion wolfcrypt/src/asn.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ ASN Options:
#include <windows.h>
#define XTIME(t1) windows_time((t1))
#define WOLFSSL_GMTIME

#else

/* default */
/* uses complete <time.h> facility */
#include <time.h>
Expand Down Expand Up @@ -420,6 +420,34 @@ time_t XTIME(time_t * timer)
#endif /* WOLFSSL_TIRTOS */


#if defined(WOLFSSL_XILINX)
#include "xrtcpsu.h"

time_t XTIME(time_t * timer)
{
time_t sec = 0;
XRtcPsu_Config* con;
XRtcPsu rtc;

con = XRtcPsu_LookupConfig(XPAR_XRTCPSU_0_DEVICE_ID);
if (con != NULL) {
if (XRtcPsu_CfgInitialize(&rtc, con, con->BaseAddr) == XST_SUCCESS) {
sec = (time_t)XRtcPsu_GetCurrentTime(&rtc);
}
else {
WOLFSSL_MSG("Unable to initialize RTC");
}
}

if (timer != NULL)
*timer = sec;

return sec;
}

#endif /* WOLFSSL_TIRTOS */


static INLINE word32 btoi(byte b)
{
return (word32)(b - 0x30);
Expand Down Expand Up @@ -1881,6 +1909,12 @@ int wc_RsaPrivateKeyDecode(const byte* input, word32* inOutIdx, RsaKey* key,
GetInt(&key->dQ, input, inOutIdx, inSz) < 0 ||
GetInt(&key->u, input, inOutIdx, inSz) < 0 ) return ASN_RSA_KEY_E;

#ifdef WOLFSSL_XILINX_CRYPT
if (wc_InitRsaHw(key) != 0) {
return BAD_STATE_E;
}
#endif

return 0;
}
#endif /* HAVE_USER_RSA */
Expand Down
6 changes: 6 additions & 0 deletions wolfcrypt/src/evp.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/

#if !defined(WOLFSSL_EVP_INCLUDED)
#warning evp.c does not need to be compiled seperatly from ssl.c
#else

static unsigned int cipherType(const WOLFSSL_EVP_CIPHER *cipher);

WOLFSSL_API int wolfSSL_EVP_EncryptInit(WOLFSSL_EVP_CIPHER_CTX* ctx,
Expand Down Expand Up @@ -537,3 +541,5 @@ WOLFSSL_API int wolfSSL_EVP_add_digest(const WOLFSSL_EVP_MD *digest)
/* nothing to do */
return 0;
}
#endif /* WOLFSSL_EVP_INCLUDED */

4 changes: 3 additions & 1 deletion wolfcrypt/src/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ EXTRA_DIST += wolfcrypt/src/port/ti/ti-aes.c \
wolfcrypt/src/port/arm/armv8-sha256.c \
wolfcrypt/src/port/nxp/ksdk_port.c \
wolfcrypt/src/port/atmel/atmel.c \
wolfcrypt/src/port/atmel/README.md
wolfcrypt/src/port/atmel/README.md \
wolfcrypt/src/port/xilinx/xil-sha3.c \
wolfcrypt/src/port/xilinx/xil-aesgcm.c

if BUILD_CAVIUM
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/cavium/cavium_nitrox.c
Expand Down
4 changes: 2 additions & 2 deletions wolfcrypt/src/port/arm/armv8-aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,7 @@ static void GMULT(byte* X, byte* Y)
}


static void GHASH(Aes* aes, const byte* a, word32 aSz,
void GHASH(Aes* aes, const byte* a, word32 aSz,
const byte* c, word32 cSz, byte* s, word32 sSz)
{
byte x[AES_BLOCK_SIZE];
Expand Down Expand Up @@ -4100,7 +4100,7 @@ static void GMULT(byte* X, byte* Y)
}


static void GHASH(Aes* aes, const byte* a, word32 aSz,
void GHASH(Aes* aes, const byte* a, word32 aSz,
const byte* c, word32 cSz, byte* s, word32 sSz)
{
byte x[AES_BLOCK_SIZE];
Expand Down
Loading