mirror of https://github.com/wolfSSL/wolfssl
FIPS Update
1. Add SHA-3 to the src/include.am so that it is always included in FIPSv2. 2. Tweak the SHA-3 header to follow the new FIPS pattern.
This commit is contained in:
parent
0c5d704c7f
commit
6352208e04
|
@ -2110,7 +2110,7 @@ AM_CONDITIONAL([BUILD_SHA224], [test "x$ENABLED_SHA224" = "xyes"])
|
|||
SHA3_DEFAULT=no
|
||||
if test "$host_cpu" = "x86_64" || test "$host_cpu" = "aarch64"
|
||||
then
|
||||
if test "x$ENABLED_FIPS" = "xno"
|
||||
if test "x$ENABLED_FIPS" = "xno" || test "x$FIPS_VERSION" = "xv2"
|
||||
then
|
||||
SHA3_DEFAULT=yes
|
||||
fi
|
||||
|
|
|
@ -60,6 +60,10 @@ if BUILD_SHA512
|
|||
src_libwolfssl_la_SOURCES += ctaocrypt/src/sha512.c
|
||||
endif
|
||||
|
||||
if BUILD_FIPS_V2
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha3.c
|
||||
endif
|
||||
|
||||
src_libwolfssl_la_SOURCES += ctaocrypt/src/fips.c
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/fipsv2.c
|
||||
src_libwolfssl_la_SOURCES += ctaocrypt/src/fips_test.c
|
||||
|
@ -150,9 +154,11 @@ if BUILD_SHA512
|
|||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha512.c
|
||||
endif
|
||||
|
||||
if !BUILD_FIPS_V2
|
||||
if BUILD_SHA3
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha3.c
|
||||
endif
|
||||
endif
|
||||
|
||||
src_libwolfssl_la_SOURCES += \
|
||||
wolfcrypt/src/logging.c \
|
||||
|
|
|
@ -31,128 +31,6 @@
|
|||
#include <wolfssl/wolfcrypt/sha3.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
|
||||
/* fips wrapper calls, user can call direct */
|
||||
#ifdef HAVE_FIPS
|
||||
|
||||
int wc_InitSha3_224(wc_Sha3* sha, void* heap, int devId)
|
||||
{
|
||||
(void)heap;
|
||||
(void)devId;
|
||||
if (sha == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
return InitSha3_224_fips(sha);
|
||||
}
|
||||
int wc_Sha3_224_Update(wc_Sha3* sha, const byte* data, word32 len)
|
||||
{
|
||||
if (sha == NULL || (data == NULL && len > 0)) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
return Sha3_224_Update_fips(sha, data, len);
|
||||
}
|
||||
int wc_Sha3_224_Final(wc_Sha3* sha, byte* out)
|
||||
{
|
||||
if (sha == NULL || out == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
return Sha3_224_Final_fips(sha, out);
|
||||
}
|
||||
void wc_Sha3_224_Free(wc_Sha3* sha)
|
||||
{
|
||||
(void)sha;
|
||||
/* Not supported in FIPS */
|
||||
}
|
||||
|
||||
int wc_InitSha3_256(wc_Sha3* sha, void* heap, int devId)
|
||||
{
|
||||
(void)heap;
|
||||
(void)devId;
|
||||
if (sha == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
return InitSha3_256_fips(sha);
|
||||
}
|
||||
int wc_Sha3_256_Update(wc_Sha3* sha, const byte* data, word32 len)
|
||||
{
|
||||
if (sha == NULL || (data == NULL && len > 0)) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
return Sha3_256_Update_fips(sha, data, len);
|
||||
}
|
||||
int wc_Sha3_256_Final(wc_Sha3* sha, byte* out)
|
||||
{
|
||||
if (sha == NULL || out == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
return Sha3_256_Final_fips(sha, out);
|
||||
}
|
||||
void wc_Sha3_256_Free(wc_Sha3* sha)
|
||||
{
|
||||
(void)sha;
|
||||
/* Not supported in FIPS */
|
||||
}
|
||||
|
||||
int wc_InitSha3_384(wc_Sha3* sha, void* heap, int devId)
|
||||
{
|
||||
(void)heap;
|
||||
(void)devId;
|
||||
if (sha == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
return InitSha3_384_fips(sha);
|
||||
}
|
||||
int wc_Sha3_384_Update(wc_Sha3* sha, const byte* data, word32 len)
|
||||
{
|
||||
if (sha == NULL || (data == NULL && len > 0)) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
return Sha3_384_Update_fips(sha, data, len);
|
||||
}
|
||||
int wc_Sha3_384_Final(wc_Sha3* sha, byte* out)
|
||||
{
|
||||
if (sha == NULL || out == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
return Sha3_384_Final_fips(sha, out);
|
||||
}
|
||||
void wc_Sha3_384_Free(wc_Sha3* sha)
|
||||
{
|
||||
(void)sha;
|
||||
/* Not supported in FIPS */
|
||||
}
|
||||
|
||||
int wc_InitSha3_512(wc_Sha3* sha, void* heap, int devId)
|
||||
{
|
||||
(void)heap;
|
||||
(void)devId;
|
||||
if (sha == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
return InitSha3_512_fips(sha);
|
||||
}
|
||||
int wc_Sha3_512_Update(wc_Sha3* sha, const byte* data, word32 len)
|
||||
{
|
||||
if (sha == NULL || (data == NULL && len > 0)) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
return Sha3_512_Update_fips(sha, data, len);
|
||||
}
|
||||
int wc_Sha3_512_Final(wc_Sha3* sha, byte* out)
|
||||
{
|
||||
if (sha == NULL || out == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
return Sha3_512_Final_fips(sha, out);
|
||||
}
|
||||
void wc_Sha3_512_Free(wc_Sha3* sha)
|
||||
{
|
||||
(void)sha;
|
||||
/* Not supported in FIPS */
|
||||
}
|
||||
|
||||
#else /* else build without fips */
|
||||
|
||||
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
|
@ -870,7 +748,7 @@ static void wc_Sha3Free(wc_Sha3* sha3)
|
|||
wolfAsync_DevCtxFree(&sha3->asyncDev, WOLFSSL_ASYNC_MARKER_SHA3);
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
}
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
|
||||
/* Copy the state of the SHA3 operation.
|
||||
*
|
||||
|
|
|
@ -29,15 +29,13 @@
|
|||
|
||||
#ifdef HAVE_FIPS
|
||||
/* for fips @wc_fips */
|
||||
#include <cyassl/ctaocrypt/sha3.h>
|
||||
#include <wolfssl/wolfcrypt/fips.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FIPS /* avoid redefinition of structs */
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#include <wolfssl/wolfcrypt/async.h>
|
||||
#endif
|
||||
|
@ -100,7 +98,7 @@ typedef struct Sha3 {
|
|||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
} wc_Sha3;
|
||||
#endif
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
|
||||
WOLFSSL_API int wc_InitSha3_224(wc_Sha3*, void*, int);
|
||||
WOLFSSL_API int wc_Sha3_224_Update(wc_Sha3*, const byte*, word32);
|
||||
|
|
Loading…
Reference in New Issue