mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +02:00
Merge pull request #2493 from ejohnstown/sync-qat
Synchronous Quick Assist Support for Sniffer
This commit is contained in:
97
configure.ac
97
configure.ac
@@ -3885,59 +3885,57 @@ AC_ARG_WITH([cavium-v],
|
|||||||
# Intel QuickAssist
|
# Intel QuickAssist
|
||||||
QAT_DIR=""
|
QAT_DIR=""
|
||||||
BUILD_INTEL_QAT_VERSION=2
|
BUILD_INTEL_QAT_VERSION=2
|
||||||
|
|
||||||
AC_ARG_WITH([intelqa],
|
AC_ARG_WITH([intelqa],
|
||||||
[ --with-intelqa=PATH PATH to Intel QuickAssist (QAT) driver dir ],
|
[AS_HELP_STRING([--with-intelqa=PATH],[PATH to Intel QuickAssist (QAT) driver dir])],
|
||||||
[
|
[ENABLED_INTEL_QA=yes; QAT_DIR=$withval],
|
||||||
AC_MSG_CHECKING([for intelqa])
|
[ENABLED_INTEL_QA=no])
|
||||||
CPPFLAGS="$CPPFLAGS -DHAVE_INTEL_QA -DDO_CRYPTO -DUSER_SPACE"
|
|
||||||
OLD_LIBS="$LIBS"
|
|
||||||
|
|
||||||
if test "x$withval" = "xyes" ; then
|
AC_ARG_WITH([intelqa-sync],
|
||||||
AC_MSG_ERROR([need a PATH for --with-intelqa])
|
[AS_HELP_STRING([--with-intelqa-sync=PATH],[PATH to Intel QuickAssist (QAT) driver dir (sync)])],
|
||||||
fi
|
[ENABLED_INTEL_QA_SYNC=yes; QAT_DIR=$withval],
|
||||||
if test "x$withval" != "xno" ; then
|
[ENABLED_INTEL_QA_SYNC=no])
|
||||||
QAT_DIR=$withval
|
|
||||||
fi
|
|
||||||
|
|
||||||
CPPFLAGS="$CPPFLAGS -I$QAT_DIR/quickassist/include -I$QAT_DIR/quickassist/include/lac -I$QAT_DIR/quickassist/utilities/osal/include \
|
AS_IF([test "x$ENABLED_INTEL_QA" = "xyes" && test "x$ENABLED_INTEL_QA_SYNC" = "xyes"],
|
||||||
-I$QAT_DIR/quickassist/utilities/osal/src/linux/user_space/include -I$QAT_DIR/quickassist/lookaside/access_layer/include \
|
[AC_MSG_ERROR([Both Intel QA Async and Sync are selected, only select one.])])
|
||||||
-I$QAT_DIR/quickassist/lookaside/access_layer/src/common/include -I$srcdir/wolfssl -I$srcdir/wolfssl/wolfcrypt/port/intel \
|
|
||||||
-I$QAT_DIR/quickassist/utilities/libusdm_drv"
|
|
||||||
|
|
||||||
LDFLAGS="$LDFLAGS -L$QAT_DIR/build"
|
AS_IF([test "x$ENABLED_INTEL_QA" = "xyes" || test "x$ENABLED_INTEL_QA_SYNC" = "xyes"],
|
||||||
LIBS="$LIBS -lqat_s -lusdm_drv_s"
|
[AC_MSG_CHECKING([for intelqa])
|
||||||
|
AS_IF([test "x$ENABLED_INTEL_QA" = "xyes"],
|
||||||
|
[AM_CPPFLAGS="$AM_CPPFLAGS -DHAVE_INTEL_QA -DDO_CRYPTO -DUSER_SPACE"; intelqa_opt=""],
|
||||||
|
[AM_CPPFLAGS="$AM_CPPFLAGS -DHAVE_INTEL_QA_SYNC -DQAT_USE_POLLING_THREAD -DO_CRYPTO -DUSER_SPACE"; intelqa_opt="-sync"])
|
||||||
|
OLD_LIBS="$LIBS"
|
||||||
|
OLD_CPPFLAGS="$CPPFLAGS"
|
||||||
|
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "cpa_cy_common.h"]], [[ Cpa16U count = 0; cpaCyGetNumInstances(&count); ]])],
|
AS_IF([test "x$QAT_DIR" = "xyes"],[AC_MSG_ERROR([need a PATH for --with-intelqa$intelqa_opt])])
|
||||||
[ intelqa_linked=yes ],[ intelqa_linked=no ])
|
|
||||||
if test "x$intelqa_linked" = "xno" ; then
|
AM_CPPFLAGS="$AM_CPPFLAGS -I$QAT_DIR/quickassist/include -I$QAT_DIR/quickassist/include/lac -I$QAT_DIR/quickassist/utilities/osal/include \
|
||||||
# Try old QAT driver libraries
|
-I$QAT_DIR/quickassist/utilities/osal/src/linux/user_space/include -I$QAT_DIR/quickassist/lookaside/access_layer/include \
|
||||||
|
-I$QAT_DIR/quickassist/lookaside/access_layer/src/common/include -I$srcdir/wolfssl -I$srcdir/wolfssl/wolfcrypt/port/intel \
|
||||||
|
-I$QAT_DIR/quickassist/utilities/libusdm_drv"
|
||||||
|
CPPFLAGS="$AM_CPPFLAGS"
|
||||||
|
|
||||||
|
LDFLAGS="$LDFLAGS -L$QAT_DIR/build"
|
||||||
|
LIBS="$LIBS -lqat_s -lusdm_drv_s"
|
||||||
|
|
||||||
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "cpa_cy_common.h"]],[[Cpa16U count = 0; cpaCyGetNumInstances(&count);]])],[intelqa_linked=yes],[intelqa_linked=no])
|
||||||
|
|
||||||
|
AS_IF([test "x$intelqa_linked" = "xno"],
|
||||||
|
[# Try old QAT driver libraries
|
||||||
LIBS="$OLD_LIBS -licp_qa_al_s"
|
LIBS="$OLD_LIBS -licp_qa_al_s"
|
||||||
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "cpa_cy_common.h"]],[[Cpa16U count = 0; cpaCyGetNumInstances(&count);]])],[intelqa_linked=yes],[intelqa_linked=no])
|
||||||
|
AS_IF([test "x$intelqa_linked" = "xno"],
|
||||||
|
[AC_MSG_ERROR([Intel QuickAssist not found. If it's already installed, specify its path using --with-intelqa$intelqa_opt=/dir/])],
|
||||||
|
[BUILD_INTEL_QAT_VERSION=1])
|
||||||
|
])
|
||||||
|
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "cpa_cy_common.h"]], [[ Cpa16U count = 0; cpaCyGetNumInstances(&count); ]])],
|
AC_MSG_RESULT([yes])
|
||||||
[ intelqa_linked=yes ],[ intelqa_linked=no ])
|
|
||||||
if test "x$intelqa_linked" = "xno" ; then
|
|
||||||
AC_MSG_ERROR([Intel QuickAssist not found.
|
|
||||||
If it's already installed, specify its path using --with-intelqa=/dir/])
|
|
||||||
else
|
|
||||||
BUILD_INTEL_QAT_VERSION=1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
AM_CFLAGS="$AM_CFLAGS -DHAVE_INTEL_QA -DDO_CRYPTO -DUSER_SPACE"
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT([yes])
|
|
||||||
|
|
||||||
if test "x$BUILD_INTEL_QAT_VERSION" == "x1" ; then
|
AS_IF([test "x$BUILD_INTEL_QAT_VERSION" == "x1"],
|
||||||
LIB_ADD="-ladf_proxy -losal -lrt $LIB_ADD"
|
[LIB_ADD="-ladf_proxy -losal -lrt $LIB_ADD"],
|
||||||
else
|
[LIB_ADD="-losal -lrt $LIB_ADD"])
|
||||||
LIB_ADD="-losal -lrt $LIB_ADD"
|
CPPFLAGS="$OLD_CPPFLAGS"
|
||||||
fi
|
])
|
||||||
|
|
||||||
ENABLED_INTEL_QA=yes
|
|
||||||
],
|
|
||||||
[
|
|
||||||
ENABLED_INTEL_QA=no
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Single Precision maths implementation
|
# Single Precision maths implementation
|
||||||
@@ -4367,7 +4365,7 @@ fi
|
|||||||
# check for async if using Intel QuckAssist or Cavium
|
# check for async if using Intel QuckAssist or Cavium
|
||||||
if test "x$ENABLED_INTEL_QA" = "xyes" || test "x$ENABLED_CAVIUM" = "xyes" ; then
|
if test "x$ENABLED_INTEL_QA" = "xyes" || test "x$ENABLED_CAVIUM" = "xyes" ; then
|
||||||
if test "x$ENABLED_ASYNCCRYPT" = "xno" ; then
|
if test "x$ENABLED_ASYNCCRYPT" = "xno" ; then
|
||||||
AC_MSG_ERROR([Please enable enable asynchronous support using --enable-asynccrypt])
|
AC_MSG_ERROR([Please enable asynchronous support using --enable-asynccrypt])
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -4582,6 +4580,10 @@ AS_IF([test "x$ENABLED_OCSP" = "xyes" && \
|
|||||||
test "x$ENABLED_ECC" = "xno"],
|
test "x$ENABLED_ECC" = "xno"],
|
||||||
[AC_MSG_ERROR([please enable rsa or ecc if enabling ocsp.])])
|
[AC_MSG_ERROR([please enable rsa or ecc if enabling ocsp.])])
|
||||||
|
|
||||||
|
# Sync Intel QA requires the crypto callback
|
||||||
|
AS_IF([test "x$ENABLED_CRYPTOCB" = "xno" && test "x$ENABLED_INTEL_QA_SYNC" = "xyes"],
|
||||||
|
[AC_MSG_ERROR([please enable the crypto callback support using --enable-cryptocb])])
|
||||||
|
|
||||||
# checks for pkcs7 needed enables
|
# checks for pkcs7 needed enables
|
||||||
AS_IF([test "x$ENABLED_PKCS7" = "xyes" && \
|
AS_IF([test "x$ENABLED_PKCS7" = "xyes" && \
|
||||||
test "x$ENABLED_RSA" = "xno" && \
|
test "x$ENABLED_RSA" = "xno" && \
|
||||||
@@ -4807,7 +4809,7 @@ if test "$ENABLED_DISTRO" = "no"
|
|||||||
then
|
then
|
||||||
CFLAGS="$CFLAGS $USER_C_EXTRA_FLAGS"
|
CFLAGS="$CFLAGS $USER_C_EXTRA_FLAGS"
|
||||||
fi
|
fi
|
||||||
OPTION_FLAGS="$USER_CFLAGS $USER_C_EXTRA_FLAGS $CPPFLAGS $AM_CFLAGS"
|
OPTION_FLAGS="$USER_CFLAGS $USER_C_EXTRA_FLAGS $CPPFLAGS $AM_CPPFLAGS $CFLAGS $AM_CFLAGS"
|
||||||
|
|
||||||
|
|
||||||
# The following AM_CONDITIONAL statements set flags for use in the Makefiles.
|
# The following AM_CONDITIONAL statements set flags for use in the Makefiles.
|
||||||
@@ -4899,6 +4901,7 @@ AM_CONDITIONAL([BUILD_PKCS11],[test "x$ENABLED_PKCS11" = "xyes"])
|
|||||||
AM_CONDITIONAL([BUILD_CAVIUM],[test "x$ENABLED_CAVIUM" = "xyes"])
|
AM_CONDITIONAL([BUILD_CAVIUM],[test "x$ENABLED_CAVIUM" = "xyes"])
|
||||||
AM_CONDITIONAL([BUILD_CAVIUM_V],[test "x$ENABLED_CAVIUM_V" = "xyes"])
|
AM_CONDITIONAL([BUILD_CAVIUM_V],[test "x$ENABLED_CAVIUM_V" = "xyes"])
|
||||||
AM_CONDITIONAL([BUILD_INTEL_QA],[test "x$ENABLED_INTEL_QA" = "xyes"])
|
AM_CONDITIONAL([BUILD_INTEL_QA],[test "x$ENABLED_INTEL_QA" = "xyes"])
|
||||||
|
AM_CONDITIONAL([BUILD_INTEL_QA_SYNC],[test "x$ENABLED_INTEL_QA_SYNC" = "xyes"])
|
||||||
AM_CONDITIONAL([BUILD_SP],[test "x$ENABLED_SP" = "xyes"])
|
AM_CONDITIONAL([BUILD_SP],[test "x$ENABLED_SP" = "xyes"])
|
||||||
AM_CONDITIONAL([BUILD_SP_C],[test "x$ENABLED_SP" = "xyes" && test "x$ENABLED_SP_ASM" = "xno" ])
|
AM_CONDITIONAL([BUILD_SP_C],[test "x$ENABLED_SP" = "xyes" && test "x$ENABLED_SP_ASM" = "xno" ])
|
||||||
AM_CONDITIONAL([BUILD_SP_ARM64],[test "x$ENABLED_SP_ARM64_ASM" = "xyes" ])
|
AM_CONDITIONAL([BUILD_SP_ARM64],[test "x$ENABLED_SP_ARM64_ASM" = "xyes" ])
|
||||||
|
@@ -54,6 +54,13 @@
|
|||||||
#include <wolfcrypt/src/misc.c>
|
#include <wolfcrypt/src/misc.c>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WOLF_CRYPTO_CB
|
||||||
|
#include <wolfssl/wolfcrypt/cryptocb.h>
|
||||||
|
#ifdef HAVE_INTEL_QA_SYNC
|
||||||
|
#include <wolfssl/wolfcrypt/port/intel/quickassist_sync.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef WOLFSSL_SNIFFER_TIMEOUT
|
#ifndef WOLFSSL_SNIFFER_TIMEOUT
|
||||||
#define WOLFSSL_SNIFFER_TIMEOUT 900
|
#define WOLFSSL_SNIFFER_TIMEOUT 900
|
||||||
@@ -449,6 +456,14 @@ static void UpdateMissedDataSessions(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WOLF_CRYPTO_CB
|
||||||
|
static int CryptoDeviceId = INVALID_DEVID;
|
||||||
|
#ifdef HAVE_INTEL_QA_SYNC
|
||||||
|
static IntelQaDev CryptoDevice;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Initialize overall Sniffer */
|
/* Initialize overall Sniffer */
|
||||||
void ssl_InitSniffer(void)
|
void ssl_InitSniffer(void)
|
||||||
{
|
{
|
||||||
@@ -460,6 +475,26 @@ void ssl_InitSniffer(void)
|
|||||||
XMEMSET(&SnifferStats, 0, sizeof(SSLStats));
|
XMEMSET(&SnifferStats, 0, sizeof(SSLStats));
|
||||||
wc_InitMutex(&StatsMutex);
|
wc_InitMutex(&StatsMutex);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef WOLF_CRYPTO_CB
|
||||||
|
#ifdef HAVE_INTEL_QA_SYNC
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
CryptoDeviceId = IntelQaInit(NULL);
|
||||||
|
if (CryptoDeviceId == INVALID_DEVID) {
|
||||||
|
WOLFSSL_MSG("Couldn't init the Intel QA");
|
||||||
|
}
|
||||||
|
rc = IntelQaOpen(&CryptoDevice, CryptoDeviceId);
|
||||||
|
if (rc != 0) {
|
||||||
|
WOLFSSL_MSG("Couldn't open the device");
|
||||||
|
}
|
||||||
|
rc = wc_CryptoCb_RegisterDevice(CryptoDeviceId,
|
||||||
|
IntelQaSymSync_CryptoDevCb, &CryptoDevice);
|
||||||
|
if (rc != 0) {
|
||||||
|
WOLFSSL_MSG("Couldn't register the device");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -588,6 +623,14 @@ void ssl_FreeSniffer(void)
|
|||||||
wc_FreeMutex(&SessionMutex);
|
wc_FreeMutex(&SessionMutex);
|
||||||
wc_FreeMutex(&ServerListMutex);
|
wc_FreeMutex(&ServerListMutex);
|
||||||
|
|
||||||
|
#ifdef WOLF_CRYPTO_CB
|
||||||
|
#ifdef HAVE_INTEL_QA_SYNC
|
||||||
|
wc_CryptoCb_UnRegisterDevice(CryptoDeviceId);
|
||||||
|
IntelQaClose(&CryptoDevice);
|
||||||
|
IntelQaDeInit(CryptoDeviceId);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
if (TraceFile) {
|
if (TraceFile) {
|
||||||
TraceOn = 0;
|
TraceOn = 0;
|
||||||
fclose(TraceFile);
|
fclose(TraceFile);
|
||||||
@@ -1335,6 +1378,9 @@ static int CreateWatchSnifferServer(char* error)
|
|||||||
FreeSnifferServer(sniffer);
|
FreeSnifferServer(sniffer);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#ifdef WOLF_CRYPTO_CB
|
||||||
|
wolfSSL_CTX_SetDevId(sniffer->ctx, CryptoDevId);
|
||||||
|
#endif
|
||||||
ServerList = sniffer;
|
ServerList = sniffer;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1433,6 +1479,9 @@ static int SetNamedPrivateKey(const char* name, const char* address, int port,
|
|||||||
FreeSnifferServer(sniffer);
|
FreeSnifferServer(sniffer);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#ifdef WOLF_CRYPTO_CB
|
||||||
|
wolfSSL_CTX_SetDevId(sniffer->ctx, CryptoDeviceId);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef HAVE_SNI
|
#ifdef HAVE_SNI
|
||||||
else {
|
else {
|
||||||
|
@@ -1457,6 +1457,12 @@
|
|||||||
}
|
}
|
||||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||||
|
|
||||||
|
#ifdef WOLF_CRYPTO_CB
|
||||||
|
if (des->devId != INVALID_DEVID) {
|
||||||
|
XMEMCPY(des->devKey, key, DES3_KEYLEN);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = DesSetKey(key + (dir == DES_ENCRYPTION ? 0:16), dir, des->key[0]);
|
ret = DesSetKey(key + (dir == DES_ENCRYPTION ? 0:16), dir, des->key[0]);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -102,15 +102,17 @@ endif
|
|||||||
|
|
||||||
if BUILD_CAVIUM
|
if BUILD_CAVIUM
|
||||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/cavium/cavium_nitrox.c
|
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/cavium/cavium_nitrox.c
|
||||||
|
|
||||||
EXTRA_DIST += wolfcrypt/src/port/cavium/README.md
|
|
||||||
endif
|
endif
|
||||||
|
EXTRA_DIST += wolfcrypt/src/port/cavium/README.md
|
||||||
|
|
||||||
if BUILD_INTEL_QA
|
if BUILD_INTEL_QA
|
||||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/intel/quickassist.c
|
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/intel/quickassist.c
|
||||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/intel/quickassist_mem.c
|
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/intel/quickassist_mem.c
|
||||||
|
endif
|
||||||
EXTRA_DIST += wolfcrypt/src/port/intel/README.md
|
EXTRA_DIST += wolfcrypt/src/port/intel/README.md
|
||||||
|
|
||||||
|
if BUILD_INTEL_QA_SYNC
|
||||||
|
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/intel/quickassist_sync.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if BUILD_CRYPTOAUTHLIB
|
if BUILD_CRYPTOAUTHLIB
|
||||||
|
1763
wolfcrypt/src/port/intel/quickassist_sync.c
Normal file
1763
wolfcrypt/src/port/intel/quickassist_sync.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -74,6 +74,10 @@
|
|||||||
#include <wolfssl/wolfcrypt/cryptocb.h>
|
#include <wolfssl/wolfcrypt/cryptocb.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_INTEL_QA_SYNC
|
||||||
|
#include <wolfssl/wolfcrypt/port/intel/quickassist_sync.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
/* 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy */
|
/* 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy */
|
||||||
#pragma warning(disable: 4996)
|
#pragma warning(disable: 4996)
|
||||||
@@ -124,7 +128,11 @@ int wolfCrypt_Init(void)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_INTEL_QA_SYNC
|
||||||
|
ret = IntelQaHardwareStart(QAT_PROCESS_NAME, QAT_LIMIT_DEV_ACCESS);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(WOLFSSL_TRACK_MEMORY) && !defined(WOLFSSL_STATIC_MEMORY)
|
#if defined(WOLFSSL_TRACK_MEMORY) && !defined(WOLFSSL_STATIC_MEMORY)
|
||||||
ret = InitMemoryTracker();
|
ret = InitMemoryTracker();
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
@@ -258,6 +266,10 @@ int wolfCrypt_Cleanup(void)
|
|||||||
wolfAsync_HardwareStop();
|
wolfAsync_HardwareStop();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_INTEL_QA_SYNC
|
||||||
|
IntelQaHardwareStop();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(WOLFSSL_IMX6_CAAM) || defined(WOLFSSL_IMX6_CAAM_RNG) || \
|
#if defined(WOLFSSL_IMX6_CAAM) || defined(WOLFSSL_IMX6_CAAM_RNG) || \
|
||||||
defined(WOLFSSL_IMX6_CAAM_BLOB)
|
defined(WOLFSSL_IMX6_CAAM_BLOB)
|
||||||
wc_caamFree();
|
wc_caamFree();
|
||||||
|
@@ -59,7 +59,7 @@ typedef struct WOLFSSL_AES_KEY {
|
|||||||
#ifdef HAVE_PKCS11
|
#ifdef HAVE_PKCS11
|
||||||
void* pkcs11_holder[(AES_MAX_ID_LEN + sizeof(int)) / sizeof(void*)];
|
void* pkcs11_holder[(AES_MAX_ID_LEN + sizeof(int)) / sizeof(void*)];
|
||||||
#endif
|
#endif
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#if defined(WOLFSSL_ASYNC_CRYPT) || defined(WOLF_CRYPTO_CB)
|
||||||
void* async_holder[128 / sizeof(void*)];
|
void* async_holder[128 / sizeof(void*)];
|
||||||
#endif
|
#endif
|
||||||
} WOLFSSL_AES_KEY;
|
} WOLFSSL_AES_KEY;
|
||||||
|
@@ -105,6 +105,7 @@ struct Des3 {
|
|||||||
WC_ASYNC_DEV asyncDev;
|
WC_ASYNC_DEV asyncDev;
|
||||||
#endif
|
#endif
|
||||||
#ifdef WOLF_CRYPTO_CB
|
#ifdef WOLF_CRYPTO_CB
|
||||||
|
word32 devKey[DES3_KEYLEN/sizeof(word32)]; /* raw key */
|
||||||
int devId;
|
int devId;
|
||||||
void* devCtx;
|
void* devCtx;
|
||||||
#endif
|
#endif
|
||||||
|
@@ -111,6 +111,10 @@ nobase_include_HEADERS+= wolfssl/wolfcrypt/port/intel/quickassist.h
|
|||||||
nobase_include_HEADERS+= wolfssl/wolfcrypt/port/intel/quickassist_mem.h
|
nobase_include_HEADERS+= wolfssl/wolfcrypt/port/intel/quickassist_mem.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if BUILD_INTEL_QA_SYNC
|
||||||
|
nobase_include_HEADERS+= wolfssl/wolfcrypt/port/intel/quickassist_sync.h
|
||||||
|
endif
|
||||||
|
|
||||||
if BUILD_SP
|
if BUILD_SP
|
||||||
nobase_include_HEADERS+= wolfssl/wolfcrypt/sp.h
|
nobase_include_HEADERS+= wolfssl/wolfcrypt/sp.h
|
||||||
nobase_include_HEADERS+= wolfssl/wolfcrypt/sp_int.h
|
nobase_include_HEADERS+= wolfssl/wolfcrypt/sp_int.h
|
||||||
|
229
wolfssl/wolfcrypt/port/intel/quickassist_sync.h
Normal file
229
wolfssl/wolfcrypt/port/intel/quickassist_sync.h
Normal file
@@ -0,0 +1,229 @@
|
|||||||
|
/* quickassist_sync.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2019 wolfSSL Inc.
|
||||||
|
*
|
||||||
|
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||||
|
*
|
||||||
|
* wolfSSL 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.
|
||||||
|
*
|
||||||
|
* wolfSSL 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _INTEL_QUICKASSIST_SYNC_H_
|
||||||
|
#define _INTEL_QUICKASSIST_SYNC_H_
|
||||||
|
|
||||||
|
#ifdef HAVE_INTEL_QA_SYNC
|
||||||
|
|
||||||
|
#include "cpa.h"
|
||||||
|
#include "cpa_cy_im.h"
|
||||||
|
#include "cpa_cy_sym.h"
|
||||||
|
#include "cpa_cy_rsa.h"
|
||||||
|
#include "cpa_cy_ln.h"
|
||||||
|
#include "cpa_cy_ecdh.h"
|
||||||
|
#include "cpa_cy_ecdsa.h"
|
||||||
|
#include "cpa_cy_dh.h"
|
||||||
|
#include "cpa_cy_drbg.h"
|
||||||
|
#include "cpa_cy_nrbg.h"
|
||||||
|
#include "cpa_cy_prime.h"
|
||||||
|
|
||||||
|
/* User space utils */
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* Optional feature for partial QAT hashing support */
|
||||||
|
/* This will process updates through hardware instead of caching them */
|
||||||
|
#define QAT_HASH_ENABLE_PARTIAL
|
||||||
|
#endif
|
||||||
|
#ifdef QAT_HASH_ENABLE_PARTIAL
|
||||||
|
#define MAX_QAT_HASH_BUFFERS 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Detect QAT driver version */
|
||||||
|
#if defined(CPA_CY_API_VERSION_NUM_MAJOR) && CPA_CY_API_VERSION_NUM_MAJOR > 1
|
||||||
|
#define QAT_V2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef QAT_V2
|
||||||
|
/* quickassist/utilities/libusdm_drv/qae_mem.h */
|
||||||
|
/* Provides user-space API's for accessing NUMA allocated memory through usdm_drv */
|
||||||
|
#include "qae_mem.h"
|
||||||
|
#include "linux/include/qae_mem_utils.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef QAT_USE_POLLING_THREAD
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
|
#ifdef QA_DEMO_MAIN
|
||||||
|
#include <semaphore.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Tunable parameters */
|
||||||
|
#ifndef QAT_PROCESS_NAME
|
||||||
|
#define QAT_PROCESS_NAME "SSL"
|
||||||
|
#endif
|
||||||
|
#ifndef QAT_LIMIT_DEV_ACCESS
|
||||||
|
#define QAT_LIMIT_DEV_ACCESS CPA_FALSE
|
||||||
|
#endif
|
||||||
|
#ifndef QAT_MAX_DEVICES
|
||||||
|
#define QAT_MAX_DEVICES (1) /* maximum number of QAT cards */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef QAT_RETRY_LIMIT
|
||||||
|
#define QAT_RETRY_LIMIT (100)
|
||||||
|
#endif
|
||||||
|
#ifndef QAT_POLL_RESP_QUOTA
|
||||||
|
#define QAT_POLL_RESP_QUOTA (0) /* all pending */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(NO_AES) || !defined(NO_DES3)
|
||||||
|
#define QAT_ENABLE_CRYPTO
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Pre-declarations */
|
||||||
|
struct IntelQaDev;
|
||||||
|
struct wc_CryptoInfo;
|
||||||
|
struct WC_BIGINT;
|
||||||
|
struct WC_RNG;
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(QAT_ENABLE_HASH) || defined(QAT_ENABLE_CRYPTO)
|
||||||
|
/* symmetric context */
|
||||||
|
typedef struct IntelQaSymCtx {
|
||||||
|
CpaCySymOpData opData;
|
||||||
|
CpaCySymSessionCtx symCtxSrc;
|
||||||
|
CpaCySymSessionCtx symCtx;
|
||||||
|
word32 symCtxSize;
|
||||||
|
|
||||||
|
/* flags */
|
||||||
|
word32 isOpen:1;
|
||||||
|
word32 isCopy:1;
|
||||||
|
} IntelQaSymCtx;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef void (*IntelQaFreeFunc)(struct IntelQaDev*);
|
||||||
|
|
||||||
|
|
||||||
|
/* QuickAssist device */
|
||||||
|
typedef struct IntelQaDev {
|
||||||
|
CpaInstanceHandle handle;
|
||||||
|
int devId;
|
||||||
|
void* heap;
|
||||||
|
|
||||||
|
/* callback return info */
|
||||||
|
int ret;
|
||||||
|
byte* out;
|
||||||
|
union {
|
||||||
|
word32* outLenPtr;
|
||||||
|
word32 outLen;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* operations */
|
||||||
|
IntelQaFreeFunc freeFunc;
|
||||||
|
union {
|
||||||
|
#ifdef QAT_ENABLE_CRYPTO
|
||||||
|
struct {
|
||||||
|
IntelQaSymCtx ctx;
|
||||||
|
CpaBufferList bufferList;
|
||||||
|
CpaFlatBuffer flatBuffer;
|
||||||
|
byte* authTag;
|
||||||
|
word32 authTagSz;
|
||||||
|
} cipher;
|
||||||
|
#endif
|
||||||
|
} op;
|
||||||
|
|
||||||
|
#ifdef QAT_USE_POLLING_THREAD
|
||||||
|
pthread_t pollingThread;
|
||||||
|
byte pollingCy;
|
||||||
|
#endif
|
||||||
|
} IntelQaDev;
|
||||||
|
|
||||||
|
|
||||||
|
/* Interface */
|
||||||
|
WOLFSSL_LOCAL int IntelQaHardwareStart(const char*, int);
|
||||||
|
WOLFSSL_LOCAL void IntelQaHardwareStop(void);
|
||||||
|
WOLFSSL_LOCAL int IntelQaInit(void*);
|
||||||
|
WOLFSSL_LOCAL void IntelQaDeInit(int);
|
||||||
|
WOLFSSL_LOCAL int IntelQaNumInstances(void);
|
||||||
|
WOLFSSL_LOCAL int IntelQaOpen(IntelQaDev*, int);
|
||||||
|
WOLFSSL_LOCAL void IntelQaClose(IntelQaDev*);
|
||||||
|
WOLFSSL_LOCAL int IntelQaDevCopy(IntelQaDev*, IntelQaDev*);
|
||||||
|
WOLFSSL_LOCAL int IntelQaPoll(IntelQaDev*);
|
||||||
|
WOLFSSL_LOCAL int IntelQaGetCyInstanceCount(void);
|
||||||
|
|
||||||
|
#ifndef NO_AES
|
||||||
|
#ifdef HAVE_AES_CBC
|
||||||
|
WOLFSSL_LOCAL int IntelQaSymAesCbcEncrypt(IntelQaDev*, byte*,
|
||||||
|
const byte*, word32, const byte*, word32, const byte*, word32);
|
||||||
|
#ifdef HAVE_AES_DECRYPT
|
||||||
|
WOLFSSL_LOCAL int IntelQaSymAesCbcDecrypt(IntelQaDev*, byte*,
|
||||||
|
const byte*, word32, const byte*, word32, const byte*, word32);
|
||||||
|
#endif /* HAVE_AES_DECRYPT */
|
||||||
|
#endif /* HAVE_AES_CBC */
|
||||||
|
|
||||||
|
#ifdef HAVE_AESGCM
|
||||||
|
WOLFSSL_LOCAL int IntelQaSymAesGcmEncrypt(IntelQaDev*, byte*,
|
||||||
|
const byte*, word32, const byte*, word32, const byte*, word32,
|
||||||
|
byte*, word32, const byte*, word32);
|
||||||
|
#ifdef HAVE_AES_DECRYPT
|
||||||
|
WOLFSSL_LOCAL int IntelQaSymAesGcmDecrypt(IntelQaDev*, byte*,
|
||||||
|
const byte*, word32, const byte*, word32, const byte*, word32,
|
||||||
|
const byte*, word32, const byte*, word32);
|
||||||
|
#endif /* HAVE_AES_DECRYPT */
|
||||||
|
#endif /* HAVE_AESGCM */
|
||||||
|
#endif /* !NO_AES */
|
||||||
|
|
||||||
|
#ifndef NO_DES3
|
||||||
|
WOLFSSL_LOCAL int IntelQaSymDes3CbcEncrypt(IntelQaDev*, byte*,
|
||||||
|
const byte*, word32, const byte*, word32, const byte* iv, word32);
|
||||||
|
WOLFSSL_LOCAL int IntelQaSymDes3CbcDecrypt(IntelQaDev* dev, byte*,
|
||||||
|
const byte*, word32, const byte*, word32, const byte* iv, word32);
|
||||||
|
#endif /*! NO_DES3 */
|
||||||
|
|
||||||
|
#ifdef WOLF_CRYPTO_CB
|
||||||
|
WOLFSSL_LOCAL int IntelQaSymSync_CryptoDevCb(int, struct wc_CryptoInfo*,
|
||||||
|
void*);
|
||||||
|
#endif /* WOLF_CRYPTO_CB */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_TRACK_MEMORY
|
||||||
|
WOLFSSL_API int InitMemoryTracker(void);
|
||||||
|
WOLFSSL_API void ShowMemoryTracker(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
WOLFSSL_API void* IntelQaMalloc(size_t size, void* heap, int type
|
||||||
|
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||||
|
, const char* func, unsigned int line
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
WOLFSSL_API void IntelQaFree(void *ptr, void* heap, int type
|
||||||
|
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||||
|
, const char* func, unsigned int line
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
WOLFSSL_API void* IntelQaRealloc(void *ptr, size_t size, void* heap, int type
|
||||||
|
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||||
|
, const char* func, unsigned int line
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
#endif /* HAVE_INTEL_QA_SYNC */
|
||||||
|
|
||||||
|
#endif /* _INTEL_QUICKASSIST_SYNC_H_ */
|
@@ -233,8 +233,13 @@
|
|||||||
WOLFSSL_API void* XMALLOC(size_t n, void* heap, int type);
|
WOLFSSL_API void* XMALLOC(size_t n, void* heap, int type);
|
||||||
WOLFSSL_API void* XREALLOC(void *p, size_t n, void* heap, int type);
|
WOLFSSL_API void* XREALLOC(void *p, size_t n, void* heap, int type);
|
||||||
WOLFSSL_API void XFREE(void *p, void* heap, int type);
|
WOLFSSL_API void XFREE(void *p, void* heap, int type);
|
||||||
#elif defined(WOLFSSL_ASYNC_CRYPT) && defined(HAVE_INTEL_QA)
|
#elif (defined(WOLFSSL_ASYNC_CRYPT) && defined(HAVE_INTEL_QA)) || \
|
||||||
#include <wolfssl/wolfcrypt/port/intel/quickassist_mem.h>
|
defined(HAVE_INTEL_QA_SYNC)
|
||||||
|
#ifndef HAVE_INTEL_QA_SYNC
|
||||||
|
#include <wolfssl/wolfcrypt/port/intel/quickassist_mem.h>
|
||||||
|
#else
|
||||||
|
#include <wolfssl/wolfcrypt/port/intel/quickassist_sync.h>
|
||||||
|
#endif
|
||||||
#undef USE_WOLFSSL_MEMORY
|
#undef USE_WOLFSSL_MEMORY
|
||||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||||
#define XMALLOC(s, h, t) IntelQaMalloc((s), (h), (t), __func__, __LINE__)
|
#define XMALLOC(s, h, t) IntelQaMalloc((s), (h), (t), __func__, __LINE__)
|
||||||
|
Reference in New Issue
Block a user