diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c index 495e03d7f..53b2bf1f3 100644 --- a/wolfcrypt/src/aes.c +++ b/wolfcrypt/src/aes.c @@ -2176,7 +2176,8 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock) ret = wc_AesSetKeyLocal(aes, userKey, keylen, iv, dir); - #if defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC) + #if defined(WOLFSSL_DEVCRYPTO) && \ + (defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC)) aes->ctx.cfd = -1; XMEMCPY(aes->devKey, userKey, keylen); #endif @@ -9457,7 +9458,8 @@ int wc_AesInit(Aes* aes, void* heap, int devId) aes->alFd = -1; aes->rdFd = -1; #endif -#if defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC) +#if defined(WOLFSSL_DEVCRYPTO) && \ + (defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC)) aes->ctx.cfd = -1; #endif @@ -9481,7 +9483,8 @@ void wc_AesFree(Aes* aes) close(aes->alFd); } #endif /* WOLFSSL_AFALG */ -#if defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC) +#if defined(WOLFSSL_DEVCRYPTO) && \ + (defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC)) wc_DevCryptoFree(&aes->ctx); ForceZero((byte*)aes->devKey, AES_MAX_KEY_SIZE/WOLFSSL_BIT_SIZE); #endif diff --git a/wolfcrypt/src/include.am b/wolfcrypt/src/include.am index 9ff96930e..0d7e8eb5b 100644 --- a/wolfcrypt/src/include.am +++ b/wolfcrypt/src/include.am @@ -67,7 +67,8 @@ EXTRA_DIST += wolfcrypt/src/port/ti/ti-aes.c \ wolfcrypt/src/port/af_alg/afalg_aes.c \ wolfcrypt/src/port/af_alg/afalg_hash.c \ wolfcrypt/src/port/devcrypto/devcrypto_hash.c \ - wolfcrypt/src/port/devcrypto/wc_devcrypto.c + wolfcrypt/src/port/devcrypto/wc_devcrypto.c \ + wolfcrypt/src/port/devcrypto/README.md if BUILD_CRYPTODEV src_libwolfssl_la_SOURCES += wolfcrypt/src/cryptodev.c diff --git a/wolfcrypt/src/port/devcrypto/README.md b/wolfcrypt/src/port/devcrypto/README.md new file mode 100644 index 000000000..7844dca86 --- /dev/null +++ b/wolfcrypt/src/port/devcrypto/README.md @@ -0,0 +1,43 @@ +# Description + +Used to build with cryptodev-linux library with Linux OS. + +# Quick Start + +## Installing cryptodev module + +If not already installed then the cryptodev-linux module will need installed. + +``` +git clone https://github.com/cryptodev-linux/cryptodev-linux.git +cd cryptodev-linux +make +sudo make install +modprobe cryptodev +``` + + +## Options for building wolfSSL + +For default build with all supported features use: + +``` +./configure --enable-cryptodev +``` + +Or for more control over features used: + +``` +./configure --enable-devcrypto=cbc +./configure --enable-devcrypto=hash +./configure --enable-devcrypto=aes +./configure --enable-devcrypto=all +``` + +Then build the wolfSSL library with: + +``` +make +sudo make install +./wolfcrypt/test/testwolfcrypt +``` diff --git a/wolfcrypt/src/port/devcrypto/devcrypto_hash.c b/wolfcrypt/src/port/devcrypto/devcrypto_hash.c index 9e986336b..975c98567 100644 --- a/wolfcrypt/src/port/devcrypto/devcrypto_hash.c +++ b/wolfcrypt/src/port/devcrypto/devcrypto_hash.c @@ -61,7 +61,7 @@ static int HashInit(void* ctx, int type, byte* key, word32 keySz) WC_CRYPTODEV* cdev; if ((cdev = GetHashContext(ctx, type)) == NULL) { - WOLFSSL_MSG("Unsuported hash type"); + WOLFSSL_MSG("Unsupported hash type"); return BAD_FUNC_ARG; } diff --git a/wolfcrypt/src/port/devcrypto/wc_devcrypto.c b/wolfcrypt/src/port/devcrypto/wc_devcrypto.c index f8372f948..1fae9331b 100644 --- a/wolfcrypt/src/port/devcrypto/wc_devcrypto.c +++ b/wolfcrypt/src/port/devcrypto/wc_devcrypto.c @@ -47,7 +47,7 @@ int wc_DevCryptoCreate(WC_CRYPTODEV* ctx, int type, byte* key, word32 keySz) XMEMSET(ctx, 0, sizeof(WC_CRYPTODEV)); switch (type) { case CRYPTO_SHA1: - case CRYPTO_SHA2_256: + case CRYPTO_SHA2_256: isHash = 1; break; @@ -128,7 +128,7 @@ void wc_SetupCrypt(struct crypt_op* crt, WC_CRYPTODEV* dev, } -/* setup crypt_op structure for symetric key operations */ +/* setup crypt_op structure for symmetric key operations */ void wc_SetupCryptSym(struct crypt_op* crt, WC_CRYPTODEV* dev, byte* src, word32 srcSz, byte* dst, byte* iv, int flag) diff --git a/wolfssl/openssl/aes.h b/wolfssl/openssl/aes.h index 13af80f3c..f6f45ae11 100644 --- a/wolfssl/openssl/aes.h +++ b/wolfssl/openssl/aes.h @@ -48,7 +48,8 @@ typedef struct WOLFSSL_AES_KEY { /* key-based fast multiplication table. */ ALIGN16 void* M0[4096 / sizeof(void*)]; #endif /* GCM_TABLE */ - #if defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC) + #if defined(WOLFSSL_DEVCRYPTO) && \ + (defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC)) /* large enough for additional devcrypto information */ void* devKey[288 / sizeof(void*)]; #endif diff --git a/wolfssl/wolfcrypt/aes.h b/wolfssl/wolfcrypt/aes.h index 123ee4135..40ada48fa 100644 --- a/wolfssl/wolfcrypt/aes.h +++ b/wolfssl/wolfcrypt/aes.h @@ -166,7 +166,8 @@ typedef struct Aes { struct msghdr msg; int dir; /* flag for encrpyt or decrypt */ #endif -#if defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC) +#if defined(WOLFSSL_DEVCRYPTO) && \ + (defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC)) word32 devKey[AES_MAX_KEY_SIZE/WOLFSSL_BIT_SIZE/sizeof(word32)]; /* raw key */ WC_CRYPTODEV ctx; #endif diff --git a/wolfssl/wolfcrypt/port/devcrypto/wc_devcrypto.h b/wolfssl/wolfcrypt/port/devcrypto/wc_devcrypto.h index ad63971d2..c3a1fab9f 100644 --- a/wolfssl/wolfcrypt/port/devcrypto/wc_devcrypto.h +++ b/wolfssl/wolfcrypt/port/devcrypto/wc_devcrypto.h @@ -25,6 +25,8 @@ #include +#ifdef WOLFSSL_DEVCRYPTO + #include #include #include @@ -45,6 +47,7 @@ WOLFSSL_LOCAL void wc_SetupCryptAead(struct crypt_auth_op* crt, WC_CRYPTODEV* de byte* src, word32 srcSz, byte* dst, byte* iv, word32 ivSz, int flag, byte* authIn, word32 authInSz, byte* authTag, word32 authTagSz); +#endif /* WOLFSSL_DEVCRYPTO */ #endif /* WOLFSSL_DEVCRYPTO_H */ diff --git a/wolfssl/wolfcrypt/sha256.h b/wolfssl/wolfcrypt/sha256.h index f65179f92..71f06e1f0 100644 --- a/wolfssl/wolfcrypt/sha256.h +++ b/wolfssl/wolfcrypt/sha256.h @@ -80,7 +80,7 @@ #ifdef WOLFSSL_ASYNC_CRYPT #include #endif -#ifdef WOLFSSL_DEVCRYPTO_HASH +#if defined(WOLFSSL_DEVCRYPTO) && defined(WOLFSSL_DEVCRYPTO_HASH) #include #endif