minor adjustments and add README

This commit is contained in:
Jacob Barthelmeh
2018-09-20 15:59:29 -06:00
parent 96a7e366bc
commit fe2f9d4aa4
9 changed files with 62 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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
```

View File

@ -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;
}

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -25,6 +25,8 @@
#include <wolfssl/wolfcrypt/types.h>
#ifdef WOLFSSL_DEVCRYPTO
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
@ -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 */

View File

@ -80,7 +80,7 @@
#ifdef WOLFSSL_ASYNC_CRYPT
#include <wolfssl/wolfcrypt/async.h>
#endif
#ifdef WOLFSSL_DEVCRYPTO_HASH
#if defined(WOLFSSL_DEVCRYPTO) && defined(WOLFSSL_DEVCRYPTO_HASH)
#include <wolfssl/wolfcrypt/port/devcrypto/wc_devcrypto.h>
#endif