Synchronous Quick Assist Support for Sniffer

1. Add configure option for sync IntelQA that uses the crypto callback API.
2. Refactor the IntelQA configure checks so they are usable by both the sync and async options.
3. Make a synchonous copy of the quickassist files.
4. Replace the printfs in the code with a logging macro.
5. Added padding to the AES_KEY structure for WOLF_CRYPTO_CB.
6. Tie in the crypto device to the sniffer.
7. When setting up the symmetric operation, add a build case for the sniffer to use malloc instead of realloc. Sniffer usually uses the middle of another buffer for the input data rather than the beginning of the buffer as it has the TCP/IP data to handle as well.
8. Add the raw key to the DES3 structure.
9. Copy the functions from qa_mem over to qa_sync.
pull/2493/head
John Safranek 2019-10-02 10:08:46 -07:00
parent 43e391528d
commit 9a5eb1bb67
11 changed files with 2116 additions and 54 deletions

View File

@ -3872,59 +3872,57 @@ AC_ARG_WITH([cavium-v],
# Intel QuickAssist
QAT_DIR=""
BUILD_INTEL_QAT_VERSION=2
AC_ARG_WITH([intelqa],
[ --with-intelqa=PATH PATH to Intel QuickAssist (QAT) driver dir ],
[
AC_MSG_CHECKING([for intelqa])
CPPFLAGS="$CPPFLAGS -DHAVE_INTEL_QA -DDO_CRYPTO -DUSER_SPACE"
OLD_LIBS="$LIBS"
[AS_HELP_STRING([--with-intelqa=PATH],[PATH to Intel QuickAssist (QAT) driver dir])],
[ENABLED_INTEL_QA=yes; QAT_DIR=$withval],
[ENABLED_INTEL_QA=no])
if test "x$withval" = "xyes" ; then
AC_MSG_ERROR([need a PATH for --with-intelqa])
fi
if test "x$withval" != "xno" ; then
QAT_DIR=$withval
fi
AC_ARG_WITH([intelqa-sync],
[AS_HELP_STRING([--with-intelqa-sync=PATH],[PATH to Intel QuickAssist (QAT) driver dir (sync)])],
[ENABLED_INTEL_QA_SYNC=yes; QAT_DIR=$withval],
[ENABLED_INTEL_QA_SYNC=no])
CPPFLAGS="$CPPFLAGS -I$QAT_DIR/quickassist/include -I$QAT_DIR/quickassist/include/lac -I$QAT_DIR/quickassist/utilities/osal/include \
-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"
AS_IF([test "x$ENABLED_INTEL_QA" = "xyes" && test "x$ENABLED_INTEL_QA_SYNC" = "xyes"],
[AC_MSG_ERROR([Both Intel QA Async and Sync are selected, only select one.])])
LDFLAGS="$LDFLAGS -L$QAT_DIR/build"
LIBS="$LIBS -lqat_s -lusdm_drv_s"
AS_IF([test "x$ENABLED_INTEL_QA" = "xyes" || test "x$ENABLED_INTEL_QA_SYNC" = "xyes"],
[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); ]])],
[ intelqa_linked=yes ],[ intelqa_linked=no ])
if test "x$intelqa_linked" = "xno" ; then
# Try old QAT driver libraries
AS_IF([test "x$QAT_DIR" = "xyes"],[AC_MSG_ERROR([need a PATH for --with-intelqa$intelqa_opt])])
AM_CPPFLAGS="$AM_CPPFLAGS -I$QAT_DIR/quickassist/include -I$QAT_DIR/quickassist/include/lac -I$QAT_DIR/quickassist/utilities/osal/include \
-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"
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); ]])],
[ 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])
AC_MSG_RESULT([yes])
if test "x$BUILD_INTEL_QAT_VERSION" == "x1" ; then
LIB_ADD="-ladf_proxy -losal -lrt $LIB_ADD"
else
LIB_ADD="-losal -lrt $LIB_ADD"
fi
ENABLED_INTEL_QA=yes
],
[
ENABLED_INTEL_QA=no
]
)
AS_IF([test "x$BUILD_INTEL_QAT_VERSION" == "x1"],
[LIB_ADD="-ladf_proxy -losal -lrt $LIB_ADD"],
[LIB_ADD="-losal -lrt $LIB_ADD"])
CPPFLAGS="$OLD_CPPFLAGS"
])
# Single Precision maths implementation
@ -4354,7 +4352,7 @@ fi
# 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_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
@ -4569,6 +4567,10 @@ AS_IF([test "x$ENABLED_OCSP" = "xyes" && \
test "x$ENABLED_ECC" = "xno"],
[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
AS_IF([test "x$ENABLED_PKCS7" = "xyes" && \
test "x$ENABLED_RSA" = "xno" && \
@ -4794,7 +4796,7 @@ if test "$ENABLED_DISTRO" = "no"
then
CFLAGS="$CFLAGS $USER_C_EXTRA_FLAGS"
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.
@ -4886,6 +4888,7 @@ AM_CONDITIONAL([BUILD_PKCS11],[test "x$ENABLED_PKCS11" = "xyes"])
AM_CONDITIONAL([BUILD_CAVIUM],[test "x$ENABLED_CAVIUM" = "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_SYNC],[test "x$ENABLED_INTEL_QA_SYNC" = "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_ARM64],[test "x$ENABLED_SP_ARM64_ASM" = "xyes" ])

View File

@ -54,6 +54,13 @@
#include <wolfcrypt/src/misc.c>
#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
#define WOLFSSL_SNIFFER_TIMEOUT 900
@ -449,6 +456,14 @@ static void UpdateMissedDataSessions(void)
#endif
#ifdef WOLF_CRYPTO_CB
static int CryptoDeviceId = INVALID_DEVID;
#ifdef HAVE_INTEL_QA_SYNC
static IntelQaDev CryptoDevice;
#endif
#endif
/* Initialize overall Sniffer */
void ssl_InitSniffer(void)
{
@ -460,6 +475,26 @@ void ssl_InitSniffer(void)
XMEMSET(&SnifferStats, 0, sizeof(SSLStats));
wc_InitMutex(&StatsMutex);
#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
}
@ -1335,6 +1370,9 @@ static int CreateWatchSnifferServer(char* error)
FreeSnifferServer(sniffer);
return -1;
}
#ifdef WOLF_CRYPTO_CB
wolfSSL_CTX_SetDevId(sniffer->ctx, CryptoDevId);
#endif
ServerList = sniffer;
return 0;
@ -1433,6 +1471,9 @@ static int SetNamedPrivateKey(const char* name, const char* address, int port,
FreeSnifferServer(sniffer);
return -1;
}
#ifdef WOLF_CRYPTO_CB
wolfSSL_CTX_SetDevId(sniffer->ctx, CryptoDeviceId);
#endif
}
#ifdef HAVE_SNI
else {

View File

@ -1457,6 +1457,12 @@
}
#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]);
if (ret != 0)
return ret;

View File

@ -102,15 +102,17 @@ endif
if BUILD_CAVIUM
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/cavium/cavium_nitrox.c
EXTRA_DIST += wolfcrypt/src/port/cavium/README.md
endif
EXTRA_DIST += wolfcrypt/src/port/cavium/README.md
if BUILD_INTEL_QA
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/intel/quickassist.c
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/intel/quickassist_mem.c
endif
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
if BUILD_CRYPTOAUTHLIB

File diff suppressed because it is too large Load Diff

View File

@ -74,6 +74,10 @@
#include <wolfssl/wolfcrypt/cryptocb.h>
#endif
#ifdef HAVE_INTEL_QA_SYNC
#include <wolfssl/wolfcrypt/port/intel/quickassist_sync.h>
#endif
#ifdef _MSC_VER
/* 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy */
#pragma warning(disable: 4996)
@ -124,7 +128,11 @@ int wolfCrypt_Init(void)
return ret;
}
#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)
ret = InitMemoryTracker();
if (ret != 0) {

View File

@ -59,7 +59,7 @@ typedef struct WOLFSSL_AES_KEY {
#ifdef HAVE_PKCS11
void* pkcs11_holder[(AES_MAX_ID_LEN + sizeof(int)) / sizeof(void*)];
#endif
#ifdef WOLFSSL_ASYNC_CRYPT
#if defined(WOLFSSL_ASYNC_CRYPT) || defined(WOLF_CRYPTO_CB)
void* async_holder[128 / sizeof(void*)];
#endif
} WOLFSSL_AES_KEY;

View File

@ -105,6 +105,7 @@ struct Des3 {
WC_ASYNC_DEV asyncDev;
#endif
#ifdef WOLF_CRYPTO_CB
word32 devKey[DES3_KEYLEN/sizeof(word32)]; /* raw key */
int devId;
void* devCtx;
#endif

View File

@ -111,6 +111,10 @@ nobase_include_HEADERS+= wolfssl/wolfcrypt/port/intel/quickassist.h
nobase_include_HEADERS+= wolfssl/wolfcrypt/port/intel/quickassist_mem.h
endif
if BUILD_INTEL_QA_SYNC
nobase_include_HEADERS+= wolfssl/wolfcrypt/port/intel/quickassist_sync.h
endif
if BUILD_SP
nobase_include_HEADERS+= wolfssl/wolfcrypt/sp.h
nobase_include_HEADERS+= wolfssl/wolfcrypt/sp_int.h

View 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_ */

View File

@ -233,8 +233,13 @@
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 XFREE(void *p, void* heap, int type);
#elif defined(WOLFSSL_ASYNC_CRYPT) && defined(HAVE_INTEL_QA)
#include <wolfssl/wolfcrypt/port/intel/quickassist_mem.h>
#elif (defined(WOLFSSL_ASYNC_CRYPT) && defined(HAVE_INTEL_QA)) || \
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
#ifdef WOLFSSL_DEBUG_MEMORY
#define XMALLOC(s, h, t) IntelQaMalloc((s), (h), (t), __func__, __LINE__)