Improve speed of Intel AVX1/2 ASM for SHA-256 and SHA-512

This commit is contained in:
Sean Parkinson
2017-10-31 09:05:52 +10:00
parent 0ade0eb55b
commit 1ede982495
4 changed files with 3503 additions and 1803 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -66,6 +66,14 @@
#include <wolfssl/wolfcrypt/async.h> #include <wolfssl/wolfcrypt/async.h>
#endif #endif
#if defined(_MSC_VER)
#define SHA256_NOINLINE __declspec(noinline)
#elif defined(__GNUC__)
#define SHA256_NOINLINE __attribute__((noinline))
#else
#define SHA256_NOINLINE
#endif
#ifndef NO_OLD_WC_NAMES #ifndef NO_OLD_WC_NAMES
#define Sha256 wc_Sha256 #define Sha256 wc_Sha256
#define SHA256 WC_SHA256 #define SHA256 WC_SHA256
@@ -96,6 +104,7 @@ typedef struct wc_Sha256 {
word32 loLen; /* length in bytes */ word32 loLen; /* length in bytes */
word32 hiLen; /* length in bytes */ word32 hiLen; /* length in bytes */
void* heap; void* heap;
const byte* data;
#ifdef WOLFSSL_PIC32MZ_HASH #ifdef WOLFSSL_PIC32MZ_HASH
hashUpdCache cache; /* cache for updates */ hashUpdCache cache; /* cache for updates */
#endif #endif

View File

@@ -59,6 +59,14 @@
#include <wolfssl/wolfcrypt/async.h> #include <wolfssl/wolfcrypt/async.h>
#endif #endif
#if defined(_MSC_VER)
#define SHA512_NOINLINE __declspec(noinline)
#elif defined(__GNUC__)
#define SHA512_NOINLINE __attribute__((noinline))
#else
#define SHA512_NOINLINE
#endif
#ifndef NO_OLD_WC_NAMES #ifndef NO_OLD_WC_NAMES
#define Sha512 wc_Sha512 #define Sha512 wc_Sha512
#define SHA512 WC_SHA512 #define SHA512 WC_SHA512
@@ -78,12 +86,13 @@ enum {
/* wc_Sha512 digest */ /* wc_Sha512 digest */
typedef struct wc_Sha512 { typedef struct wc_Sha512 {
word64 digest[WC_SHA512_DIGEST_SIZE / sizeof(word64)];
word64 buffer[WC_SHA512_BLOCK_SIZE / sizeof(word64)];
word32 buffLen; /* in bytes */ word32 buffLen; /* in bytes */
word64 loLen; /* length in bytes */ word64 loLen; /* length in bytes */
word64 hiLen; /* length in bytes */ word64 hiLen; /* length in bytes */
word64 digest[WC_SHA512_DIGEST_SIZE / sizeof(word64)];
word64 buffer[WC_SHA512_BLOCK_SIZE / sizeof(word64)];
void* heap; void* heap;
const byte* data;
#ifdef WOLFSSL_ASYNC_CRYPT #ifdef WOLFSSL_ASYNC_CRYPT
WC_ASYNC_DEV asyncDev; WC_ASYNC_DEV asyncDev;
#endif /* WOLFSSL_ASYNC_CRYPT */ #endif /* WOLFSSL_ASYNC_CRYPT */