forked from wolfSSL/wolfssl
Fixing some play-nice between sync QAT and sync Octeon.
This commit is contained in:
@ -61,6 +61,9 @@
|
||||
#ifdef HAVE_INTEL_QA_SYNC
|
||||
#include <wolfssl/wolfcrypt/port/intel/quickassist_sync.h>
|
||||
#endif
|
||||
#ifdef HAVE_CAVIUM_OCTEON_SYNC
|
||||
#include <wolfssl/wolfcrypt/port/cavium/cavium_octeon_sync.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@ -508,16 +511,28 @@ void ssl_InitSniffer(void)
|
||||
int rc;
|
||||
CryptoDeviceId = IntelQaInit(NULL);
|
||||
if (CryptoDeviceId == INVALID_DEVID) {
|
||||
WOLFSSL_MSG("Couldn't init the Intel QA");
|
||||
printf("Couldn't init the Intel QA\n");
|
||||
}
|
||||
rc = IntelQaOpen(&CryptoDevice, CryptoDeviceId);
|
||||
if (rc != 0) {
|
||||
WOLFSSL_MSG("Couldn't open the device");
|
||||
printf("Couldn't open the device\n");
|
||||
}
|
||||
rc = wc_CryptoCb_RegisterDevice(CryptoDeviceId,
|
||||
IntelQaSymSync_CryptoDevCb, &CryptoDevice);
|
||||
if (rc != 0) {
|
||||
WOLFSSL_MSG("Couldn't register the device");
|
||||
printf("Couldn't register the device\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_CAVIUM_OCTEON_SYNC
|
||||
{
|
||||
CryptoDeviceId = wc_CryptoCb_GetDevIdOcteon();
|
||||
if (CryptoDeviceId == INVALID_DEVID) {
|
||||
printf("Couldn't get the Octeon device ID\n");
|
||||
}
|
||||
if (wc_CryptoCb_InitOcteon() != 0) {
|
||||
printf("Couldn't init the Cavium Octeon\n");
|
||||
CryptoDeviceId = INVALID_DEVID;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -656,6 +671,9 @@ void ssl_FreeSniffer(void)
|
||||
IntelQaClose(&CryptoDevice);
|
||||
IntelQaDeInit(CryptoDeviceId);
|
||||
#endif
|
||||
#ifdef HAVE_CAVIUM_OCTEON_SYNC
|
||||
wc_CryptoCb_CleanupOcteon();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (TraceFile) {
|
||||
|
@ -174,6 +174,9 @@
|
||||
|
||||
#ifdef WOLF_CRYPTO_CB
|
||||
#include <wolfssl/wolfcrypt/cryptocb.h>
|
||||
#ifdef HAVE_INTEL_QA_SYNC
|
||||
#include <wolfssl/wolfcrypt/port/intel/quickassist_sync.h>
|
||||
#endif
|
||||
#ifdef HAVE_CAVIUM_OCTEON_SYNC
|
||||
#include <wolfssl/wolfcrypt/port/cavium/cavium_octeon_sync.h>
|
||||
#endif
|
||||
@ -1305,16 +1308,16 @@ static void* benchmarks_do(void* args)
|
||||
int rc;
|
||||
devId = IntelQaInit(NULL);
|
||||
if (devId == INVALID_DEVID) {
|
||||
WOLFSSL_MSG("Couldn't init the Intel QA");
|
||||
printf("Couldn't init the Intel QA\n");
|
||||
}
|
||||
rc = IntelQaOpen(&devQat, devId);
|
||||
if (rc != 0) {
|
||||
WOLFSSL_MSG("Couldn't open the device");
|
||||
printf("Couldn't open the device\n");
|
||||
}
|
||||
rc = wc_CryptoCb_RegisterDevice(devId,
|
||||
IntelQaSymSync_CryptoDevCb, &devQat);
|
||||
if (rc != 0) {
|
||||
WOLFSSL_MSG("Couldn't register the device");
|
||||
printf("Couldn't register the device\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1372,7 +1375,7 @@ static void* benchmarks_do(void* args)
|
||||
XMEMSET(bench_plain, 0, (size_t)bench_buf_size);
|
||||
XMEMSET(bench_cipher, 0, (size_t)bench_buf_size);
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) || defined(HAVE_INTEL_QA_SYNC)
|
||||
bench_key = (byte*)XMALLOC(sizeof(bench_key_buf), HEAP_HINT, DYNAMIC_TYPE_WOLF_BIGINT);
|
||||
bench_iv = (byte*)XMALLOC(sizeof(bench_iv_buf), HEAP_HINT, DYNAMIC_TYPE_WOLF_BIGINT);
|
||||
if (bench_key == NULL || bench_iv == NULL) {
|
||||
@ -1824,9 +1827,9 @@ exit:
|
||||
|
||||
#ifdef WOLF_CRYPTO_CB
|
||||
#ifdef HAVE_INTEL_QA_SYNC
|
||||
wc_CryptoCb_UnRegisterDevice(CryptoDeviceId);
|
||||
IntelQaClose(&CryptoDevice);
|
||||
IntelQaDeInit(CryptoDeviceId);
|
||||
wc_CryptoCb_UnRegisterDevice(devId);
|
||||
IntelQaClose(&devQat);
|
||||
IntelQaDeInit(devId);
|
||||
#endif
|
||||
#ifdef HAVE_CAVIUM_OCTEON_SYNC
|
||||
wc_CryptoCb_CleanupOcteon();
|
||||
|
@ -3629,6 +3629,12 @@ int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len)
|
||||
wc_AesGcmSetKey_ex(aes, key, len, 0);
|
||||
#endif
|
||||
|
||||
#ifdef WOLF_CRYPTO_CB
|
||||
if (aes->devId != INVALID_DEVID) {
|
||||
XMEMCPY(aes->devKey, key, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_IMX6_CAAM_BLOB
|
||||
ForceZero(local, sizeof(local));
|
||||
#endif
|
||||
|
@ -503,7 +503,7 @@ static int Octeon_AesGcm_SetKey(Aes* aes)
|
||||
ret = BAD_FUNC_ARG;
|
||||
|
||||
if (ret != 0) {
|
||||
word32* key = (word32*)aes->devKey;
|
||||
uint64_t* key = (uint64_t*)aes->devKey;
|
||||
|
||||
CVMX_MT_AES_KEY(key[0], 0);
|
||||
CVMX_MT_AES_KEY(key[1], 1);
|
||||
|
@ -76,6 +76,7 @@
|
||||
|
||||
#ifdef HAVE_INTEL_QA_SYNC
|
||||
#include <wolfssl/wolfcrypt/port/intel/quickassist_sync.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CAVIUM_OCTEON_SYNC
|
||||
#include <wolfssl/wolfcrypt/port/cavium/cavium_octeon_sync.h>
|
||||
|
@ -109,7 +109,6 @@ struct Des3 {
|
||||
#ifdef WOLF_CRYPTO_CB
|
||||
int devId;
|
||||
void* devCtx;
|
||||
word32 devKey[DES3_KEY_SIZE/sizeof(word32)]; /* raw key */
|
||||
#endif
|
||||
void* heap;
|
||||
};
|
||||
|
@ -155,16 +155,16 @@ typedef struct 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);
|
||||
WOLFSSL_API int IntelQaHardwareStart(const char*, int);
|
||||
WOLFSSL_API void IntelQaHardwareStop(void);
|
||||
WOLFSSL_API int IntelQaInit(void*);
|
||||
WOLFSSL_API void IntelQaDeInit(int);
|
||||
WOLFSSL_API int IntelQaNumInstances(void);
|
||||
WOLFSSL_API int IntelQaOpen(IntelQaDev*, int);
|
||||
WOLFSSL_API void IntelQaClose(IntelQaDev*);
|
||||
WOLFSSL_API int IntelQaDevCopy(IntelQaDev*, IntelQaDev*);
|
||||
WOLFSSL_API int IntelQaPoll(IntelQaDev*);
|
||||
WOLFSSL_API int IntelQaGetCyInstanceCount(void);
|
||||
|
||||
#ifndef NO_AES
|
||||
#ifdef HAVE_AES_CBC
|
||||
@ -196,7 +196,7 @@ WOLFSSL_LOCAL int IntelQaGetCyInstanceCount(void);
|
||||
#endif /*! NO_DES3 */
|
||||
|
||||
#ifdef WOLF_CRYPTO_CB
|
||||
WOLFSSL_LOCAL int IntelQaSymSync_CryptoDevCb(int, struct wc_CryptoInfo*,
|
||||
WOLFSSL_API int IntelQaSymSync_CryptoDevCb(int, struct wc_CryptoInfo*,
|
||||
void*);
|
||||
#endif /* WOLF_CRYPTO_CB */
|
||||
|
||||
|
Reference in New Issue
Block a user