Added support for SHA512 via psoc6 crypto
This commit is contained in:
parent
82520572b0
commit
b1947478bb
@ -48,8 +48,64 @@ int psoc6_crypto_port_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_SHA512
|
||||
int wc_InitSha512(wc_Sha512* sha)
|
||||
{
|
||||
cy_en_crypto_status_t res;
|
||||
if (!sha)
|
||||
return BAD_FUNC_ARG;
|
||||
Cy_Crypto_Core_MemSet(crypto_base, sha, 0, sizeof(sha));
|
||||
res = Cy_Crypto_Core_Sha_Init(crypto_base, &sha->hash_state, CY_CRYPTO_MODE_SHA512, &sha->sha_buffers);
|
||||
if (res != CY_CRYPTO_SUCCESS)
|
||||
return (int)res;
|
||||
return (int) Cy_Crypto_Core_Sha_Start(crypto_base, &sha->hash_state);
|
||||
}
|
||||
|
||||
int wc_Sha512Update(wc_Sha512* sha, const byte* in, word32 sz)
|
||||
{
|
||||
if ((!sha) || (!in))
|
||||
return BAD_FUNC_ARG;
|
||||
if (sz == 0)
|
||||
return 0;
|
||||
|
||||
return (int)Cy_Crypto_Core_Sha_Update(crypto_base, &sha->hash_state, in, sz);
|
||||
}
|
||||
|
||||
int wc_Sha512Final(wc_Sha512* sha, byte* hash)
|
||||
{
|
||||
if ((!sha) || (!hash))
|
||||
return BAD_FUNC_ARG;
|
||||
return (int)Cy_Crypto_Core_Sha_Finish(crypto_base, &sha->hash_state, hash);
|
||||
}
|
||||
|
||||
int wc_Sha512GetHash(wc_Sha512* sha, byte* hash)
|
||||
{
|
||||
if ((!sha) || (!hash))
|
||||
return BAD_FUNC_ARG;
|
||||
Cy_Crypto_Core_MemCpy(crypto_base, hash, sha->hash_state.hash, WC_SHA512_DIGEST_SIZE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wc_Sha512Copy(wc_Sha512* src, wc_Sha512* dst)
|
||||
{
|
||||
cy_en_crypto_status_t res;
|
||||
if ((!dst) || (!src))
|
||||
return BAD_FUNC_ARG;
|
||||
Cy_Crypto_Core_MemCpy(crypto_base, dst, src, sizeof(wc_Sha512));
|
||||
return (int)Cy_Crypto_Core_Sha_Init(crypto_base, &dst->hash_state, CY_CRYPTO_MODE_SHA512, &dst->sha_buffers);
|
||||
}
|
||||
|
||||
void wc_Sha512Free(wc_Sha512* sha)
|
||||
{
|
||||
if (sha)
|
||||
Cy_Crypto_Core_Sha_Free(crypto_base, &sha->hash_state);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NO_SHA256
|
||||
|
||||
|
||||
int wc_InitSha256(wc_Sha256* sha)
|
||||
{
|
||||
cy_en_crypto_status_t res;
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#if (defined(WOLFSSL_SHA512) || defined(WOLFSSL_SHA384)) && !defined(WOLFSSL_ARMASM)
|
||||
#if (defined(WOLFSSL_SHA512) || defined(WOLFSSL_SHA384)) && !defined(WOLFSSL_ARMASM) && !defined(WOLFSSL_PSOC6_CRYPTO)
|
||||
|
||||
#if defined(HAVE_FIPS) && \
|
||||
defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
|
||||
|
@ -36,9 +36,19 @@
|
||||
#include "cy_crypto_common.h"
|
||||
#include "cy_crypto_core.h"
|
||||
|
||||
#ifdef WOLFSSL_SHA512
|
||||
typedef struct wc_Sha512 {
|
||||
cy_stc_crypto_sha_state_t hash_state;
|
||||
cy_en_crypto_sha_mode_t sha_mode;
|
||||
cy_stc_crypto_v2_sha512_buffers_t sha_buffers;
|
||||
} wc_Sha512;
|
||||
|
||||
#define WC_SHA512_TYPE_DEFINED
|
||||
#include <wolfssl/wolfcrypt/sha512.h>
|
||||
#endif
|
||||
|
||||
#ifndef NO_SHA256
|
||||
|
||||
#include "cy_crypto_core_sha.h"
|
||||
typedef struct wc_Sha256 {
|
||||
cy_stc_crypto_sha_state_t hash_state;
|
||||
cy_en_crypto_sha_mode_t sha_mode;
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#if defined(WOLFSSL_SHA512) || defined(WOLFSSL_SHA384)
|
||||
|
||||
|
||||
#if defined(HAVE_FIPS) && \
|
||||
defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
|
||||
#include <wolfssl/wolfcrypt/fips.h>
|
||||
@ -111,6 +112,8 @@ enum {
|
||||
|
||||
#ifdef WOLFSSL_IMX6_CAAM
|
||||
#include "wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h"
|
||||
#elif defined (WOLFSSL_PSOC6_CRYPTO)
|
||||
#include "wolfssl/wolfcrypt/port/cypress/psoc6_crypto.h"
|
||||
#else
|
||||
/* wc_Sha512 digest */
|
||||
struct wc_Sha512 {
|
||||
@ -153,6 +156,7 @@ WOLFSSL_LOCAL void Transform_Sha512_Len(wc_Sha512* sha512, const byte* data,
|
||||
|
||||
#ifdef WOLFSSL_SHA512
|
||||
|
||||
|
||||
WOLFSSL_API int wc_InitSha512(wc_Sha512*);
|
||||
WOLFSSL_API int wc_InitSha512_ex(wc_Sha512*, void*, int);
|
||||
WOLFSSL_API int wc_Sha512Update(wc_Sha512*, const byte*, word32);
|
||||
|
Loading…
x
Reference in New Issue
Block a user