From 35d40f263ec3e0b4db7718d2987a49bcd9d0827e Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Fri, 22 Jul 2022 16:19:55 -0700 Subject: [PATCH] more macro guards with CAAM builds --- wolfcrypt/src/port/caam/wolfcaam_aes.c | 2 +- wolfcrypt/src/port/caam/wolfcaam_init.c | 6 ++++-- wolfcrypt/src/port/devcrypto/wc_devcrypto.c | 2 +- wolfssl/wolfcrypt/aes.h | 7 +++---- wolfssl/wolfcrypt/port/caam/wolfcaam_hash.h | 7 ++++++- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/wolfcrypt/src/port/caam/wolfcaam_aes.c b/wolfcrypt/src/port/caam/wolfcaam_aes.c index b52184a15..9bd398585 100644 --- a/wolfcrypt/src/port/caam/wolfcaam_aes.c +++ b/wolfcrypt/src/port/caam/wolfcaam_aes.c @@ -25,7 +25,7 @@ #include -#if (WOLFSSL_CAAM) && !defined(NO_AES) +#if defined(WOLFSSL_CAAM) && !defined(NO_AES) #include #include diff --git a/wolfcrypt/src/port/caam/wolfcaam_init.c b/wolfcrypt/src/port/caam/wolfcaam_init.c index 8f87b5f8d..c5dc2a739 100644 --- a/wolfcrypt/src/port/caam/wolfcaam_init.c +++ b/wolfcrypt/src/port/caam/wolfcaam_init.c @@ -193,20 +193,22 @@ static int wc_CAAM_router(int devId, wc_CryptoInfo* info, void* ctx) info->hash.digest); break; + #ifdef WOLFSSL_SHA384 case WC_HASH_TYPE_SHA384: ret = wc_CAAM_Sha384Hash(info->hash.sha384, info->hash.in, info->hash.inSz, info->hash.digest); break; - + #endif + #ifdef WOLFSSL_SHA512 case WC_HASH_TYPE_SHA512: ret = wc_CAAM_Sha512Hash(info->hash.sha512, info->hash.in, info->hash.inSz, info->hash.digest); break; - + #endif default: WOLFSSL_MSG("Unknown or unsupported hash type"); ret = CRYPTOCB_UNAVAILABLE; diff --git a/wolfcrypt/src/port/devcrypto/wc_devcrypto.c b/wolfcrypt/src/port/devcrypto/wc_devcrypto.c index 5c8d99217..2a21d676c 100644 --- a/wolfcrypt/src/port/devcrypto/wc_devcrypto.c +++ b/wolfcrypt/src/port/devcrypto/wc_devcrypto.c @@ -122,7 +122,7 @@ int wc_DevCryptoCreate(WC_CRYPTODEV* ctx, int type, byte* key, word32 keySz) case CRYPTO_SHA2_512_HMAC: ctx->sess.cipher = 0; ctx->sess.mac = type; - ctx->sess.mackey = (uint8_t*)key; + ctx->sess.mackey = (u_int8_t*)key; ctx->sess.mackeylen = keySz; break; diff --git a/wolfssl/wolfcrypt/aes.h b/wolfssl/wolfcrypt/aes.h index 8fbc16f06..3de0ab4fa 100644 --- a/wolfssl/wolfcrypt/aes.h +++ b/wolfssl/wolfcrypt/aes.h @@ -191,10 +191,6 @@ struct Aes { int ctxInitDone; int keyId; #endif -#ifdef WOLFSSL_CAAM - int blackKey; /* black key / hsm key id */ -#endif - #ifdef GCM_TABLE /* key-based fast multiplication table. */ ALIGN16 byte M0[256][AES_BLOCK_SIZE]; @@ -209,6 +205,9 @@ struct Aes { word32 y0; #endif #endif /* HAVE_AESGCM */ +#ifdef WOLFSSL_CAAM + int blackKey; /* black key / hsm key id */ +#endif #ifdef WOLFSSL_AESNI byte use_aesni; #endif /* WOLFSSL_AESNI */ diff --git a/wolfssl/wolfcrypt/port/caam/wolfcaam_hash.h b/wolfssl/wolfcrypt/port/caam/wolfcaam_hash.h index 43daf9984..5df748601 100644 --- a/wolfssl/wolfcrypt/port/caam/wolfcaam_hash.h +++ b/wolfssl/wolfcrypt/port/caam/wolfcaam_hash.h @@ -26,19 +26,24 @@ #include +#ifndef NO_SHA WOLFSSL_LOCAL int wc_CAAM_ShaHash(wc_Sha* sha, const byte* in, word32 inSz, byte* digest); +#endif #ifdef WOLFSSL_SHA224 WOLFSSL_LOCAL int wc_CAAM_Sha224Hash(wc_Sha224* sha224, const byte* in, word32 inSz, byte* digest); #endif WOLFSSL_LOCAL int wc_CAAM_Sha256Hash(wc_Sha256* sha256, const byte* in, word32 inSz, byte* digest); +#if defined(WOLFSSL_SHA384) WOLFSSL_LOCAL int wc_CAAM_Sha384Hash(wc_Sha384* sha384, const byte* in, word32 inSz, byte* digest); +#endif +#if defined(WOLFSSL_SHA512) WOLFSSL_LOCAL int wc_CAAM_Sha512Hash(wc_Sha512* sha512, const byte* in, word32 inSz, byte* digest); - +#endif #if !defined(NO_HMAC) #ifndef WC_HMAC_TYPE_DEFINED