Skip to content

Commit 3a5e171

Browse files
committed
Check-in fips_test.h changes to master as well
1 parent c98ce0d commit 3a5e171

1 file changed

Lines changed: 31 additions & 11 deletions

File tree

wolfssl/wolfcrypt/fips_test.h

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@
3131
extern "C" {
3232
#endif
3333

34+
/* Added for FIPS v5.3 or later */
35+
#if defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,3)
36+
/* Determine FIPS in core hash type and size */
37+
#ifndef NO_SHA256
38+
#define FIPS_IN_CORE_DIGEST_SIZE 32
39+
#define FIPS_IN_CORE_HASH_TYPE WC_SHA256
40+
#define FIPS_IN_CORE_KEY_SZ 32
41+
#define FIPS_IN_CORE_VERIFY_SZ FIPS_IN_CORE_KEY_SZ
42+
#elif defined(WOLFSSL_SHA384)
43+
#define FIPS_IN_CORE_DIGEST_SIZE 48
44+
#define FIPS_IN_CORE_HASH_TYPE WC_SHA384
45+
#define FIPS_IN_CORE_KEY_SZ 48
46+
#define FIPS_IN_CORE_VERIFY_SZ FIPS_IN_CORE_KEY_SZ
47+
#else
48+
#error No FIPS hash (SHA2-256 or SHA2-384)
49+
#endif
50+
#endif /* FIPS v5.3 or later */
51+
52+
3453
enum FipsCastId {
3554
FIPS_CAST_AES_CBC,
3655
FIPS_CAST_AES_GCM,
@@ -58,10 +77,10 @@ enum FipsCastStateId {
5877
};
5978

6079
enum FipsModeId {
61-
FIPS_MODE_INIT,
62-
FIPS_MODE_NORMAL,
63-
FIPS_MODE_DEGRADED,
64-
FIPS_MODE_FAILED
80+
FIPS_MODE_INIT = 0,
81+
FIPS_MODE_NORMAL = 1,
82+
FIPS_MODE_DEGRADED = 2,
83+
FIPS_MODE_FAILED = 3
6584
};
6685

6786

@@ -73,20 +92,21 @@ WOLFSSL_API int wolfCrypt_SetCb_fips(wolfCrypt_fips_cb cbf);
7392

7493
/* Public get status functions */
7594
WOLFSSL_API int wolfCrypt_GetStatus_fips(void);
95+
WOLFSSL_API int wolfCrypt_GetMode_fips(void);
7696
WOLFSSL_API const char* wolfCrypt_GetCoreHash_fips(void);
7797

7898
#ifdef HAVE_FORCE_FIPS_FAILURE
7999
/* Public function to force failure mode for operational testing */
80-
WOLFSSL_API int wolfCrypt_SetStatus_fips(int);
100+
WOLFSSL_API int wolfCrypt_SetStatus_fips(int status);
81101
#endif
82102

83-
WOLFSSL_LOCAL int DoIntegrityTest(char*, int);
84-
WOLFSSL_LOCAL int DoPOST(char*, int);
85-
WOLFSSL_LOCAL int DoCAST(int);
86-
WOLFSSL_LOCAL int DoKnownAnswerTests(char*, int); /* FIPSv1 and FIPSv2 */
103+
WOLFSSL_LOCAL int DoPOST(char* base16_hash, int base16_hashSz);
104+
WOLFSSL_LOCAL int DoCAST(int type);
105+
WOLFSSL_LOCAL int DoKnownAnswerTests(char* base16_hash, int base16_hashSz); /* FIPSv1 and FIPSv2 */
87106

88-
WOLFSSL_API int wc_RunCast_fips(int);
89-
WOLFSSL_API int wc_GetCastStatus_fips(int);
107+
WOLFSSL_API int wc_RunCast_fips(int type);
108+
WOLFSSL_API int wc_GetCastStatus_fips(int type);
109+
WOLFSSL_API int wc_RunAllCast_fips(void);
90110

91111
#ifdef __cplusplus
92112
} /* extern "C" */

0 commit comments

Comments
 (0)