summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/crypto.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/crypto.h')
-rw-r--r--src/lib/libcrypto/crypto.h182
1 files changed, 107 insertions, 75 deletions
diff --git a/src/lib/libcrypto/crypto.h b/src/lib/libcrypto/crypto.h
index 22fd939e65..d2b5ffe332 100644
--- a/src/lib/libcrypto/crypto.h
+++ b/src/lib/libcrypto/crypto.h
@@ -1,4 +1,57 @@
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 */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 55/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 56 * All rights reserved.
4 * 57 *
@@ -55,12 +108,19 @@
55 * copied and put under another distribution licence 108 * copied and put under another distribution licence
56 * [including the GNU Public Licence.] 109 * [including the GNU Public Licence.]
57 */ 110 */
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 */
58 116
59#ifndef HEADER_CRYPTO_H 117#ifndef HEADER_CRYPTO_H
60#define HEADER_CRYPTO_H 118#define HEADER_CRYPTO_H
61 119
62#include <stdlib.h> 120#include <stdlib.h>
63 121
122#include <openssl/e_os2.h>
123
64#ifndef OPENSSL_NO_FP_API 124#ifndef OPENSSL_NO_FP_API
65#include <stdio.h> 125#include <stdio.h>
66#endif 126#endif
@@ -68,6 +128,7 @@
68#include <openssl/stack.h> 128#include <openssl/stack.h>
69#include <openssl/safestack.h> 129#include <openssl/safestack.h>
70#include <openssl/opensslv.h> 130#include <openssl/opensslv.h>
131#include <openssl/ossl_typ.h>
71 132
72#ifdef CHARSET_EBCDIC 133#ifdef CHARSET_EBCDIC
73#include <openssl/ebcdic.h> 134#include <openssl/ebcdic.h>
@@ -92,15 +153,39 @@ extern "C" {
92#define SSLEAY_PLATFORM 4 153#define SSLEAY_PLATFORM 4
93#define SSLEAY_DIR 5 154#define SSLEAY_DIR 5
94 155
156/* Already declared in ossl_typ.h */
157#if 0
158typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
159/* Called when a new object is created */
160typedef 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 */
163typedef 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 */
166typedef 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 */
171typedef 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
95/* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock 180/* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock
96 * names in cryptlib.c 181 * names in cryptlib.c
97 */ 182 */
98 183
99#define CRYPTO_LOCK_ERR 1 184#define CRYPTO_LOCK_ERR 1
100#define CRYPTO_LOCK_EX_DATA 2 185#define CRYPTO_LOCK_EX_DATA 2
101#define CRYPTO_LOCK_X509 3 186#define CRYPTO_LOCK_X509 3
102#define CRYPTO_LOCK_X509_INFO 4 187#define CRYPTO_LOCK_X509_INFO 4
103#define CRYPTO_LOCK_X509_PKEY 5 188#define CRYPTO_LOCK_X509_PKEY 5
104#define CRYPTO_LOCK_X509_CRL 6 189#define CRYPTO_LOCK_X509_CRL 6
105#define CRYPTO_LOCK_X509_REQ 7 190#define CRYPTO_LOCK_X509_REQ 7
106#define CRYPTO_LOCK_DSA 8 191#define CRYPTO_LOCK_DSA 8
@@ -127,10 +212,14 @@ extern "C" {
127#define CRYPTO_LOCK_DYNLOCK 29 212#define CRYPTO_LOCK_DYNLOCK 29
128#define CRYPTO_LOCK_ENGINE 30 213#define CRYPTO_LOCK_ENGINE 30
129#define CRYPTO_LOCK_UI 31 214#define CRYPTO_LOCK_UI 31
130#define CRYPTO_LOCK_HWCRHK 32 /* This is a HACK which will disappear in 0.9.8 */ 215#define CRYPTO_LOCK_ECDSA 32
131#define CRYPTO_LOCK_FIPS 33 216#define CRYPTO_LOCK_EC 33
132#define CRYPTO_LOCK_FIPS2 34 217#define CRYPTO_LOCK_ECDH 34
133#define CRYPTO_NUM_LOCKS 35 218#define CRYPTO_LOCK_BN 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
134 223
135#define CRYPTO_LOCK 1 224#define CRYPTO_LOCK 1
136#define CRYPTO_UNLOCK 2 225#define CRYPTO_UNLOCK 2
@@ -191,21 +280,11 @@ typedef struct
191/* predec of the BIO type */ 280/* predec of the BIO type */
192typedef struct bio_st BIO_dummy; 281typedef struct bio_st BIO_dummy;
193 282
194typedef struct crypto_ex_data_st 283struct crypto_ex_data_st
195 { 284 {
196 STACK *sk; 285 STACK *sk;
197 int dummy; /* gcc is screwing up this data structure :-( */ 286 int dummy; /* gcc is screwing up this data structure :-( */
198 } CRYPTO_EX_DATA; 287 };
199
200/* Called when a new object is created */
201typedef 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 */
204typedef 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 */
207typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
208 int idx, long argl, void *argp);
209 288
210/* This stuff is basically class callback functions 289/* This stuff is basically class callback functions
211 * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */ 290 * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */
@@ -237,6 +316,10 @@ DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
237#define CRYPTO_EX_INDEX_ENGINE 9 316#define CRYPTO_EX_INDEX_ENGINE 9
238#define CRYPTO_EX_INDEX_X509 10 317#define CRYPTO_EX_INDEX_X509 10
239#define CRYPTO_EX_INDEX_UI 11 318#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
240 323
241/* Dynamically assigned indexes start from this value (don't use directly, use 324/* Dynamically assigned indexes start from this value (don't use directly, use
242 * via CRYPTO_ex_data_new_class). */ 325 * via CRYPTO_ex_data_new_class). */
@@ -434,61 +517,10 @@ void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
434 517
435/* die if we have to */ 518/* die if we have to */
436void OpenSSLDie(const char *file,int line,const char *assertion); 519void OpenSSLDie(const char *file,int line,const char *assertion);
437#define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1)) 520#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)
490 521
491#endif /* def OPENSSL_FIPS */ 522unsigned long *OPENSSL_ia32cap_loc(void);
523#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))
492 524
493/* BEGIN ERROR CODES */ 525/* BEGIN ERROR CODES */
494/* The following lines are auto generated by the script mkerr.pl. Any changes 526/* The following lines are auto generated by the script mkerr.pl. Any changes