From 825f3119592744c35c203e2b69b2a533f8dac43d Mon Sep 17 00:00:00 2001 From: John Safranek Date: Fri, 11 Oct 2019 13:20:24 -0400 Subject: [PATCH] add OCTEON and QAT to wolfCrypt test, update SHA-1 to reset ret when it will do the software sha --- wolfcrypt/src/sha.c | 2 ++ wolfcrypt/test/test.c | 54 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/wolfcrypt/src/sha.c b/wolfcrypt/src/sha.c index 1eee40bc3..cdd7146c3 100644 --- a/wolfcrypt/src/sha.c +++ b/wolfcrypt/src/sha.c @@ -499,6 +499,7 @@ int wc_ShaUpdate(wc_Sha* sha, const byte* data, word32 len) ret = wc_CryptoCb_ShaHash(sha, data, len, NULL); if (ret != CRYPTOCB_UNAVAILABLE) return ret; + ret = 0; /* reset ret */ /* fall-through when unavailable */ } #endif @@ -653,6 +654,7 @@ int wc_ShaFinal(wc_Sha* sha, byte* hash) ret = wc_CryptoCb_ShaHash(sha, NULL, 0, hash); if (ret != CRYPTOCB_UNAVAILABLE) return ret; + ret = 0; /* reset ret */ /* fall-through when unavailable */ } #endif diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 9c3db9618..04de111b9 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -196,6 +196,12 @@ #endif #ifdef WOLF_CRYPTO_CB #include + #ifdef HAVE_INTEL_QA_SYNC + #include + #endif + #ifdef HAVE_CAVIUM_OCTEON_SYNC + #include + #endif #endif #ifdef _MSC_VER @@ -252,6 +258,10 @@ static void initDefaultName(void); /* for async devices */ static int devId = INVALID_DEVID; +#if defined(WOLF_CRYPTO_CB) && defined(HAVE_INTEL_QA_SYNC) + static THREAD_LS_T IntelQaDev devQat; +#endif + #ifdef HAVE_WNR const char* wnrConfigFile = "wnr-example.conf"; #endif @@ -560,6 +570,39 @@ initDefaultName(); (void)devId; #endif /* WOLFSSL_ASYNC_CRYPT */ +#ifdef WOLF_CRYPTO_CB +#ifdef HAVE_INTEL_QA_SYNC + { + int rc; + devId = IntelQaInit(NULL); + if (devId == INVALID_DEVID) { + printf("Couldn't init the Intel QA\n"); + } + rc = IntelQaOpen(&devQat, devId); + if (rc != 0) { + printf("Couldn't open the device\n"); + } + rc = wc_CryptoCb_RegisterDevice(devId, + IntelQaSymSync_CryptoDevCb, &devQat); + if (rc != 0) { + printf("Couldn't register the device\n"); + } + } +#endif +#ifdef HAVE_CAVIUM_OCTEON_SYNC + { + devId = wc_CryptoCb_GetDevIdOcteon(); + if (devId == INVALID_DEVID) { + printf("Couldn't get the Octeon device ID\n"); + } + if (wc_CryptoCb_InitOcteon() != 0) { + printf("Couldn't init the Cavium Octeon\n"); + devId = INVALID_DEVID; + } + } +#endif +#endif + #ifdef HAVE_SELFTEST if ( (ret = wolfCrypt_SelfTest()) != 0) return err_sys("CAVP selftest failed!\n", ret); @@ -1122,6 +1165,17 @@ initDefaultName(); test_pass("cert piv test passed!\n"); #endif +#ifdef WOLF_CRYPTO_CB +#ifdef HAVE_INTEL_QA_SYNC + wc_CryptoCb_UnRegisterDevice(devId); + IntelQaClose(&devQat); + IntelQaDeInit(devId); +#endif +#ifdef HAVE_CAVIUM_OCTEON_SYNC + wc_CryptoCb_CleanupOcteon(); +#endif +#endif + #ifdef WOLFSSL_ASYNC_CRYPT wolfAsync_DevClose(&devId); #endif