1193645Ssimon/* ====================================================================
2193645Ssimon * Copyright (c) 2003 The OpenSSL Project.  All rights reserved.
3193645Ssimon *
4193645Ssimon * Redistribution and use in source and binary forms, with or without
5193645Ssimon * modification, are permitted provided that the following conditions
6193645Ssimon * are met:
7193645Ssimon *
8193645Ssimon * 1. Redistributions of source code must retain the above copyright
9296465Sdelphij *    notice, this list of conditions and the following disclaimer.
10193645Ssimon *
11193645Ssimon * 2. Redistributions in binary form must reproduce the above copyright
12193645Ssimon *    notice, this list of conditions and the following disclaimer in
13193645Ssimon *    the documentation and/or other materials provided with the
14193645Ssimon *    distribution.
15193645Ssimon *
16193645Ssimon * 3. All advertising materials mentioning features or use of this
17193645Ssimon *    software must display the following acknowledgment:
18193645Ssimon *    "This product includes software developed by the OpenSSL Project
19193645Ssimon *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
20193645Ssimon *
21193645Ssimon * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
22193645Ssimon *    endorse or promote products derived from this software without
23193645Ssimon *    prior written permission. For written permission, please contact
24193645Ssimon *    openssl-core@openssl.org.
25193645Ssimon *
26193645Ssimon * 5. Products derived from this software may not be called "OpenSSL"
27193645Ssimon *    nor may "OpenSSL" appear in their names without prior written
28193645Ssimon *    permission of the OpenSSL Project.
29193645Ssimon *
30193645Ssimon * 6. Redistributions of any form whatsoever must retain the following
31193645Ssimon *    acknowledgment:
32193645Ssimon *    "This product includes software developed by the OpenSSL Project
33193645Ssimon *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
34193645Ssimon *
35193645Ssimon * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36193645Ssimon * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37193645Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38193645Ssimon * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
39193645Ssimon * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40193645Ssimon * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41193645Ssimon * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42193645Ssimon * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43193645Ssimon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44193645Ssimon * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45193645Ssimon * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46193645Ssimon * OF THE POSSIBILITY OF SUCH DAMAGE.
47193645Ssimon *
48193645Ssimon */
49193645Ssimon
50193645Ssimon#include <openssl/opensslconf.h>
51193645Ssimon
52193645Ssimon#ifndef OPENSSL_FIPS
53296465Sdelphij# error FIPS is disabled.
54193645Ssimon#endif
55193645Ssimon
56193645Ssimon#ifdef OPENSSL_FIPS
57193645Ssimon
58193645Ssimon#ifdef  __cplusplus
59193645Ssimonextern "C" {
60193645Ssimon#endif
61193645Ssimon
62193645Ssimonstruct dsa_st;
63193645Ssimonstruct evp_pkey_st;
64193645Ssimonstruct env_md_st;
65193645Ssimonstruct evp_cipher_st;
66193645Ssimonstruct evp_cipher_ctx_st;
67193645Ssimon
68193645Ssimonint FIPS_mode_set(int onoff);
69193645Ssimonint FIPS_mode(void);
70193645Ssimonconst void *FIPS_rand_check(void);
71193645Ssimonint FIPS_selftest_failed(void);
72193645Ssimonvoid FIPS_selftest_check(void);
73193645Ssimonvoid FIPS_corrupt_sha1(void);
74193645Ssimonint FIPS_selftest_sha1(void);
75193645Ssimonvoid FIPS_corrupt_aes(void);
76193645Ssimonint FIPS_selftest_aes(void);
77193645Ssimonvoid FIPS_corrupt_des(void);
78193645Ssimonint FIPS_selftest_des(void);
79193645Ssimonvoid FIPS_corrupt_rsa(void);
80193645Ssimonvoid FIPS_corrupt_rsa_keygen(void);
81193645Ssimonint FIPS_selftest_rsa(void);
82193645Ssimonvoid FIPS_corrupt_dsa(void);
83193645Ssimonvoid FIPS_corrupt_dsa_keygen(void);
84193645Ssimonint FIPS_selftest_dsa(void);
85193645Ssimonvoid FIPS_corrupt_rng(void);
86193645Ssimonvoid FIPS_rng_stick(void);
87193645Ssimonint FIPS_selftest_rng(void);
88193645Ssimonint FIPS_selftest_hmac(void);
89193645Ssimon
90193645Ssimonint fips_pkey_signature_test(struct evp_pkey_st *pkey,
91296465Sdelphij                             const unsigned char *tbs, int tbslen,
92296465Sdelphij                             const unsigned char *kat, unsigned int katlen,
93296465Sdelphij                             const struct env_md_st *digest,
94296465Sdelphij                             unsigned int md_flags, const char *fail_str);
95193645Ssimon
96193645Ssimonint fips_cipher_test(struct evp_cipher_ctx_st *ctx,
97296465Sdelphij                     const struct evp_cipher_st *cipher,
98296465Sdelphij                     const unsigned char *key,
99296465Sdelphij                     const unsigned char *iv,
100296465Sdelphij                     const unsigned char *plaintext,
101296465Sdelphij                     const unsigned char *ciphertext, int len);
102193645Ssimon
103193645Ssimon/* BEGIN ERROR CODES */
104296465Sdelphij/*
105296465Sdelphij * The following lines are auto generated by the script mkerr.pl. Any changes
106193645Ssimon * made after this point may be overwritten when the script is next run.
107193645Ssimon */
108193645Ssimonvoid ERR_load_FIPS_strings(void);
109193645Ssimon
110193645Ssimon/* Error codes for the FIPS functions. */
111193645Ssimon
112193645Ssimon/* Function codes. */
113296465Sdelphij# define FIPS_F_DH_BUILTIN_GENPARAMS                      100
114296465Sdelphij# define FIPS_F_DSA_BUILTIN_PARAMGEN                      101
115296465Sdelphij# define FIPS_F_DSA_DO_SIGN                               102
116296465Sdelphij# define FIPS_F_DSA_DO_VERIFY                             103
117296465Sdelphij# define FIPS_F_EVP_CIPHERINIT_EX                         124
118296465Sdelphij# define FIPS_F_EVP_DIGESTINIT_EX                         125
119296465Sdelphij# define FIPS_F_FIPS_CHECK_DSA                            104
120296465Sdelphij# define FIPS_F_FIPS_CHECK_INCORE_FINGERPRINT             105
121296465Sdelphij# define FIPS_F_FIPS_CHECK_RSA                            106
122296465Sdelphij# define FIPS_F_FIPS_DSA_CHECK                            107
123296465Sdelphij# define FIPS_F_FIPS_MODE_SET                             108
124296465Sdelphij# define FIPS_F_FIPS_PKEY_SIGNATURE_TEST                  109
125296465Sdelphij# define FIPS_F_FIPS_SELFTEST_AES                         110
126296465Sdelphij# define FIPS_F_FIPS_SELFTEST_DES                         111
127296465Sdelphij# define FIPS_F_FIPS_SELFTEST_DSA                         112
128296465Sdelphij# define FIPS_F_FIPS_SELFTEST_HMAC                        113
129296465Sdelphij# define FIPS_F_FIPS_SELFTEST_RNG                         114
130296465Sdelphij# define FIPS_F_FIPS_SELFTEST_SHA1                        115
131296465Sdelphij# define FIPS_F_HASH_FINAL                                123
132296465Sdelphij# define FIPS_F_RSA_BUILTIN_KEYGEN                        116
133296465Sdelphij# define FIPS_F_RSA_EAY_PRIVATE_DECRYPT                   117
134296465Sdelphij# define FIPS_F_RSA_EAY_PRIVATE_ENCRYPT                   118
135296465Sdelphij# define FIPS_F_RSA_EAY_PUBLIC_DECRYPT                    119
136296465Sdelphij# define FIPS_F_RSA_EAY_PUBLIC_ENCRYPT                    120
137296465Sdelphij# define FIPS_F_RSA_X931_GENERATE_KEY_EX                  121
138296465Sdelphij# define FIPS_F_SSLEAY_RAND_BYTES                         122
139193645Ssimon
140193645Ssimon/* Reason codes. */
141296465Sdelphij# define FIPS_R_CANNOT_READ_EXE                           103
142296465Sdelphij# define FIPS_R_CANNOT_READ_EXE_DIGEST                    104
143296465Sdelphij# define FIPS_R_CONTRADICTING_EVIDENCE                    114
144296465Sdelphij# define FIPS_R_EXE_DIGEST_DOES_NOT_MATCH                 105
145296465Sdelphij# define FIPS_R_FINGERPRINT_DOES_NOT_MATCH                110
146296465Sdelphij# define FIPS_R_FINGERPRINT_DOES_NOT_MATCH_NONPIC_RELOCATED 111
147296465Sdelphij# define FIPS_R_FINGERPRINT_DOES_NOT_MATCH_SEGMENT_ALIASING 112
148296465Sdelphij# define FIPS_R_FIPS_MODE_ALREADY_SET                     102
149296465Sdelphij# define FIPS_R_FIPS_SELFTEST_FAILED                      106
150296465Sdelphij# define FIPS_R_INVALID_KEY_LENGTH                        109
151296465Sdelphij# define FIPS_R_KEY_TOO_SHORT                             108
152296465Sdelphij# define FIPS_R_NON_FIPS_METHOD                           100
153296465Sdelphij# define FIPS_R_PAIRWISE_TEST_FAILED                      107
154296465Sdelphij# define FIPS_R_RSA_DECRYPT_ERROR                         115
155296465Sdelphij# define FIPS_R_RSA_ENCRYPT_ERROR                         116
156296465Sdelphij# define FIPS_R_SELFTEST_FAILED                           101
157296465Sdelphij# define FIPS_R_TEST_FAILURE                              117
158296465Sdelphij# define FIPS_R_UNSUPPORTED_PLATFORM                      113
159193645Ssimon
160193645Ssimon#ifdef  __cplusplus
161193645Ssimon}
162193645Ssimon#endif
163193645Ssimon#endif
164