fips_test.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* fips_test.h
  2. *
  3. * Copyright (C) 2006-2021 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. #ifndef WOLF_CRYPT_FIPS_TEST_H
  22. #define WOLF_CRYPT_FIPS_TEST_H
  23. #include <wolfssl/wolfcrypt/types.h>
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. enum FipsCastId {
  28. FIPS_CAST_AES_CBC,
  29. FIPS_CAST_AES_GCM,
  30. FIPS_CAST_HMAC_SHA1,
  31. FIPS_CAST_HMAC_SHA2_256,
  32. FIPS_CAST_HMAC_SHA2_512,
  33. FIPS_CAST_HMAC_SHA3_256,
  34. FIPS_CAST_DRBG,
  35. FIPS_CAST_RSA_SIGN_PKCS1v15,
  36. FIPS_CAST_ECC_CDH,
  37. FIPS_CAST_ECC_PRIMITIVE_Z,
  38. FIPS_CAST_DH_PRIMITIVE_Z,
  39. FIPS_CAST_ECDSA,
  40. FIPS_CAST_KDF_TLS12,
  41. FIPS_CAST_KDF_TLS13,
  42. FIPS_CAST_KDF_SSH,
  43. FIPS_CAST_COUNT
  44. };
  45. enum FipsCastStateId {
  46. FIPS_CAST_STATE_INIT,
  47. FIPS_CAST_STATE_PROCESSING,
  48. FIPS_CAST_STATE_SUCCESS,
  49. FIPS_CAST_STATE_FAILURE
  50. };
  51. enum FipsModeId {
  52. FIPS_MODE_INIT = 0,
  53. FIPS_MODE_NORMAL = 1,
  54. FIPS_MODE_DEGRADED = 2,
  55. FIPS_MODE_FAILED = 3
  56. };
  57. /* FIPS failure callback */
  58. typedef void(*wolfCrypt_fips_cb)(int ok, int err, const char* hash);
  59. /* Public set function */
  60. WOLFSSL_API int wolfCrypt_SetCb_fips(wolfCrypt_fips_cb cbf);
  61. /* Public get status functions */
  62. WOLFSSL_API int wolfCrypt_GetStatus_fips(void);
  63. WOLFSSL_API int wolfCrypt_GetMode_fips(void);
  64. WOLFSSL_API const char* wolfCrypt_GetCoreHash_fips(void);
  65. #ifdef HAVE_FORCE_FIPS_FAILURE
  66. /* Public function to force failure mode for operational testing */
  67. WOLFSSL_API int wolfCrypt_SetStatus_fips(int);
  68. #endif
  69. WOLFSSL_LOCAL int DoIntegrityTest(char*, int);
  70. WOLFSSL_LOCAL int DoPOST(char*, int);
  71. WOLFSSL_LOCAL int DoCAST(int);
  72. WOLFSSL_LOCAL int DoKnownAnswerTests(char*, int); /* FIPSv1 and FIPSv2 */
  73. WOLFSSL_API int wc_RunCast_fips(int);
  74. WOLFSSL_API int wc_GetCastStatus_fips(int);
  75. WOLFSSL_API int wc_RunAllCast_fips(void);
  76. #ifdef __cplusplus
  77. } /* extern "C" */
  78. #endif
  79. #endif /* WOLF_CRYPT_FIPS_TEST_H */