diff options
Diffstat (limited to 'src/lib/libcrypto/crypto.h')
-rw-r--r-- | src/lib/libcrypto/crypto.h | 182 |
1 files changed, 75 insertions, 107 deletions
diff --git a/src/lib/libcrypto/crypto.h b/src/lib/libcrypto/crypto.h index d2b5ffe332..22fd939e65 100644 --- a/src/lib/libcrypto/crypto.h +++ b/src/lib/libcrypto/crypto.h | |||
@@ -1,57 +1,4 @@ | |||
1 | /* crypto/crypto.h */ | 1 | /* crypto/crypto.h */ |
2 | /* ==================================================================== | ||
3 | * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * | ||
9 | * 1. Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in | ||
14 | * the documentation and/or other materials provided with the | ||
15 | * distribution. | ||
16 | * | ||
17 | * 3. All advertising materials mentioning features or use of this | ||
18 | * software must display the following acknowledgment: | ||
19 | * "This product includes software developed by the OpenSSL Project | ||
20 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
21 | * | ||
22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
23 | * endorse or promote products derived from this software without | ||
24 | * prior written permission. For written permission, please contact | ||
25 | * openssl-core@openssl.org. | ||
26 | * | ||
27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
28 | * nor may "OpenSSL" appear in their names without prior written | ||
29 | * permission of the OpenSSL Project. | ||
30 | * | ||
31 | * 6. Redistributions of any form whatsoever must retain the following | ||
32 | * acknowledgment: | ||
33 | * "This product includes software developed by the OpenSSL Project | ||
34 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
35 | * | ||
36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
48 | * ==================================================================== | ||
49 | * | ||
50 | * This product includes cryptographic software written by Eric Young | ||
51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
52 | * Hudson (tjh@cryptsoft.com). | ||
53 | * | ||
54 | */ | ||
55 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
56 | * All rights reserved. | 3 | * All rights reserved. |
57 | * | 4 | * |
@@ -108,19 +55,12 @@ | |||
108 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
109 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
110 | */ | 57 | */ |
111 | /* ==================================================================== | ||
112 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | ||
113 | * ECDH support in OpenSSL originally developed by | ||
114 | * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. | ||
115 | */ | ||
116 | 58 | ||
117 | #ifndef HEADER_CRYPTO_H | 59 | #ifndef HEADER_CRYPTO_H |
118 | #define HEADER_CRYPTO_H | 60 | #define HEADER_CRYPTO_H |
119 | 61 | ||
120 | #include <stdlib.h> | 62 | #include <stdlib.h> |
121 | 63 | ||
122 | #include <openssl/e_os2.h> | ||
123 | |||
124 | #ifndef OPENSSL_NO_FP_API | 64 | #ifndef OPENSSL_NO_FP_API |
125 | #include <stdio.h> | 65 | #include <stdio.h> |
126 | #endif | 66 | #endif |
@@ -128,7 +68,6 @@ | |||
128 | #include <openssl/stack.h> | 68 | #include <openssl/stack.h> |
129 | #include <openssl/safestack.h> | 69 | #include <openssl/safestack.h> |
130 | #include <openssl/opensslv.h> | 70 | #include <openssl/opensslv.h> |
131 | #include <openssl/ossl_typ.h> | ||
132 | 71 | ||
133 | #ifdef CHARSET_EBCDIC | 72 | #ifdef CHARSET_EBCDIC |
134 | #include <openssl/ebcdic.h> | 73 | #include <openssl/ebcdic.h> |
@@ -153,39 +92,15 @@ extern "C" { | |||
153 | #define SSLEAY_PLATFORM 4 | 92 | #define SSLEAY_PLATFORM 4 |
154 | #define SSLEAY_DIR 5 | 93 | #define SSLEAY_DIR 5 |
155 | 94 | ||
156 | /* Already declared in ossl_typ.h */ | ||
157 | #if 0 | ||
158 | typedef struct crypto_ex_data_st CRYPTO_EX_DATA; | ||
159 | /* Called when a new object is created */ | ||
160 | typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, | ||
161 | int idx, long argl, void *argp); | ||
162 | /* Called when an object is free()ed */ | ||
163 | typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, | ||
164 | int idx, long argl, void *argp); | ||
165 | /* Called when we need to dup an object */ | ||
166 | typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, | ||
167 | int idx, long argl, void *argp); | ||
168 | #endif | ||
169 | |||
170 | /* A generic structure to pass assorted data in a expandable way */ | ||
171 | typedef struct openssl_item_st | ||
172 | { | ||
173 | int code; | ||
174 | void *value; /* Not used for flag attributes */ | ||
175 | size_t value_size; /* Max size of value for output, length for input */ | ||
176 | size_t *value_length; /* Returned length of value for output */ | ||
177 | } OPENSSL_ITEM; | ||
178 | |||
179 | |||
180 | /* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock | 95 | /* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock |
181 | * names in cryptlib.c | 96 | * names in cryptlib.c |
182 | */ | 97 | */ |
183 | 98 | ||
184 | #define CRYPTO_LOCK_ERR 1 | 99 | #define CRYPTO_LOCK_ERR 1 |
185 | #define CRYPTO_LOCK_EX_DATA 2 | 100 | #define CRYPTO_LOCK_EX_DATA 2 |
186 | #define CRYPTO_LOCK_X509 3 | 101 | #define CRYPTO_LOCK_X509 3 |
187 | #define CRYPTO_LOCK_X509_INFO 4 | 102 | #define CRYPTO_LOCK_X509_INFO 4 |
188 | #define CRYPTO_LOCK_X509_PKEY 5 | 103 | #define CRYPTO_LOCK_X509_PKEY 5 |
189 | #define CRYPTO_LOCK_X509_CRL 6 | 104 | #define CRYPTO_LOCK_X509_CRL 6 |
190 | #define CRYPTO_LOCK_X509_REQ 7 | 105 | #define CRYPTO_LOCK_X509_REQ 7 |
191 | #define CRYPTO_LOCK_DSA 8 | 106 | #define CRYPTO_LOCK_DSA 8 |
@@ -212,14 +127,10 @@ typedef struct openssl_item_st | |||
212 | #define CRYPTO_LOCK_DYNLOCK 29 | 127 | #define CRYPTO_LOCK_DYNLOCK 29 |
213 | #define CRYPTO_LOCK_ENGINE 30 | 128 | #define CRYPTO_LOCK_ENGINE 30 |
214 | #define CRYPTO_LOCK_UI 31 | 129 | #define CRYPTO_LOCK_UI 31 |
215 | #define CRYPTO_LOCK_ECDSA 32 | 130 | #define CRYPTO_LOCK_HWCRHK 32 /* This is a HACK which will disappear in 0.9.8 */ |
216 | #define CRYPTO_LOCK_EC 33 | 131 | #define CRYPTO_LOCK_FIPS 33 |
217 | #define CRYPTO_LOCK_ECDH 34 | 132 | #define CRYPTO_LOCK_FIPS2 34 |
218 | #define CRYPTO_LOCK_BN 35 | 133 | #define CRYPTO_NUM_LOCKS 35 |
219 | #define CRYPTO_LOCK_EC_PRE_COMP 36 | ||
220 | #define CRYPTO_LOCK_STORE 37 | ||
221 | #define CRYPTO_LOCK_COMP 38 | ||
222 | #define CRYPTO_NUM_LOCKS 39 | ||
223 | 134 | ||
224 | #define CRYPTO_LOCK 1 | 135 | #define CRYPTO_LOCK 1 |
225 | #define CRYPTO_UNLOCK 2 | 136 | #define CRYPTO_UNLOCK 2 |
@@ -280,11 +191,21 @@ typedef struct | |||
280 | /* predec of the BIO type */ | 191 | /* predec of the BIO type */ |
281 | typedef struct bio_st BIO_dummy; | 192 | typedef struct bio_st BIO_dummy; |
282 | 193 | ||
283 | struct crypto_ex_data_st | 194 | typedef struct crypto_ex_data_st |
284 | { | 195 | { |
285 | STACK *sk; | 196 | STACK *sk; |
286 | int dummy; /* gcc is screwing up this data structure :-( */ | 197 | int dummy; /* gcc is screwing up this data structure :-( */ |
287 | }; | 198 | } CRYPTO_EX_DATA; |
199 | |||
200 | /* Called when a new object is created */ | ||
201 | typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, | ||
202 | int idx, long argl, void *argp); | ||
203 | /* Called when an object is free()ed */ | ||
204 | typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, | ||
205 | int idx, long argl, void *argp); | ||
206 | /* Called when we need to dup an object */ | ||
207 | typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, | ||
208 | int idx, long argl, void *argp); | ||
288 | 209 | ||
289 | /* This stuff is basically class callback functions | 210 | /* This stuff is basically class callback functions |
290 | * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */ | 211 | * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */ |
@@ -316,10 +237,6 @@ DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS) | |||
316 | #define CRYPTO_EX_INDEX_ENGINE 9 | 237 | #define CRYPTO_EX_INDEX_ENGINE 9 |
317 | #define CRYPTO_EX_INDEX_X509 10 | 238 | #define CRYPTO_EX_INDEX_X509 10 |
318 | #define CRYPTO_EX_INDEX_UI 11 | 239 | #define CRYPTO_EX_INDEX_UI 11 |
319 | #define CRYPTO_EX_INDEX_ECDSA 12 | ||
320 | #define CRYPTO_EX_INDEX_ECDH 13 | ||
321 | #define CRYPTO_EX_INDEX_COMP 14 | ||
322 | #define CRYPTO_EX_INDEX_STORE 15 | ||
323 | 240 | ||
324 | /* Dynamically assigned indexes start from this value (don't use directly, use | 241 | /* Dynamically assigned indexes start from this value (don't use directly, use |
325 | * via CRYPTO_ex_data_new_class). */ | 242 | * via CRYPTO_ex_data_new_class). */ |
@@ -517,10 +434,61 @@ void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb); | |||
517 | 434 | ||
518 | /* die if we have to */ | 435 | /* die if we have to */ |
519 | void OpenSSLDie(const char *file,int line,const char *assertion); | 436 | void OpenSSLDie(const char *file,int line,const char *assertion); |
520 | #define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1)) | 437 | #define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1)) |
438 | |||
439 | #ifdef OPENSSL_FIPS | ||
440 | #define FIPS_ERROR_IGNORED(alg) OpenSSLDie(__FILE__, __LINE__, \ | ||
441 | alg " previous FIPS forbidden algorithm error ignored"); | ||
442 | |||
443 | #define FIPS_BAD_ABORT(alg) OpenSSLDie(__FILE__, __LINE__, \ | ||
444 | #alg " Algorithm forbidden in FIPS mode"); | ||
445 | |||
446 | #ifdef OPENSSL_FIPS_STRICT | ||
447 | #define FIPS_BAD_ALGORITHM(alg) FIPS_BAD_ABORT(alg) | ||
448 | #else | ||
449 | #define FIPS_BAD_ALGORITHM(alg) \ | ||
450 | { \ | ||
451 | FIPSerr(FIPS_F_HASH_FINAL,FIPS_R_NON_FIPS_METHOD); \ | ||
452 | ERR_add_error_data(2, "Algorithm=", #alg); \ | ||
453 | return 0; \ | ||
454 | } | ||
455 | #endif | ||
456 | |||
457 | /* Low level digest API blocking macro */ | ||
458 | |||
459 | #define FIPS_NON_FIPS_MD_Init(alg) \ | ||
460 | int alg##_Init(alg##_CTX *c) \ | ||
461 | { \ | ||
462 | if (FIPS_mode()) \ | ||
463 | FIPS_BAD_ALGORITHM(alg) \ | ||
464 | return private_##alg##_Init(c); \ | ||
465 | } \ | ||
466 | int private_##alg##_Init(alg##_CTX *c) | ||
467 | |||
468 | /* For ciphers the API often varies from cipher to cipher and each needs to | ||
469 | * be treated as a special case. Variable key length ciphers (Blowfish, RC4, | ||
470 | * CAST) however are very similar and can use a blocking macro. | ||
471 | */ | ||
472 | |||
473 | #define FIPS_NON_FIPS_VCIPHER_Init(alg) \ | ||
474 | void alg##_set_key(alg##_KEY *key, int len, const unsigned char *data) \ | ||
475 | { \ | ||
476 | if (FIPS_mode()) \ | ||
477 | FIPS_BAD_ABORT(alg) \ | ||
478 | private_##alg##_set_key(key, len, data); \ | ||
479 | } \ | ||
480 | void private_##alg##_set_key(alg##_KEY *key, int len, \ | ||
481 | const unsigned char *data) | ||
482 | |||
483 | #else | ||
484 | |||
485 | #define FIPS_NON_FIPS_VCIPHER_Init(alg) \ | ||
486 | void alg##_set_key(alg##_KEY *key, int len, const unsigned char *data) | ||
487 | |||
488 | #define FIPS_NON_FIPS_MD_Init(alg) \ | ||
489 | int alg##_Init(alg##_CTX *c) | ||
521 | 490 | ||
522 | unsigned long *OPENSSL_ia32cap_loc(void); | 491 | #endif /* def OPENSSL_FIPS */ |
523 | #define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc())) | ||
524 | 492 | ||
525 | /* BEGIN ERROR CODES */ | 493 | /* BEGIN ERROR CODES */ |
526 | /* The following lines are auto generated by the script mkerr.pl. Any changes | 494 | /* The following lines are auto generated by the script mkerr.pl. Any changes |