Tanguy Pruvot
10 years ago
9 changed files with 5067 additions and 3 deletions
@ -0,0 +1,902 @@ |
|||||||
|
/* crypto/bn/bn.h */ |
||||||
|
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* This package is an SSL implementation written |
||||||
|
* by Eric Young (eay@cryptsoft.com). |
||||||
|
* The implementation was written so as to conform with Netscapes SSL. |
||||||
|
* |
||||||
|
* This library is free for commercial and non-commercial use as long as |
||||||
|
* the following conditions are aheared to. The following conditions |
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA, |
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation |
||||||
|
* included with this distribution is covered by the same copyright terms |
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com). |
||||||
|
* |
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in |
||||||
|
* the code are not to be removed. |
||||||
|
* If this package is used in a product, Eric Young should be given attribution |
||||||
|
* as the author of the parts of the library used. |
||||||
|
* This can be in the form of a textual message at program startup or |
||||||
|
* in documentation (online or textual) provided with the package. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions |
||||||
|
* are met: |
||||||
|
* 1. Redistributions of source code must retain the copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer in the |
||||||
|
* documentation and/or other materials provided with the distribution. |
||||||
|
* 3. All advertising materials mentioning features or use of this software |
||||||
|
* must display the following acknowledgement: |
||||||
|
* "This product includes cryptographic software written by |
||||||
|
* Eric Young (eay@cryptsoft.com)" |
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library |
||||||
|
* being used are not cryptographic related :-). |
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from |
||||||
|
* the apps directory (application code) you must include an acknowledgement: |
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||||
|
* SUCH DAMAGE. |
||||||
|
* |
||||||
|
* The licence and distribution terms for any publically available version or |
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be |
||||||
|
* copied and put under another distribution licence |
||||||
|
* [including the GNU Public Licence.] |
||||||
|
*/ |
||||||
|
/* ====================================================================
|
||||||
|
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions |
||||||
|
* are met: |
||||||
|
* |
||||||
|
* 1. Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer in |
||||||
|
* the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* |
||||||
|
* 3. All advertising materials mentioning features or use of this |
||||||
|
* software must display the following acknowledgment: |
||||||
|
* "This product includes software developed by the OpenSSL Project |
||||||
|
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||||
|
* |
||||||
|
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to |
||||||
|
* endorse or promote products derived from this software without |
||||||
|
* prior written permission. For written permission, please contact |
||||||
|
* openssl-core@openssl.org. |
||||||
|
* |
||||||
|
* 5. Products derived from this software may not be called "OpenSSL" |
||||||
|
* nor may "OpenSSL" appear in their names without prior written |
||||||
|
* permission of the OpenSSL Project. |
||||||
|
* |
||||||
|
* 6. Redistributions of any form whatsoever must retain the following |
||||||
|
* acknowledgment: |
||||||
|
* "This product includes software developed by the OpenSSL Project |
||||||
|
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY |
||||||
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR |
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* ==================================================================== |
||||||
|
* |
||||||
|
* This product includes cryptographic software written by Eric Young |
||||||
|
* (eay@cryptsoft.com). This product includes software written by Tim |
||||||
|
* Hudson (tjh@cryptsoft.com). |
||||||
|
* |
||||||
|
*/ |
||||||
|
/* ====================================================================
|
||||||
|
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
||||||
|
* |
||||||
|
* Portions of the attached software ("Contribution") are developed by |
||||||
|
* SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. |
||||||
|
* |
||||||
|
* The Contribution is licensed pursuant to the Eric Young open source |
||||||
|
* license provided above. |
||||||
|
* |
||||||
|
* The binary polynomial arithmetic software is originally written by |
||||||
|
* Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef HEADER_BN_H |
||||||
|
#define HEADER_BN_H |
||||||
|
|
||||||
|
#include <openssl/e_os2.h> |
||||||
|
#ifndef OPENSSL_NO_FP_API |
||||||
|
#include <stdio.h> /* FILE */ |
||||||
|
#endif |
||||||
|
#include <openssl/ossl_typ.h> |
||||||
|
#include <openssl/crypto.h> |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/* These preprocessor symbols control various aspects of the bignum headers and
|
||||||
|
* library code. They're not defined by any "normal" configuration, as they are |
||||||
|
* intended for development and testing purposes. NB: defining all three can be |
||||||
|
* useful for debugging application code as well as openssl itself. |
||||||
|
* |
||||||
|
* BN_DEBUG - turn on various debugging alterations to the bignum code |
||||||
|
* BN_DEBUG_RAND - uses random poisoning of unused words to trip up |
||||||
|
* mismanagement of bignum internals. You must also define BN_DEBUG. |
||||||
|
*/ |
||||||
|
/* #define BN_DEBUG */ |
||||||
|
/* #define BN_DEBUG_RAND */ |
||||||
|
|
||||||
|
#ifndef OPENSSL_SMALL_FOOTPRINT |
||||||
|
#define BN_MUL_COMBA |
||||||
|
#define BN_SQR_COMBA |
||||||
|
#define BN_RECURSION |
||||||
|
#endif |
||||||
|
|
||||||
|
/* This next option uses the C libraries (2 word)/(1 word) function.
|
||||||
|
* If it is not defined, I use my C version (which is slower). |
||||||
|
* The reason for this flag is that when the particular C compiler |
||||||
|
* library routine is used, and the library is linked with a different |
||||||
|
* compiler, the library is missing. This mostly happens when the |
||||||
|
* library is built with gcc and then linked using normal cc. This would |
||||||
|
* be a common occurrence because gcc normally produces code that is |
||||||
|
* 2 times faster than system compilers for the big number stuff. |
||||||
|
* For machines with only one compiler (or shared libraries), this should |
||||||
|
* be on. Again this in only really a problem on machines |
||||||
|
* using "long long's", are 32bit, and are not using my assembler code. */ |
||||||
|
#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \ |
||||||
|
defined(OPENSSL_SYS_WIN32) || defined(linux) |
||||||
|
# ifndef BN_DIV2W |
||||||
|
# define BN_DIV2W |
||||||
|
# endif |
||||||
|
#endif |
||||||
|
|
||||||
|
/* assuming long is 64bit - this is the DEC Alpha
|
||||||
|
* unsigned long long is only 64 bits :-(, don't define |
||||||
|
* BN_LLONG for the DEC Alpha */ |
||||||
|
#ifdef SIXTY_FOUR_BIT_LONG |
||||||
|
#define BN_ULLONG unsigned long long |
||||||
|
#define BN_ULONG unsigned long |
||||||
|
#define BN_LONG long |
||||||
|
#define BN_BITS 128 |
||||||
|
#define BN_BYTES 8 |
||||||
|
#define BN_BITS2 64 |
||||||
|
#define BN_BITS4 32 |
||||||
|
#define BN_MASK (0xffffffffffffffffffffffffffffffffLL) |
||||||
|
#define BN_MASK2 (0xffffffffffffffffL) |
||||||
|
#define BN_MASK2l (0xffffffffL) |
||||||
|
#define BN_MASK2h (0xffffffff00000000L) |
||||||
|
#define BN_MASK2h1 (0xffffffff80000000L) |
||||||
|
#define BN_TBIT (0x8000000000000000L) |
||||||
|
#define BN_DEC_CONV (10000000000000000000UL) |
||||||
|
#define BN_DEC_FMT1 "%lu" |
||||||
|
#define BN_DEC_FMT2 "%019lu" |
||||||
|
#define BN_DEC_NUM 19 |
||||||
|
#define BN_HEX_FMT1 "%lX" |
||||||
|
#define BN_HEX_FMT2 "%016lX" |
||||||
|
#endif |
||||||
|
|
||||||
|
/* This is where the long long data type is 64 bits, but long is 32.
|
||||||
|
* For machines where there are 64bit registers, this is the mode to use. |
||||||
|
* IRIX, on R4000 and above should use this mode, along with the relevant |
||||||
|
* assembler code :-). Do NOT define BN_LLONG. |
||||||
|
*/ |
||||||
|
#ifdef SIXTY_FOUR_BIT |
||||||
|
#undef BN_LLONG |
||||||
|
#undef BN_ULLONG |
||||||
|
#define BN_ULONG unsigned long long |
||||||
|
#define BN_LONG long long |
||||||
|
#define BN_BITS 128 |
||||||
|
#define BN_BYTES 8 |
||||||
|
#define BN_BITS2 64 |
||||||
|
#define BN_BITS4 32 |
||||||
|
#define BN_MASK2 (0xffffffffffffffffLL) |
||||||
|
#define BN_MASK2l (0xffffffffL) |
||||||
|
#define BN_MASK2h (0xffffffff00000000LL) |
||||||
|
#define BN_MASK2h1 (0xffffffff80000000LL) |
||||||
|
#define BN_TBIT (0x8000000000000000LL) |
||||||
|
#define BN_DEC_CONV (10000000000000000000ULL) |
||||||
|
#define BN_DEC_FMT1 "%llu" |
||||||
|
#define BN_DEC_FMT2 "%019llu" |
||||||
|
#define BN_DEC_NUM 19 |
||||||
|
#define BN_HEX_FMT1 "%llX" |
||||||
|
#define BN_HEX_FMT2 "%016llX" |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef THIRTY_TWO_BIT |
||||||
|
#ifdef BN_LLONG |
||||||
|
# if defined(_WIN32) && !defined(__GNUC__) |
||||||
|
# define BN_ULLONG unsigned __int64 |
||||||
|
# define BN_MASK (0xffffffffffffffffI64) |
||||||
|
# else |
||||||
|
# define BN_ULLONG unsigned long long |
||||||
|
# define BN_MASK (0xffffffffffffffffLL) |
||||||
|
# endif |
||||||
|
#endif |
||||||
|
#define BN_ULONG unsigned int |
||||||
|
#define BN_LONG int |
||||||
|
#define BN_BITS 64 |
||||||
|
#define BN_BYTES 4 |
||||||
|
#define BN_BITS2 32 |
||||||
|
#define BN_BITS4 16 |
||||||
|
#define BN_MASK2 (0xffffffffL) |
||||||
|
#define BN_MASK2l (0xffff) |
||||||
|
#define BN_MASK2h1 (0xffff8000L) |
||||||
|
#define BN_MASK2h (0xffff0000L) |
||||||
|
#define BN_TBIT (0x80000000L) |
||||||
|
#define BN_DEC_CONV (1000000000L) |
||||||
|
#define BN_DEC_FMT1 "%u" |
||||||
|
#define BN_DEC_FMT2 "%09u" |
||||||
|
#define BN_DEC_NUM 9 |
||||||
|
#define BN_HEX_FMT1 "%X" |
||||||
|
#define BN_HEX_FMT2 "%08X" |
||||||
|
#endif |
||||||
|
|
||||||
|
/* 2011-02-22 SMS.
|
||||||
|
* In various places, a size_t variable or a type cast to size_t was |
||||||
|
* used to perform integer-only operations on pointers. This failed on |
||||||
|
* VMS with 64-bit pointers (CC /POINTER_SIZE = 64) because size_t is |
||||||
|
* still only 32 bits. What's needed in these cases is an integer type |
||||||
|
* with the same size as a pointer, which size_t is not certain to be. |
||||||
|
* The only fix here is VMS-specific. |
||||||
|
*/ |
||||||
|
#if defined(OPENSSL_SYS_VMS) |
||||||
|
# if __INITIAL_POINTER_SIZE == 64 |
||||||
|
# define PTR_SIZE_INT long long |
||||||
|
# else /* __INITIAL_POINTER_SIZE == 64 */ |
||||||
|
# define PTR_SIZE_INT int |
||||||
|
# endif /* __INITIAL_POINTER_SIZE == 64 [else] */ |
||||||
|
#else /* defined(OPENSSL_SYS_VMS) */ |
||||||
|
# define PTR_SIZE_INT size_t |
||||||
|
#endif /* defined(OPENSSL_SYS_VMS) [else] */ |
||||||
|
|
||||||
|
#define BN_DEFAULT_BITS 1280 |
||||||
|
|
||||||
|
#define BN_FLG_MALLOCED 0x01 |
||||||
|
#define BN_FLG_STATIC_DATA 0x02 |
||||||
|
#define BN_FLG_CONSTTIME 0x04 /* avoid leaking exponent information through timing, |
||||||
|
* BN_mod_exp_mont() will call BN_mod_exp_mont_consttime, |
||||||
|
* BN_div() will call BN_div_no_branch, |
||||||
|
* BN_mod_inverse() will call BN_mod_inverse_no_branch. |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef OPENSSL_NO_DEPRECATED |
||||||
|
#define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME /* deprecated name for the flag */ |
||||||
|
/* avoid leaking exponent information through timings
|
||||||
|
* (BN_mod_exp_mont() will call BN_mod_exp_mont_consttime) */ |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifndef OPENSSL_NO_DEPRECATED |
||||||
|
#define BN_FLG_FREE 0x8000 /* used for debuging */ |
||||||
|
#endif |
||||||
|
#define BN_set_flags(b,n) ((b)->flags|=(n)) |
||||||
|
#define BN_get_flags(b,n) ((b)->flags&(n)) |
||||||
|
|
||||||
|
/* get a clone of a BIGNUM with changed flags, for *temporary* use only
|
||||||
|
* (the two BIGNUMs cannot not be used in parallel!) */ |
||||||
|
#define BN_with_flags(dest,b,n) ((dest)->d=(b)->d, \ |
||||||
|
(dest)->top=(b)->top, \ |
||||||
|
(dest)->dmax=(b)->dmax, \ |
||||||
|
(dest)->neg=(b)->neg, \ |
||||||
|
(dest)->flags=(((dest)->flags & BN_FLG_MALLOCED) \ |
||||||
|
| ((b)->flags & ~BN_FLG_MALLOCED) \ |
||||||
|
| BN_FLG_STATIC_DATA \ |
||||||
|
| (n))) |
||||||
|
|
||||||
|
/* Already declared in ossl_typ.h */ |
||||||
|
#if 0 |
||||||
|
typedef struct bignum_st BIGNUM; |
||||||
|
/* Used for temp variables (declaration hidden in bn_lcl.h) */ |
||||||
|
typedef struct bignum_ctx BN_CTX; |
||||||
|
typedef struct bn_blinding_st BN_BLINDING; |
||||||
|
typedef struct bn_mont_ctx_st BN_MONT_CTX; |
||||||
|
typedef struct bn_recp_ctx_st BN_RECP_CTX; |
||||||
|
typedef struct bn_gencb_st BN_GENCB; |
||||||
|
#endif |
||||||
|
|
||||||
|
struct bignum_st |
||||||
|
{ |
||||||
|
BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */ |
||||||
|
int top; /* Index of last used d +1. */ |
||||||
|
/* The next are internal book keeping for bn_expand. */ |
||||||
|
int dmax; /* Size of the d array. */ |
||||||
|
int neg; /* one if the number is negative */ |
||||||
|
int flags; |
||||||
|
}; |
||||||
|
|
||||||
|
/* Used for montgomery multiplication */ |
||||||
|
struct bn_mont_ctx_st |
||||||
|
{ |
||||||
|
int ri; /* number of bits in R */ |
||||||
|
BIGNUM RR; /* used to convert to montgomery form */ |
||||||
|
BIGNUM N; /* The modulus */ |
||||||
|
BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1
|
||||||
|
* (Ni is only stored for bignum algorithm) */ |
||||||
|
BN_ULONG n0[2];/* least significant word(s) of Ni;
|
||||||
|
(type changed with 0.9.9, was "BN_ULONG n0;" before) */ |
||||||
|
int flags; |
||||||
|
}; |
||||||
|
|
||||||
|
/* Used for reciprocal division/mod functions
|
||||||
|
* It cannot be shared between threads |
||||||
|
*/ |
||||||
|
struct bn_recp_ctx_st |
||||||
|
{ |
||||||
|
BIGNUM N; /* the divisor */ |
||||||
|
BIGNUM Nr; /* the reciprocal */ |
||||||
|
int num_bits; |
||||||
|
int shift; |
||||||
|
int flags; |
||||||
|
}; |
||||||
|
|
||||||
|
/* Used for slow "generation" functions. */ |
||||||
|
struct bn_gencb_st |
||||||
|
{ |
||||||
|
unsigned int ver; /* To handle binary (in)compatibility */ |
||||||
|
void *arg; /* callback-specific data */ |
||||||
|
union |
||||||
|
{ |
||||||
|
/* if(ver==1) - handles old style callbacks */ |
||||||
|
void (*cb_1)(int, int, void *); |
||||||
|
/* if(ver==2) - new callback style */ |
||||||
|
int (*cb_2)(int, int, BN_GENCB *); |
||||||
|
} cb; |
||||||
|
}; |
||||||
|
/* Wrapper function to make using BN_GENCB easier, */ |
||||||
|
int BN_GENCB_call(BN_GENCB *cb, int a, int b); |
||||||
|
/* Macro to populate a BN_GENCB structure with an "old"-style callback */ |
||||||
|
#define BN_GENCB_set_old(gencb, callback, cb_arg) { \ |
||||||
|
BN_GENCB *tmp_gencb = (gencb); \ |
||||||
|
tmp_gencb->ver = 1; \ |
||||||
|
tmp_gencb->arg = (cb_arg); \ |
||||||
|
tmp_gencb->cb.cb_1 = (callback); } |
||||||
|
/* Macro to populate a BN_GENCB structure with a "new"-style callback */ |
||||||
|
#define BN_GENCB_set(gencb, callback, cb_arg) { \ |
||||||
|
BN_GENCB *tmp_gencb = (gencb); \ |
||||||
|
tmp_gencb->ver = 2; \ |
||||||
|
tmp_gencb->arg = (cb_arg); \ |
||||||
|
tmp_gencb->cb.cb_2 = (callback); } |
||||||
|
|
||||||
|
#define BN_prime_checks 0 /* default: select number of iterations |
||||||
|
based on the size of the number */ |
||||||
|
|
||||||
|
/* number of Miller-Rabin iterations for an error rate of less than 2^-80
|
||||||
|
* for random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook |
||||||
|
* of Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996]; |
||||||
|
* original paper: Damgaard, Landrock, Pomerance: Average case error estimates |
||||||
|
* for the strong probable prime test. -- Math. Comp. 61 (1993) 177-194) */ |
||||||
|
#define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \ |
||||||
|
(b) >= 850 ? 3 : \ |
||||||
|
(b) >= 650 ? 4 : \ |
||||||
|
(b) >= 550 ? 5 : \ |
||||||
|
(b) >= 450 ? 6 : \ |
||||||
|
(b) >= 400 ? 7 : \ |
||||||
|
(b) >= 350 ? 8 : \ |
||||||
|
(b) >= 300 ? 9 : \ |
||||||
|
(b) >= 250 ? 12 : \ |
||||||
|
(b) >= 200 ? 15 : \ |
||||||
|
(b) >= 150 ? 18 : \ |
||||||
|
/* b >= 100 */ 27) |
||||||
|
|
||||||
|
#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) |
||||||
|
|
||||||
|
/* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */ |
||||||
|
#define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \ |
||||||
|
(((w) == 0) && ((a)->top == 0))) |
||||||
|
#define BN_is_zero(a) ((a)->top == 0) |
||||||
|
#define BN_is_one(a) (BN_abs_is_word((a),1) && !(a)->neg) |
||||||
|
#define BN_is_word(a,w) (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg)) |
||||||
|
#define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1)) |
||||||
|
|
||||||
|
#define BN_one(a) (BN_set_word((a),1)) |
||||||
|
#define BN_zero_ex(a) \ |
||||||
|
do { \ |
||||||
|
BIGNUM *_tmp_bn = (a); \ |
||||||
|
_tmp_bn->top = 0; \ |
||||||
|
_tmp_bn->neg = 0; \ |
||||||
|
} while(0) |
||||||
|
#ifdef OPENSSL_NO_DEPRECATED |
||||||
|
#define BN_zero(a) BN_zero_ex(a) |
||||||
|
#else |
||||||
|
#define BN_zero(a) (BN_set_word((a),0)) |
||||||
|
#endif |
||||||
|
|
||||||
|
const BIGNUM *BN_value_one(void); |
||||||
|
char * BN_options(void); |
||||||
|
BN_CTX *BN_CTX_new(void); |
||||||
|
#ifndef OPENSSL_NO_DEPRECATED |
||||||
|
void BN_CTX_init(BN_CTX *c); |
||||||
|
#endif |
||||||
|
void BN_CTX_free(BN_CTX *c); |
||||||
|
void BN_CTX_start(BN_CTX *ctx); |
||||||
|
BIGNUM *BN_CTX_get(BN_CTX *ctx); |
||||||
|
void BN_CTX_end(BN_CTX *ctx); |
||||||
|
int BN_rand(BIGNUM *rnd, int bits, int top,int bottom); |
||||||
|
int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom); |
||||||
|
int BN_rand_range(BIGNUM *rnd, const BIGNUM *range); |
||||||
|
int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range); |
||||||
|
int BN_num_bits(const BIGNUM *a); |
||||||
|
int BN_num_bits_word(BN_ULONG); |
||||||
|
BIGNUM *BN_new(void); |
||||||
|
void BN_init(BIGNUM *); |
||||||
|
void BN_clear_free(BIGNUM *a); |
||||||
|
BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b); |
||||||
|
void BN_swap(BIGNUM *a, BIGNUM *b); |
||||||
|
BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret); |
||||||
|
int BN_bn2bin(const BIGNUM *a, unsigned char *to); |
||||||
|
BIGNUM *BN_mpi2bn(const unsigned char *s,int len,BIGNUM *ret); |
||||||
|
int BN_bn2mpi(const BIGNUM *a, unsigned char *to); |
||||||
|
int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); |
||||||
|
int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); |
||||||
|
int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); |
||||||
|
int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); |
||||||
|
int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); |
||||||
|
int BN_sqr(BIGNUM *r, const BIGNUM *a,BN_CTX *ctx); |
||||||
|
/** BN_set_negative sets sign of a BIGNUM
|
||||||
|
* \param b pointer to the BIGNUM object |
||||||
|
* \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise |
||||||
|
*/ |
||||||
|
void BN_set_negative(BIGNUM *b, int n); |
||||||
|
/** BN_is_negative returns 1 if the BIGNUM is negative
|
||||||
|
* \param a pointer to the BIGNUM object |
||||||
|
* \return 1 if a < 0 and 0 otherwise |
||||||
|
*/ |
||||||
|
#define BN_is_negative(a) ((a)->neg != 0) |
||||||
|
|
||||||
|
int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, |
||||||
|
BN_CTX *ctx); |
||||||
|
#define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx)) |
||||||
|
int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); |
||||||
|
int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); |
||||||
|
int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); |
||||||
|
int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); |
||||||
|
int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); |
||||||
|
int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
||||||
|
const BIGNUM *m, BN_CTX *ctx); |
||||||
|
int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); |
||||||
|
int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); |
||||||
|
int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m); |
||||||
|
int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx); |
||||||
|
int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m); |
||||||
|
|
||||||
|
BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w); |
||||||
|
BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w); |
||||||
|
int BN_mul_word(BIGNUM *a, BN_ULONG w); |
||||||
|
int BN_add_word(BIGNUM *a, BN_ULONG w); |
||||||
|
int BN_sub_word(BIGNUM *a, BN_ULONG w); |
||||||
|
int BN_set_word(BIGNUM *a, BN_ULONG w); |
||||||
|
BN_ULONG BN_get_word(const BIGNUM *a); |
||||||
|
|
||||||
|
int BN_cmp(const BIGNUM *a, const BIGNUM *b); |
||||||
|
void BN_free(BIGNUM *a); |
||||||
|
int BN_is_bit_set(const BIGNUM *a, int n); |
||||||
|
int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); |
||||||
|
int BN_lshift1(BIGNUM *r, const BIGNUM *a); |
||||||
|
int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,BN_CTX *ctx); |
||||||
|
|
||||||
|
int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
||||||
|
const BIGNUM *m,BN_CTX *ctx); |
||||||
|
int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
||||||
|
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); |
||||||
|
int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, |
||||||
|
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont); |
||||||
|
int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, |
||||||
|
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); |
||||||
|
int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1, |
||||||
|
const BIGNUM *a2, const BIGNUM *p2,const BIGNUM *m, |
||||||
|
BN_CTX *ctx,BN_MONT_CTX *m_ctx); |
||||||
|
int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
||||||
|
const BIGNUM *m,BN_CTX *ctx); |
||||||
|
|
||||||
|
int BN_mask_bits(BIGNUM *a,int n); |
||||||
|
#ifndef OPENSSL_NO_FP_API |
||||||
|
int BN_print_fp(FILE *fp, const BIGNUM *a); |
||||||
|
#endif |
||||||
|
#ifdef HEADER_BIO_H |
||||||
|
int BN_print(BIO *fp, const BIGNUM *a); |
||||||
|
#else |
||||||
|
int BN_print(void *fp, const BIGNUM *a); |
||||||
|
#endif |
||||||
|
int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx); |
||||||
|
int BN_rshift(BIGNUM *r, const BIGNUM *a, int n); |
||||||
|
int BN_rshift1(BIGNUM *r, const BIGNUM *a); |
||||||
|
void BN_clear(BIGNUM *a); |
||||||
|
BIGNUM *BN_dup(const BIGNUM *a); |
||||||
|
int BN_ucmp(const BIGNUM *a, const BIGNUM *b); |
||||||
|
int BN_set_bit(BIGNUM *a, int n); |
||||||
|
int BN_clear_bit(BIGNUM *a, int n); |
||||||
|
char * BN_bn2hex(const BIGNUM *a); |
||||||
|
char * BN_bn2dec(const BIGNUM *a); |
||||||
|
int BN_hex2bn(BIGNUM **a, const char *str); |
||||||
|
int BN_dec2bn(BIGNUM **a, const char *str); |
||||||
|
int BN_asc2bn(BIGNUM **a, const char *str); |
||||||
|
int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); |
||||||
|
int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */ |
||||||
|
BIGNUM *BN_mod_inverse(BIGNUM *ret, |
||||||
|
const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); |
||||||
|
BIGNUM *BN_mod_sqrt(BIGNUM *ret, |
||||||
|
const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); |
||||||
|
|
||||||
|
void BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords); |
||||||
|
|
||||||
|
/* Deprecated versions */ |
||||||
|
#ifndef OPENSSL_NO_DEPRECATED |
||||||
|
BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe, |
||||||
|
const BIGNUM *add, const BIGNUM *rem, |
||||||
|
void (*callback)(int,int,void *),void *cb_arg); |
||||||
|
int BN_is_prime(const BIGNUM *p,int nchecks, |
||||||
|
void (*callback)(int,int,void *), |
||||||
|
BN_CTX *ctx,void *cb_arg); |
||||||
|
int BN_is_prime_fasttest(const BIGNUM *p,int nchecks, |
||||||
|
void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg, |
||||||
|
int do_trial_division); |
||||||
|
#endif /* !defined(OPENSSL_NO_DEPRECATED) */ |
||||||
|
|
||||||
|
/* Newer versions */ |
||||||
|
int BN_generate_prime_ex(BIGNUM *ret,int bits,int safe, const BIGNUM *add, |
||||||
|
const BIGNUM *rem, BN_GENCB *cb); |
||||||
|
int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb); |
||||||
|
int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, |
||||||
|
int do_trial_division, BN_GENCB *cb); |
||||||
|
|
||||||
|
int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx); |
||||||
|
|
||||||
|
int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, |
||||||
|
const BIGNUM *Xp, const BIGNUM *Xp1, const BIGNUM *Xp2, |
||||||
|
const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb); |
||||||
|
int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, |
||||||
|
BIGNUM *Xp1, BIGNUM *Xp2, |
||||||
|
const BIGNUM *Xp, |
||||||
|
const BIGNUM *e, BN_CTX *ctx, |
||||||
|
BN_GENCB *cb); |
||||||
|
|
||||||
|
BN_MONT_CTX *BN_MONT_CTX_new(void ); |
||||||
|
void BN_MONT_CTX_init(BN_MONT_CTX *ctx); |
||||||
|
int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b, |
||||||
|
BN_MONT_CTX *mont, BN_CTX *ctx); |
||||||
|
#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\ |
||||||
|
(r),(a),&((mont)->RR),(mont),(ctx)) |
||||||
|
int BN_from_montgomery(BIGNUM *r,const BIGNUM *a, |
||||||
|
BN_MONT_CTX *mont, BN_CTX *ctx); |
||||||
|
void BN_MONT_CTX_free(BN_MONT_CTX *mont); |
||||||
|
int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *mod,BN_CTX *ctx); |
||||||
|
BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from); |
||||||
|
BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock, |
||||||
|
const BIGNUM *mod, BN_CTX *ctx); |
||||||
|
|
||||||
|
/* BN_BLINDING flags */ |
||||||
|
#define BN_BLINDING_NO_UPDATE 0x00000001 |
||||||
|
#define BN_BLINDING_NO_RECREATE 0x00000002 |
||||||
|
|
||||||
|
BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod); |
||||||
|
void BN_BLINDING_free(BN_BLINDING *b); |
||||||
|
int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx); |
||||||
|
int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); |
||||||
|
int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); |
||||||
|
int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *); |
||||||
|
int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *); |
||||||
|
#ifndef OPENSSL_NO_DEPRECATED |
||||||
|
unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *); |
||||||
|
void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long); |
||||||
|
#endif |
||||||
|
CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *); |
||||||
|
unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); |
||||||
|
void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); |
||||||
|
BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, |
||||||
|
const BIGNUM *e, BIGNUM *m, BN_CTX *ctx, |
||||||
|
int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
||||||
|
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), |
||||||
|
BN_MONT_CTX *m_ctx); |
||||||
|
|
||||||
|
#ifndef OPENSSL_NO_DEPRECATED |
||||||
|
void BN_set_params(int mul,int high,int low,int mont); |
||||||
|
int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */ |
||||||
|
#endif |
||||||
|
|
||||||
|
void BN_RECP_CTX_init(BN_RECP_CTX *recp); |
||||||
|
BN_RECP_CTX *BN_RECP_CTX_new(void); |
||||||
|
void BN_RECP_CTX_free(BN_RECP_CTX *recp); |
||||||
|
int BN_RECP_CTX_set(BN_RECP_CTX *recp,const BIGNUM *rdiv,BN_CTX *ctx); |
||||||
|
int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y, |
||||||
|
BN_RECP_CTX *recp,BN_CTX *ctx); |
||||||
|
int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
||||||
|
const BIGNUM *m, BN_CTX *ctx); |
||||||
|
int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, |
||||||
|
BN_RECP_CTX *recp, BN_CTX *ctx); |
||||||
|
|
||||||
|
#ifndef OPENSSL_NO_EC2M |
||||||
|
|
||||||
|
/* Functions for arithmetic over binary polynomials represented by BIGNUMs.
|
||||||
|
* |
||||||
|
* The BIGNUM::neg property of BIGNUMs representing binary polynomials is |
||||||
|
* ignored. |
||||||
|
* |
||||||
|
* Note that input arguments are not const so that their bit arrays can |
||||||
|
* be expanded to the appropriate size if needed. |
||||||
|
*/ |
||||||
|
|
||||||
|
int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); /*r = a + b*/ |
||||||
|
#define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b) |
||||||
|
int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p); /*r=a mod p*/ |
||||||
|
int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
||||||
|
const BIGNUM *p, BN_CTX *ctx); /* r = (a * b) mod p */ |
||||||
|
int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
||||||
|
BN_CTX *ctx); /* r = (a * a) mod p */ |
||||||
|
int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, |
||||||
|
BN_CTX *ctx); /* r = (1 / b) mod p */ |
||||||
|
int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
||||||
|
const BIGNUM *p, BN_CTX *ctx); /* r = (a / b) mod p */ |
||||||
|
int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
||||||
|
const BIGNUM *p, BN_CTX *ctx); /* r = (a ^ b) mod p */ |
||||||
|
int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
||||||
|
BN_CTX *ctx); /* r = sqrt(a) mod p */ |
||||||
|
int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
||||||
|
BN_CTX *ctx); /* r^2 + r = a mod p */ |
||||||
|
#define BN_GF2m_cmp(a, b) BN_ucmp((a), (b)) |
||||||
|
/* Some functions allow for representation of the irreducible polynomials
|
||||||
|
* as an unsigned int[], say p. The irreducible f(t) is then of the form: |
||||||
|
* t^p[0] + t^p[1] + ... + t^p[k] |
||||||
|
* where m = p[0] > p[1] > ... > p[k] = 0. |
||||||
|
*/ |
||||||
|
int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]); |
||||||
|
/* r = a mod p */ |
||||||
|
int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
||||||
|
const int p[], BN_CTX *ctx); /* r = (a * b) mod p */ |
||||||
|
int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[], |
||||||
|
BN_CTX *ctx); /* r = (a * a) mod p */ |
||||||
|
int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[], |
||||||
|
BN_CTX *ctx); /* r = (1 / b) mod p */ |
||||||
|
int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
||||||
|
const int p[], BN_CTX *ctx); /* r = (a / b) mod p */ |
||||||
|
int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
||||||
|
const int p[], BN_CTX *ctx); /* r = (a ^ b) mod p */ |
||||||
|
int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, |
||||||
|
const int p[], BN_CTX *ctx); /* r = sqrt(a) mod p */ |
||||||
|
int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a, |
||||||
|
const int p[], BN_CTX *ctx); /* r^2 + r = a mod p */ |
||||||
|
int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max); |
||||||
|
int BN_GF2m_arr2poly(const int p[], BIGNUM *a); |
||||||
|
|
||||||
|
#endif |
||||||
|
|
||||||
|
/* faster mod functions for the 'NIST primes'
|
||||||
|
* 0 <= a < p^2 */ |
||||||
|
int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); |
||||||
|
int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); |
||||||
|
int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); |
||||||
|
int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); |
||||||
|
int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); |
||||||
|
|
||||||
|
const BIGNUM *BN_get0_nist_prime_192(void); |
||||||
|
const BIGNUM *BN_get0_nist_prime_224(void); |
||||||
|
const BIGNUM *BN_get0_nist_prime_256(void); |
||||||
|
const BIGNUM *BN_get0_nist_prime_384(void); |
||||||
|
const BIGNUM *BN_get0_nist_prime_521(void); |
||||||
|
|
||||||
|
/* library internal functions */ |
||||||
|
|
||||||
|
#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\ |
||||||
|
(a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2)) |
||||||
|
#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words))) |
||||||
|
BIGNUM *bn_expand2(BIGNUM *a, int words); |
||||||
|
#ifndef OPENSSL_NO_DEPRECATED |
||||||
|
BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */ |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Bignum consistency macros
|
||||||
|
* There is one "API" macro, bn_fix_top(), for stripping leading zeroes from |
||||||
|
* bignum data after direct manipulations on the data. There is also an |
||||||
|
* "internal" macro, bn_check_top(), for verifying that there are no leading |
||||||
|
* zeroes. Unfortunately, some auditing is required due to the fact that |
||||||
|
* bn_fix_top() has become an overabused duct-tape because bignum data is |
||||||
|
* occasionally passed around in an inconsistent state. So the following |
||||||
|
* changes have been made to sort this out; |
||||||
|
* - bn_fix_top()s implementation has been moved to bn_correct_top() |
||||||
|
* - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and |
||||||
|
* bn_check_top() is as before. |
||||||
|
* - if BN_DEBUG *is* defined; |
||||||
|
* - bn_check_top() tries to pollute unused words even if the bignum 'top' is |
||||||
|
* consistent. (ed: only if BN_DEBUG_RAND is defined) |
||||||
|
* - bn_fix_top() maps to bn_check_top() rather than "fixing" anything. |
||||||
|
* The idea is to have debug builds flag up inconsistent bignums when they |
||||||
|
* occur. If that occurs in a bn_fix_top(), we examine the code in question; if |
||||||
|
* the use of bn_fix_top() was appropriate (ie. it follows directly after code |
||||||
|
* that manipulates the bignum) it is converted to bn_correct_top(), and if it |
||||||
|
* was not appropriate, we convert it permanently to bn_check_top() and track |
||||||
|
* down the cause of the bug. Eventually, no internal code should be using the |
||||||
|
* bn_fix_top() macro. External applications and libraries should try this with |
||||||
|
* their own code too, both in terms of building against the openssl headers |
||||||
|
* with BN_DEBUG defined *and* linking with a version of OpenSSL built with it |
||||||
|
* defined. This not only improves external code, it provides more test |
||||||
|
* coverage for openssl's own code. |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifdef BN_DEBUG |
||||||
|
|
||||||
|
/* We only need assert() when debugging */ |
||||||
|
#include <assert.h> |
||||||
|
|
||||||
|
#ifdef BN_DEBUG_RAND |
||||||
|
/* To avoid "make update" cvs wars due to BN_DEBUG, use some tricks */ |
||||||
|
#ifndef RAND_pseudo_bytes |
||||||
|
int RAND_pseudo_bytes(unsigned char *buf,int num); |
||||||
|
#define BN_DEBUG_TRIX |
||||||
|
#endif |
||||||
|
#define bn_pollute(a) \ |
||||||
|
do { \ |
||||||
|
const BIGNUM *_bnum1 = (a); \ |
||||||
|
if(_bnum1->top < _bnum1->dmax) { \ |
||||||
|
unsigned char _tmp_char; \ |
||||||
|
/* We cast away const without the compiler knowing, any \
|
||||||
|
* *genuinely* constant variables that aren't mutable \ |
||||||
|
* wouldn't be constructed with top!=dmax. */ \ |
||||||
|
BN_ULONG *_not_const; \ |
||||||
|
memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \ |
||||||
|
RAND_pseudo_bytes(&_tmp_char, 1); \ |
||||||
|
memset((unsigned char *)(_not_const + _bnum1->top), _tmp_char, \ |
||||||
|
(_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \ |
||||||
|
} \ |
||||||
|
} while(0) |
||||||
|
#ifdef BN_DEBUG_TRIX |
||||||
|
#undef RAND_pseudo_bytes |
||||||
|
#endif |
||||||
|
#else |
||||||
|
#define bn_pollute(a) |
||||||
|
#endif |
||||||
|
#define bn_check_top(a) \ |
||||||
|
do { \ |
||||||
|
const BIGNUM *_bnum2 = (a); \ |
||||||
|
if (_bnum2 != NULL) { \ |
||||||
|
assert((_bnum2->top == 0) || \ |
||||||
|
(_bnum2->d[_bnum2->top - 1] != 0)); \ |
||||||
|
bn_pollute(_bnum2); \ |
||||||
|
} \ |
||||||
|
} while(0) |
||||||
|
|
||||||
|
#define bn_fix_top(a) bn_check_top(a) |
||||||
|
|
||||||
|
#define bn_check_size(bn, bits) bn_wcheck_size(bn, ((bits+BN_BITS2-1))/BN_BITS2) |
||||||
|
#define bn_wcheck_size(bn, words) \ |
||||||
|
do { \ |
||||||
|
const BIGNUM *_bnum2 = (bn); \ |
||||||
|
assert(words <= (_bnum2)->dmax && words >= (_bnum2)->top); \ |
||||||
|
} while(0) |
||||||
|
|
||||||
|
#else /* !BN_DEBUG */ |
||||||
|
|
||||||
|
#define bn_pollute(a) |
||||||
|
#define bn_check_top(a) |
||||||
|
#define bn_fix_top(a) bn_correct_top(a) |
||||||
|
#define bn_check_size(bn, bits) |
||||||
|
#define bn_wcheck_size(bn, words) |
||||||
|
|
||||||
|
#endif |
||||||
|
|
||||||
|
#define bn_correct_top(a) \ |
||||||
|
{ \ |
||||||
|
BN_ULONG *ftl; \ |
||||||
|
int tmp_top = (a)->top; \ |
||||||
|
if (tmp_top > 0) \ |
||||||
|
{ \ |
||||||
|
for (ftl= &((a)->d[tmp_top-1]); tmp_top > 0; tmp_top--) \ |
||||||
|
if (*(ftl--)) break; \ |
||||||
|
(a)->top = tmp_top; \ |
||||||
|
} \ |
||||||
|
bn_pollute(a); \ |
||||||
|
} |
||||||
|
|
||||||
|
BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); |
||||||
|
BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); |
||||||
|
void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num); |
||||||
|
BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d); |
||||||
|
BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num); |
||||||
|
BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num); |
||||||
|
|
||||||
|
/* Primes from RFC 2409 */ |
||||||
|
BIGNUM *get_rfc2409_prime_768(BIGNUM *bn); |
||||||
|
BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn); |
||||||
|
|
||||||
|
/* Primes from RFC 3526 */ |
||||||
|
BIGNUM *get_rfc3526_prime_1536(BIGNUM *bn); |
||||||
|
BIGNUM *get_rfc3526_prime_2048(BIGNUM *bn); |
||||||
|
BIGNUM *get_rfc3526_prime_3072(BIGNUM *bn); |
||||||
|
BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn); |
||||||
|
BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn); |
||||||
|
BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn); |
||||||
|
|
||||||
|
int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom); |
||||||
|
|
||||||
|
/* BEGIN ERROR CODES */ |
||||||
|
/* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||||
|
* made after this point may be overwritten when the script is next run. |
||||||
|
*/ |
||||||
|
void ERR_load_BN_strings(void); |
||||||
|
|
||||||
|
/* Error codes for the BN functions. */ |
||||||
|
|
||||||
|
/* Function codes. */ |
||||||
|
#define BN_F_BNRAND 127 |
||||||
|
#define BN_F_BN_BLINDING_CONVERT_EX 100 |
||||||
|
#define BN_F_BN_BLINDING_CREATE_PARAM 128 |
||||||
|
#define BN_F_BN_BLINDING_INVERT_EX 101 |
||||||
|
#define BN_F_BN_BLINDING_NEW 102 |
||||||
|
#define BN_F_BN_BLINDING_UPDATE 103 |
||||||
|
#define BN_F_BN_BN2DEC 104 |
||||||
|
#define BN_F_BN_BN2HEX 105 |
||||||
|
#define BN_F_BN_CTX_GET 116 |
||||||
|
#define BN_F_BN_CTX_NEW 106 |
||||||
|
#define BN_F_BN_CTX_START 129 |
||||||
|
#define BN_F_BN_DIV 107 |
||||||
|
#define BN_F_BN_DIV_NO_BRANCH 138 |
||||||
|
#define BN_F_BN_DIV_RECP 130 |
||||||
|
#define BN_F_BN_EXP 123 |
||||||
|
#define BN_F_BN_EXPAND2 108 |
||||||
|
#define BN_F_BN_EXPAND_INTERNAL 120 |
||||||
|
#define BN_F_BN_GF2M_MOD 131 |
||||||
|
#define BN_F_BN_GF2M_MOD_EXP 132 |
||||||
|
#define BN_F_BN_GF2M_MOD_MUL 133 |
||||||
|
#define BN_F_BN_GF2M_MOD_SOLVE_QUAD 134 |
||||||
|
#define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 135 |
||||||
|
#define BN_F_BN_GF2M_MOD_SQR 136 |
||||||
|
#define BN_F_BN_GF2M_MOD_SQRT 137 |
||||||
|
#define BN_F_BN_MOD_EXP2_MONT 118 |
||||||
|
#define BN_F_BN_MOD_EXP_MONT 109 |
||||||
|
#define BN_F_BN_MOD_EXP_MONT_CONSTTIME 124 |
||||||
|
#define BN_F_BN_MOD_EXP_MONT_WORD 117 |
||||||
|
#define BN_F_BN_MOD_EXP_RECP 125 |
||||||
|
#define BN_F_BN_MOD_EXP_SIMPLE 126 |
||||||
|
#define BN_F_BN_MOD_INVERSE 110 |
||||||
|
#define BN_F_BN_MOD_INVERSE_NO_BRANCH 139 |
||||||
|
#define BN_F_BN_MOD_LSHIFT_QUICK 119 |
||||||
|
#define BN_F_BN_MOD_MUL_RECIPROCAL 111 |
||||||
|
#define BN_F_BN_MOD_SQRT 121 |
||||||
|
#define BN_F_BN_MPI2BN 112 |
||||||
|
#define BN_F_BN_NEW 113 |
||||||
|
#define BN_F_BN_RAND 114 |
||||||
|
#define BN_F_BN_RAND_RANGE 122 |
||||||
|
#define BN_F_BN_USUB 115 |
||||||
|
|
||||||
|
/* Reason codes. */ |
||||||
|
#define BN_R_ARG2_LT_ARG3 100 |
||||||
|
#define BN_R_BAD_RECIPROCAL 101 |
||||||
|
#define BN_R_BIGNUM_TOO_LONG 114 |
||||||
|
#define BN_R_CALLED_WITH_EVEN_MODULUS 102 |
||||||
|
#define BN_R_DIV_BY_ZERO 103 |
||||||
|
#define BN_R_ENCODING_ERROR 104 |
||||||
|
#define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105 |
||||||
|
#define BN_R_INPUT_NOT_REDUCED 110 |
||||||
|
#define BN_R_INVALID_LENGTH 106 |
||||||
|
#define BN_R_INVALID_RANGE 115 |
||||||
|
#define BN_R_NOT_A_SQUARE 111 |
||||||
|
#define BN_R_NOT_INITIALIZED 107 |
||||||
|
#define BN_R_NO_INVERSE 108 |
||||||
|
#define BN_R_NO_SOLUTION 116 |
||||||
|
#define BN_R_P_IS_NOT_PRIME 112 |
||||||
|
#define BN_R_TOO_MANY_ITERATIONS 113 |
||||||
|
#define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109 |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
#endif |
@ -0,0 +1,611 @@ |
|||||||
|
/* crypto/crypto.h */ |
||||||
|
/* ====================================================================
|
||||||
|
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions |
||||||
|
* are met: |
||||||
|
* |
||||||
|
* 1. Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer in |
||||||
|
* the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* |
||||||
|
* 3. All advertising materials mentioning features or use of this |
||||||
|
* software must display the following acknowledgment: |
||||||
|
* "This product includes software developed by the OpenSSL Project |
||||||
|
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||||
|
* |
||||||
|
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to |
||||||
|
* endorse or promote products derived from this software without |
||||||
|
* prior written permission. For written permission, please contact |
||||||
|
* openssl-core@openssl.org. |
||||||
|
* |
||||||
|
* 5. Products derived from this software may not be called "OpenSSL" |
||||||
|
* nor may "OpenSSL" appear in their names without prior written |
||||||
|
* permission of the OpenSSL Project. |
||||||
|
* |
||||||
|
* 6. Redistributions of any form whatsoever must retain the following |
||||||
|
* acknowledgment: |
||||||
|
* "This product includes software developed by the OpenSSL Project |
||||||
|
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY |
||||||
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR |
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* ==================================================================== |
||||||
|
* |
||||||
|
* This product includes cryptographic software written by Eric Young |
||||||
|
* (eay@cryptsoft.com). This product includes software written by Tim |
||||||
|
* Hudson (tjh@cryptsoft.com). |
||||||
|
* |
||||||
|
*/ |
||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* This package is an SSL implementation written |
||||||
|
* by Eric Young (eay@cryptsoft.com). |
||||||
|
* The implementation was written so as to conform with Netscapes SSL. |
||||||
|
* |
||||||
|
* This library is free for commercial and non-commercial use as long as |
||||||
|
* the following conditions are aheared to. The following conditions |
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA, |
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation |
||||||
|
* included with this distribution is covered by the same copyright terms |
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com). |
||||||
|
* |
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in |
||||||
|
* the code are not to be removed. |
||||||
|
* If this package is used in a product, Eric Young should be given attribution |
||||||
|
* as the author of the parts of the library used. |
||||||
|
* This can be in the form of a textual message at program startup or |
||||||
|
* in documentation (online or textual) provided with the package. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions |
||||||
|
* are met: |
||||||
|
* 1. Redistributions of source code must retain the copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer in the |
||||||
|
* documentation and/or other materials provided with the distribution. |
||||||
|
* 3. All advertising materials mentioning features or use of this software |
||||||
|
* must display the following acknowledgement: |
||||||
|
* "This product includes cryptographic software written by |
||||||
|
* Eric Young (eay@cryptsoft.com)" |
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library |
||||||
|
* being used are not cryptographic related :-). |
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from |
||||||
|
* the apps directory (application code) you must include an acknowledgement: |
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||||
|
* SUCH DAMAGE. |
||||||
|
* |
||||||
|
* The licence and distribution terms for any publically available version or |
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be |
||||||
|
* copied and put under another distribution licence |
||||||
|
* [including the GNU Public Licence.] |
||||||
|
*/ |
||||||
|
/* ====================================================================
|
||||||
|
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
||||||
|
* ECDH support in OpenSSL originally developed by |
||||||
|
* SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef HEADER_CRYPTO_H |
||||||
|
#define HEADER_CRYPTO_H |
||||||
|
|
||||||
|
#include <stdlib.h> |
||||||
|
|
||||||
|
#include <openssl/e_os2.h> |
||||||
|
|
||||||
|
#ifndef OPENSSL_NO_FP_API |
||||||
|
#include <stdio.h> |
||||||
|
#endif |
||||||
|
|
||||||
|
#include <openssl/stack.h> |
||||||
|
#include <openssl/safestack.h> |
||||||
|
#include <openssl/opensslv.h> |
||||||
|
#include <openssl/ossl_typ.h> |
||||||
|
|
||||||
|
#ifdef CHARSET_EBCDIC |
||||||
|
#include <openssl/ebcdic.h> |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Resolve problems on some operating systems with symbol names that clash
|
||||||
|
one way or another */ |
||||||
|
#include <openssl/symhacks.h> |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Backward compatibility to SSLeay */ |
||||||
|
/* This is more to be used to check the correct DLL is being used
|
||||||
|
* in the MS world. */ |
||||||
|
#define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER |
||||||
|
#define SSLEAY_VERSION 0 |
||||||
|
/* #define SSLEAY_OPTIONS 1 no longer supported */ |
||||||
|
#define SSLEAY_CFLAGS 2 |
||||||
|
#define SSLEAY_BUILT_ON 3 |
||||||
|
#define SSLEAY_PLATFORM 4 |
||||||
|
#define SSLEAY_DIR 5 |
||||||
|
|
||||||
|
/* Already declared in ossl_typ.h */ |
||||||
|
#if 0 |
||||||
|
typedef struct crypto_ex_data_st CRYPTO_EX_DATA; |
||||||
|
/* Called when a new object is created */ |
||||||
|
typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, |
||||||
|
int idx, long argl, void *argp); |
||||||
|
/* Called when an object is free()ed */ |
||||||
|
typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, |
||||||
|
int idx, long argl, void *argp); |
||||||
|
/* Called when we need to dup an object */ |
||||||
|
typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, |
||||||
|
int idx, long argl, void *argp); |
||||||
|
#endif |
||||||
|
|
||||||
|
/* A generic structure to pass assorted data in a expandable way */ |
||||||
|
typedef struct openssl_item_st |
||||||
|
{ |
||||||
|
int code; |
||||||
|
void *value; /* Not used for flag attributes */ |
||||||
|
size_t value_size; /* Max size of value for output, length for input */ |
||||||
|
size_t *value_length; /* Returned length of value for output */ |
||||||
|
} OPENSSL_ITEM; |
||||||
|
|
||||||
|
|
||||||
|
/* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock
|
||||||
|
* names in cryptlib.c |
||||||
|
*/ |
||||||
|
|
||||||
|
#define CRYPTO_LOCK_ERR 1 |
||||||
|
#define CRYPTO_LOCK_EX_DATA 2 |
||||||
|
#define CRYPTO_LOCK_X509 3 |
||||||
|
#define CRYPTO_LOCK_X509_INFO 4 |
||||||
|
#define CRYPTO_LOCK_X509_PKEY 5 |
||||||
|
#define CRYPTO_LOCK_X509_CRL 6 |
||||||
|
#define CRYPTO_LOCK_X509_REQ 7 |
||||||
|
#define CRYPTO_LOCK_DSA 8 |
||||||
|
#define CRYPTO_LOCK_RSA 9 |
||||||
|
#define CRYPTO_LOCK_EVP_PKEY 10 |
||||||
|
#define CRYPTO_LOCK_X509_STORE 11 |
||||||
|
#define CRYPTO_LOCK_SSL_CTX 12 |
||||||
|
#define CRYPTO_LOCK_SSL_CERT 13 |
||||||
|
#define CRYPTO_LOCK_SSL_SESSION 14 |
||||||
|
#define CRYPTO_LOCK_SSL_SESS_CERT 15 |
||||||
|
#define CRYPTO_LOCK_SSL 16 |
||||||
|
#define CRYPTO_LOCK_SSL_METHOD 17 |
||||||
|
#define CRYPTO_LOCK_RAND 18 |
||||||
|
#define CRYPTO_LOCK_RAND2 19 |
||||||
|
#define CRYPTO_LOCK_MALLOC 20 |
||||||
|
#define CRYPTO_LOCK_BIO 21 |
||||||
|
#define CRYPTO_LOCK_GETHOSTBYNAME 22 |
||||||
|
#define CRYPTO_LOCK_GETSERVBYNAME 23 |
||||||
|
#define CRYPTO_LOCK_READDIR 24 |
||||||
|
#define CRYPTO_LOCK_RSA_BLINDING 25 |
||||||
|
#define CRYPTO_LOCK_DH 26 |
||||||
|
#define CRYPTO_LOCK_MALLOC2 27 |
||||||
|
#define CRYPTO_LOCK_DSO 28 |
||||||
|
#define CRYPTO_LOCK_DYNLOCK 29 |
||||||
|
#define CRYPTO_LOCK_ENGINE 30 |
||||||
|
#define CRYPTO_LOCK_UI 31 |
||||||
|
#define CRYPTO_LOCK_ECDSA 32 |
||||||
|
#define CRYPTO_LOCK_EC 33 |
||||||
|
#define CRYPTO_LOCK_ECDH 34 |
||||||
|
#define CRYPTO_LOCK_BN 35 |
||||||
|
#define CRYPTO_LOCK_EC_PRE_COMP 36 |
||||||
|
#define CRYPTO_LOCK_STORE 37 |
||||||
|
#define CRYPTO_LOCK_COMP 38 |
||||||
|
#define CRYPTO_LOCK_FIPS 39 |
||||||
|
#define CRYPTO_LOCK_FIPS2 40 |
||||||
|
#define CRYPTO_NUM_LOCKS 41 |
||||||
|
|
||||||
|
#define CRYPTO_LOCK 1 |
||||||
|
#define CRYPTO_UNLOCK 2 |
||||||
|
#define CRYPTO_READ 4 |
||||||
|
#define CRYPTO_WRITE 8 |
||||||
|
|
||||||
|
#ifndef OPENSSL_NO_LOCKING |
||||||
|
#ifndef CRYPTO_w_lock |
||||||
|
#define CRYPTO_w_lock(type) \ |
||||||
|
CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) |
||||||
|
#define CRYPTO_w_unlock(type) \ |
||||||
|
CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) |
||||||
|
#define CRYPTO_r_lock(type) \ |
||||||
|
CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__) |
||||||
|
#define CRYPTO_r_unlock(type) \ |
||||||
|
CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__) |
||||||
|
#define CRYPTO_add(addr,amount,type) \ |
||||||
|
CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__) |
||||||
|
#endif |
||||||
|
#else |
||||||
|
#define CRYPTO_w_lock(a) |
||||||
|
#define CRYPTO_w_unlock(a) |
||||||
|
#define CRYPTO_r_lock(a) |
||||||
|
#define CRYPTO_r_unlock(a) |
||||||
|
#define CRYPTO_add(a,b,c) ((*(a))+=(b)) |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Some applications as well as some parts of OpenSSL need to allocate
|
||||||
|
and deallocate locks in a dynamic fashion. The following typedef |
||||||
|
makes this possible in a type-safe manner. */ |
||||||
|
/* struct CRYPTO_dynlock_value has to be defined by the application. */ |
||||||
|
typedef struct |
||||||
|
{ |
||||||
|
int references; |
||||||
|
struct CRYPTO_dynlock_value *data; |
||||||
|
} CRYPTO_dynlock; |
||||||
|
|
||||||
|
|
||||||
|
/* The following can be used to detect memory leaks in the SSLeay library.
|
||||||
|
* It used, it turns on malloc checking */ |
||||||
|
|
||||||
|
#define CRYPTO_MEM_CHECK_OFF 0x0 /* an enume */ |
||||||
|
#define CRYPTO_MEM_CHECK_ON 0x1 /* a bit */ |
||||||
|
#define CRYPTO_MEM_CHECK_ENABLE 0x2 /* a bit */ |
||||||
|
#define CRYPTO_MEM_CHECK_DISABLE 0x3 /* an enume */ |
||||||
|
|
||||||
|
/* The following are bit values to turn on or off options connected to the
|
||||||
|
* malloc checking functionality */ |
||||||
|
|
||||||
|
/* Adds time to the memory checking information */ |
||||||
|
#define V_CRYPTO_MDEBUG_TIME 0x1 /* a bit */ |
||||||
|
/* Adds thread number to the memory checking information */ |
||||||
|
#define V_CRYPTO_MDEBUG_THREAD 0x2 /* a bit */ |
||||||
|
|
||||||
|
#define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD) |
||||||
|
|
||||||
|
|
||||||
|
/* predec of the BIO type */ |
||||||
|
typedef struct bio_st BIO_dummy; |
||||||
|
|
||||||
|
struct crypto_ex_data_st |
||||||
|
{ |
||||||
|
STACK_OF(void) *sk; |
||||||
|
int dummy; /* gcc is screwing up this data structure :-( */ |
||||||
|
}; |
||||||
|
DECLARE_STACK_OF(void) |
||||||
|
|
||||||
|
/* This stuff is basically class callback functions
|
||||||
|
* The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */ |
||||||
|
|
||||||
|
typedef struct crypto_ex_data_func_st |
||||||
|
{ |
||||||
|
long argl; /* Arbitary long */ |
||||||
|
void *argp; /* Arbitary void * */ |
||||||
|
CRYPTO_EX_new *new_func; |
||||||
|
CRYPTO_EX_free *free_func; |
||||||
|
CRYPTO_EX_dup *dup_func; |
||||||
|
} CRYPTO_EX_DATA_FUNCS; |
||||||
|
|
||||||
|
DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS) |
||||||
|
|
||||||
|
/* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA
|
||||||
|
* entry. |
||||||
|
*/ |
||||||
|
|
||||||
|
#define CRYPTO_EX_INDEX_BIO 0 |
||||||
|
#define CRYPTO_EX_INDEX_SSL 1 |
||||||
|
#define CRYPTO_EX_INDEX_SSL_CTX 2 |
||||||
|
#define CRYPTO_EX_INDEX_SSL_SESSION 3 |
||||||
|
#define CRYPTO_EX_INDEX_X509_STORE 4 |
||||||
|
#define CRYPTO_EX_INDEX_X509_STORE_CTX 5 |
||||||
|
#define CRYPTO_EX_INDEX_RSA 6 |
||||||
|
#define CRYPTO_EX_INDEX_DSA 7 |
||||||
|
#define CRYPTO_EX_INDEX_DH 8 |
||||||
|
#define CRYPTO_EX_INDEX_ENGINE 9 |
||||||
|
#define CRYPTO_EX_INDEX_X509 10 |
||||||
|
#define CRYPTO_EX_INDEX_UI 11 |
||||||
|
#define CRYPTO_EX_INDEX_ECDSA 12 |
||||||
|
#define CRYPTO_EX_INDEX_ECDH 13 |
||||||
|
#define CRYPTO_EX_INDEX_COMP 14 |
||||||
|
#define CRYPTO_EX_INDEX_STORE 15 |
||||||
|
|
||||||
|
/* Dynamically assigned indexes start from this value (don't use directly, use
|
||||||
|
* via CRYPTO_ex_data_new_class). */ |
||||||
|
#define CRYPTO_EX_INDEX_USER 100 |
||||||
|
|
||||||
|
|
||||||
|
/* This is the default callbacks, but we can have others as well:
|
||||||
|
* this is needed in Win32 where the application malloc and the |
||||||
|
* library malloc may not be the same. |
||||||
|
*/ |
||||||
|
#define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\ |
||||||
|
malloc, realloc, free) |
||||||
|
|
||||||
|
#if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD |
||||||
|
# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */ |
||||||
|
# define CRYPTO_MDEBUG |
||||||
|
# endif |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Set standard debugging functions (not done by default
|
||||||
|
* unless CRYPTO_MDEBUG is defined) */ |
||||||
|
#define CRYPTO_malloc_debug_init() do {\ |
||||||
|
CRYPTO_set_mem_debug_functions(\ |
||||||
|
CRYPTO_dbg_malloc,\ |
||||||
|
CRYPTO_dbg_realloc,\ |
||||||
|
CRYPTO_dbg_free,\ |
||||||
|
CRYPTO_dbg_set_options,\ |
||||||
|
CRYPTO_dbg_get_options);\ |
||||||
|
} while(0) |
||||||
|
|
||||||
|
int CRYPTO_mem_ctrl(int mode); |
||||||
|
int CRYPTO_is_mem_check_on(void); |
||||||
|
|
||||||
|
/* for applications */ |
||||||
|
#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON) |
||||||
|
#define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF) |
||||||
|
|
||||||
|
/* for library-internal use */ |
||||||
|
#define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE) |
||||||
|
#define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE) |
||||||
|
#define is_MemCheck_on() CRYPTO_is_mem_check_on() |
||||||
|
|
||||||
|
#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__) |
||||||
|
#define OPENSSL_strdup(str) CRYPTO_strdup((str),__FILE__,__LINE__) |
||||||
|
#define OPENSSL_realloc(addr,num) \ |
||||||
|
CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__) |
||||||
|
#define OPENSSL_realloc_clean(addr,old_num,num) \ |
||||||
|
CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__) |
||||||
|
#define OPENSSL_remalloc(addr,num) \ |
||||||
|
CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__) |
||||||
|
#define OPENSSL_freeFunc CRYPTO_free |
||||||
|
#define OPENSSL_free(addr) CRYPTO_free(addr) |
||||||
|
|
||||||
|
#define OPENSSL_malloc_locked(num) \ |
||||||
|
CRYPTO_malloc_locked((int)num,__FILE__,__LINE__) |
||||||
|
#define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr) |
||||||
|
|
||||||
|
|
||||||
|
const char *SSLeay_version(int type); |
||||||
|
unsigned long SSLeay(void); |
||||||
|
|
||||||
|
int OPENSSL_issetugid(void); |
||||||
|
|
||||||
|
/* An opaque type representing an implementation of "ex_data" support */ |
||||||
|
typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL; |
||||||
|
/* Return an opaque pointer to the current "ex_data" implementation */ |
||||||
|
const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void); |
||||||
|
/* Sets the "ex_data" implementation to be used (if it's not too late) */ |
||||||
|
int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i); |
||||||
|
/* Get a new "ex_data" class, and return the corresponding "class_index" */ |
||||||
|
int CRYPTO_ex_data_new_class(void); |
||||||
|
/* Within a given class, get/register a new index */ |
||||||
|
int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, |
||||||
|
CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, |
||||||
|
CRYPTO_EX_free *free_func); |
||||||
|
/* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given
|
||||||
|
* class (invokes whatever per-class callbacks are applicable) */ |
||||||
|
int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); |
||||||
|
int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, |
||||||
|
CRYPTO_EX_DATA *from); |
||||||
|
void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); |
||||||
|
/* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index
|
||||||
|
* (relative to the class type involved) */ |
||||||
|
int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val); |
||||||
|
void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx); |
||||||
|
/* This function cleans up all "ex_data" state. It mustn't be called under
|
||||||
|
* potential race-conditions. */ |
||||||
|
void CRYPTO_cleanup_all_ex_data(void); |
||||||
|
|
||||||
|
int CRYPTO_get_new_lockid(char *name); |
||||||
|
|
||||||
|
int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */ |
||||||
|
void CRYPTO_lock(int mode, int type,const char *file,int line); |
||||||
|
void CRYPTO_set_locking_callback(void (*func)(int mode,int type, |
||||||
|
const char *file,int line)); |
||||||
|
void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file, |
||||||
|
int line); |
||||||
|
void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type, |
||||||
|
const char *file, int line)); |
||||||
|
int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type, |
||||||
|
const char *file,int line); |
||||||
|
|
||||||
|
/* Don't use this structure directly. */ |
||||||
|
typedef struct crypto_threadid_st |
||||||
|
{ |
||||||
|
void *ptr; |
||||||
|
unsigned long val; |
||||||
|
} CRYPTO_THREADID; |
||||||
|
/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */ |
||||||
|
void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val); |
||||||
|
void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr); |
||||||
|
int CRYPTO_THREADID_set_callback(void (*threadid_func)(CRYPTO_THREADID *)); |
||||||
|
void (*CRYPTO_THREADID_get_callback(void))(CRYPTO_THREADID *); |
||||||
|
void CRYPTO_THREADID_current(CRYPTO_THREADID *id); |
||||||
|
int CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b); |
||||||
|
void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src); |
||||||
|
unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id); |
||||||
|
#ifndef OPENSSL_NO_DEPRECATED |
||||||
|
void CRYPTO_set_id_callback(unsigned long (*func)(void)); |
||||||
|
unsigned long (*CRYPTO_get_id_callback(void))(void); |
||||||
|
unsigned long CRYPTO_thread_id(void); |
||||||
|
#endif |
||||||
|
|
||||||
|
const char *CRYPTO_get_lock_name(int type); |
||||||
|
int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file, |
||||||
|
int line); |
||||||
|
|
||||||
|
int CRYPTO_get_new_dynlockid(void); |
||||||
|
void CRYPTO_destroy_dynlockid(int i); |
||||||
|
struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i); |
||||||
|
void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line)); |
||||||
|
void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)); |
||||||
|
void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line)); |
||||||
|
struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line); |
||||||
|
void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line); |
||||||
|
void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line); |
||||||
|
|
||||||
|
/* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions --
|
||||||
|
* call the latter last if you need different functions */ |
||||||
|
int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *)); |
||||||
|
int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *)); |
||||||
|
int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int), |
||||||
|
void *(*r)(void *,size_t,const char *,int), |
||||||
|
void (*f)(void *)); |
||||||
|
int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int), |
||||||
|
void (*free_func)(void *)); |
||||||
|
int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int), |
||||||
|
void (*r)(void *,void *,int,const char *,int,int), |
||||||
|
void (*f)(void *,int), |
||||||
|
void (*so)(long), |
||||||
|
long (*go)(void)); |
||||||
|
void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *)); |
||||||
|
void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *)); |
||||||
|
void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int), |
||||||
|
void *(**r)(void *, size_t,const char *,int), |
||||||
|
void (**f)(void *)); |
||||||
|
void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int), |
||||||
|
void (**f)(void *)); |
||||||
|
void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int), |
||||||
|
void (**r)(void *,void *,int,const char *,int,int), |
||||||
|
void (**f)(void *,int), |
||||||
|
void (**so)(long), |
||||||
|
long (**go)(void)); |
||||||
|
|
||||||
|
void *CRYPTO_malloc_locked(int num, const char *file, int line); |
||||||
|
void CRYPTO_free_locked(void *ptr); |
||||||
|
void *CRYPTO_malloc(int num, const char *file, int line); |
||||||
|
char *CRYPTO_strdup(const char *str, const char *file, int line); |
||||||
|
void CRYPTO_free(void *ptr); |
||||||
|
void *CRYPTO_realloc(void *addr,int num, const char *file, int line); |
||||||
|
void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file, |
||||||
|
int line); |
||||||
|
void *CRYPTO_remalloc(void *addr,int num, const char *file, int line); |
||||||
|
|
||||||
|
void OPENSSL_cleanse(void *ptr, size_t len); |
||||||
|
|
||||||
|
void CRYPTO_set_mem_debug_options(long bits); |
||||||
|
long CRYPTO_get_mem_debug_options(void); |
||||||
|
|
||||||
|
#define CRYPTO_push_info(info) \ |
||||||
|
CRYPTO_push_info_(info, __FILE__, __LINE__); |
||||||
|
int CRYPTO_push_info_(const char *info, const char *file, int line); |
||||||
|
int CRYPTO_pop_info(void); |
||||||
|
int CRYPTO_remove_all_info(void); |
||||||
|
|
||||||
|
|
||||||
|
/* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro;
|
||||||
|
* used as default in CRYPTO_MDEBUG compilations): */ |
||||||
|
/* The last argument has the following significance:
|
||||||
|
* |
||||||
|
* 0: called before the actual memory allocation has taken place |
||||||
|
* 1: called after the actual memory allocation has taken place |
||||||
|
*/ |
||||||
|
void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p); |
||||||
|
void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p); |
||||||
|
void CRYPTO_dbg_free(void *addr,int before_p); |
||||||
|
/* Tell the debugging code about options. By default, the following values
|
||||||
|
* apply: |
||||||
|
* |
||||||
|
* 0: Clear all options. |
||||||
|
* V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option. |
||||||
|
* V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option. |
||||||
|
* V_CRYPTO_MDEBUG_ALL (3): 1 + 2 |
||||||
|
*/ |
||||||
|
void CRYPTO_dbg_set_options(long bits); |
||||||
|
long CRYPTO_dbg_get_options(void); |
||||||
|
|
||||||
|
|
||||||
|
#ifndef OPENSSL_NO_FP_API |
||||||
|
void CRYPTO_mem_leaks_fp(FILE *); |
||||||
|
#endif |
||||||
|
void CRYPTO_mem_leaks(struct bio_st *bio); |
||||||
|
/* unsigned long order, char *file, int line, int num_bytes, char *addr */ |
||||||
|
typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *); |
||||||
|
void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb); |
||||||
|
|
||||||
|
/* die if we have to */ |
||||||
|
void OpenSSLDie(const char *file,int line,const char *assertion); |
||||||
|
#define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1)) |
||||||
|
|
||||||
|
unsigned long *OPENSSL_ia32cap_loc(void); |
||||||
|
#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc())) |
||||||
|
int OPENSSL_isservice(void); |
||||||
|
|
||||||
|
int FIPS_mode(void); |
||||||
|
int FIPS_mode_set(int r); |
||||||
|
|
||||||
|
void OPENSSL_init(void); |
||||||
|
|
||||||
|
#define fips_md_init(alg) fips_md_init_ctx(alg, alg) |
||||||
|
|
||||||
|
#ifdef OPENSSL_FIPS |
||||||
|
#define fips_md_init_ctx(alg, cx) \ |
||||||
|
int alg##_Init(cx##_CTX *c) \ |
||||||
|
{ \ |
||||||
|
if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \ |
||||||
|
"Low level API call to digest " #alg " forbidden in FIPS mode!"); \ |
||||||
|
return private_##alg##_Init(c); \ |
||||||
|
} \ |
||||||
|
int private_##alg##_Init(cx##_CTX *c) |
||||||
|
|
||||||
|
#define fips_cipher_abort(alg) \ |
||||||
|
if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \ |
||||||
|
"Low level API call to cipher " #alg " forbidden in FIPS mode!") |
||||||
|
|
||||||
|
#else |
||||||
|
#define fips_md_init_ctx(alg, cx) \ |
||||||
|
int alg##_Init(cx##_CTX *c) |
||||||
|
#define fips_cipher_abort(alg) while(0) |
||||||
|
#endif |
||||||
|
|
||||||
|
/* CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal. It
|
||||||
|
* takes an amount of time dependent on |len|, but independent of the contents |
||||||
|
* of |a| and |b|. Unlike memcmp, it cannot be used to put elements into a |
||||||
|
* defined order as the return value when a != b is undefined, other than to be |
||||||
|
* non-zero. */ |
||||||
|
int CRYPTO_memcmp(const void *a, const void *b, size_t len); |
||||||
|
|
||||||
|
/* BEGIN ERROR CODES */ |
||||||
|
/* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||||
|
* made after this point may be overwritten when the script is next run. |
||||||
|
*/ |
||||||
|
void ERR_load_CRYPTO_strings(void); |
||||||
|
|
||||||
|
/* Error codes for the CRYPTO functions. */ |
||||||
|
|
||||||
|
/* Function codes. */ |
||||||
|
#define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100 |
||||||
|
#define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103 |
||||||
|
#define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101 |
||||||
|
#define CRYPTO_F_CRYPTO_SET_EX_DATA 102 |
||||||
|
#define CRYPTO_F_DEF_ADD_INDEX 104 |
||||||
|
#define CRYPTO_F_DEF_GET_CLASS 105 |
||||||
|
#define CRYPTO_F_FIPS_MODE_SET 109 |
||||||
|
#define CRYPTO_F_INT_DUP_EX_DATA 106 |
||||||
|
#define CRYPTO_F_INT_FREE_EX_DATA 107 |
||||||
|
#define CRYPTO_F_INT_NEW_EX_DATA 108 |
||||||
|
|
||||||
|
/* Reason codes. */ |
||||||
|
#define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED 101 |
||||||
|
#define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100 |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
#endif |
@ -0,0 +1,89 @@ |
|||||||
|
#ifndef HEADER_OPENSSLV_H |
||||||
|
#define HEADER_OPENSSLV_H |
||||||
|
|
||||||
|
/* Numeric release version identifier:
|
||||||
|
* MNNFFPPS: major minor fix patch status |
||||||
|
* The status nibble has one of the values 0 for development, 1 to e for betas |
||||||
|
* 1 to 14, and f for release. The patch level is exactly that. |
||||||
|
* For example: |
||||||
|
* 0.9.3-dev 0x00903000 |
||||||
|
* 0.9.3-beta1 0x00903001 |
||||||
|
* 0.9.3-beta2-dev 0x00903002 |
||||||
|
* 0.9.3-beta2 0x00903002 (same as ...beta2-dev) |
||||||
|
* 0.9.3 0x0090300f |
||||||
|
* 0.9.3a 0x0090301f |
||||||
|
* 0.9.4 0x0090400f |
||||||
|
* 1.2.3z 0x102031af |
||||||
|
* |
||||||
|
* For continuity reasons (because 0.9.5 is already out, and is coded |
||||||
|
* 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level |
||||||
|
* part is slightly different, by setting the highest bit. This means |
||||||
|
* that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start |
||||||
|
* with 0x0090600S... |
||||||
|
* |
||||||
|
* (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.) |
||||||
|
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for |
||||||
|
* major minor fix final patch/beta) |
||||||
|
*/ |
||||||
|
#define OPENSSL_VERSION_NUMBER 0x1000109fL |
||||||
|
#ifdef OPENSSL_FIPS |
||||||
|
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1i-fips 6 Aug 2014" |
||||||
|
#else |
||||||
|
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1i 6 Aug 2014" |
||||||
|
#endif |
||||||
|
#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT |
||||||
|
|
||||||
|
|
||||||
|
/* The macros below are to be used for shared library (.so, .dll, ...)
|
||||||
|
* versioning. That kind of versioning works a bit differently between |
||||||
|
* operating systems. The most usual scheme is to set a major and a minor |
||||||
|
* number, and have the runtime loader check that the major number is equal |
||||||
|
* to what it was at application link time, while the minor number has to |
||||||
|
* be greater or equal to what it was at application link time. With this |
||||||
|
* scheme, the version number is usually part of the file name, like this: |
||||||
|
* |
||||||
|
* libcrypto.so.0.9 |
||||||
|
* |
||||||
|
* Some unixen also make a softlink with the major verson number only: |
||||||
|
* |
||||||
|
* libcrypto.so.0 |
||||||
|
* |
||||||
|
* On Tru64 and IRIX 6.x it works a little bit differently. There, the |
||||||
|
* shared library version is stored in the file, and is actually a series |
||||||
|
* of versions, separated by colons. The rightmost version present in the |
||||||
|
* library when linking an application is stored in the application to be |
||||||
|
* matched at run time. When the application is run, a check is done to |
||||||
|
* see if the library version stored in the application matches any of the |
||||||
|
* versions in the version string of the library itself. |
||||||
|
* This version string can be constructed in any way, depending on what |
||||||
|
* kind of matching is desired. However, to implement the same scheme as |
||||||
|
* the one used in the other unixen, all compatible versions, from lowest |
||||||
|
* to highest, should be part of the string. Consecutive builds would |
||||||
|
* give the following versions strings: |
||||||
|
* |
||||||
|
* 3.0 |
||||||
|
* 3.0:3.1 |
||||||
|
* 3.0:3.1:3.2 |
||||||
|
* 4.0 |
||||||
|
* 4.0:4.1 |
||||||
|
* |
||||||
|
* Notice how version 4 is completely incompatible with version, and |
||||||
|
* therefore give the breach you can see. |
||||||
|
* |
||||||
|
* There may be other schemes as well that I haven't yet discovered. |
||||||
|
* |
||||||
|
* So, here's the way it works here: first of all, the library version |
||||||
|
* number doesn't need at all to match the overall OpenSSL version. |
||||||
|
* However, it's nice and more understandable if it actually does. |
||||||
|
* The current library version is stored in the macro SHLIB_VERSION_NUMBER, |
||||||
|
* which is just a piece of text in the format "M.m.e" (Major, minor, edit). |
||||||
|
* For the sake of Tru64, IRIX, and any other OS that behaves in similar ways, |
||||||
|
* we need to keep a history of version numbers, which is done in the |
||||||
|
* macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and |
||||||
|
* should only keep the versions that are binary compatible with the current. |
||||||
|
*/ |
||||||
|
#define SHLIB_VERSION_HISTORY "" |
||||||
|
#define SHLIB_VERSION_NUMBER "1.0.0" |
||||||
|
|
||||||
|
|
||||||
|
#endif /* HEADER_OPENSSLV_H */ |
@ -0,0 +1,202 @@ |
|||||||
|
/* ====================================================================
|
||||||
|
* Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions |
||||||
|
* are met: |
||||||
|
* |
||||||
|
* 1. Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer in |
||||||
|
* the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* |
||||||
|
* 3. All advertising materials mentioning features or use of this |
||||||
|
* software must display the following acknowledgment: |
||||||
|
* "This product includes software developed by the OpenSSL Project |
||||||
|
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||||
|
* |
||||||
|
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to |
||||||
|
* endorse or promote products derived from this software without |
||||||
|
* prior written permission. For written permission, please contact |
||||||
|
* openssl-core@openssl.org. |
||||||
|
* |
||||||
|
* 5. Products derived from this software may not be called "OpenSSL" |
||||||
|
* nor may "OpenSSL" appear in their names without prior written |
||||||
|
* permission of the OpenSSL Project. |
||||||
|
* |
||||||
|
* 6. Redistributions of any form whatsoever must retain the following |
||||||
|
* acknowledgment: |
||||||
|
* "This product includes software developed by the OpenSSL Project |
||||||
|
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY |
||||||
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR |
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* ==================================================================== |
||||||
|
* |
||||||
|
* This product includes cryptographic software written by Eric Young |
||||||
|
* (eay@cryptsoft.com). This product includes software written by Tim |
||||||
|
* Hudson (tjh@cryptsoft.com). |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef HEADER_OPENSSL_TYPES_H |
||||||
|
#define HEADER_OPENSSL_TYPES_H |
||||||
|
|
||||||
|
#include <openssl/e_os2.h> |
||||||
|
|
||||||
|
#ifdef NO_ASN1_TYPEDEFS |
||||||
|
#define ASN1_INTEGER ASN1_STRING |
||||||
|
#define ASN1_ENUMERATED ASN1_STRING |
||||||
|
#define ASN1_BIT_STRING ASN1_STRING |
||||||
|
#define ASN1_OCTET_STRING ASN1_STRING |
||||||
|
#define ASN1_PRINTABLESTRING ASN1_STRING |
||||||
|
#define ASN1_T61STRING ASN1_STRING |
||||||
|
#define ASN1_IA5STRING ASN1_STRING |
||||||
|
#define ASN1_UTCTIME ASN1_STRING |
||||||
|
#define ASN1_GENERALIZEDTIME ASN1_STRING |
||||||
|
#define ASN1_TIME ASN1_STRING |
||||||
|
#define ASN1_GENERALSTRING ASN1_STRING |
||||||
|
#define ASN1_UNIVERSALSTRING ASN1_STRING |
||||||
|
#define ASN1_BMPSTRING ASN1_STRING |
||||||
|
#define ASN1_VISIBLESTRING ASN1_STRING |
||||||
|
#define ASN1_UTF8STRING ASN1_STRING |
||||||
|
#define ASN1_BOOLEAN int |
||||||
|
#define ASN1_NULL int |
||||||
|
#else |
||||||
|
typedef struct asn1_string_st ASN1_INTEGER; |
||||||
|
typedef struct asn1_string_st ASN1_ENUMERATED; |
||||||
|
typedef struct asn1_string_st ASN1_BIT_STRING; |
||||||
|
typedef struct asn1_string_st ASN1_OCTET_STRING; |
||||||
|
typedef struct asn1_string_st ASN1_PRINTABLESTRING; |
||||||
|
typedef struct asn1_string_st ASN1_T61STRING; |
||||||
|
typedef struct asn1_string_st ASN1_IA5STRING; |
||||||
|
typedef struct asn1_string_st ASN1_GENERALSTRING; |
||||||
|
typedef struct asn1_string_st ASN1_UNIVERSALSTRING; |
||||||
|
typedef struct asn1_string_st ASN1_BMPSTRING; |
||||||
|
typedef struct asn1_string_st ASN1_UTCTIME; |
||||||
|
typedef struct asn1_string_st ASN1_TIME; |
||||||
|
typedef struct asn1_string_st ASN1_GENERALIZEDTIME; |
||||||
|
typedef struct asn1_string_st ASN1_VISIBLESTRING; |
||||||
|
typedef struct asn1_string_st ASN1_UTF8STRING; |
||||||
|
typedef struct asn1_string_st ASN1_STRING; |
||||||
|
typedef int ASN1_BOOLEAN; |
||||||
|
typedef int ASN1_NULL; |
||||||
|
#endif |
||||||
|
|
||||||
|
typedef struct ASN1_ITEM_st ASN1_ITEM; |
||||||
|
typedef struct asn1_pctx_st ASN1_PCTX; |
||||||
|
|
||||||
|
#ifdef OPENSSL_SYS_WIN32 |
||||||
|
#undef X509_NAME |
||||||
|
#undef X509_EXTENSIONS |
||||||
|
#undef X509_CERT_PAIR |
||||||
|
#undef PKCS7_ISSUER_AND_SERIAL |
||||||
|
#undef OCSP_REQUEST |
||||||
|
#undef OCSP_RESPONSE |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef BIGNUM |
||||||
|
#undef BIGNUM |
||||||
|
#endif |
||||||
|
typedef struct bignum_st BIGNUM; |
||||||
|
typedef struct bignum_ctx BN_CTX; |
||||||
|
typedef struct bn_blinding_st BN_BLINDING; |
||||||
|
typedef struct bn_mont_ctx_st BN_MONT_CTX; |
||||||
|
typedef struct bn_recp_ctx_st BN_RECP_CTX; |
||||||
|
typedef struct bn_gencb_st BN_GENCB; |
||||||
|
|
||||||
|
typedef struct buf_mem_st BUF_MEM; |
||||||
|
|
||||||
|
typedef struct evp_cipher_st EVP_CIPHER; |
||||||
|
typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; |
||||||
|
typedef struct env_md_st EVP_MD; |
||||||
|
typedef struct env_md_ctx_st EVP_MD_CTX; |
||||||
|
typedef struct evp_pkey_st EVP_PKEY; |
||||||
|
|
||||||
|
typedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD; |
||||||
|
|
||||||
|
typedef struct evp_pkey_method_st EVP_PKEY_METHOD; |
||||||
|
typedef struct evp_pkey_ctx_st EVP_PKEY_CTX; |
||||||
|
|
||||||
|
typedef struct dh_st DH; |
||||||
|
typedef struct dh_method DH_METHOD; |
||||||
|
|
||||||
|
typedef struct dsa_st DSA; |
||||||
|
typedef struct dsa_method DSA_METHOD; |
||||||
|
|
||||||
|
typedef struct rsa_st RSA; |
||||||
|
typedef struct rsa_meth_st RSA_METHOD; |
||||||
|
|
||||||
|
typedef struct rand_meth_st RAND_METHOD; |
||||||
|
|
||||||
|
typedef struct ecdh_method ECDH_METHOD; |
||||||
|
typedef struct ecdsa_method ECDSA_METHOD; |
||||||
|
|
||||||
|
typedef struct x509_st X509; |
||||||
|
typedef struct X509_algor_st X509_ALGOR; |
||||||
|
typedef struct X509_crl_st X509_CRL; |
||||||
|
typedef struct x509_crl_method_st X509_CRL_METHOD; |
||||||
|
typedef struct x509_revoked_st X509_REVOKED; |
||||||
|
typedef struct X509_name_st X509_NAME; |
||||||
|
typedef struct X509_pubkey_st X509_PUBKEY; |
||||||
|
typedef struct x509_store_st X509_STORE; |
||||||
|
typedef struct x509_store_ctx_st X509_STORE_CTX; |
||||||
|
|
||||||
|
typedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO; |
||||||
|
|
||||||
|
typedef struct v3_ext_ctx X509V3_CTX; |
||||||
|
typedef struct conf_st CONF; |
||||||
|
|
||||||
|
typedef struct store_st STORE; |
||||||
|
typedef struct store_method_st STORE_METHOD; |
||||||
|
|
||||||
|
typedef struct ui_st UI; |
||||||
|
typedef struct ui_method_st UI_METHOD; |
||||||
|
|
||||||
|
typedef struct st_ERR_FNS ERR_FNS; |
||||||
|
|
||||||
|
typedef struct engine_st ENGINE; |
||||||
|
typedef struct ssl_st SSL; |
||||||
|
typedef struct ssl_ctx_st SSL_CTX; |
||||||
|
|
||||||
|
typedef struct X509_POLICY_NODE_st X509_POLICY_NODE; |
||||||
|
typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL; |
||||||
|
typedef struct X509_POLICY_TREE_st X509_POLICY_TREE; |
||||||
|
typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE; |
||||||
|
|
||||||
|
typedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID; |
||||||
|
typedef struct DIST_POINT_st DIST_POINT; |
||||||
|
typedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT; |
||||||
|
typedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS; |
||||||
|
|
||||||
|
/* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */ |
||||||
|
#define DECLARE_PKCS12_STACK_OF(type) /* Nothing */ |
||||||
|
#define IMPLEMENT_PKCS12_STACK_OF(type) /* Nothing */ |
||||||
|
|
||||||
|
typedef struct crypto_ex_data_st CRYPTO_EX_DATA; |
||||||
|
/* Callback types for crypto.h */ |
||||||
|
typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, |
||||||
|
int idx, long argl, void *argp); |
||||||
|
typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, |
||||||
|
int idx, long argl, void *argp); |
||||||
|
typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, |
||||||
|
int idx, long argl, void *argp); |
||||||
|
|
||||||
|
typedef struct ocsp_req_ctx_st OCSP_REQ_CTX; |
||||||
|
typedef struct ocsp_response_st OCSP_RESPONSE; |
||||||
|
typedef struct ocsp_responder_id_st OCSP_RESPID; |
||||||
|
|
||||||
|
#endif /* def HEADER_OPENSSL_TYPES_H */ |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,108 @@ |
|||||||
|
/* crypto/stack/stack.h */ |
||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* This package is an SSL implementation written |
||||||
|
* by Eric Young (eay@cryptsoft.com). |
||||||
|
* The implementation was written so as to conform with Netscapes SSL. |
||||||
|
* |
||||||
|
* This library is free for commercial and non-commercial use as long as |
||||||
|
* the following conditions are aheared to. The following conditions |
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA, |
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation |
||||||
|
* included with this distribution is covered by the same copyright terms |
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com). |
||||||
|
* |
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in |
||||||
|
* the code are not to be removed. |
||||||
|
* If this package is used in a product, Eric Young should be given attribution |
||||||
|
* as the author of the parts of the library used. |
||||||
|
* This can be in the form of a textual message at program startup or |
||||||
|
* in documentation (online or textual) provided with the package. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions |
||||||
|
* are met: |
||||||
|
* 1. Redistributions of source code must retain the copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer in the |
||||||
|
* documentation and/or other materials provided with the distribution. |
||||||
|
* 3. All advertising materials mentioning features or use of this software |
||||||
|
* must display the following acknowledgement: |
||||||
|
* "This product includes cryptographic software written by |
||||||
|
* Eric Young (eay@cryptsoft.com)" |
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library |
||||||
|
* being used are not cryptographic related :-). |
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from |
||||||
|
* the apps directory (application code) you must include an acknowledgement: |
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||||
|
* SUCH DAMAGE. |
||||||
|
* |
||||||
|
* The licence and distribution terms for any publically available version or |
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be |
||||||
|
* copied and put under another distribution licence |
||||||
|
* [including the GNU Public Licence.] |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef HEADER_STACK_H |
||||||
|
#define HEADER_STACK_H |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
typedef struct stack_st |
||||||
|
{ |
||||||
|
int num; |
||||||
|
char **data; |
||||||
|
int sorted; |
||||||
|
|
||||||
|
int num_alloc; |
||||||
|
int (*comp)(const void *, const void *); |
||||||
|
} _STACK; /* Use STACK_OF(...) instead */ |
||||||
|
|
||||||
|
#define M_sk_num(sk) ((sk) ? (sk)->num:-1) |
||||||
|
#define M_sk_value(sk,n) ((sk) ? (sk)->data[n] : NULL) |
||||||
|
|
||||||
|
int sk_num(const _STACK *); |
||||||
|
void *sk_value(const _STACK *, int); |
||||||
|
|
||||||
|
void *sk_set(_STACK *, int, void *); |
||||||
|
|
||||||
|
_STACK *sk_new(int (*cmp)(const void *, const void *)); |
||||||
|
_STACK *sk_new_null(void); |
||||||
|
void sk_free(_STACK *); |
||||||
|
void sk_pop_free(_STACK *st, void (*func)(void *)); |
||||||
|
int sk_insert(_STACK *sk, void *data, int where); |
||||||
|
void *sk_delete(_STACK *st, int loc); |
||||||
|
void *sk_delete_ptr(_STACK *st, void *p); |
||||||
|
int sk_find(_STACK *st, void *data); |
||||||
|
int sk_find_ex(_STACK *st, void *data); |
||||||
|
int sk_push(_STACK *st, void *data); |
||||||
|
int sk_unshift(_STACK *st, void *data); |
||||||
|
void *sk_shift(_STACK *st); |
||||||
|
void *sk_pop(_STACK *st); |
||||||
|
void sk_zero(_STACK *st); |
||||||
|
int (*sk_set_cmp_func(_STACK *sk, int (*c)(const void *, const void *))) |
||||||
|
(const void *, const void *); |
||||||
|
_STACK *sk_dup(_STACK *st); |
||||||
|
void sk_sort(_STACK *st); |
||||||
|
int sk_is_sorted(const _STACK *st); |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,481 @@ |
|||||||
|
/* ====================================================================
|
||||||
|
* Copyright (c) 1999 The OpenSSL Project. All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions |
||||||
|
* are met: |
||||||
|
* |
||||||
|
* 1. Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer in |
||||||
|
* the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* |
||||||
|
* 3. All advertising materials mentioning features or use of this |
||||||
|
* software must display the following acknowledgment: |
||||||
|
* "This product includes software developed by the OpenSSL Project |
||||||
|
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||||
|
* |
||||||
|
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to |
||||||
|
* endorse or promote products derived from this software without |
||||||
|
* prior written permission. For written permission, please contact |
||||||
|
* openssl-core@openssl.org. |
||||||
|
* |
||||||
|
* 5. Products derived from this software may not be called "OpenSSL" |
||||||
|
* nor may "OpenSSL" appear in their names without prior written |
||||||
|
* permission of the OpenSSL Project. |
||||||
|
* |
||||||
|
* 6. Redistributions of any form whatsoever must retain the following |
||||||
|
* acknowledgment: |
||||||
|
* "This product includes software developed by the OpenSSL Project |
||||||
|
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY |
||||||
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR |
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* ==================================================================== |
||||||
|
* |
||||||
|
* This product includes cryptographic software written by Eric Young |
||||||
|
* (eay@cryptsoft.com). This product includes software written by Tim |
||||||
|
* Hudson (tjh@cryptsoft.com). |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef HEADER_SYMHACKS_H |
||||||
|
#define HEADER_SYMHACKS_H |
||||||
|
|
||||||
|
#include <openssl/e_os2.h> |
||||||
|
|
||||||
|
/* Hacks to solve the problem with linkers incapable of handling very long
|
||||||
|
symbol names. In the case of VMS, the limit is 31 characters on VMS for |
||||||
|
VAX. */ |
||||||
|
/* Note that this affects util/libeay.num and util/ssleay.num... you may
|
||||||
|
change those manually, but that's not recommended, as those files are |
||||||
|
controlled centrally and updated on Unix, and the central definition |
||||||
|
may disagree with yours, which in turn may come with shareable library |
||||||
|
incompatibilities. */ |
||||||
|
#ifdef OPENSSL_SYS_VMS |
||||||
|
|
||||||
|
/* Hack a long name in crypto/ex_data.c */ |
||||||
|
#undef CRYPTO_get_ex_data_implementation |
||||||
|
#define CRYPTO_get_ex_data_implementation CRYPTO_get_ex_data_impl |
||||||
|
#undef CRYPTO_set_ex_data_implementation |
||||||
|
#define CRYPTO_set_ex_data_implementation CRYPTO_set_ex_data_impl |
||||||
|
|
||||||
|
/* Hack a long name in crypto/asn1/a_mbstr.c */ |
||||||
|
#undef ASN1_STRING_set_default_mask_asc |
||||||
|
#define ASN1_STRING_set_default_mask_asc ASN1_STRING_set_def_mask_asc |
||||||
|
|
||||||
|
#if 0 /* No longer needed, since safestack macro magic does the job */
|
||||||
|
/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) */ |
||||||
|
#undef i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO |
||||||
|
#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO i2d_ASN1_SET_OF_PKCS7_SIGINF |
||||||
|
#undef d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO |
||||||
|
#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO d2i_ASN1_SET_OF_PKCS7_SIGINF |
||||||
|
#endif |
||||||
|
|
||||||
|
#if 0 /* No longer needed, since safestack macro magic does the job */
|
||||||
|
/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) */ |
||||||
|
#undef i2d_ASN1_SET_OF_PKCS7_RECIP_INFO |
||||||
|
#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO i2d_ASN1_SET_OF_PKCS7_RECINF |
||||||
|
#undef d2i_ASN1_SET_OF_PKCS7_RECIP_INFO |
||||||
|
#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO d2i_ASN1_SET_OF_PKCS7_RECINF |
||||||
|
#endif |
||||||
|
|
||||||
|
#if 0 /* No longer needed, since safestack macro magic does the job */
|
||||||
|
/* Hack the names created with DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) */ |
||||||
|
#undef i2d_ASN1_SET_OF_ACCESS_DESCRIPTION |
||||||
|
#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION i2d_ASN1_SET_OF_ACC_DESC |
||||||
|
#undef d2i_ASN1_SET_OF_ACCESS_DESCRIPTION |
||||||
|
#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION d2i_ASN1_SET_OF_ACC_DESC |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Hack the names created with DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE) */ |
||||||
|
#undef PEM_read_NETSCAPE_CERT_SEQUENCE |
||||||
|
#define PEM_read_NETSCAPE_CERT_SEQUENCE PEM_read_NS_CERT_SEQ |
||||||
|
#undef PEM_write_NETSCAPE_CERT_SEQUENCE |
||||||
|
#define PEM_write_NETSCAPE_CERT_SEQUENCE PEM_write_NS_CERT_SEQ |
||||||
|
#undef PEM_read_bio_NETSCAPE_CERT_SEQUENCE |
||||||
|
#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE PEM_read_bio_NS_CERT_SEQ |
||||||
|
#undef PEM_write_bio_NETSCAPE_CERT_SEQUENCE |
||||||
|
#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE PEM_write_bio_NS_CERT_SEQ |
||||||
|
#undef PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE |
||||||
|
#define PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE PEM_write_cb_bio_NS_CERT_SEQ |
||||||
|
|
||||||
|
/* Hack the names created with DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO) */ |
||||||
|
#undef PEM_read_PKCS8_PRIV_KEY_INFO |
||||||
|
#define PEM_read_PKCS8_PRIV_KEY_INFO PEM_read_P8_PRIV_KEY_INFO |
||||||
|
#undef PEM_write_PKCS8_PRIV_KEY_INFO |
||||||
|
#define PEM_write_PKCS8_PRIV_KEY_INFO PEM_write_P8_PRIV_KEY_INFO |
||||||
|
#undef PEM_read_bio_PKCS8_PRIV_KEY_INFO |
||||||
|
#define PEM_read_bio_PKCS8_PRIV_KEY_INFO PEM_read_bio_P8_PRIV_KEY_INFO |
||||||
|
#undef PEM_write_bio_PKCS8_PRIV_KEY_INFO |
||||||
|
#define PEM_write_bio_PKCS8_PRIV_KEY_INFO PEM_write_bio_P8_PRIV_KEY_INFO |
||||||
|
#undef PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO |
||||||
|
#define PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO PEM_wrt_cb_bio_P8_PRIV_KEY_INFO |
||||||
|
|
||||||
|
/* Hack other PEM names */ |
||||||
|
#undef PEM_write_bio_PKCS8PrivateKey_nid |
||||||
|
#define PEM_write_bio_PKCS8PrivateKey_nid PEM_write_bio_PKCS8PrivKey_nid |
||||||
|
|
||||||
|
/* Hack some long X509 names */ |
||||||
|
#undef X509_REVOKED_get_ext_by_critical |
||||||
|
#define X509_REVOKED_get_ext_by_critical X509_REVOKED_get_ext_by_critic |
||||||
|
#undef X509_policy_tree_get0_user_policies |
||||||
|
#define X509_policy_tree_get0_user_policies X509_pcy_tree_get0_usr_policies |
||||||
|
#undef X509_policy_node_get0_qualifiers |
||||||
|
#define X509_policy_node_get0_qualifiers X509_pcy_node_get0_qualifiers |
||||||
|
#undef X509_STORE_CTX_get_explicit_policy |
||||||
|
#define X509_STORE_CTX_get_explicit_policy X509_STORE_CTX_get_expl_policy |
||||||
|
#undef X509_STORE_CTX_get0_current_issuer |
||||||
|
#define X509_STORE_CTX_get0_current_issuer X509_STORE_CTX_get0_cur_issuer |
||||||
|
|
||||||
|
/* Hack some long CRYPTO names */ |
||||||
|
#undef CRYPTO_set_dynlock_destroy_callback |
||||||
|
#define CRYPTO_set_dynlock_destroy_callback CRYPTO_set_dynlock_destroy_cb |
||||||
|
#undef CRYPTO_set_dynlock_create_callback |
||||||
|
#define CRYPTO_set_dynlock_create_callback CRYPTO_set_dynlock_create_cb |
||||||
|
#undef CRYPTO_set_dynlock_lock_callback |
||||||
|
#define CRYPTO_set_dynlock_lock_callback CRYPTO_set_dynlock_lock_cb |
||||||
|
#undef CRYPTO_get_dynlock_lock_callback |
||||||
|
#define CRYPTO_get_dynlock_lock_callback CRYPTO_get_dynlock_lock_cb |
||||||
|
#undef CRYPTO_get_dynlock_destroy_callback |
||||||
|
#define CRYPTO_get_dynlock_destroy_callback CRYPTO_get_dynlock_destroy_cb |
||||||
|
#undef CRYPTO_get_dynlock_create_callback |
||||||
|
#define CRYPTO_get_dynlock_create_callback CRYPTO_get_dynlock_create_cb |
||||||
|
#undef CRYPTO_set_locked_mem_ex_functions |
||||||
|
#define CRYPTO_set_locked_mem_ex_functions CRYPTO_set_locked_mem_ex_funcs |
||||||
|
#undef CRYPTO_get_locked_mem_ex_functions |
||||||
|
#define CRYPTO_get_locked_mem_ex_functions CRYPTO_get_locked_mem_ex_funcs |
||||||
|
|
||||||
|
/* Hack some long SSL names */ |
||||||
|
#undef SSL_CTX_set_default_verify_paths |
||||||
|
#define SSL_CTX_set_default_verify_paths SSL_CTX_set_def_verify_paths |
||||||
|
#undef SSL_get_ex_data_X509_STORE_CTX_idx |
||||||
|
#define SSL_get_ex_data_X509_STORE_CTX_idx SSL_get_ex_d_X509_STORE_CTX_idx |
||||||
|
#undef SSL_add_file_cert_subjects_to_stack |
||||||
|
#define SSL_add_file_cert_subjects_to_stack SSL_add_file_cert_subjs_to_stk |
||||||
|
#undef SSL_add_dir_cert_subjects_to_stack |
||||||
|
#define SSL_add_dir_cert_subjects_to_stack SSL_add_dir_cert_subjs_to_stk |
||||||
|
#undef SSL_CTX_use_certificate_chain_file |
||||||
|
#define SSL_CTX_use_certificate_chain_file SSL_CTX_use_cert_chain_file |
||||||
|
#undef SSL_CTX_set_cert_verify_callback |
||||||
|
#define SSL_CTX_set_cert_verify_callback SSL_CTX_set_cert_verify_cb |
||||||
|
#undef SSL_CTX_set_default_passwd_cb_userdata |
||||||
|
#define SSL_CTX_set_default_passwd_cb_userdata SSL_CTX_set_def_passwd_cb_ud |
||||||
|
#undef SSL_COMP_get_compression_methods |
||||||
|
#define SSL_COMP_get_compression_methods SSL_COMP_get_compress_methods |
||||||
|
#undef ssl_add_clienthello_renegotiate_ext |
||||||
|
#define ssl_add_clienthello_renegotiate_ext ssl_add_clienthello_reneg_ext |
||||||
|
#undef ssl_add_serverhello_renegotiate_ext |
||||||
|
#define ssl_add_serverhello_renegotiate_ext ssl_add_serverhello_reneg_ext |
||||||
|
#undef ssl_parse_clienthello_renegotiate_ext |
||||||
|
#define ssl_parse_clienthello_renegotiate_ext ssl_parse_clienthello_reneg_ext |
||||||
|
#undef ssl_parse_serverhello_renegotiate_ext |
||||||
|
#define ssl_parse_serverhello_renegotiate_ext ssl_parse_serverhello_reneg_ext |
||||||
|
#undef SSL_srp_server_param_with_username |
||||||
|
#define SSL_srp_server_param_with_username SSL_srp_server_param_with_un |
||||||
|
#undef SSL_CTX_set_srp_client_pwd_callback |
||||||
|
#define SSL_CTX_set_srp_client_pwd_callback SSL_CTX_set_srp_client_pwd_cb |
||||||
|
#undef SSL_CTX_set_srp_verify_param_callback |
||||||
|
#define SSL_CTX_set_srp_verify_param_callback SSL_CTX_set_srp_vfy_param_cb |
||||||
|
#undef SSL_CTX_set_srp_username_callback |
||||||
|
#define SSL_CTX_set_srp_username_callback SSL_CTX_set_srp_un_cb |
||||||
|
#undef ssl_add_clienthello_use_srtp_ext |
||||||
|
#define ssl_add_clienthello_use_srtp_ext ssl_add_clihello_use_srtp_ext |
||||||
|
#undef ssl_add_serverhello_use_srtp_ext |
||||||
|
#define ssl_add_serverhello_use_srtp_ext ssl_add_serhello_use_srtp_ext |
||||||
|
#undef ssl_parse_clienthello_use_srtp_ext |
||||||
|
#define ssl_parse_clienthello_use_srtp_ext ssl_parse_clihello_use_srtp_ext |
||||||
|
#undef ssl_parse_serverhello_use_srtp_ext |
||||||
|
#define ssl_parse_serverhello_use_srtp_ext ssl_parse_serhello_use_srtp_ext |
||||||
|
#undef SSL_CTX_set_next_protos_advertised_cb |
||||||
|
#define SSL_CTX_set_next_protos_advertised_cb SSL_CTX_set_next_protos_adv_cb |
||||||
|
#undef SSL_CTX_set_next_proto_select_cb |
||||||
|
#define SSL_CTX_set_next_proto_select_cb SSL_CTX_set_next_proto_sel_cb |
||||||
|
#undef ssl3_cbc_record_digest_supported |
||||||
|
#define ssl3_cbc_record_digest_supported ssl3_cbc_record_digest_support |
||||||
|
#undef ssl_check_clienthello_tlsext_late |
||||||
|
#define ssl_check_clienthello_tlsext_late ssl_check_clihello_tlsext_late |
||||||
|
#undef ssl_check_clienthello_tlsext_early |
||||||
|
#define ssl_check_clienthello_tlsext_early ssl_check_clihello_tlsext_early |
||||||
|
|
||||||
|
/* Hack some long ENGINE names */ |
||||||
|
#undef ENGINE_get_default_BN_mod_exp_crt |
||||||
|
#define ENGINE_get_default_BN_mod_exp_crt ENGINE_get_def_BN_mod_exp_crt |
||||||
|
#undef ENGINE_set_default_BN_mod_exp_crt |
||||||
|
#define ENGINE_set_default_BN_mod_exp_crt ENGINE_set_def_BN_mod_exp_crt |
||||||
|
#undef ENGINE_set_load_privkey_function |
||||||
|
#define ENGINE_set_load_privkey_function ENGINE_set_load_privkey_fn |
||||||
|
#undef ENGINE_get_load_privkey_function |
||||||
|
#define ENGINE_get_load_privkey_function ENGINE_get_load_privkey_fn |
||||||
|
#undef ENGINE_unregister_pkey_asn1_meths |
||||||
|
#define ENGINE_unregister_pkey_asn1_meths ENGINE_unreg_pkey_asn1_meths |
||||||
|
#undef ENGINE_register_all_pkey_asn1_meths |
||||||
|
#define ENGINE_register_all_pkey_asn1_meths ENGINE_reg_all_pkey_asn1_meths |
||||||
|
#undef ENGINE_set_default_pkey_asn1_meths |
||||||
|
#define ENGINE_set_default_pkey_asn1_meths ENGINE_set_def_pkey_asn1_meths |
||||||
|
#undef ENGINE_get_pkey_asn1_meth_engine |
||||||
|
#define ENGINE_get_pkey_asn1_meth_engine ENGINE_get_pkey_asn1_meth_eng |
||||||
|
#undef ENGINE_set_load_ssl_client_cert_function |
||||||
|
#define ENGINE_set_load_ssl_client_cert_function \ |
||||||
|
ENGINE_set_ld_ssl_clnt_cert_fn |
||||||
|
#undef ENGINE_get_ssl_client_cert_function |
||||||
|
#define ENGINE_get_ssl_client_cert_function ENGINE_get_ssl_client_cert_fn |
||||||
|
|
||||||
|
/* Hack some long OCSP names */ |
||||||
|
#undef OCSP_REQUEST_get_ext_by_critical |
||||||
|
#define OCSP_REQUEST_get_ext_by_critical OCSP_REQUEST_get_ext_by_crit |
||||||
|
#undef OCSP_BASICRESP_get_ext_by_critical |
||||||
|
#define OCSP_BASICRESP_get_ext_by_critical OCSP_BASICRESP_get_ext_by_crit |
||||||
|
#undef OCSP_SINGLERESP_get_ext_by_critical |
||||||
|
#define OCSP_SINGLERESP_get_ext_by_critical OCSP_SINGLERESP_get_ext_by_crit |
||||||
|
|
||||||
|
/* Hack some long DES names */ |
||||||
|
#undef _ossl_old_des_ede3_cfb64_encrypt |
||||||
|
#define _ossl_old_des_ede3_cfb64_encrypt _ossl_odes_ede3_cfb64_encrypt |
||||||
|
#undef _ossl_old_des_ede3_ofb64_encrypt |
||||||
|
#define _ossl_old_des_ede3_ofb64_encrypt _ossl_odes_ede3_ofb64_encrypt |
||||||
|
|
||||||
|
/* Hack some long EVP names */ |
||||||
|
#undef OPENSSL_add_all_algorithms_noconf |
||||||
|
#define OPENSSL_add_all_algorithms_noconf OPENSSL_add_all_algo_noconf |
||||||
|
#undef OPENSSL_add_all_algorithms_conf |
||||||
|
#define OPENSSL_add_all_algorithms_conf OPENSSL_add_all_algo_conf |
||||||
|
#undef EVP_PKEY_meth_set_verify_recover |
||||||
|
#define EVP_PKEY_meth_set_verify_recover EVP_PKEY_meth_set_vrfy_recover |
||||||
|
|
||||||
|
/* Hack some long EC names */ |
||||||
|
#undef EC_GROUP_set_point_conversion_form |
||||||
|
#define EC_GROUP_set_point_conversion_form EC_GROUP_set_point_conv_form |
||||||
|
#undef EC_GROUP_get_point_conversion_form |
||||||
|
#define EC_GROUP_get_point_conversion_form EC_GROUP_get_point_conv_form |
||||||
|
#undef EC_GROUP_clear_free_all_extra_data |
||||||
|
#define EC_GROUP_clear_free_all_extra_data EC_GROUP_clr_free_all_xtra_data |
||||||
|
#undef EC_KEY_set_public_key_affine_coordinates |
||||||
|
#define EC_KEY_set_public_key_affine_coordinates \ |
||||||
|
EC_KEY_set_pub_key_aff_coords |
||||||
|
#undef EC_POINT_set_Jprojective_coordinates_GFp |
||||||
|
#define EC_POINT_set_Jprojective_coordinates_GFp \ |
||||||
|
EC_POINT_set_Jproj_coords_GFp |
||||||
|
#undef EC_POINT_get_Jprojective_coordinates_GFp |
||||||
|
#define EC_POINT_get_Jprojective_coordinates_GFp \ |
||||||
|
EC_POINT_get_Jproj_coords_GFp |
||||||
|
#undef EC_POINT_set_affine_coordinates_GFp |
||||||
|
#define EC_POINT_set_affine_coordinates_GFp EC_POINT_set_affine_coords_GFp |
||||||
|
#undef EC_POINT_get_affine_coordinates_GFp |
||||||
|
#define EC_POINT_get_affine_coordinates_GFp EC_POINT_get_affine_coords_GFp |
||||||
|
#undef EC_POINT_set_compressed_coordinates_GFp |
||||||
|
#define EC_POINT_set_compressed_coordinates_GFp EC_POINT_set_compr_coords_GFp |
||||||
|
#undef EC_POINT_set_affine_coordinates_GF2m |
||||||
|
#define EC_POINT_set_affine_coordinates_GF2m EC_POINT_set_affine_coords_GF2m |
||||||
|
#undef EC_POINT_get_affine_coordinates_GF2m |
||||||
|
#define EC_POINT_get_affine_coordinates_GF2m EC_POINT_get_affine_coords_GF2m |
||||||
|
#undef EC_POINT_set_compressed_coordinates_GF2m |
||||||
|
#define EC_POINT_set_compressed_coordinates_GF2m \ |
||||||
|
EC_POINT_set_compr_coords_GF2m |
||||||
|
#undef ec_GF2m_simple_group_clear_finish |
||||||
|
#define ec_GF2m_simple_group_clear_finish ec_GF2m_simple_grp_clr_finish |
||||||
|
#undef ec_GF2m_simple_group_check_discriminant |
||||||
|
#define ec_GF2m_simple_group_check_discriminant ec_GF2m_simple_grp_chk_discrim |
||||||
|
#undef ec_GF2m_simple_point_clear_finish |
||||||
|
#define ec_GF2m_simple_point_clear_finish ec_GF2m_simple_pt_clr_finish |
||||||
|
#undef ec_GF2m_simple_point_set_to_infinity |
||||||
|
#define ec_GF2m_simple_point_set_to_infinity ec_GF2m_simple_pt_set_to_inf |
||||||
|
#undef ec_GF2m_simple_points_make_affine |
||||||
|
#define ec_GF2m_simple_points_make_affine ec_GF2m_simple_pts_make_affine |
||||||
|
#undef ec_GF2m_simple_point_set_affine_coordinates |
||||||
|
#define ec_GF2m_simple_point_set_affine_coordinates \ |
||||||
|
ec_GF2m_smp_pt_set_af_coords |
||||||
|
#undef ec_GF2m_simple_point_get_affine_coordinates |
||||||
|
#define ec_GF2m_simple_point_get_affine_coordinates \ |
||||||
|
ec_GF2m_smp_pt_get_af_coords |
||||||
|
#undef ec_GF2m_simple_set_compressed_coordinates |
||||||
|
#define ec_GF2m_simple_set_compressed_coordinates \ |
||||||
|
ec_GF2m_smp_set_compr_coords |
||||||
|
#undef ec_GFp_simple_group_set_curve_GFp |
||||||
|
#define ec_GFp_simple_group_set_curve_GFp ec_GFp_simple_grp_set_curve_GFp |
||||||
|
#undef ec_GFp_simple_group_get_curve_GFp |
||||||
|
#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp |
||||||
|
#undef ec_GFp_simple_group_clear_finish |
||||||
|
#define ec_GFp_simple_group_clear_finish ec_GFp_simple_grp_clear_finish |
||||||
|
#undef ec_GFp_simple_group_set_generator |
||||||
|
#define ec_GFp_simple_group_set_generator ec_GFp_simple_grp_set_generator |
||||||
|
#undef ec_GFp_simple_group_get0_generator |
||||||
|
#define ec_GFp_simple_group_get0_generator ec_GFp_simple_grp_gt0_generator |
||||||
|
#undef ec_GFp_simple_group_get_cofactor |
||||||
|
#define ec_GFp_simple_group_get_cofactor ec_GFp_simple_grp_get_cofactor |
||||||
|
#undef ec_GFp_simple_point_clear_finish |
||||||
|
#define ec_GFp_simple_point_clear_finish ec_GFp_simple_pt_clear_finish |
||||||
|
#undef ec_GFp_simple_point_set_to_infinity |
||||||
|
#define ec_GFp_simple_point_set_to_infinity ec_GFp_simple_pt_set_to_inf |
||||||
|
#undef ec_GFp_simple_points_make_affine |
||||||
|
#define ec_GFp_simple_points_make_affine ec_GFp_simple_pts_make_affine |
||||||
|
#undef ec_GFp_simple_set_Jprojective_coordinates_GFp |
||||||
|
#define ec_GFp_simple_set_Jprojective_coordinates_GFp \ |
||||||
|
ec_GFp_smp_set_Jproj_coords_GFp |
||||||
|
#undef ec_GFp_simple_get_Jprojective_coordinates_GFp |
||||||
|
#define ec_GFp_simple_get_Jprojective_coordinates_GFp \ |
||||||
|
ec_GFp_smp_get_Jproj_coords_GFp |
||||||
|
#undef ec_GFp_simple_point_set_affine_coordinates_GFp |
||||||
|
#define ec_GFp_simple_point_set_affine_coordinates_GFp \ |
||||||
|
ec_GFp_smp_pt_set_af_coords_GFp |
||||||
|
#undef ec_GFp_simple_point_get_affine_coordinates_GFp |
||||||
|
#define ec_GFp_simple_point_get_affine_coordinates_GFp \ |
||||||
|
ec_GFp_smp_pt_get_af_coords_GFp |
||||||
|
#undef ec_GFp_simple_set_compressed_coordinates_GFp |
||||||
|
#define ec_GFp_simple_set_compressed_coordinates_GFp \ |
||||||
|
ec_GFp_smp_set_compr_coords_GFp |
||||||
|
#undef ec_GFp_simple_point_set_affine_coordinates |
||||||
|
#define ec_GFp_simple_point_set_affine_coordinates \ |
||||||
|
ec_GFp_smp_pt_set_af_coords |
||||||
|
#undef ec_GFp_simple_point_get_affine_coordinates |
||||||
|
#define ec_GFp_simple_point_get_affine_coordinates \ |
||||||
|
ec_GFp_smp_pt_get_af_coords |
||||||
|
#undef ec_GFp_simple_set_compressed_coordinates |
||||||
|
#define ec_GFp_simple_set_compressed_coordinates \ |
||||||
|
ec_GFp_smp_set_compr_coords |
||||||
|
#undef ec_GFp_simple_group_check_discriminant |
||||||
|
#define ec_GFp_simple_group_check_discriminant ec_GFp_simple_grp_chk_discrim |
||||||
|
|
||||||
|
/* Hack som long STORE names */ |
||||||
|
#undef STORE_method_set_initialise_function |
||||||
|
#define STORE_method_set_initialise_function STORE_meth_set_initialise_fn |
||||||
|
#undef STORE_method_set_cleanup_function |
||||||
|
#define STORE_method_set_cleanup_function STORE_meth_set_cleanup_fn |
||||||
|
#undef STORE_method_set_generate_function |
||||||
|
#define STORE_method_set_generate_function STORE_meth_set_generate_fn |
||||||
|
#undef STORE_method_set_modify_function |
||||||
|
#define STORE_method_set_modify_function STORE_meth_set_modify_fn |
||||||
|
#undef STORE_method_set_revoke_function |
||||||
|
#define STORE_method_set_revoke_function STORE_meth_set_revoke_fn |
||||||
|
#undef STORE_method_set_delete_function |
||||||
|
#define STORE_method_set_delete_function STORE_meth_set_delete_fn |
||||||
|
#undef STORE_method_set_list_start_function |
||||||
|
#define STORE_method_set_list_start_function STORE_meth_set_list_start_fn |
||||||
|
#undef STORE_method_set_list_next_function |
||||||
|
#define STORE_method_set_list_next_function STORE_meth_set_list_next_fn |
||||||
|
#undef STORE_method_set_list_end_function |
||||||
|
#define STORE_method_set_list_end_function STORE_meth_set_list_end_fn |
||||||
|
#undef STORE_method_set_update_store_function |
||||||
|
#define STORE_method_set_update_store_function STORE_meth_set_update_store_fn |
||||||
|
#undef STORE_method_set_lock_store_function |
||||||
|
#define STORE_method_set_lock_store_function STORE_meth_set_lock_store_fn |
||||||
|
#undef STORE_method_set_unlock_store_function |
||||||
|
#define STORE_method_set_unlock_store_function STORE_meth_set_unlock_store_fn |
||||||
|
#undef STORE_method_get_initialise_function |
||||||
|
#define STORE_method_get_initialise_function STORE_meth_get_initialise_fn |
||||||
|
#undef STORE_method_get_cleanup_function |
||||||
|
#define STORE_method_get_cleanup_function STORE_meth_get_cleanup_fn |
||||||
|
#undef STORE_method_get_generate_function |
||||||
|
#define STORE_method_get_generate_function STORE_meth_get_generate_fn |
||||||
|
#undef STORE_method_get_modify_function |
||||||
|
#define STORE_method_get_modify_function STORE_meth_get_modify_fn |
||||||
|
#undef STORE_method_get_revoke_function |
||||||
|
#define STORE_method_get_revoke_function STORE_meth_get_revoke_fn |
||||||
|
#undef STORE_method_get_delete_function |
||||||
|
#define STORE_method_get_delete_function STORE_meth_get_delete_fn |
||||||
|
#undef STORE_method_get_list_start_function |
||||||
|
#define STORE_method_get_list_start_function STORE_meth_get_list_start_fn |
||||||
|
#undef STORE_method_get_list_next_function |
||||||
|
#define STORE_method_get_list_next_function STORE_meth_get_list_next_fn |
||||||
|
#undef STORE_method_get_list_end_function |
||||||
|
#define STORE_method_get_list_end_function STORE_meth_get_list_end_fn |
||||||
|
#undef STORE_method_get_update_store_function |
||||||
|
#define STORE_method_get_update_store_function STORE_meth_get_update_store_fn |
||||||
|
#undef STORE_method_get_lock_store_function |
||||||
|
#define STORE_method_get_lock_store_function STORE_meth_get_lock_store_fn |
||||||
|
#undef STORE_method_get_unlock_store_function |
||||||
|
#define STORE_method_get_unlock_store_function STORE_meth_get_unlock_store_fn |
||||||
|
|
||||||
|
/* Hack some long TS names */ |
||||||
|
#undef TS_RESP_CTX_set_status_info_cond |
||||||
|
#define TS_RESP_CTX_set_status_info_cond TS_RESP_CTX_set_stat_info_cond |
||||||
|
#undef TS_RESP_CTX_set_clock_precision_digits |
||||||
|
#define TS_RESP_CTX_set_clock_precision_digits TS_RESP_CTX_set_clk_prec_digits |
||||||
|
#undef TS_CONF_set_clock_precision_digits |
||||||
|
#define TS_CONF_set_clock_precision_digits TS_CONF_set_clk_prec_digits |
||||||
|
|
||||||
|
/* Hack some long CMS names */ |
||||||
|
#undef CMS_RecipientInfo_ktri_get0_algs |
||||||
|
#define CMS_RecipientInfo_ktri_get0_algs CMS_RecipInfo_ktri_get0_algs |
||||||
|
#undef CMS_RecipientInfo_ktri_get0_signer_id |
||||||
|
#define CMS_RecipientInfo_ktri_get0_signer_id CMS_RecipInfo_ktri_get0_sigr_id |
||||||
|
#undef CMS_OtherRevocationInfoFormat_it |
||||||
|
#define CMS_OtherRevocationInfoFormat_it CMS_OtherRevocInfoFormat_it |
||||||
|
#undef CMS_KeyAgreeRecipientIdentifier_it |
||||||
|
#define CMS_KeyAgreeRecipientIdentifier_it CMS_KeyAgreeRecipIdentifier_it |
||||||
|
#undef CMS_OriginatorIdentifierOrKey_it |
||||||
|
#define CMS_OriginatorIdentifierOrKey_it CMS_OriginatorIdOrKey_it |
||||||
|
#undef cms_SignerIdentifier_get0_signer_id |
||||||
|
#define cms_SignerIdentifier_get0_signer_id cms_SignerId_get0_signer_id |
||||||
|
|
||||||
|
/* Hack some long DTLS1 names */ |
||||||
|
#undef dtls1_retransmit_buffered_messages |
||||||
|
#define dtls1_retransmit_buffered_messages dtls1_retransmit_buffered_msgs |
||||||
|
|
||||||
|
/* Hack some long SRP names */ |
||||||
|
#undef SRP_generate_server_master_secret |
||||||
|
#define SRP_generate_server_master_secret SRP_gen_server_master_secret |
||||||
|
#undef SRP_generate_client_master_secret |
||||||
|
#define SRP_generate_client_master_secret SRP_gen_client_master_secret |
||||||
|
|
||||||
|
/* Hack some long UI names */ |
||||||
|
#undef UI_method_get_prompt_constructor |
||||||
|
#define UI_method_get_prompt_constructor UI_method_get_prompt_constructr |
||||||
|
#undef UI_method_set_prompt_constructor |
||||||
|
#define UI_method_set_prompt_constructor UI_method_set_prompt_constructr |
||||||
|
|
||||||
|
#endif /* defined OPENSSL_SYS_VMS */ |
||||||
|
|
||||||
|
|
||||||
|
/* Case insensitive linking causes problems.... */ |
||||||
|
#if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) |
||||||
|
#undef ERR_load_CRYPTO_strings |
||||||
|
#define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings |
||||||
|
#undef OCSP_crlID_new |
||||||
|
#define OCSP_crlID_new OCSP_crlID2_new |
||||||
|
|
||||||
|
#undef d2i_ECPARAMETERS |
||||||
|
#define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS |
||||||
|
#undef i2d_ECPARAMETERS |
||||||
|
#define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS |
||||||
|
#undef d2i_ECPKPARAMETERS |
||||||
|
#define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS |
||||||
|
#undef i2d_ECPKPARAMETERS |
||||||
|
#define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS |
||||||
|
|
||||||
|
/* These functions do not seem to exist! However, I'm paranoid...
|
||||||
|
Original command in x509v3.h: |
||||||
|
These functions are being redefined in another directory, |
||||||
|
and clash when the linker is case-insensitive, so let's |
||||||
|
hide them a little, by giving them an extra 'o' at the |
||||||
|
beginning of the name... */ |
||||||
|
#undef X509v3_cleanup_extensions |
||||||
|
#define X509v3_cleanup_extensions oX509v3_cleanup_extensions |
||||||
|
#undef X509v3_add_extension |
||||||
|
#define X509v3_add_extension oX509v3_add_extension |
||||||
|
#undef X509v3_add_netscape_extensions |
||||||
|
#define X509v3_add_netscape_extensions oX509v3_add_netscape_extensions |
||||||
|
#undef X509v3_add_standard_extensions |
||||||
|
#define X509v3_add_standard_extensions oX509v3_add_standard_extensions |
||||||
|
|
||||||
|
/* This one clashes with CMS_data_create */ |
||||||
|
#undef cms_Data_create |
||||||
|
#define cms_Data_create priv_cms_Data_create |
||||||
|
|
||||||
|
#endif |
||||||
|
|
||||||
|
|
||||||
|
#endif /* ! defined HEADER_VMS_IDHACKS_H */ |
Loading…
Reference in new issue