diff --git a/wolfcrypt/src/port/cavium/cavium_octeon_sync.c b/wolfcrypt/src/port/cavium/cavium_octeon_sync.c index 38aec4455..735a9ad3f 100644 --- a/wolfcrypt/src/port/cavium/cavium_octeon_sync.c +++ b/wolfcrypt/src/port/cavium/cavium_octeon_sync.c @@ -52,6 +52,7 @@ #include #endif +#define NOOPT __attribute__((optimize("O0"))) static int devId = 1234; @@ -423,7 +424,7 @@ static int Octeon_AesCbc_Decrypt(Aes *aes, : [r1] "=&d"(in1) , [r2] "=&d"(in2) \ : [r3] "d"(out1), [r4] "d"(out2)) -static void Octeon_GHASH_Restore(word16 poly, byte* h) +static NOOPT void Octeon_GHASH_Restore(word16 poly, byte* h) { word64* bigH = (word64*)h; CVMX_MT_GFM_POLY((word64)poly); @@ -432,7 +433,7 @@ static void Octeon_GHASH_Restore(word16 poly, byte* h) } -static void Octeon_GHASH_Init(word16 poly, byte* h) +static NOOPT void Octeon_GHASH_Init(word16 poly, byte* h) { Octeon_GHASH_Restore(poly, h); CVMX_MT_GFM_RESINP(0, 0); @@ -440,7 +441,7 @@ static void Octeon_GHASH_Init(word16 poly, byte* h) } -static void Octeon_GHASH_Update(byte* in) +static NOOPT void Octeon_GHASH_Update(byte* in) { word64* bigIn = (word64*)in; CVMX_MT_GFM_XOR0(bigIn[0]); @@ -448,7 +449,7 @@ static void Octeon_GHASH_Update(byte* in) } -static void Octeon_GHASH_Final(byte* out, word64 authInSz, word64 inSz) +static NOOPT void Octeon_GHASH_Final(byte* out, word64 authInSz, word64 inSz) { word64* bigOut = (word64*)out; @@ -460,7 +461,7 @@ static void Octeon_GHASH_Final(byte* out, word64 authInSz, word64 inSz) /* Sets the Octeon key with the key found in the Aes record. */ -static int Octeon_AesGcm_SetKey(Aes* aes) +static NOOPT int Octeon_AesGcm_SetKey(Aes* aes) { int ret = 0; @@ -490,7 +491,7 @@ static int Octeon_AesGcm_SetKey(Aes* aes) } -static int Octeon_AesGcm_SetIV(Aes* aes, byte* iv, word32 ivSz) +static NOOPT int Octeon_AesGcm_SetIV(Aes* aes, byte* iv, word32 ivSz) { int ret = 0; @@ -531,7 +532,7 @@ static int Octeon_AesGcm_SetIV(Aes* aes, byte* iv, word32 ivSz) } -static int Octeon_AesGcm_SetAAD(Aes* aes, byte* aad, word32 aadSz) +static NOOPT int Octeon_AesGcm_SetAAD(Aes* aes, byte* aad, word32 aadSz) { word64* p; ALIGN16 byte aesBlock[AES_BLOCK_SIZE]; @@ -667,7 +668,7 @@ static int Octeon_AesGcm_SetEncrypt(Aes* aes, byte* in, byte* out, word32 inSz, } -static int Octeon_AesGcm_Finalize(Aes* aes, word32 inSz, word32 aadSz, +static NOOPT int Octeon_AesGcm_Finalize(Aes* aes, word32 inSz, word32 aadSz, byte* tag) { word64 bigSz; diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index db7602d4d..6e7b600f1 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -869,7 +869,8 @@ initDefaultName(); return err_sys("AES-GCM test failed!\n", ret); #endif #if !defined(WOLFSSL_AFALG_XILINX_AES) && !defined(WOLFSSL_XILINX_CRYPT) && \ - !(defined(WOLF_CRYPTO_CB) && defined(HAVE_INTEL_QA_SYNC)) + !(defined(WOLF_CRYPTO_CB) && \ + (defined(HAVE_INTEL_QA_SYNC) || defined(HAVE_CAVIUM_OCTEON_SYNC))) if ((ret = aesgcm_default_test()) != 0) { return err_sys("AES-GCM test failed!\n", ret); } @@ -1130,7 +1131,8 @@ initDefaultName(); test_pass("blob test passed!\n"); #endif -#ifdef WOLF_CRYPTO_CB +#if defined(WOLF_CRYPTO_CB) && \ + !(defined(HAVE_INTEL_QAT_SYNC) || defined(HAVE_CAVIUM_OCTEON_SYNC)) if ( (ret = cryptocb_test()) != 0) return err_sys("crypto callback test failed!\n", ret); else @@ -7233,7 +7235,6 @@ int aesgcm_default_test(void) 0x3a, 0x7a, 0x56, 0x05, 0x09, 0xa2, 0xd9, 0xf2 }; - byte key2[] = { 0x01, 0x6d, 0xbb, 0x38, 0xda, 0xa7, 0x6d, 0xfe, 0x7d, 0xa3, 0x84, 0xeb, 0xf1, 0x24, 0x03, 0x64 @@ -7281,7 +7282,6 @@ int aesgcm_default_test(void) if (ret != 0) { return ret; } - ret = aesgcm_default_test_helper(key2, sizeof(key2), iv2, sizeof(iv2), plain2, sizeof(plain2), cipher2, sizeof(cipher2), NULL, 0, tag2, sizeof(tag2)); @@ -7368,7 +7368,8 @@ int aesgcm_test(void) !defined(WOLFSSL_PIC32MZ_CRYPT) && \ !defined(FREESCALE_LTC) && !defined(FREESCALE_MMCAU) && \ !defined(WOLFSSL_XILINX_CRYPT) && !defined(WOLFSSL_AFALG_XILINX_AES) && \ - !(defined(WOLF_CRYPTO_CB) && defined(HAVE_INTEL_QA_SYNC)) + !(defined(WOLF_CRYPTO_CB) && \ + (defined(HAVE_INTEL_QA_SYNC) || defined(HAVE_CAVIUM_OCTEON_SYNC))) #define ENABLE_NON_12BYTE_IV_TEST #ifdef WOLFSSL_AES_192 @@ -7715,7 +7716,8 @@ int aesgcm_test(void) #if defined(WOLFSSL_AES_256) && !defined(WOLFSSL_AFALG_XILINX_AES) && \ !defined(WOLFSSL_XILINX_CRYPT) && \ - !(defined(WOLF_CRYPTO_CB) && defined(HAVE_INTEL_QA_SYNC)) + !(defined(WOLF_CRYPTO_CB) && \ + defined(HAVE_INTEL_QA_SYNC) || defined(HAVE_CAVIUM_OCTEON_SYNC)) XMEMSET(resultT, 0, sizeof(resultT)); XMEMSET(resultC, 0, sizeof(resultC)); XMEMSET(resultP, 0, sizeof(resultP)); @@ -7750,7 +7752,8 @@ int aesgcm_test(void) #if !defined(HAVE_FIPS) || \ (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) /* Test encrypt with internally generated IV */ -#if defined(WOLFSSL_AES_256) && !(defined(WC_NO_RNG) || defined(HAVE_SELFTEST)) +#if defined(WOLFSSL_AES_256) && !(defined(WC_NO_RNG) || defined(HAVE_SELFTEST)) \ + && !(defined(WOLF_CRYPTO_CB) && defined(HAVE_CAVIUM_OCTEON_SYNC)) { WC_RNG rng; byte randIV[12];