diff --git a/src/sniffer.c b/src/sniffer.c index 12fd113d8..7741c3f63 100644 --- a/src/sniffer.c +++ b/src/sniffer.c @@ -61,6 +61,9 @@ #ifdef HAVE_INTEL_QA_SYNC #include #endif + #ifdef HAVE_CAVIUM_OCTEON_SYNC + #include + #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) { diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 2e13b27e4..58a3f2391 100755 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -174,6 +174,9 @@ #ifdef WOLF_CRYPTO_CB #include + #ifdef HAVE_INTEL_QA_SYNC + #include + #endif #ifdef HAVE_CAVIUM_OCTEON_SYNC #include #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(); diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c index 08b3fec73..caf798795 100644 --- a/wolfcrypt/src/aes.c +++ b/wolfcrypt/src/aes.c @@ -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 diff --git a/wolfcrypt/src/port/cavium/cavium_octeon_sync.c b/wolfcrypt/src/port/cavium/cavium_octeon_sync.c index dc7577111..b379ab0dd 100644 --- a/wolfcrypt/src/port/cavium/cavium_octeon_sync.c +++ b/wolfcrypt/src/port/cavium/cavium_octeon_sync.c @@ -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); diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index f13a23740..18ca54180 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -76,6 +76,7 @@ #ifdef HAVE_INTEL_QA_SYNC #include +#endif #ifdef HAVE_CAVIUM_OCTEON_SYNC #include diff --git a/wolfssl/wolfcrypt/des3.h b/wolfssl/wolfcrypt/des3.h index 9c5e5d530..69cd6ed47 100644 --- a/wolfssl/wolfcrypt/des3.h +++ b/wolfssl/wolfcrypt/des3.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; }; diff --git a/wolfssl/wolfcrypt/port/intel/quickassist_sync.h b/wolfssl/wolfcrypt/port/intel/quickassist_sync.h index 974d2b500..6a03ced37 100644 --- a/wolfssl/wolfcrypt/port/intel/quickassist_sync.h +++ b/wolfssl/wolfcrypt/port/intel/quickassist_sync.h @@ -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 */