fips.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /* ====================================================================
  2. * Copyright (c) 2003 The OpenSSL Project. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in
  13. * the documentation and/or other materials provided with the
  14. * distribution.
  15. *
  16. * 3. All advertising materials mentioning features or use of this
  17. * software must display the following acknowledgment:
  18. * "This product includes software developed by the OpenSSL Project
  19. * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
  20. *
  21. * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
  22. * endorse or promote products derived from this software without
  23. * prior written permission. For written permission, please contact
  24. * openssl-core@openssl.org.
  25. *
  26. * 5. Products derived from this software may not be called "OpenSSL"
  27. * nor may "OpenSSL" appear in their names without prior written
  28. * permission of the OpenSSL Project.
  29. *
  30. * 6. Redistributions of any form whatsoever must retain the following
  31. * acknowledgment:
  32. * "This product includes software developed by the OpenSSL Project
  33. * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
  34. *
  35. * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
  36. * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  37. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  38. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
  39. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  41. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  42. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  43. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  44. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  45. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  46. * OF THE POSSIBILITY OF SUCH DAMAGE.
  47. *
  48. */
  49. #include <openssl/opensslconf.h>
  50. #ifndef OPENSSL_FIPS
  51. # error FIPS is disabled.
  52. #endif
  53. #ifdef OPENSSL_FIPS
  54. #ifdef __cplusplus
  55. extern "C" {
  56. #endif
  57. struct dsa_st;
  58. struct evp_pkey_st;
  59. struct env_md_st;
  60. struct evp_cipher_st;
  61. struct evp_cipher_ctx_st;
  62. int FIPS_mode_set(int onoff);
  63. int FIPS_mode(void);
  64. const void *FIPS_rand_check(void);
  65. int FIPS_selftest_failed(void);
  66. void FIPS_selftest_check(void);
  67. void FIPS_corrupt_sha1(void);
  68. int FIPS_selftest_sha1(void);
  69. void FIPS_corrupt_aes(void);
  70. int FIPS_selftest_aes(void);
  71. void FIPS_corrupt_des(void);
  72. int FIPS_selftest_des(void);
  73. void FIPS_corrupt_rsa(void);
  74. void FIPS_corrupt_rsa_keygen(void);
  75. int FIPS_selftest_rsa(void);
  76. void FIPS_corrupt_dsa(void);
  77. void FIPS_corrupt_dsa_keygen(void);
  78. int FIPS_selftest_dsa(void);
  79. void FIPS_corrupt_rng(void);
  80. void FIPS_rng_stick(void);
  81. int FIPS_selftest_rng(void);
  82. int FIPS_selftest_hmac(void);
  83. int fips_pkey_signature_test(struct evp_pkey_st *pkey,
  84. const unsigned char *tbs, int tbslen,
  85. const unsigned char *kat, unsigned int katlen,
  86. const struct env_md_st *digest,
  87. unsigned int md_flags, const char *fail_str);
  88. int fips_cipher_test(struct evp_cipher_ctx_st *ctx,
  89. const struct evp_cipher_st *cipher,
  90. const unsigned char *key,
  91. const unsigned char *iv,
  92. const unsigned char *plaintext,
  93. const unsigned char *ciphertext, int len);
  94. /* BEGIN ERROR CODES */
  95. /*
  96. * The following lines are auto generated by the script mkerr.pl. Any changes
  97. * made after this point may be overwritten when the script is next run.
  98. */
  99. void ERR_load_FIPS_strings(void);
  100. /* Error codes for the FIPS functions. */
  101. /* Function codes. */
  102. # define FIPS_F_DH_BUILTIN_GENPARAMS 100
  103. # define FIPS_F_DSA_BUILTIN_PARAMGEN 101
  104. # define FIPS_F_DSA_DO_SIGN 102
  105. # define FIPS_F_DSA_DO_VERIFY 103
  106. # define FIPS_F_EVP_CIPHERINIT_EX 124
  107. # define FIPS_F_EVP_DIGESTINIT_EX 125
  108. # define FIPS_F_FIPS_CHECK_DSA 104
  109. # define FIPS_F_FIPS_CHECK_INCORE_FINGERPRINT 105
  110. # define FIPS_F_FIPS_CHECK_RSA 106
  111. # define FIPS_F_FIPS_DSA_CHECK 107
  112. # define FIPS_F_FIPS_MODE_SET 108
  113. # define FIPS_F_FIPS_PKEY_SIGNATURE_TEST 109
  114. # define FIPS_F_FIPS_SELFTEST_AES 110
  115. # define FIPS_F_FIPS_SELFTEST_DES 111
  116. # define FIPS_F_FIPS_SELFTEST_DSA 112
  117. # define FIPS_F_FIPS_SELFTEST_HMAC 113
  118. # define FIPS_F_FIPS_SELFTEST_RNG 114
  119. # define FIPS_F_FIPS_SELFTEST_SHA1 115
  120. # define FIPS_F_HASH_FINAL 123
  121. # define FIPS_F_RSA_BUILTIN_KEYGEN 116
  122. # define FIPS_F_RSA_EAY_PRIVATE_DECRYPT 117
  123. # define FIPS_F_RSA_EAY_PRIVATE_ENCRYPT 118
  124. # define FIPS_F_RSA_EAY_PUBLIC_DECRYPT 119
  125. # define FIPS_F_RSA_EAY_PUBLIC_ENCRYPT 120
  126. # define FIPS_F_RSA_X931_GENERATE_KEY_EX 121
  127. # define FIPS_F_SSLEAY_RAND_BYTES 122
  128. /* Reason codes. */
  129. # define FIPS_R_CANNOT_READ_EXE 103
  130. # define FIPS_R_CANNOT_READ_EXE_DIGEST 104
  131. # define FIPS_R_CONTRADICTING_EVIDENCE 114
  132. # define FIPS_R_EXE_DIGEST_DOES_NOT_MATCH 105
  133. # define FIPS_R_FINGERPRINT_DOES_NOT_MATCH 110
  134. # define FIPS_R_FINGERPRINT_DOES_NOT_MATCH_NONPIC_RELOCATED 111
  135. # define FIPS_R_FINGERPRINT_DOES_NOT_MATCH_SEGMENT_ALIASING 112
  136. # define FIPS_R_FIPS_MODE_ALREADY_SET 102
  137. # define FIPS_R_FIPS_SELFTEST_FAILED 106
  138. # define FIPS_R_INVALID_KEY_LENGTH 109
  139. # define FIPS_R_KEY_TOO_SHORT 108
  140. # define FIPS_R_NON_FIPS_METHOD 100
  141. # define FIPS_R_PAIRWISE_TEST_FAILED 107
  142. # define FIPS_R_RSA_DECRYPT_ERROR 115
  143. # define FIPS_R_RSA_ENCRYPT_ERROR 116
  144. # define FIPS_R_SELFTEST_FAILED 101
  145. # define FIPS_R_TEST_FAILURE 117
  146. # define FIPS_R_UNSUPPORTED_PLATFORM 113
  147. #ifdef __cplusplus
  148. }
  149. #endif
  150. #endif