mirror of https://github.com/lukechilds/node.git
Browse Source
This replaces all sources of openssl-1.0.2k.tar.gz into deps/openssl/openssl PR-URL: https://github.com/nodejs/node/pull/11021 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>v6.x
committed by
Myles Borins
181 changed files with 1122 additions and 39081 deletions
@ -1 +1,265 @@ |
|||
#include "../../config/opensslconf.h" |
|||
/* opensslconf.h */ |
|||
/* WARNING: Generated automatically from opensslconf.h.in by Configure. */ |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
/* OpenSSL was configured with the following options: */ |
|||
#ifndef OPENSSL_DOING_MAKEDEPEND |
|||
|
|||
|
|||
#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 |
|||
# define OPENSSL_NO_EC_NISTP_64_GCC_128 |
|||
#endif |
|||
#ifndef OPENSSL_NO_GMP |
|||
# define OPENSSL_NO_GMP |
|||
#endif |
|||
#ifndef OPENSSL_NO_JPAKE |
|||
# define OPENSSL_NO_JPAKE |
|||
#endif |
|||
#ifndef OPENSSL_NO_KRB5 |
|||
# define OPENSSL_NO_KRB5 |
|||
#endif |
|||
#ifndef OPENSSL_NO_LIBUNBOUND |
|||
# define OPENSSL_NO_LIBUNBOUND |
|||
#endif |
|||
#ifndef OPENSSL_NO_MD2 |
|||
# define OPENSSL_NO_MD2 |
|||
#endif |
|||
#ifndef OPENSSL_NO_RC5 |
|||
# define OPENSSL_NO_RC5 |
|||
#endif |
|||
#ifndef OPENSSL_NO_RFC3779 |
|||
# define OPENSSL_NO_RFC3779 |
|||
#endif |
|||
#ifndef OPENSSL_NO_SCTP |
|||
# define OPENSSL_NO_SCTP |
|||
#endif |
|||
#ifndef OPENSSL_NO_SSL_TRACE |
|||
# define OPENSSL_NO_SSL_TRACE |
|||
#endif |
|||
#ifndef OPENSSL_NO_SSL2 |
|||
# define OPENSSL_NO_SSL2 |
|||
#endif |
|||
#ifndef OPENSSL_NO_STORE |
|||
# define OPENSSL_NO_STORE |
|||
#endif |
|||
#ifndef OPENSSL_NO_UNIT_TEST |
|||
# define OPENSSL_NO_UNIT_TEST |
|||
#endif |
|||
#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS |
|||
# define OPENSSL_NO_WEAK_SSL_CIPHERS |
|||
#endif |
|||
|
|||
#endif /* OPENSSL_DOING_MAKEDEPEND */ |
|||
|
|||
#ifndef OPENSSL_NO_DYNAMIC_ENGINE |
|||
# define OPENSSL_NO_DYNAMIC_ENGINE |
|||
#endif |
|||
|
|||
/* The OPENSSL_NO_* macros are also defined as NO_* if the application
|
|||
asks for it. This is a transient feature that is provided for those |
|||
who haven't had the time to do the appropriate changes in their |
|||
applications. */ |
|||
#ifdef OPENSSL_ALGORITHM_DEFINES |
|||
# if defined(OPENSSL_NO_EC_NISTP_64_GCC_128) && !defined(NO_EC_NISTP_64_GCC_128) |
|||
# define NO_EC_NISTP_64_GCC_128 |
|||
# endif |
|||
# if defined(OPENSSL_NO_GMP) && !defined(NO_GMP) |
|||
# define NO_GMP |
|||
# endif |
|||
# if defined(OPENSSL_NO_JPAKE) && !defined(NO_JPAKE) |
|||
# define NO_JPAKE |
|||
# endif |
|||
# if defined(OPENSSL_NO_KRB5) && !defined(NO_KRB5) |
|||
# define NO_KRB5 |
|||
# endif |
|||
# if defined(OPENSSL_NO_LIBUNBOUND) && !defined(NO_LIBUNBOUND) |
|||
# define NO_LIBUNBOUND |
|||
# endif |
|||
# if defined(OPENSSL_NO_MD2) && !defined(NO_MD2) |
|||
# define NO_MD2 |
|||
# endif |
|||
# if defined(OPENSSL_NO_RC5) && !defined(NO_RC5) |
|||
# define NO_RC5 |
|||
# endif |
|||
# if defined(OPENSSL_NO_RFC3779) && !defined(NO_RFC3779) |
|||
# define NO_RFC3779 |
|||
# endif |
|||
# if defined(OPENSSL_NO_SCTP) && !defined(NO_SCTP) |
|||
# define NO_SCTP |
|||
# endif |
|||
# if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) |
|||
# define NO_SSL_TRACE |
|||
# endif |
|||
# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) |
|||
# define NO_SSL2 |
|||
# endif |
|||
# if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) |
|||
# define NO_STORE |
|||
# endif |
|||
# if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) |
|||
# define NO_UNIT_TEST |
|||
# endif |
|||
# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) |
|||
# define NO_WEAK_SSL_CIPHERS |
|||
# endif |
|||
#endif |
|||
|
|||
/* crypto/opensslconf.h.in */ |
|||
|
|||
/* Generate 80386 code? */ |
|||
#undef I386_ONLY |
|||
|
|||
#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */ |
|||
#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) |
|||
#define ENGINESDIR "/usr/local/ssl/lib/engines" |
|||
#define OPENSSLDIR "/usr/local/ssl" |
|||
#endif |
|||
#endif |
|||
|
|||
#undef OPENSSL_UNISTD |
|||
#define OPENSSL_UNISTD <unistd.h> |
|||
|
|||
#undef OPENSSL_EXPORT_VAR_AS_FUNCTION |
|||
|
|||
#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) |
|||
#define IDEA_INT unsigned int |
|||
#endif |
|||
|
|||
#if defined(HEADER_MD2_H) && !defined(MD2_INT) |
|||
#define MD2_INT unsigned int |
|||
#endif |
|||
|
|||
#if defined(HEADER_RC2_H) && !defined(RC2_INT) |
|||
/* I need to put in a mod for the alpha - eay */ |
|||
#define RC2_INT unsigned int |
|||
#endif |
|||
|
|||
#if defined(HEADER_RC4_H) |
|||
#if !defined(RC4_INT) |
|||
/* using int types make the structure larger but make the code faster
|
|||
* on most boxes I have tested - up to %20 faster. */ |
|||
/*
|
|||
* I don't know what does "most" mean, but declaring "int" is a must on: |
|||
* - Intel P6 because partial register stalls are very expensive; |
|||
* - elder Alpha because it lacks byte load/store instructions; |
|||
*/ |
|||
#define RC4_INT unsigned int |
|||
#endif |
|||
#if !defined(RC4_CHUNK) |
|||
/*
|
|||
* This enables code handling data aligned at natural CPU word |
|||
* boundary. See crypto/rc4/rc4_enc.c for further details. |
|||
*/ |
|||
#undef RC4_CHUNK |
|||
#endif |
|||
#endif |
|||
|
|||
#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) |
|||
/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
|
|||
* %20 speed up (longs are 8 bytes, int's are 4). */ |
|||
#ifndef DES_LONG |
|||
#define DES_LONG unsigned long |
|||
#endif |
|||
#endif |
|||
|
|||
#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) |
|||
#define CONFIG_HEADER_BN_H |
|||
#undef BN_LLONG |
|||
|
|||
/* Should we define BN_DIV2W here? */ |
|||
|
|||
/* Only one for the following should be defined */ |
|||
#undef SIXTY_FOUR_BIT_LONG |
|||
#undef SIXTY_FOUR_BIT |
|||
#define THIRTY_TWO_BIT |
|||
#endif |
|||
|
|||
#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) |
|||
#define CONFIG_HEADER_RC4_LOCL_H |
|||
/* if this is defined data[i] is used instead of *data, this is a %20
|
|||
* speedup on x86 */ |
|||
#undef RC4_INDEX |
|||
#endif |
|||
|
|||
#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) |
|||
#define CONFIG_HEADER_BF_LOCL_H |
|||
#undef BF_PTR |
|||
#endif /* HEADER_BF_LOCL_H */ |
|||
|
|||
#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) |
|||
#define CONFIG_HEADER_DES_LOCL_H |
|||
#ifndef DES_DEFAULT_OPTIONS |
|||
/* the following is tweaked from a config script, that is why it is a
|
|||
* protected undef/define */ |
|||
#ifndef DES_PTR |
|||
#undef DES_PTR |
|||
#endif |
|||
|
|||
/* This helps C compiler generate the correct code for multiple functional
|
|||
* units. It reduces register dependancies at the expense of 2 more |
|||
* registers */ |
|||
#ifndef DES_RISC1 |
|||
#undef DES_RISC1 |
|||
#endif |
|||
|
|||
#ifndef DES_RISC2 |
|||
#undef DES_RISC2 |
|||
#endif |
|||
|
|||
#if defined(DES_RISC1) && defined(DES_RISC2) |
|||
#error YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! |
|||
#endif |
|||
|
|||
/* Unroll the inner loop, this sometimes helps, sometimes hinders.
|
|||
* Very mucy CPU dependant */ |
|||
#ifndef DES_UNROLL |
|||
#undef DES_UNROLL |
|||
#endif |
|||
|
|||
/* These default values were supplied by
|
|||
* Peter Gutman <pgut001@cs.auckland.ac.nz> |
|||
* They are only used if nothing else has been defined */ |
|||
#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) |
|||
/* Special defines which change the way the code is built depending on the
|
|||
CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find |
|||
even newer MIPS CPU's, but at the moment one size fits all for |
|||
optimization options. Older Sparc's work better with only UNROLL, but |
|||
there's no way to tell at compile time what it is you're running on */ |
|||
|
|||
#if defined( __sun ) || defined ( sun ) /* Newer Sparc's */ |
|||
# define DES_PTR |
|||
# define DES_RISC1 |
|||
# define DES_UNROLL |
|||
#elif defined( __ultrix ) /* Older MIPS */ |
|||
# define DES_PTR |
|||
# define DES_RISC2 |
|||
# define DES_UNROLL |
|||
#elif defined( __osf1__ ) /* Alpha */ |
|||
# define DES_PTR |
|||
# define DES_RISC2 |
|||
#elif defined ( _AIX ) /* RS6000 */ |
|||
/* Unknown */ |
|||
#elif defined( __hpux ) /* HP-PA */ |
|||
/* Unknown */ |
|||
#elif defined( __aux ) /* 68K */ |
|||
/* Unknown */ |
|||
#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ |
|||
# define DES_UNROLL |
|||
#elif defined( __sgi ) /* Newer MIPS */ |
|||
# define DES_PTR |
|||
# define DES_RISC2 |
|||
# define DES_UNROLL |
|||
#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ |
|||
# define DES_PTR |
|||
# define DES_RISC1 |
|||
# define DES_UNROLL |
|||
#endif /* Systems-specific speed defines */ |
|||
#endif |
|||
|
|||
#endif /* DES_DEFAULT_OPTIONS */ |
|||
#endif /* HEADER_DES_LOCL_H */ |
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
|
@ -1,149 +0,0 @@ |
|||
/* crypto/aes/aes.h */ |
|||
/* ====================================================================
|
|||
* Copyright (c) 1998-2002 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. |
|||
* ==================================================================== |
|||
* |
|||
*/ |
|||
|
|||
#ifndef HEADER_AES_H |
|||
# define HEADER_AES_H |
|||
|
|||
# include <openssl/opensslconf.h> |
|||
|
|||
# ifdef OPENSSL_NO_AES |
|||
# error AES is disabled. |
|||
# endif |
|||
|
|||
# include <stddef.h> |
|||
|
|||
# define AES_ENCRYPT 1 |
|||
# define AES_DECRYPT 0 |
|||
|
|||
/*
|
|||
* Because array size can't be a const in C, the following two are macros. |
|||
* Both sizes are in bytes. |
|||
*/ |
|||
# define AES_MAXNR 14 |
|||
# define AES_BLOCK_SIZE 16 |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
/* This should be a hidden type, but EVP requires that the size be known */ |
|||
struct aes_key_st { |
|||
# ifdef AES_LONG |
|||
unsigned long rd_key[4 * (AES_MAXNR + 1)]; |
|||
# else |
|||
unsigned int rd_key[4 * (AES_MAXNR + 1)]; |
|||
# endif |
|||
int rounds; |
|||
}; |
|||
typedef struct aes_key_st AES_KEY; |
|||
|
|||
const char *AES_options(void); |
|||
|
|||
int AES_set_encrypt_key(const unsigned char *userKey, const int bits, |
|||
AES_KEY *key); |
|||
int AES_set_decrypt_key(const unsigned char *userKey, const int bits, |
|||
AES_KEY *key); |
|||
|
|||
int private_AES_set_encrypt_key(const unsigned char *userKey, const int bits, |
|||
AES_KEY *key); |
|||
int private_AES_set_decrypt_key(const unsigned char *userKey, const int bits, |
|||
AES_KEY *key); |
|||
|
|||
void AES_encrypt(const unsigned char *in, unsigned char *out, |
|||
const AES_KEY *key); |
|||
void AES_decrypt(const unsigned char *in, unsigned char *out, |
|||
const AES_KEY *key); |
|||
|
|||
void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, |
|||
const AES_KEY *key, const int enc); |
|||
void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, |
|||
size_t length, const AES_KEY *key, |
|||
unsigned char *ivec, const int enc); |
|||
void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, |
|||
size_t length, const AES_KEY *key, |
|||
unsigned char *ivec, int *num, const int enc); |
|||
void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, |
|||
size_t length, const AES_KEY *key, |
|||
unsigned char *ivec, int *num, const int enc); |
|||
void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, |
|||
size_t length, const AES_KEY *key, |
|||
unsigned char *ivec, int *num, const int enc); |
|||
void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, |
|||
size_t length, const AES_KEY *key, |
|||
unsigned char *ivec, int *num); |
|||
void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, |
|||
size_t length, const AES_KEY *key, |
|||
unsigned char ivec[AES_BLOCK_SIZE], |
|||
unsigned char ecount_buf[AES_BLOCK_SIZE], |
|||
unsigned int *num); |
|||
/* NB: the IV is _two_ blocks long */ |
|||
void AES_ige_encrypt(const unsigned char *in, unsigned char *out, |
|||
size_t length, const AES_KEY *key, |
|||
unsigned char *ivec, const int enc); |
|||
/* NB: the IV is _four_ blocks long */ |
|||
void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out, |
|||
size_t length, const AES_KEY *key, |
|||
const AES_KEY *key2, const unsigned char *ivec, |
|||
const int enc); |
|||
|
|||
int AES_wrap_key(AES_KEY *key, const unsigned char *iv, |
|||
unsigned char *out, |
|||
const unsigned char *in, unsigned int inlen); |
|||
int AES_unwrap_key(AES_KEY *key, const unsigned char *iv, |
|||
unsigned char *out, |
|||
const unsigned char *in, unsigned int inlen); |
|||
|
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
|
|||
#endif /* !HEADER_AES_H */ |
File diff suppressed because it is too large
@ -1,579 +0,0 @@ |
|||
/* crypto/asn1/asn1_mac.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_ASN1_MAC_H |
|||
# define HEADER_ASN1_MAC_H |
|||
|
|||
# include <openssl/asn1.h> |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
# ifndef ASN1_MAC_ERR_LIB |
|||
# define ASN1_MAC_ERR_LIB ERR_LIB_ASN1 |
|||
# endif |
|||
|
|||
# define ASN1_MAC_H_err(f,r,line) \ |
|||
ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),__FILE__,(line)) |
|||
|
|||
# define M_ASN1_D2I_vars(a,type,func) \ |
|||
ASN1_const_CTX c; \ |
|||
type ret=NULL; \ |
|||
\ |
|||
c.pp=(const unsigned char **)pp; \ |
|||
c.q= *(const unsigned char **)pp; \ |
|||
c.error=ERR_R_NESTED_ASN1_ERROR; \ |
|||
if ((a == NULL) || ((*a) == NULL)) \ |
|||
{ if ((ret=(type)func()) == NULL) \ |
|||
{ c.line=__LINE__; goto err; } } \ |
|||
else ret=(*a); |
|||
|
|||
# define M_ASN1_D2I_Init() \ |
|||
c.p= *(const unsigned char **)pp; \ |
|||
c.max=(length == 0)?0:(c.p+length); |
|||
|
|||
# define M_ASN1_D2I_Finish_2(a) \ |
|||
if (!asn1_const_Finish(&c)) \ |
|||
{ c.line=__LINE__; goto err; } \ |
|||
*(const unsigned char **)pp=c.p; \ |
|||
if (a != NULL) (*a)=ret; \ |
|||
return(ret); |
|||
|
|||
# define M_ASN1_D2I_Finish(a,func,e) \ |
|||
M_ASN1_D2I_Finish_2(a); \ |
|||
err:\ |
|||
ASN1_MAC_H_err((e),c.error,c.line); \ |
|||
asn1_add_error(*(const unsigned char **)pp,(int)(c.q- *pp)); \ |
|||
if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \ |
|||
return(NULL) |
|||
|
|||
# define M_ASN1_D2I_start_sequence() \ |
|||
if (!asn1_GetSequence(&c,&length)) \ |
|||
{ c.line=__LINE__; goto err; } |
|||
/* Begin reading ASN1 without a surrounding sequence */ |
|||
# define M_ASN1_D2I_begin() \ |
|||
c.slen = length; |
|||
|
|||
/* End reading ASN1 with no check on length */ |
|||
# define M_ASN1_D2I_Finish_nolen(a, func, e) \ |
|||
*pp=c.p; \ |
|||
if (a != NULL) (*a)=ret; \ |
|||
return(ret); \ |
|||
err:\ |
|||
ASN1_MAC_H_err((e),c.error,c.line); \ |
|||
asn1_add_error(*pp,(int)(c.q- *pp)); \ |
|||
if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \ |
|||
return(NULL) |
|||
|
|||
# define M_ASN1_D2I_end_sequence() \ |
|||
(((c.inf&1) == 0)?(c.slen <= 0): \ |
|||
(c.eos=ASN1_const_check_infinite_end(&c.p,c.slen))) |
|||
|
|||
/* Don't use this with d2i_ASN1_BOOLEAN() */ |
|||
# define M_ASN1_D2I_get(b, func) \ |
|||
c.q=c.p; \ |
|||
if (func(&(b),&c.p,c.slen) == NULL) \ |
|||
{c.line=__LINE__; goto err; } \ |
|||
c.slen-=(c.p-c.q); |
|||
|
|||
/* Don't use this with d2i_ASN1_BOOLEAN() */ |
|||
# define M_ASN1_D2I_get_x(type,b,func) \ |
|||
c.q=c.p; \ |
|||
if (((D2I_OF(type))func)(&(b),&c.p,c.slen) == NULL) \ |
|||
{c.line=__LINE__; goto err; } \ |
|||
c.slen-=(c.p-c.q); |
|||
|
|||
/* use this instead () */ |
|||
# define M_ASN1_D2I_get_int(b,func) \ |
|||
c.q=c.p; \ |
|||
if (func(&(b),&c.p,c.slen) < 0) \ |
|||
{c.line=__LINE__; goto err; } \ |
|||
c.slen-=(c.p-c.q); |
|||
|
|||
# define M_ASN1_D2I_get_opt(b,func,type) \ |
|||
if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \ |
|||
== (V_ASN1_UNIVERSAL|(type)))) \ |
|||
{ \ |
|||
M_ASN1_D2I_get(b,func); \ |
|||
} |
|||
|
|||
# define M_ASN1_D2I_get_int_opt(b,func,type) \ |
|||
if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \ |
|||
== (V_ASN1_UNIVERSAL|(type)))) \ |
|||
{ \ |
|||
M_ASN1_D2I_get_int(b,func); \ |
|||
} |
|||
|
|||
# define M_ASN1_D2I_get_imp(b,func, type) \ |
|||
M_ASN1_next=(_tmp& V_ASN1_CONSTRUCTED)|type; \ |
|||
c.q=c.p; \ |
|||
if (func(&(b),&c.p,c.slen) == NULL) \ |
|||
{c.line=__LINE__; M_ASN1_next_prev = _tmp; goto err; } \ |
|||
c.slen-=(c.p-c.q);\ |
|||
M_ASN1_next_prev=_tmp; |
|||
|
|||
# define M_ASN1_D2I_get_IMP_opt(b,func,tag,type) \ |
|||
if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) == \ |
|||
(V_ASN1_CONTEXT_SPECIFIC|(tag)))) \ |
|||
{ \ |
|||
unsigned char _tmp = M_ASN1_next; \ |
|||
M_ASN1_D2I_get_imp(b,func, type);\ |
|||
} |
|||
|
|||
# define M_ASN1_D2I_get_set(r,func,free_func) \ |
|||
M_ASN1_D2I_get_imp_set(r,func,free_func, \ |
|||
V_ASN1_SET,V_ASN1_UNIVERSAL); |
|||
|
|||
# define M_ASN1_D2I_get_set_type(type,r,func,free_func) \ |
|||
M_ASN1_D2I_get_imp_set_type(type,r,func,free_func, \ |
|||
V_ASN1_SET,V_ASN1_UNIVERSAL); |
|||
|
|||
# define M_ASN1_D2I_get_set_opt(r,func,free_func) \ |
|||
if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ |
|||
V_ASN1_CONSTRUCTED|V_ASN1_SET)))\ |
|||
{ M_ASN1_D2I_get_set(r,func,free_func); } |
|||
|
|||
# define M_ASN1_D2I_get_set_opt_type(type,r,func,free_func) \ |
|||
if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ |
|||
V_ASN1_CONSTRUCTED|V_ASN1_SET)))\ |
|||
{ M_ASN1_D2I_get_set_type(type,r,func,free_func); } |
|||
|
|||
# define M_ASN1_I2D_len_SET_opt(a,f) \ |
|||
if ((a != NULL) && (sk_num(a) != 0)) \ |
|||
M_ASN1_I2D_len_SET(a,f); |
|||
|
|||
# define M_ASN1_I2D_put_SET_opt(a,f) \ |
|||
if ((a != NULL) && (sk_num(a) != 0)) \ |
|||
M_ASN1_I2D_put_SET(a,f); |
|||
|
|||
# define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \ |
|||
if ((a != NULL) && (sk_num(a) != 0)) \ |
|||
M_ASN1_I2D_put_SEQUENCE(a,f); |
|||
|
|||
# define M_ASN1_I2D_put_SEQUENCE_opt_type(type,a,f) \ |
|||
if ((a != NULL) && (sk_##type##_num(a) != 0)) \ |
|||
M_ASN1_I2D_put_SEQUENCE_type(type,a,f); |
|||
|
|||
# define M_ASN1_D2I_get_IMP_set_opt(b,func,free_func,tag) \ |
|||
if ((c.slen != 0) && \ |
|||
(M_ASN1_next == \ |
|||
(V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\ |
|||
{ \ |
|||
M_ASN1_D2I_get_imp_set(b,func,free_func,\ |
|||
tag,V_ASN1_CONTEXT_SPECIFIC); \ |
|||
} |
|||
|
|||
# define M_ASN1_D2I_get_IMP_set_opt_type(type,b,func,free_func,tag) \ |
|||
if ((c.slen != 0) && \ |
|||
(M_ASN1_next == \ |
|||
(V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\ |
|||
{ \ |
|||
M_ASN1_D2I_get_imp_set_type(type,b,func,free_func,\ |
|||
tag,V_ASN1_CONTEXT_SPECIFIC); \ |
|||
} |
|||
|
|||
# define M_ASN1_D2I_get_seq(r,func,free_func) \ |
|||
M_ASN1_D2I_get_imp_set(r,func,free_func,\ |
|||
V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); |
|||
|
|||
# define M_ASN1_D2I_get_seq_type(type,r,func,free_func) \ |
|||
M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\ |
|||
V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL) |
|||
|
|||
# define M_ASN1_D2I_get_seq_opt(r,func,free_func) \ |
|||
if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ |
|||
V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\ |
|||
{ M_ASN1_D2I_get_seq(r,func,free_func); } |
|||
|
|||
# define M_ASN1_D2I_get_seq_opt_type(type,r,func,free_func) \ |
|||
if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ |
|||
V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\ |
|||
{ M_ASN1_D2I_get_seq_type(type,r,func,free_func); } |
|||
|
|||
# define M_ASN1_D2I_get_IMP_set(r,func,free_func,x) \ |
|||
M_ASN1_D2I_get_imp_set(r,func,free_func,\ |
|||
x,V_ASN1_CONTEXT_SPECIFIC); |
|||
|
|||
# define M_ASN1_D2I_get_IMP_set_type(type,r,func,free_func,x) \ |
|||
M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\ |
|||
x,V_ASN1_CONTEXT_SPECIFIC); |
|||
|
|||
# define M_ASN1_D2I_get_imp_set(r,func,free_func,a,b) \ |
|||
c.q=c.p; \ |
|||
if (d2i_ASN1_SET(&(r),&c.p,c.slen,(char *(*)())func,\ |
|||
(void (*)())free_func,a,b) == NULL) \ |
|||
{ c.line=__LINE__; goto err; } \ |
|||
c.slen-=(c.p-c.q); |
|||
|
|||
# define M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,a,b) \ |
|||
c.q=c.p; \ |
|||
if (d2i_ASN1_SET_OF_##type(&(r),&c.p,c.slen,func,\ |
|||
free_func,a,b) == NULL) \ |
|||
{ c.line=__LINE__; goto err; } \ |
|||
c.slen-=(c.p-c.q); |
|||
|
|||
# define M_ASN1_D2I_get_set_strings(r,func,a,b) \ |
|||
c.q=c.p; \ |
|||
if (d2i_ASN1_STRING_SET(&(r),&c.p,c.slen,a,b) == NULL) \ |
|||
{ c.line=__LINE__; goto err; } \ |
|||
c.slen-=(c.p-c.q); |
|||
|
|||
# define M_ASN1_D2I_get_EXP_opt(r,func,tag) \ |
|||
if ((c.slen != 0L) && (M_ASN1_next == \ |
|||
(V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ |
|||
{ \ |
|||
int Tinf,Ttag,Tclass; \ |
|||
long Tlen; \ |
|||
\ |
|||
c.q=c.p; \ |
|||
Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ |
|||
if (Tinf & 0x80) \ |
|||
{ c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \ |
|||
c.line=__LINE__; goto err; } \ |
|||
if (Tinf == (V_ASN1_CONSTRUCTED+1)) \ |
|||
Tlen = c.slen - (c.p - c.q) - 2; \ |
|||
if (func(&(r),&c.p,Tlen) == NULL) \ |
|||
{ c.line=__LINE__; goto err; } \ |
|||
if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \ |
|||
Tlen = c.slen - (c.p - c.q); \ |
|||
if(!ASN1_const_check_infinite_end(&c.p, Tlen)) \ |
|||
{ c.error=ERR_R_MISSING_ASN1_EOS; \ |
|||
c.line=__LINE__; goto err; } \ |
|||
}\ |
|||
c.slen-=(c.p-c.q); \ |
|||
} |
|||
|
|||
# define M_ASN1_D2I_get_EXP_set_opt(r,func,free_func,tag,b) \ |
|||
if ((c.slen != 0) && (M_ASN1_next == \ |
|||
(V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ |
|||
{ \ |
|||
int Tinf,Ttag,Tclass; \ |
|||
long Tlen; \ |
|||
\ |
|||
c.q=c.p; \ |
|||
Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ |
|||
if (Tinf & 0x80) \ |
|||
{ c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \ |
|||
c.line=__LINE__; goto err; } \ |
|||
if (Tinf == (V_ASN1_CONSTRUCTED+1)) \ |
|||
Tlen = c.slen - (c.p - c.q) - 2; \ |
|||
if (d2i_ASN1_SET(&(r),&c.p,Tlen,(char *(*)())func, \ |
|||
(void (*)())free_func, \ |
|||
b,V_ASN1_UNIVERSAL) == NULL) \ |
|||
{ c.line=__LINE__; goto err; } \ |
|||
if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \ |
|||
Tlen = c.slen - (c.p - c.q); \ |
|||
if(!ASN1_check_infinite_end(&c.p, Tlen)) \ |
|||
{ c.error=ERR_R_MISSING_ASN1_EOS; \ |
|||
c.line=__LINE__; goto err; } \ |
|||
}\ |
|||
c.slen-=(c.p-c.q); \ |
|||
} |
|||
|
|||
# define M_ASN1_D2I_get_EXP_set_opt_type(type,r,func,free_func,tag,b) \ |
|||
if ((c.slen != 0) && (M_ASN1_next == \ |
|||
(V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ |
|||
{ \ |
|||
int Tinf,Ttag,Tclass; \ |
|||
long Tlen; \ |
|||
\ |
|||
c.q=c.p; \ |
|||
Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ |
|||
if (Tinf & 0x80) \ |
|||
{ c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \ |
|||
c.line=__LINE__; goto err; } \ |
|||
if (Tinf == (V_ASN1_CONSTRUCTED+1)) \ |
|||
Tlen = c.slen - (c.p - c.q) - 2; \ |
|||
if (d2i_ASN1_SET_OF_##type(&(r),&c.p,Tlen,func, \ |
|||
free_func,b,V_ASN1_UNIVERSAL) == NULL) \ |
|||
{ c.line=__LINE__; goto err; } \ |
|||
if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \ |
|||
Tlen = c.slen - (c.p - c.q); \ |
|||
if(!ASN1_check_infinite_end(&c.p, Tlen)) \ |
|||
{ c.error=ERR_R_MISSING_ASN1_EOS; \ |
|||
c.line=__LINE__; goto err; } \ |
|||
}\ |
|||
c.slen-=(c.p-c.q); \ |
|||
} |
|||
|
|||
/* New macros */ |
|||
# define M_ASN1_New_Malloc(ret,type) \ |
|||
if ((ret=(type *)OPENSSL_malloc(sizeof(type))) == NULL) \ |
|||
{ c.line=__LINE__; goto err2; } |
|||
|
|||
# define M_ASN1_New(arg,func) \ |
|||
if (((arg)=func()) == NULL) return(NULL) |
|||
|
|||
# define M_ASN1_New_Error(a) \ |
|||
/*- err: ASN1_MAC_H_err((a),ERR_R_NESTED_ASN1_ERROR,c.line); \
|
|||
return(NULL);*/ \ |
|||
err2: ASN1_MAC_H_err((a),ERR_R_MALLOC_FAILURE,c.line); \ |
|||
return(NULL) |
|||
|
|||
/*
|
|||
* BIG UGLY WARNING! This is so damn ugly I wanna puke. Unfortunately, some |
|||
* macros that use ASN1_const_CTX still insist on writing in the input |
|||
* stream. ARGH! ARGH! ARGH! Let's get rid of this macro package. Please? -- |
|||
* Richard Levitte |
|||
*/ |
|||
# define M_ASN1_next (*((unsigned char *)(c.p))) |
|||
# define M_ASN1_next_prev (*((unsigned char *)(c.q))) |
|||
|
|||
/*************************************************/ |
|||
|
|||
# define M_ASN1_I2D_vars(a) int r=0,ret=0; \ |
|||
unsigned char *p; \ |
|||
if (a == NULL) return(0) |
|||
|
|||
/* Length Macros */ |
|||
# define M_ASN1_I2D_len(a,f) ret+=f(a,NULL) |
|||
# define M_ASN1_I2D_len_IMP_opt(a,f) if (a != NULL) M_ASN1_I2D_len(a,f) |
|||
|
|||
# define M_ASN1_I2D_len_SET(a,f) \ |
|||
ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET); |
|||
|
|||
# define M_ASN1_I2D_len_SET_type(type,a,f) \ |
|||
ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SET, \ |
|||
V_ASN1_UNIVERSAL,IS_SET); |
|||
|
|||
# define M_ASN1_I2D_len_SEQUENCE(a,f) \ |
|||
ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \ |
|||
IS_SEQUENCE); |
|||
|
|||
# define M_ASN1_I2D_len_SEQUENCE_type(type,a,f) \ |
|||
ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SEQUENCE, \ |
|||
V_ASN1_UNIVERSAL,IS_SEQUENCE) |
|||
|
|||
# define M_ASN1_I2D_len_SEQUENCE_opt(a,f) \ |
|||
if ((a != NULL) && (sk_num(a) != 0)) \ |
|||
M_ASN1_I2D_len_SEQUENCE(a,f); |
|||
|
|||
# define M_ASN1_I2D_len_SEQUENCE_opt_type(type,a,f) \ |
|||
if ((a != NULL) && (sk_##type##_num(a) != 0)) \ |
|||
M_ASN1_I2D_len_SEQUENCE_type(type,a,f); |
|||
|
|||
# define M_ASN1_I2D_len_IMP_SET(a,f,x) \ |
|||
ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET); |
|||
|
|||
# define M_ASN1_I2D_len_IMP_SET_type(type,a,f,x) \ |
|||
ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \ |
|||
V_ASN1_CONTEXT_SPECIFIC,IS_SET); |
|||
|
|||
# define M_ASN1_I2D_len_IMP_SET_opt(a,f,x) \ |
|||
if ((a != NULL) && (sk_num(a) != 0)) \ |
|||
ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \ |
|||
IS_SET); |
|||
|
|||
# define M_ASN1_I2D_len_IMP_SET_opt_type(type,a,f,x) \ |
|||
if ((a != NULL) && (sk_##type##_num(a) != 0)) \ |
|||
ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \ |
|||
V_ASN1_CONTEXT_SPECIFIC,IS_SET); |
|||
|
|||
# define M_ASN1_I2D_len_IMP_SEQUENCE(a,f,x) \ |
|||
ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \ |
|||
IS_SEQUENCE); |
|||
|
|||
# define M_ASN1_I2D_len_IMP_SEQUENCE_opt(a,f,x) \ |
|||
if ((a != NULL) && (sk_num(a) != 0)) \ |
|||
ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \ |
|||
IS_SEQUENCE); |
|||
|
|||
# define M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(type,a,f,x) \ |
|||
if ((a != NULL) && (sk_##type##_num(a) != 0)) \ |
|||
ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \ |
|||
V_ASN1_CONTEXT_SPECIFIC, \ |
|||
IS_SEQUENCE); |
|||
|
|||
# define M_ASN1_I2D_len_EXP_opt(a,f,mtag,v) \ |
|||
if (a != NULL)\ |
|||
{ \ |
|||
v=f(a,NULL); \ |
|||
ret+=ASN1_object_size(1,v,mtag); \ |
|||
} |
|||
|
|||
# define M_ASN1_I2D_len_EXP_SET_opt(a,f,mtag,tag,v) \ |
|||
if ((a != NULL) && (sk_num(a) != 0))\ |
|||
{ \ |
|||
v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL,IS_SET); \ |
|||
ret+=ASN1_object_size(1,v,mtag); \ |
|||
} |
|||
|
|||
# define M_ASN1_I2D_len_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \ |
|||
if ((a != NULL) && (sk_num(a) != 0))\ |
|||
{ \ |
|||
v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL, \ |
|||
IS_SEQUENCE); \ |
|||
ret+=ASN1_object_size(1,v,mtag); \ |
|||
} |
|||
|
|||
# define M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \ |
|||
if ((a != NULL) && (sk_##type##_num(a) != 0))\ |
|||
{ \ |
|||
v=i2d_ASN1_SET_OF_##type(a,NULL,f,tag, \ |
|||
V_ASN1_UNIVERSAL, \ |
|||
IS_SEQUENCE); \ |
|||
ret+=ASN1_object_size(1,v,mtag); \ |
|||
} |
|||
|
|||
/* Put Macros */ |
|||
# define M_ASN1_I2D_put(a,f) f(a,&p) |
|||
|
|||
# define M_ASN1_I2D_put_IMP_opt(a,f,t) \ |
|||
if (a != NULL) \ |
|||
{ \ |
|||
unsigned char *q=p; \ |
|||
f(a,&p); \ |
|||
*q=(V_ASN1_CONTEXT_SPECIFIC|t|(*q&V_ASN1_CONSTRUCTED));\ |
|||
} |
|||
|
|||
# define M_ASN1_I2D_put_SET(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SET,\ |
|||
V_ASN1_UNIVERSAL,IS_SET) |
|||
# define M_ASN1_I2D_put_SET_type(type,a,f) \ |
|||
i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET) |
|||
# define M_ASN1_I2D_put_IMP_SET(a,f,x) i2d_ASN1_SET(a,&p,f,x,\ |
|||
V_ASN1_CONTEXT_SPECIFIC,IS_SET) |
|||
# define M_ASN1_I2D_put_IMP_SET_type(type,a,f,x) \ |
|||
i2d_ASN1_SET_OF_##type(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET) |
|||
# define M_ASN1_I2D_put_IMP_SEQUENCE(a,f,x) i2d_ASN1_SET(a,&p,f,x,\ |
|||
V_ASN1_CONTEXT_SPECIFIC,IS_SEQUENCE) |
|||
|
|||
# define M_ASN1_I2D_put_SEQUENCE(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SEQUENCE,\ |
|||
V_ASN1_UNIVERSAL,IS_SEQUENCE) |
|||
|
|||
# define M_ASN1_I2D_put_SEQUENCE_type(type,a,f) \ |
|||
i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \ |
|||
IS_SEQUENCE) |
|||
|
|||
# define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \ |
|||
if ((a != NULL) && (sk_num(a) != 0)) \ |
|||
M_ASN1_I2D_put_SEQUENCE(a,f); |
|||
|
|||
# define M_ASN1_I2D_put_IMP_SET_opt(a,f,x) \ |
|||
if ((a != NULL) && (sk_num(a) != 0)) \ |
|||
{ i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \ |
|||
IS_SET); } |
|||
|
|||
# define M_ASN1_I2D_put_IMP_SET_opt_type(type,a,f,x) \ |
|||
if ((a != NULL) && (sk_##type##_num(a) != 0)) \ |
|||
{ i2d_ASN1_SET_OF_##type(a,&p,f,x, \ |
|||
V_ASN1_CONTEXT_SPECIFIC, \ |
|||
IS_SET); } |
|||
|
|||
# define M_ASN1_I2D_put_IMP_SEQUENCE_opt(a,f,x) \ |
|||
if ((a != NULL) && (sk_num(a) != 0)) \ |
|||
{ i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \ |
|||
IS_SEQUENCE); } |
|||
|
|||
# define M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(type,a,f,x) \ |
|||
if ((a != NULL) && (sk_##type##_num(a) != 0)) \ |
|||
{ i2d_ASN1_SET_OF_##type(a,&p,f,x, \ |
|||
V_ASN1_CONTEXT_SPECIFIC, \ |
|||
IS_SEQUENCE); } |
|||
|
|||
# define M_ASN1_I2D_put_EXP_opt(a,f,tag,v) \ |
|||
if (a != NULL) \ |
|||
{ \ |
|||
ASN1_put_object(&p,1,v,tag,V_ASN1_CONTEXT_SPECIFIC); \ |
|||
f(a,&p); \ |
|||
} |
|||
|
|||
# define M_ASN1_I2D_put_EXP_SET_opt(a,f,mtag,tag,v) \ |
|||
if ((a != NULL) && (sk_num(a) != 0)) \ |
|||
{ \ |
|||
ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \ |
|||
i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SET); \ |
|||
} |
|||
|
|||
# define M_ASN1_I2D_put_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \ |
|||
if ((a != NULL) && (sk_num(a) != 0)) \ |
|||
{ \ |
|||
ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \ |
|||
i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SEQUENCE); \ |
|||
} |
|||
|
|||
# define M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \ |
|||
if ((a != NULL) && (sk_##type##_num(a) != 0)) \ |
|||
{ \ |
|||
ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \ |
|||
i2d_ASN1_SET_OF_##type(a,&p,f,tag,V_ASN1_UNIVERSAL, \ |
|||
IS_SEQUENCE); \ |
|||
} |
|||
|
|||
# define M_ASN1_I2D_seq_total() \ |
|||
r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); \ |
|||
if (pp == NULL) return(r); \ |
|||
p= *pp; \ |
|||
ASN1_put_object(&p,1,ret,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL) |
|||
|
|||
# define M_ASN1_I2D_INF_seq_start(tag,ctx) \ |
|||
*(p++)=(V_ASN1_CONSTRUCTED|(tag)|(ctx)); \ |
|||
*(p++)=0x80 |
|||
|
|||
# define M_ASN1_I2D_INF_seq_end() *(p++)=0x00; *(p++)=0x00 |
|||
|
|||
# define M_ASN1_I2D_finish() *pp=p; \ |
|||
return(r); |
|||
|
|||
int asn1_GetSequence(ASN1_const_CTX *c, long *length); |
|||
void asn1_add_error(const unsigned char *address, int offset); |
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
|
|||
#endif |
@ -1,973 +0,0 @@ |
|||
/* asn1t.h */ |
|||
/*
|
|||
* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project |
|||
* 2000. |
|||
*/ |
|||
/* ====================================================================
|
|||
* Copyright (c) 2000-2005 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 |
|||
* licensing@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_ASN1T_H |
|||
# define HEADER_ASN1T_H |
|||
|
|||
# include <stddef.h> |
|||
# include <openssl/e_os2.h> |
|||
# include <openssl/asn1.h> |
|||
|
|||
# ifdef OPENSSL_BUILD_SHLIBCRYPTO |
|||
# undef OPENSSL_EXTERN |
|||
# define OPENSSL_EXTERN OPENSSL_EXPORT |
|||
# endif |
|||
|
|||
/* ASN1 template defines, structures and functions */ |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION |
|||
|
|||
/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ |
|||
# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr)) |
|||
|
|||
/* Macros for start and end of ASN1_ITEM definition */ |
|||
|
|||
# define ASN1_ITEM_start(itname) \ |
|||
OPENSSL_GLOBAL const ASN1_ITEM itname##_it = { |
|||
|
|||
# define ASN1_ITEM_end(itname) \ |
|||
}; |
|||
|
|||
# else |
|||
|
|||
/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ |
|||
# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr())) |
|||
|
|||
/* Macros for start and end of ASN1_ITEM definition */ |
|||
|
|||
# define ASN1_ITEM_start(itname) \ |
|||
const ASN1_ITEM * itname##_it(void) \ |
|||
{ \ |
|||
static const ASN1_ITEM local_it = { |
|||
|
|||
# define ASN1_ITEM_end(itname) \ |
|||
}; \ |
|||
return &local_it; \ |
|||
} |
|||
|
|||
# endif |
|||
|
|||
/* Macros to aid ASN1 template writing */ |
|||
|
|||
# define ASN1_ITEM_TEMPLATE(tname) \ |
|||
static const ASN1_TEMPLATE tname##_item_tt |
|||
|
|||
# define ASN1_ITEM_TEMPLATE_END(tname) \ |
|||
;\ |
|||
ASN1_ITEM_start(tname) \ |
|||
ASN1_ITYPE_PRIMITIVE,\ |
|||
-1,\ |
|||
&tname##_item_tt,\ |
|||
0,\ |
|||
NULL,\ |
|||
0,\ |
|||
#tname \ |
|||
ASN1_ITEM_end(tname) |
|||
|
|||
/* This is a ASN1 type which just embeds a template */ |
|||
|
|||
/*-
|
|||
* This pair helps declare a SEQUENCE. We can do: |
|||
* |
|||
* ASN1_SEQUENCE(stname) = { |
|||
* ... SEQUENCE components ... |
|||
* } ASN1_SEQUENCE_END(stname) |
|||
* |
|||
* This will produce an ASN1_ITEM called stname_it |
|||
* for a structure called stname. |
|||
* |
|||
* If you want the same structure but a different |
|||
* name then use: |
|||
* |
|||
* ASN1_SEQUENCE(itname) = { |
|||
* ... SEQUENCE components ... |
|||
* } ASN1_SEQUENCE_END_name(stname, itname) |
|||
* |
|||
* This will create an item called itname_it using |
|||
* a structure called stname. |
|||
*/ |
|||
|
|||
# define ASN1_SEQUENCE(tname) \ |
|||
static const ASN1_TEMPLATE tname##_seq_tt[] |
|||
|
|||
# define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname) |
|||
|
|||
# define ASN1_SEQUENCE_END_name(stname, tname) \ |
|||
;\ |
|||
ASN1_ITEM_start(tname) \ |
|||
ASN1_ITYPE_SEQUENCE,\ |
|||
V_ASN1_SEQUENCE,\ |
|||
tname##_seq_tt,\ |
|||
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ |
|||
NULL,\ |
|||
sizeof(stname),\ |
|||
#stname \ |
|||
ASN1_ITEM_end(tname) |
|||
|
|||
# define ASN1_NDEF_SEQUENCE(tname) \ |
|||
ASN1_SEQUENCE(tname) |
|||
|
|||
# define ASN1_NDEF_SEQUENCE_cb(tname, cb) \ |
|||
ASN1_SEQUENCE_cb(tname, cb) |
|||
|
|||
# define ASN1_SEQUENCE_cb(tname, cb) \ |
|||
static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ |
|||
ASN1_SEQUENCE(tname) |
|||
|
|||
# define ASN1_BROKEN_SEQUENCE(tname) \ |
|||
static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \ |
|||
ASN1_SEQUENCE(tname) |
|||
|
|||
# define ASN1_SEQUENCE_ref(tname, cb, lck) \ |
|||
static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; \ |
|||
ASN1_SEQUENCE(tname) |
|||
|
|||
# define ASN1_SEQUENCE_enc(tname, enc, cb) \ |
|||
static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \ |
|||
ASN1_SEQUENCE(tname) |
|||
|
|||
# define ASN1_NDEF_SEQUENCE_END(tname) \ |
|||
;\ |
|||
ASN1_ITEM_start(tname) \ |
|||
ASN1_ITYPE_NDEF_SEQUENCE,\ |
|||
V_ASN1_SEQUENCE,\ |
|||
tname##_seq_tt,\ |
|||
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ |
|||
NULL,\ |
|||
sizeof(tname),\ |
|||
#tname \ |
|||
ASN1_ITEM_end(tname) |
|||
|
|||
# define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname) |
|||
|
|||
# define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) |
|||
|
|||
# define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) |
|||
|
|||
# define ASN1_SEQUENCE_END_ref(stname, tname) \ |
|||
;\ |
|||
ASN1_ITEM_start(tname) \ |
|||
ASN1_ITYPE_SEQUENCE,\ |
|||
V_ASN1_SEQUENCE,\ |
|||
tname##_seq_tt,\ |
|||
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ |
|||
&tname##_aux,\ |
|||
sizeof(stname),\ |
|||
#stname \ |
|||
ASN1_ITEM_end(tname) |
|||
|
|||
# define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \ |
|||
;\ |
|||
ASN1_ITEM_start(tname) \ |
|||
ASN1_ITYPE_NDEF_SEQUENCE,\ |
|||
V_ASN1_SEQUENCE,\ |
|||
tname##_seq_tt,\ |
|||
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ |
|||
&tname##_aux,\ |
|||
sizeof(stname),\ |
|||
#stname \ |
|||
ASN1_ITEM_end(tname) |
|||
|
|||
/*-
|
|||
* This pair helps declare a CHOICE type. We can do: |
|||
* |
|||
* ASN1_CHOICE(chname) = { |
|||
* ... CHOICE options ... |
|||
* ASN1_CHOICE_END(chname) |
|||
* |
|||
* This will produce an ASN1_ITEM called chname_it |
|||
* for a structure called chname. The structure |
|||
* definition must look like this: |
|||
* typedef struct { |
|||
* int type; |
|||
* union { |
|||
* ASN1_SOMETHING *opt1; |
|||
* ASN1_SOMEOTHER *opt2; |
|||
* } value; |
|||
* } chname; |
|||
* |
|||
* the name of the selector must be 'type'. |
|||
* to use an alternative selector name use the |
|||
* ASN1_CHOICE_END_selector() version. |
|||
*/ |
|||
|
|||
# define ASN1_CHOICE(tname) \ |
|||
static const ASN1_TEMPLATE tname##_ch_tt[] |
|||
|
|||
# define ASN1_CHOICE_cb(tname, cb) \ |
|||
static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ |
|||
ASN1_CHOICE(tname) |
|||
|
|||
# define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname) |
|||
|
|||
# define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type) |
|||
|
|||
# define ASN1_CHOICE_END_selector(stname, tname, selname) \ |
|||
;\ |
|||
ASN1_ITEM_start(tname) \ |
|||
ASN1_ITYPE_CHOICE,\ |
|||
offsetof(stname,selname) ,\ |
|||
tname##_ch_tt,\ |
|||
sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ |
|||
NULL,\ |
|||
sizeof(stname),\ |
|||
#stname \ |
|||
ASN1_ITEM_end(tname) |
|||
|
|||
# define ASN1_CHOICE_END_cb(stname, tname, selname) \ |
|||
;\ |
|||
ASN1_ITEM_start(tname) \ |
|||
ASN1_ITYPE_CHOICE,\ |
|||
offsetof(stname,selname) ,\ |
|||
tname##_ch_tt,\ |
|||
sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ |
|||
&tname##_aux,\ |
|||
sizeof(stname),\ |
|||
#stname \ |
|||
ASN1_ITEM_end(tname) |
|||
|
|||
/* This helps with the template wrapper form of ASN1_ITEM */ |
|||
|
|||
# define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \ |
|||
(flags), (tag), 0,\ |
|||
#name, ASN1_ITEM_ref(type) } |
|||
|
|||
/* These help with SEQUENCE or CHOICE components */ |
|||
|
|||
/* used to declare other types */ |
|||
|
|||
# define ASN1_EX_TYPE(flags, tag, stname, field, type) { \ |
|||
(flags), (tag), offsetof(stname, field),\ |
|||
#field, ASN1_ITEM_ref(type) } |
|||
|
|||
/* used when the structure is combined with the parent */ |
|||
|
|||
# define ASN1_EX_COMBINE(flags, tag, type) { \ |
|||
(flags)|ASN1_TFLG_COMBINE, (tag), 0, NULL, ASN1_ITEM_ref(type) } |
|||
|
|||
/* implicit and explicit helper macros */ |
|||
|
|||
# define ASN1_IMP_EX(stname, field, type, tag, ex) \ |
|||
ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type) |
|||
|
|||
# define ASN1_EXP_EX(stname, field, type, tag, ex) \ |
|||
ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type) |
|||
|
|||
/* Any defined by macros: the field used is in the table itself */ |
|||
|
|||
# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION |
|||
# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } |
|||
# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } |
|||
# else |
|||
# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb } |
|||
# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb } |
|||
# endif |
|||
/* Plain simple type */ |
|||
# define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type) |
|||
|
|||
/* OPTIONAL simple type */ |
|||
# define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type) |
|||
|
|||
/* IMPLICIT tagged simple type */ |
|||
# define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0) |
|||
|
|||
/* IMPLICIT tagged OPTIONAL simple type */ |
|||
# define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) |
|||
|
|||
/* Same as above but EXPLICIT */ |
|||
|
|||
# define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0) |
|||
# define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) |
|||
|
|||
/* SEQUENCE OF type */ |
|||
# define ASN1_SEQUENCE_OF(stname, field, type) \ |
|||
ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type) |
|||
|
|||
/* OPTIONAL SEQUENCE OF */ |
|||
# define ASN1_SEQUENCE_OF_OPT(stname, field, type) \ |
|||
ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) |
|||
|
|||
/* Same as above but for SET OF */ |
|||
|
|||
# define ASN1_SET_OF(stname, field, type) \ |
|||
ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type) |
|||
|
|||
# define ASN1_SET_OF_OPT(stname, field, type) \ |
|||
ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) |
|||
|
|||
/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */ |
|||
|
|||
# define ASN1_IMP_SET_OF(stname, field, type, tag) \ |
|||
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) |
|||
|
|||
# define ASN1_EXP_SET_OF(stname, field, type, tag) \ |
|||
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) |
|||
|
|||
# define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \ |
|||
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) |
|||
|
|||
# define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \ |
|||
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) |
|||
|
|||
# define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \ |
|||
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) |
|||
|
|||
# define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \ |
|||
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) |
|||
|
|||
# define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \ |
|||
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) |
|||
|
|||
# define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \ |
|||
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) |
|||
|
|||
/* EXPLICIT using indefinite length constructed form */ |
|||
# define ASN1_NDEF_EXP(stname, field, type, tag) \ |
|||
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF) |
|||
|
|||
/* EXPLICIT OPTIONAL using indefinite length constructed form */ |
|||
# define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \ |
|||
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF) |
|||
|
|||
/* Macros for the ASN1_ADB structure */ |
|||
|
|||
# define ASN1_ADB(name) \ |
|||
static const ASN1_ADB_TABLE name##_adbtbl[] |
|||
|
|||
# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION |
|||
|
|||
# define ASN1_ADB_END(name, flags, field, app_table, def, none) \ |
|||
;\ |
|||
static const ASN1_ADB name##_adb = {\ |
|||
flags,\ |
|||
offsetof(name, field),\ |
|||
app_table,\ |
|||
name##_adbtbl,\ |
|||
sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ |
|||
def,\ |
|||
none\ |
|||
} |
|||
|
|||
# else |
|||
|
|||
# define ASN1_ADB_END(name, flags, field, app_table, def, none) \ |
|||
;\ |
|||
static const ASN1_ITEM *name##_adb(void) \ |
|||
{ \ |
|||
static const ASN1_ADB internal_adb = \ |
|||
{\ |
|||
flags,\ |
|||
offsetof(name, field),\ |
|||
app_table,\ |
|||
name##_adbtbl,\ |
|||
sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ |
|||
def,\ |
|||
none\ |
|||
}; \ |
|||
return (const ASN1_ITEM *) &internal_adb; \ |
|||
} \ |
|||
void dummy_function(void) |
|||
|
|||
# endif |
|||
|
|||
# define ADB_ENTRY(val, template) {val, template} |
|||
|
|||
# define ASN1_ADB_TEMPLATE(name) \ |
|||
static const ASN1_TEMPLATE name##_tt |
|||
|
|||
/*
|
|||
* This is the ASN1 template structure that defines a wrapper round the |
|||
* actual type. It determines the actual position of the field in the value |
|||
* structure, various flags such as OPTIONAL and the field name. |
|||
*/ |
|||
|
|||
struct ASN1_TEMPLATE_st { |
|||
unsigned long flags; /* Various flags */ |
|||
long tag; /* tag, not used if no tagging */ |
|||
unsigned long offset; /* Offset of this field in structure */ |
|||
# ifndef NO_ASN1_FIELD_NAMES |
|||
const char *field_name; /* Field name */ |
|||
# endif |
|||
ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */ |
|||
}; |
|||
|
|||
/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */ |
|||
|
|||
# define ASN1_TEMPLATE_item(t) (t->item_ptr) |
|||
# define ASN1_TEMPLATE_adb(t) (t->item_ptr) |
|||
|
|||
typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE; |
|||
typedef struct ASN1_ADB_st ASN1_ADB; |
|||
|
|||
struct ASN1_ADB_st { |
|||
unsigned long flags; /* Various flags */ |
|||
unsigned long offset; /* Offset of selector field */ |
|||
STACK_OF(ASN1_ADB_TABLE) **app_items; /* Application defined items */ |
|||
const ASN1_ADB_TABLE *tbl; /* Table of possible types */ |
|||
long tblcount; /* Number of entries in tbl */ |
|||
const ASN1_TEMPLATE *default_tt; /* Type to use if no match */ |
|||
const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */ |
|||
}; |
|||
|
|||
struct ASN1_ADB_TABLE_st { |
|||
long value; /* NID for an object or value for an int */ |
|||
const ASN1_TEMPLATE tt; /* item for this value */ |
|||
}; |
|||
|
|||
/* template flags */ |
|||
|
|||
/* Field is optional */ |
|||
# define ASN1_TFLG_OPTIONAL (0x1) |
|||
|
|||
/* Field is a SET OF */ |
|||
# define ASN1_TFLG_SET_OF (0x1 << 1) |
|||
|
|||
/* Field is a SEQUENCE OF */ |
|||
# define ASN1_TFLG_SEQUENCE_OF (0x2 << 1) |
|||
|
|||
/*
|
|||
* Special case: this refers to a SET OF that will be sorted into DER order |
|||
* when encoded *and* the corresponding STACK will be modified to match the |
|||
* new order. |
|||
*/ |
|||
# define ASN1_TFLG_SET_ORDER (0x3 << 1) |
|||
|
|||
/* Mask for SET OF or SEQUENCE OF */ |
|||
# define ASN1_TFLG_SK_MASK (0x3 << 1) |
|||
|
|||
/*
|
|||
* These flags mean the tag should be taken from the tag field. If EXPLICIT |
|||
* then the underlying type is used for the inner tag. |
|||
*/ |
|||
|
|||
/* IMPLICIT tagging */ |
|||
# define ASN1_TFLG_IMPTAG (0x1 << 3) |
|||
|
|||
/* EXPLICIT tagging, inner tag from underlying type */ |
|||
# define ASN1_TFLG_EXPTAG (0x2 << 3) |
|||
|
|||
# define ASN1_TFLG_TAG_MASK (0x3 << 3) |
|||
|
|||
/* context specific IMPLICIT */ |
|||
# define ASN1_TFLG_IMPLICIT ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT |
|||
|
|||
/* context specific EXPLICIT */ |
|||
# define ASN1_TFLG_EXPLICIT ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT |
|||
|
|||
/*
|
|||
* If tagging is in force these determine the type of tag to use. Otherwise |
|||
* the tag is determined by the underlying type. These values reflect the |
|||
* actual octet format. |
|||
*/ |
|||
|
|||
/* Universal tag */ |
|||
# define ASN1_TFLG_UNIVERSAL (0x0<<6) |
|||
/* Application tag */ |
|||
# define ASN1_TFLG_APPLICATION (0x1<<6) |
|||
/* Context specific tag */ |
|||
# define ASN1_TFLG_CONTEXT (0x2<<6) |
|||
/* Private tag */ |
|||
# define ASN1_TFLG_PRIVATE (0x3<<6) |
|||
|
|||
# define ASN1_TFLG_TAG_CLASS (0x3<<6) |
|||
|
|||
/*
|
|||
* These are for ANY DEFINED BY type. In this case the 'item' field points to |
|||
* an ASN1_ADB structure which contains a table of values to decode the |
|||
* relevant type |
|||
*/ |
|||
|
|||
# define ASN1_TFLG_ADB_MASK (0x3<<8) |
|||
|
|||
# define ASN1_TFLG_ADB_OID (0x1<<8) |
|||
|
|||
# define ASN1_TFLG_ADB_INT (0x1<<9) |
|||
|
|||
/*
|
|||
* This flag means a parent structure is passed instead of the field: this is |
|||
* useful is a SEQUENCE is being combined with a CHOICE for example. Since |
|||
* this means the structure and item name will differ we need to use the |
|||
* ASN1_CHOICE_END_name() macro for example. |
|||
*/ |
|||
|
|||
# define ASN1_TFLG_COMBINE (0x1<<10) |
|||
|
|||
/*
|
|||
* This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes |
|||
* indefinite length constructed encoding to be used if required. |
|||
*/ |
|||
|
|||
# define ASN1_TFLG_NDEF (0x1<<11) |
|||
|
|||
/* This is the actual ASN1 item itself */ |
|||
|
|||
struct ASN1_ITEM_st { |
|||
char itype; /* The item type, primitive, SEQUENCE, CHOICE
|
|||
* or extern */ |
|||
long utype; /* underlying type */ |
|||
const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains
|
|||
* the contents */ |
|||
long tcount; /* Number of templates if SEQUENCE or CHOICE */ |
|||
const void *funcs; /* functions that handle this type */ |
|||
long size; /* Structure size (usually) */ |
|||
# ifndef NO_ASN1_FIELD_NAMES |
|||
const char *sname; /* Structure name */ |
|||
# endif |
|||
}; |
|||
|
|||
/*-
|
|||
* These are values for the itype field and |
|||
* determine how the type is interpreted. |
|||
* |
|||
* For PRIMITIVE types the underlying type |
|||
* determines the behaviour if items is NULL. |
|||
* |
|||
* Otherwise templates must contain a single |
|||
* template and the type is treated in the |
|||
* same way as the type specified in the template. |
|||
* |
|||
* For SEQUENCE types the templates field points |
|||
* to the members, the size field is the |
|||
* structure size. |
|||
* |
|||
* For CHOICE types the templates field points |
|||
* to each possible member (typically a union) |
|||
* and the 'size' field is the offset of the |
|||
* selector. |
|||
* |
|||
* The 'funcs' field is used for application |
|||
* specific functions. |
|||
* |
|||
* For COMPAT types the funcs field gives a |
|||
* set of functions that handle this type, this |
|||
* supports the old d2i, i2d convention. |
|||
* |
|||
* The EXTERN type uses a new style d2i/i2d. |
|||
* The new style should be used where possible |
|||
* because it avoids things like the d2i IMPLICIT |
|||
* hack. |
|||
* |
|||
* MSTRING is a multiple string type, it is used |
|||
* for a CHOICE of character strings where the |
|||
* actual strings all occupy an ASN1_STRING |
|||
* structure. In this case the 'utype' field |
|||
* has a special meaning, it is used as a mask |
|||
* of acceptable types using the B_ASN1 constants. |
|||
* |
|||
* NDEF_SEQUENCE is the same as SEQUENCE except |
|||
* that it will use indefinite length constructed |
|||
* encoding if requested. |
|||
* |
|||
*/ |
|||
|
|||
# define ASN1_ITYPE_PRIMITIVE 0x0 |
|||
|
|||
# define ASN1_ITYPE_SEQUENCE 0x1 |
|||
|
|||
# define ASN1_ITYPE_CHOICE 0x2 |
|||
|
|||
# define ASN1_ITYPE_COMPAT 0x3 |
|||
|
|||
# define ASN1_ITYPE_EXTERN 0x4 |
|||
|
|||
# define ASN1_ITYPE_MSTRING 0x5 |
|||
|
|||
# define ASN1_ITYPE_NDEF_SEQUENCE 0x6 |
|||
|
|||
/*
|
|||
* Cache for ASN1 tag and length, so we don't keep re-reading it for things |
|||
* like CHOICE |
|||
*/ |
|||
|
|||
struct ASN1_TLC_st { |
|||
char valid; /* Values below are valid */ |
|||
int ret; /* return value */ |
|||
long plen; /* length */ |
|||
int ptag; /* class value */ |
|||
int pclass; /* class value */ |
|||
int hdrlen; /* header length */ |
|||
}; |
|||
|
|||
/* Typedefs for ASN1 function pointers */ |
|||
|
|||
typedef ASN1_VALUE *ASN1_new_func(void); |
|||
typedef void ASN1_free_func(ASN1_VALUE *a); |
|||
typedef ASN1_VALUE *ASN1_d2i_func(ASN1_VALUE **a, const unsigned char **in, |
|||
long length); |
|||
typedef int ASN1_i2d_func(ASN1_VALUE *a, unsigned char **in); |
|||
|
|||
typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, |
|||
const ASN1_ITEM *it, int tag, int aclass, char opt, |
|||
ASN1_TLC *ctx); |
|||
|
|||
typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out, |
|||
const ASN1_ITEM *it, int tag, int aclass); |
|||
typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it); |
|||
typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it); |
|||
|
|||
typedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval, |
|||
int indent, const char *fname, |
|||
const ASN1_PCTX *pctx); |
|||
|
|||
typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, |
|||
int *putype, const ASN1_ITEM *it); |
|||
typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, |
|||
int len, int utype, char *free_cont, |
|||
const ASN1_ITEM *it); |
|||
typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval, |
|||
const ASN1_ITEM *it, int indent, |
|||
const ASN1_PCTX *pctx); |
|||
|
|||
typedef struct ASN1_COMPAT_FUNCS_st { |
|||
ASN1_new_func *asn1_new; |
|||
ASN1_free_func *asn1_free; |
|||
ASN1_d2i_func *asn1_d2i; |
|||
ASN1_i2d_func *asn1_i2d; |
|||
} ASN1_COMPAT_FUNCS; |
|||
|
|||
typedef struct ASN1_EXTERN_FUNCS_st { |
|||
void *app_data; |
|||
ASN1_ex_new_func *asn1_ex_new; |
|||
ASN1_ex_free_func *asn1_ex_free; |
|||
ASN1_ex_free_func *asn1_ex_clear; |
|||
ASN1_ex_d2i *asn1_ex_d2i; |
|||
ASN1_ex_i2d *asn1_ex_i2d; |
|||
ASN1_ex_print_func *asn1_ex_print; |
|||
} ASN1_EXTERN_FUNCS; |
|||
|
|||
typedef struct ASN1_PRIMITIVE_FUNCS_st { |
|||
void *app_data; |
|||
unsigned long flags; |
|||
ASN1_ex_new_func *prim_new; |
|||
ASN1_ex_free_func *prim_free; |
|||
ASN1_ex_free_func *prim_clear; |
|||
ASN1_primitive_c2i *prim_c2i; |
|||
ASN1_primitive_i2c *prim_i2c; |
|||
ASN1_primitive_print *prim_print; |
|||
} ASN1_PRIMITIVE_FUNCS; |
|||
|
|||
/*
|
|||
* This is the ASN1_AUX structure: it handles various miscellaneous |
|||
* requirements. For example the use of reference counts and an informational |
|||
* callback. The "informational callback" is called at various points during |
|||
* the ASN1 encoding and decoding. It can be used to provide minor |
|||
* customisation of the structures used. This is most useful where the |
|||
* supplied routines *almost* do the right thing but need some extra help at |
|||
* a few points. If the callback returns zero then it is assumed a fatal |
|||
* error has occurred and the main operation should be abandoned. If major |
|||
* changes in the default behaviour are required then an external type is |
|||
* more appropriate. |
|||
*/ |
|||
|
|||
typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it, |
|||
void *exarg); |
|||
|
|||
typedef struct ASN1_AUX_st { |
|||
void *app_data; |
|||
int flags; |
|||
int ref_offset; /* Offset of reference value */ |
|||
int ref_lock; /* Lock type to use */ |
|||
ASN1_aux_cb *asn1_cb; |
|||
int enc_offset; /* Offset of ASN1_ENCODING structure */ |
|||
} ASN1_AUX; |
|||
|
|||
/* For print related callbacks exarg points to this structure */ |
|||
typedef struct ASN1_PRINT_ARG_st { |
|||
BIO *out; |
|||
int indent; |
|||
const ASN1_PCTX *pctx; |
|||
} ASN1_PRINT_ARG; |
|||
|
|||
/* For streaming related callbacks exarg points to this structure */ |
|||
typedef struct ASN1_STREAM_ARG_st { |
|||
/* BIO to stream through */ |
|||
BIO *out; |
|||
/* BIO with filters appended */ |
|||
BIO *ndef_bio; |
|||
/* Streaming I/O boundary */ |
|||
unsigned char **boundary; |
|||
} ASN1_STREAM_ARG; |
|||
|
|||
/* Flags in ASN1_AUX */ |
|||
|
|||
/* Use a reference count */ |
|||
# define ASN1_AFLG_REFCOUNT 1 |
|||
/* Save the encoding of structure (useful for signatures) */ |
|||
# define ASN1_AFLG_ENCODING 2 |
|||
/* The Sequence length is invalid */ |
|||
# define ASN1_AFLG_BROKEN 4 |
|||
|
|||
/* operation values for asn1_cb */ |
|||
|
|||
# define ASN1_OP_NEW_PRE 0 |
|||
# define ASN1_OP_NEW_POST 1 |
|||
# define ASN1_OP_FREE_PRE 2 |
|||
# define ASN1_OP_FREE_POST 3 |
|||
# define ASN1_OP_D2I_PRE 4 |
|||
# define ASN1_OP_D2I_POST 5 |
|||
# define ASN1_OP_I2D_PRE 6 |
|||
# define ASN1_OP_I2D_POST 7 |
|||
# define ASN1_OP_PRINT_PRE 8 |
|||
# define ASN1_OP_PRINT_POST 9 |
|||
# define ASN1_OP_STREAM_PRE 10 |
|||
# define ASN1_OP_STREAM_POST 11 |
|||
# define ASN1_OP_DETACHED_PRE 12 |
|||
# define ASN1_OP_DETACHED_POST 13 |
|||
|
|||
/* Macro to implement a primitive type */ |
|||
# define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0) |
|||
# define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \ |
|||
ASN1_ITEM_start(itname) \ |
|||
ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \ |
|||
ASN1_ITEM_end(itname) |
|||
|
|||
/* Macro to implement a multi string type */ |
|||
# define IMPLEMENT_ASN1_MSTRING(itname, mask) \ |
|||
ASN1_ITEM_start(itname) \ |
|||
ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \ |
|||
ASN1_ITEM_end(itname) |
|||
|
|||
/* Macro to implement an ASN1_ITEM in terms of old style funcs */ |
|||
|
|||
# define IMPLEMENT_COMPAT_ASN1(sname) IMPLEMENT_COMPAT_ASN1_type(sname, V_ASN1_SEQUENCE) |
|||
|
|||
# define IMPLEMENT_COMPAT_ASN1_type(sname, tag) \ |
|||
static const ASN1_COMPAT_FUNCS sname##_ff = { \ |
|||
(ASN1_new_func *)sname##_new, \ |
|||
(ASN1_free_func *)sname##_free, \ |
|||
(ASN1_d2i_func *)d2i_##sname, \ |
|||
(ASN1_i2d_func *)i2d_##sname, \ |
|||
}; \ |
|||
ASN1_ITEM_start(sname) \ |
|||
ASN1_ITYPE_COMPAT, \ |
|||
tag, \ |
|||
NULL, \ |
|||
0, \ |
|||
&sname##_ff, \ |
|||
0, \ |
|||
#sname \ |
|||
ASN1_ITEM_end(sname) |
|||
|
|||
# define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \ |
|||
ASN1_ITEM_start(sname) \ |
|||
ASN1_ITYPE_EXTERN, \ |
|||
tag, \ |
|||
NULL, \ |
|||
0, \ |
|||
&fptrs, \ |
|||
0, \ |
|||
#sname \ |
|||
ASN1_ITEM_end(sname) |
|||
|
|||
/* Macro to implement standard functions in terms of ASN1_ITEM structures */ |
|||
|
|||
# define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname) |
|||
|
|||
# define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname) |
|||
|
|||
# define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \ |
|||
IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname) |
|||
|
|||
# define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \ |
|||
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname) |
|||
|
|||
# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \ |
|||
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname) |
|||
|
|||
# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \ |
|||
pre stname *fname##_new(void) \ |
|||
{ \ |
|||
return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ |
|||
} \ |
|||
pre void fname##_free(stname *a) \ |
|||
{ \ |
|||
ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ |
|||
} |
|||
|
|||
# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \ |
|||
stname *fname##_new(void) \ |
|||
{ \ |
|||
return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ |
|||
} \ |
|||
void fname##_free(stname *a) \ |
|||
{ \ |
|||
ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ |
|||
} |
|||
|
|||
# define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \ |
|||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ |
|||
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) |
|||
|
|||
# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ |
|||
stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ |
|||
{ \ |
|||
return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ |
|||
} \ |
|||
int i2d_##fname(stname *a, unsigned char **out) \ |
|||
{ \ |
|||
return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ |
|||
} |
|||
|
|||
# define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \ |
|||
int i2d_##stname##_NDEF(stname *a, unsigned char **out) \ |
|||
{ \ |
|||
return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\ |
|||
} |
|||
|
|||
/*
|
|||
* This includes evil casts to remove const: they will go away when full ASN1 |
|||
* constification is done. |
|||
*/ |
|||
# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ |
|||
stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ |
|||
{ \ |
|||
return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ |
|||
} \ |
|||
int i2d_##fname(const stname *a, unsigned char **out) \ |
|||
{ \ |
|||
return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ |
|||
} |
|||
|
|||
# define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \ |
|||
stname * stname##_dup(stname *x) \ |
|||
{ \ |
|||
return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \ |
|||
} |
|||
|
|||
# define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \ |
|||
IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname) |
|||
|
|||
# define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \ |
|||
int fname##_print_ctx(BIO *out, stname *x, int indent, \ |
|||
const ASN1_PCTX *pctx) \ |
|||
{ \ |
|||
return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \ |
|||
ASN1_ITEM_rptr(itname), pctx); \ |
|||
} |
|||
|
|||
# define IMPLEMENT_ASN1_FUNCTIONS_const(name) \ |
|||
IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name) |
|||
|
|||
# define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \ |
|||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ |
|||
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) |
|||
|
|||
/* external definitions for primitive types */ |
|||
|
|||
DECLARE_ASN1_ITEM(ASN1_BOOLEAN) |
|||
DECLARE_ASN1_ITEM(ASN1_TBOOLEAN) |
|||
DECLARE_ASN1_ITEM(ASN1_FBOOLEAN) |
|||
DECLARE_ASN1_ITEM(ASN1_SEQUENCE) |
|||
DECLARE_ASN1_ITEM(CBIGNUM) |
|||
DECLARE_ASN1_ITEM(BIGNUM) |
|||
DECLARE_ASN1_ITEM(LONG) |
|||
DECLARE_ASN1_ITEM(ZLONG) |
|||
|
|||
DECLARE_STACK_OF(ASN1_VALUE) |
|||
|
|||
/* Functions used internally by the ASN1 code */ |
|||
|
|||
int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it); |
|||
void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it); |
|||
int ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); |
|||
int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it); |
|||
|
|||
void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); |
|||
int ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, |
|||
const ASN1_TEMPLATE *tt); |
|||
int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, |
|||
const ASN1_ITEM *it, int tag, int aclass, char opt, |
|||
ASN1_TLC *ctx); |
|||
|
|||
int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, |
|||
const ASN1_ITEM *it, int tag, int aclass); |
|||
int ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out, |
|||
const ASN1_TEMPLATE *tt); |
|||
void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it); |
|||
|
|||
int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, |
|||
const ASN1_ITEM *it); |
|||
int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, |
|||
int utype, char *free_cont, const ASN1_ITEM *it); |
|||
|
|||
int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it); |
|||
int asn1_set_choice_selector(ASN1_VALUE **pval, int value, |
|||
const ASN1_ITEM *it); |
|||
|
|||
ASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); |
|||
|
|||
const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, |
|||
int nullerr); |
|||
|
|||
int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it); |
|||
|
|||
void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it); |
|||
void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it); |
|||
int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval, |
|||
const ASN1_ITEM *it); |
|||
int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, |
|||
const ASN1_ITEM *it); |
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
#endif |
@ -1,883 +0,0 @@ |
|||
/* crypto/bio/bio.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_BIO_H |
|||
# define HEADER_BIO_H |
|||
|
|||
# include <openssl/e_os2.h> |
|||
|
|||
# ifndef OPENSSL_NO_FP_API |
|||
# include <stdio.h> |
|||
# endif |
|||
# include <stdarg.h> |
|||
|
|||
# include <openssl/crypto.h> |
|||
|
|||
# ifndef OPENSSL_NO_SCTP |
|||
# ifndef OPENSSL_SYS_VMS |
|||
# include <stdint.h> |
|||
# else |
|||
# include <inttypes.h> |
|||
# endif |
|||
# endif |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
/* These are the 'types' of BIOs */ |
|||
# define BIO_TYPE_NONE 0 |
|||
# define BIO_TYPE_MEM (1|0x0400) |
|||
# define BIO_TYPE_FILE (2|0x0400) |
|||
|
|||
# define BIO_TYPE_FD (4|0x0400|0x0100) |
|||
# define BIO_TYPE_SOCKET (5|0x0400|0x0100) |
|||
# define BIO_TYPE_NULL (6|0x0400) |
|||
# define BIO_TYPE_SSL (7|0x0200) |
|||
# define BIO_TYPE_MD (8|0x0200)/* passive filter */ |
|||
# define BIO_TYPE_BUFFER (9|0x0200)/* filter */ |
|||
# define BIO_TYPE_CIPHER (10|0x0200)/* filter */ |
|||
# define BIO_TYPE_BASE64 (11|0x0200)/* filter */ |
|||
# define BIO_TYPE_CONNECT (12|0x0400|0x0100)/* socket - connect */ |
|||
# define BIO_TYPE_ACCEPT (13|0x0400|0x0100)/* socket for accept */ |
|||
# define BIO_TYPE_PROXY_CLIENT (14|0x0200)/* client proxy BIO */ |
|||
# define BIO_TYPE_PROXY_SERVER (15|0x0200)/* server proxy BIO */ |
|||
# define BIO_TYPE_NBIO_TEST (16|0x0200)/* server proxy BIO */ |
|||
# define BIO_TYPE_NULL_FILTER (17|0x0200) |
|||
# define BIO_TYPE_BER (18|0x0200)/* BER -> bin filter */ |
|||
# define BIO_TYPE_BIO (19|0x0400)/* (half a) BIO pair */ |
|||
# define BIO_TYPE_LINEBUFFER (20|0x0200)/* filter */ |
|||
# define BIO_TYPE_DGRAM (21|0x0400|0x0100) |
|||
# ifndef OPENSSL_NO_SCTP |
|||
# define BIO_TYPE_DGRAM_SCTP (24|0x0400|0x0100) |
|||
# endif |
|||
# define BIO_TYPE_ASN1 (22|0x0200)/* filter */ |
|||
# define BIO_TYPE_COMP (23|0x0200)/* filter */ |
|||
|
|||
# define BIO_TYPE_DESCRIPTOR 0x0100/* socket, fd, connect or accept */ |
|||
# define BIO_TYPE_FILTER 0x0200 |
|||
# define BIO_TYPE_SOURCE_SINK 0x0400 |
|||
|
|||
/*
|
|||
* BIO_FILENAME_READ|BIO_CLOSE to open or close on free. |
|||
* BIO_set_fp(in,stdin,BIO_NOCLOSE); |
|||
*/ |
|||
# define BIO_NOCLOSE 0x00 |
|||
# define BIO_CLOSE 0x01 |
|||
|
|||
/*
|
|||
* These are used in the following macros and are passed to BIO_ctrl() |
|||
*/ |
|||
# define BIO_CTRL_RESET 1/* opt - rewind/zero etc */ |
|||
# define BIO_CTRL_EOF 2/* opt - are we at the eof */ |
|||
# define BIO_CTRL_INFO 3/* opt - extra tit-bits */ |
|||
# define BIO_CTRL_SET 4/* man - set the 'IO' type */ |
|||
# define BIO_CTRL_GET 5/* man - get the 'IO' type */ |
|||
# define BIO_CTRL_PUSH 6/* opt - internal, used to signify change */ |
|||
# define BIO_CTRL_POP 7/* opt - internal, used to signify change */ |
|||
# define BIO_CTRL_GET_CLOSE 8/* man - set the 'close' on free */ |
|||
# define BIO_CTRL_SET_CLOSE 9/* man - set the 'close' on free */ |
|||
# define BIO_CTRL_PENDING 10/* opt - is their more data buffered */ |
|||
# define BIO_CTRL_FLUSH 11/* opt - 'flush' buffered output */ |
|||
# define BIO_CTRL_DUP 12/* man - extra stuff for 'duped' BIO */ |
|||
# define BIO_CTRL_WPENDING 13/* opt - number of bytes still to write */ |
|||
/* callback is int cb(BIO *bio,state,ret); */ |
|||
# define BIO_CTRL_SET_CALLBACK 14/* opt - set callback function */ |
|||
# define BIO_CTRL_GET_CALLBACK 15/* opt - set callback function */ |
|||
|
|||
# define BIO_CTRL_SET_FILENAME 30/* BIO_s_file special */ |
|||
|
|||
/* dgram BIO stuff */ |
|||
# define BIO_CTRL_DGRAM_CONNECT 31/* BIO dgram special */ |
|||
# define BIO_CTRL_DGRAM_SET_CONNECTED 32/* allow for an externally connected |
|||
* socket to be passed in */ |
|||
# define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33/* setsockopt, essentially */ |
|||
# define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34/* getsockopt, essentially */ |
|||
# define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35/* setsockopt, essentially */ |
|||
# define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36/* getsockopt, essentially */ |
|||
|
|||
# define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37/* flag whether the last */ |
|||
# define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38/* I/O operation tiemd out */ |
|||
|
|||
/* #ifdef IP_MTU_DISCOVER */ |
|||
# define BIO_CTRL_DGRAM_MTU_DISCOVER 39/* set DF bit on egress packets */ |
|||
/* #endif */ |
|||
|
|||
# define BIO_CTRL_DGRAM_QUERY_MTU 40/* as kernel for current MTU */ |
|||
# define BIO_CTRL_DGRAM_GET_FALLBACK_MTU 47 |
|||
# define BIO_CTRL_DGRAM_GET_MTU 41/* get cached value for MTU */ |
|||
# define BIO_CTRL_DGRAM_SET_MTU 42/* set cached value for MTU. |
|||
* want to use this if asking |
|||
* the kernel fails */ |
|||
|
|||
# define BIO_CTRL_DGRAM_MTU_EXCEEDED 43/* check whether the MTU was |
|||
* exceed in the previous write |
|||
* operation */ |
|||
|
|||
# define BIO_CTRL_DGRAM_GET_PEER 46 |
|||
# define BIO_CTRL_DGRAM_SET_PEER 44/* Destination for the data */ |
|||
|
|||
# define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT 45/* Next DTLS handshake timeout |
|||
* to adjust socket timeouts */ |
|||
# define BIO_CTRL_DGRAM_SET_DONT_FRAG 48 |
|||
|
|||
# define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD 49 |
|||
|
|||
# ifndef OPENSSL_NO_SCTP |
|||
/* SCTP stuff */ |
|||
# define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE 50 |
|||
# define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY 51 |
|||
# define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY 52 |
|||
# define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD 53 |
|||
# define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO 60 |
|||
# define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO 61 |
|||
# define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO 62 |
|||
# define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO 63 |
|||
# define BIO_CTRL_DGRAM_SCTP_GET_PRINFO 64 |
|||
# define BIO_CTRL_DGRAM_SCTP_SET_PRINFO 65 |
|||
# define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN 70 |
|||
# endif |
|||
|
|||
/* modifiers */ |
|||
# define BIO_FP_READ 0x02 |
|||
# define BIO_FP_WRITE 0x04 |
|||
# define BIO_FP_APPEND 0x08 |
|||
# define BIO_FP_TEXT 0x10 |
|||
|
|||
# define BIO_FLAGS_READ 0x01 |
|||
# define BIO_FLAGS_WRITE 0x02 |
|||
# define BIO_FLAGS_IO_SPECIAL 0x04 |
|||
# define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL) |
|||
# define BIO_FLAGS_SHOULD_RETRY 0x08 |
|||
# ifndef BIO_FLAGS_UPLINK |
|||
/*
|
|||
* "UPLINK" flag denotes file descriptors provided by application. It |
|||
* defaults to 0, as most platforms don't require UPLINK interface. |
|||
*/ |
|||
# define BIO_FLAGS_UPLINK 0 |
|||
# endif |
|||
|
|||
/* Used in BIO_gethostbyname() */ |
|||
# define BIO_GHBN_CTRL_HITS 1 |
|||
# define BIO_GHBN_CTRL_MISSES 2 |
|||
# define BIO_GHBN_CTRL_CACHE_SIZE 3 |
|||
# define BIO_GHBN_CTRL_GET_ENTRY 4 |
|||
# define BIO_GHBN_CTRL_FLUSH 5 |
|||
|
|||
/* Mostly used in the SSL BIO */ |
|||
/*-
|
|||
* Not used anymore |
|||
* #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10 |
|||
* #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20 |
|||
* #define BIO_FLAGS_PROTOCOL_STARTUP 0x40 |
|||
*/ |
|||
|
|||
# define BIO_FLAGS_BASE64_NO_NL 0x100 |
|||
|
|||
/*
|
|||
* This is used with memory BIOs: it means we shouldn't free up or change the |
|||
* data in any way. |
|||
*/ |
|||
# define BIO_FLAGS_MEM_RDONLY 0x200 |
|||
|
|||
typedef struct bio_st BIO; |
|||
|
|||
void BIO_set_flags(BIO *b, int flags); |
|||
int BIO_test_flags(const BIO *b, int flags); |
|||
void BIO_clear_flags(BIO *b, int flags); |
|||
|
|||
# define BIO_get_flags(b) BIO_test_flags(b, ~(0x0)) |
|||
# define BIO_set_retry_special(b) \ |
|||
BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY)) |
|||
# define BIO_set_retry_read(b) \ |
|||
BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY)) |
|||
# define BIO_set_retry_write(b) \ |
|||
BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY)) |
|||
|
|||
/* These are normally used internally in BIOs */ |
|||
# define BIO_clear_retry_flags(b) \ |
|||
BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) |
|||
# define BIO_get_retry_flags(b) \ |
|||
BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) |
|||
|
|||
/* These should be used by the application to tell why we should retry */ |
|||
# define BIO_should_read(a) BIO_test_flags(a, BIO_FLAGS_READ) |
|||
# define BIO_should_write(a) BIO_test_flags(a, BIO_FLAGS_WRITE) |
|||
# define BIO_should_io_special(a) BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL) |
|||
# define BIO_retry_type(a) BIO_test_flags(a, BIO_FLAGS_RWS) |
|||
# define BIO_should_retry(a) BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY) |
|||
|
|||
/*
|
|||
* The next three are used in conjunction with the BIO_should_io_special() |
|||
* condition. After this returns true, BIO *BIO_get_retry_BIO(BIO *bio, int |
|||
* *reason); will walk the BIO stack and return the 'reason' for the special |
|||
* and the offending BIO. Given a BIO, BIO_get_retry_reason(bio) will return |
|||
* the code. |
|||
*/ |
|||
/*
|
|||
* Returned from the SSL bio when the certificate retrieval code had an error |
|||
*/ |
|||
# define BIO_RR_SSL_X509_LOOKUP 0x01 |
|||
/* Returned from the connect BIO when a connect would have blocked */ |
|||
# define BIO_RR_CONNECT 0x02 |
|||
/* Returned from the accept BIO when an accept would have blocked */ |
|||
# define BIO_RR_ACCEPT 0x03 |
|||
|
|||
/* These are passed by the BIO callback */ |
|||
# define BIO_CB_FREE 0x01 |
|||
# define BIO_CB_READ 0x02 |
|||
# define BIO_CB_WRITE 0x03 |
|||
# define BIO_CB_PUTS 0x04 |
|||
# define BIO_CB_GETS 0x05 |
|||
# define BIO_CB_CTRL 0x06 |
|||
|
|||
/*
|
|||
* The callback is called before and after the underling operation, The |
|||
* BIO_CB_RETURN flag indicates if it is after the call |
|||
*/ |
|||
# define BIO_CB_RETURN 0x80 |
|||
# define BIO_CB_return(a) ((a)|BIO_CB_RETURN) |
|||
# define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN)) |
|||
# define BIO_cb_post(a) ((a)&BIO_CB_RETURN) |
|||
|
|||
long (*BIO_get_callback(const BIO *b)) (struct bio_st *, int, const char *, |
|||
int, long, long); |
|||
void BIO_set_callback(BIO *b, |
|||
long (*callback) (struct bio_st *, int, const char *, |
|||
int, long, long)); |
|||
char *BIO_get_callback_arg(const BIO *b); |
|||
void BIO_set_callback_arg(BIO *b, char *arg); |
|||
|
|||
const char *BIO_method_name(const BIO *b); |
|||
int BIO_method_type(const BIO *b); |
|||
|
|||
typedef void bio_info_cb (struct bio_st *, int, const char *, int, long, |
|||
long); |
|||
|
|||
typedef struct bio_method_st { |
|||
int type; |
|||
const char *name; |
|||
int (*bwrite) (BIO *, const char *, int); |
|||
int (*bread) (BIO *, char *, int); |
|||
int (*bputs) (BIO *, const char *); |
|||
int (*bgets) (BIO *, char *, int); |
|||
long (*ctrl) (BIO *, int, long, void *); |
|||
int (*create) (BIO *); |
|||
int (*destroy) (BIO *); |
|||
long (*callback_ctrl) (BIO *, int, bio_info_cb *); |
|||
} BIO_METHOD; |
|||
|
|||
struct bio_st { |
|||
BIO_METHOD *method; |
|||
/* bio, mode, argp, argi, argl, ret */ |
|||
long (*callback) (struct bio_st *, int, const char *, int, long, long); |
|||
char *cb_arg; /* first argument for the callback */ |
|||
int init; |
|||
int shutdown; |
|||
int flags; /* extra storage */ |
|||
int retry_reason; |
|||
int num; |
|||
void *ptr; |
|||
struct bio_st *next_bio; /* used by filter BIOs */ |
|||
struct bio_st *prev_bio; /* used by filter BIOs */ |
|||
int references; |
|||
unsigned long num_read; |
|||
unsigned long num_write; |
|||
CRYPTO_EX_DATA ex_data; |
|||
}; |
|||
|
|||
DECLARE_STACK_OF(BIO) |
|||
|
|||
typedef struct bio_f_buffer_ctx_struct { |
|||
/*-
|
|||
* Buffers are setup like this: |
|||
* |
|||
* <---------------------- size -----------------------> |
|||
* +---------------------------------------------------+ |
|||
* | consumed | remaining | free space | |
|||
* +---------------------------------------------------+ |
|||
* <-- off --><------- len -------> |
|||
*/ |
|||
/*- BIO *bio; *//*
|
|||
* this is now in the BIO struct |
|||
*/ |
|||
int ibuf_size; /* how big is the input buffer */ |
|||
int obuf_size; /* how big is the output buffer */ |
|||
char *ibuf; /* the char array */ |
|||
int ibuf_len; /* how many bytes are in it */ |
|||
int ibuf_off; /* write/read offset */ |
|||
char *obuf; /* the char array */ |
|||
int obuf_len; /* how many bytes are in it */ |
|||
int obuf_off; /* write/read offset */ |
|||
} BIO_F_BUFFER_CTX; |
|||
|
|||
/* Prefix and suffix callback in ASN1 BIO */ |
|||
typedef int asn1_ps_func (BIO *b, unsigned char **pbuf, int *plen, |
|||
void *parg); |
|||
|
|||
# ifndef OPENSSL_NO_SCTP |
|||
/* SCTP parameter structs */ |
|||
struct bio_dgram_sctp_sndinfo { |
|||
uint16_t snd_sid; |
|||
uint16_t snd_flags; |
|||
uint32_t snd_ppid; |
|||
uint32_t snd_context; |
|||
}; |
|||
|
|||
struct bio_dgram_sctp_rcvinfo { |
|||
uint16_t rcv_sid; |
|||
uint16_t rcv_ssn; |
|||
uint16_t rcv_flags; |
|||
uint32_t rcv_ppid; |
|||
uint32_t rcv_tsn; |
|||
uint32_t rcv_cumtsn; |
|||
uint32_t rcv_context; |
|||
}; |
|||
|
|||
struct bio_dgram_sctp_prinfo { |
|||
uint16_t pr_policy; |
|||
uint32_t pr_value; |
|||
}; |
|||
# endif |
|||
|
|||
/* connect BIO stuff */ |
|||
# define BIO_CONN_S_BEFORE 1 |
|||
# define BIO_CONN_S_GET_IP 2 |
|||
# define BIO_CONN_S_GET_PORT 3 |
|||
# define BIO_CONN_S_CREATE_SOCKET 4 |
|||
# define BIO_CONN_S_CONNECT 5 |
|||
# define BIO_CONN_S_OK 6 |
|||
# define BIO_CONN_S_BLOCKED_CONNECT 7 |
|||
# define BIO_CONN_S_NBIO 8 |
|||
/*
|
|||
* #define BIO_CONN_get_param_hostname BIO_ctrl |
|||
*/ |
|||
|
|||
# define BIO_C_SET_CONNECT 100 |
|||
# define BIO_C_DO_STATE_MACHINE 101 |
|||
# define BIO_C_SET_NBIO 102 |
|||
# define BIO_C_SET_PROXY_PARAM 103 |
|||
# define BIO_C_SET_FD 104 |
|||
# define BIO_C_GET_FD 105 |
|||
# define BIO_C_SET_FILE_PTR 106 |
|||
# define BIO_C_GET_FILE_PTR 107 |
|||
# define BIO_C_SET_FILENAME 108 |
|||
# define BIO_C_SET_SSL 109 |
|||
# define BIO_C_GET_SSL 110 |
|||
# define BIO_C_SET_MD 111 |
|||
# define BIO_C_GET_MD 112 |
|||
# define BIO_C_GET_CIPHER_STATUS 113 |
|||
# define BIO_C_SET_BUF_MEM 114 |
|||
# define BIO_C_GET_BUF_MEM_PTR 115 |
|||
# define BIO_C_GET_BUFF_NUM_LINES 116 |
|||
# define BIO_C_SET_BUFF_SIZE 117 |
|||
# define BIO_C_SET_ACCEPT 118 |
|||
# define BIO_C_SSL_MODE 119 |
|||
# define BIO_C_GET_MD_CTX 120 |
|||
# define BIO_C_GET_PROXY_PARAM 121 |
|||
# define BIO_C_SET_BUFF_READ_DATA 122/* data to read first */ |
|||
# define BIO_C_GET_CONNECT 123 |
|||
# define BIO_C_GET_ACCEPT 124 |
|||
# define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125 |
|||
# define BIO_C_GET_SSL_NUM_RENEGOTIATES 126 |
|||
# define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127 |
|||
# define BIO_C_FILE_SEEK 128 |
|||
# define BIO_C_GET_CIPHER_CTX 129 |
|||
# define BIO_C_SET_BUF_MEM_EOF_RETURN 130/* return end of input |
|||
* value */ |
|||
# define BIO_C_SET_BIND_MODE 131 |
|||
# define BIO_C_GET_BIND_MODE 132 |
|||
# define BIO_C_FILE_TELL 133 |
|||
# define BIO_C_GET_SOCKS 134 |
|||
# define BIO_C_SET_SOCKS 135 |
|||
|
|||
# define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */ |
|||
# define BIO_C_GET_WRITE_BUF_SIZE 137 |
|||
# define BIO_C_MAKE_BIO_PAIR 138 |
|||
# define BIO_C_DESTROY_BIO_PAIR 139 |
|||
# define BIO_C_GET_WRITE_GUARANTEE 140 |
|||
# define BIO_C_GET_READ_REQUEST 141 |
|||
# define BIO_C_SHUTDOWN_WR 142 |
|||
# define BIO_C_NREAD0 143 |
|||
# define BIO_C_NREAD 144 |
|||
# define BIO_C_NWRITE0 145 |
|||
# define BIO_C_NWRITE 146 |
|||
# define BIO_C_RESET_READ_REQUEST 147 |
|||
# define BIO_C_SET_MD_CTX 148 |
|||
|
|||
# define BIO_C_SET_PREFIX 149 |
|||
# define BIO_C_GET_PREFIX 150 |
|||
# define BIO_C_SET_SUFFIX 151 |
|||
# define BIO_C_GET_SUFFIX 152 |
|||
|
|||
# define BIO_C_SET_EX_ARG 153 |
|||
# define BIO_C_GET_EX_ARG 154 |
|||
|
|||
# define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg) |
|||
# define BIO_get_app_data(s) BIO_get_ex_data(s,0) |
|||
|
|||
/* BIO_s_connect() and BIO_s_socks4a_connect() */ |
|||
# define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name) |
|||
# define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port) |
|||
# define BIO_set_conn_ip(b,ip) BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip) |
|||
# define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port) |
|||
# define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0) |
|||
# define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1) |
|||
# define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2) |
|||
# define BIO_get_conn_int_port(b) BIO_ctrl(b,BIO_C_GET_CONNECT,3,NULL) |
|||
|
|||
# define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) |
|||
|
|||
/* BIO_s_accept() */ |
|||
# define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name) |
|||
# define BIO_get_accept_port(b) BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0) |
|||
/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */ |
|||
# define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?(void *)"a":NULL) |
|||
# define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio) |
|||
|
|||
# define BIO_BIND_NORMAL 0 |
|||
# define BIO_BIND_REUSEADDR_IF_UNUSED 1 |
|||
# define BIO_BIND_REUSEADDR 2 |
|||
# define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL) |
|||
# define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL) |
|||
|
|||
/* BIO_s_accept() and BIO_s_connect() */ |
|||
# define BIO_do_connect(b) BIO_do_handshake(b) |
|||
# define BIO_do_accept(b) BIO_do_handshake(b) |
|||
# define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL) |
|||
|
|||
/* BIO_s_proxy_client() */ |
|||
# define BIO_set_url(b,url) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url)) |
|||
# define BIO_set_proxies(b,p) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p)) |
|||
/* BIO_set_nbio(b,n) */ |
|||
# define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s)) |
|||
/* BIO *BIO_get_filter_bio(BIO *bio); */ |
|||
# define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)())) |
|||
# define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk) |
|||
# define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool) |
|||
|
|||
# define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp) |
|||
# define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p)) |
|||
# define BIO_get_url(b,url) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url)) |
|||
# define BIO_get_no_connect_return(b) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL) |
|||
|
|||
/* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */ |
|||
# define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd) |
|||
# define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c) |
|||
|
|||
/* BIO_s_file() */ |
|||
# define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp) |
|||
# define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp) |
|||
|
|||
/* BIO_s_fd() and BIO_s_file() */ |
|||
# define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL) |
|||
# define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL) |
|||
|
|||
/*
|
|||
* name is cast to lose const, but might be better to route through a |
|||
* function so we can do it safely |
|||
*/ |
|||
# ifdef CONST_STRICT |
|||
/*
|
|||
* If you are wondering why this isn't defined, its because CONST_STRICT is |
|||
* purely a compile-time kludge to allow const to be checked. |
|||
*/ |
|||
int BIO_read_filename(BIO *b, const char *name); |
|||
# else |
|||
# define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ |
|||
BIO_CLOSE|BIO_FP_READ,(char *)name) |
|||
# endif |
|||
# define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ |
|||
BIO_CLOSE|BIO_FP_WRITE,name) |
|||
# define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ |
|||
BIO_CLOSE|BIO_FP_APPEND,name) |
|||
# define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ |
|||
BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name) |
|||
|
|||
/*
|
|||
* WARNING WARNING, this ups the reference count on the read bio of the SSL |
|||
* structure. This is because the ssl read BIO is now pointed to by the |
|||
* next_bio field in the bio. So when you free the BIO, make sure you are |
|||
* doing a BIO_free_all() to catch the underlying BIO. |
|||
*/ |
|||
# define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl) |
|||
# define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp) |
|||
# define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL) |
|||
# define BIO_set_ssl_renegotiate_bytes(b,num) \ |
|||
BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL) |
|||
# define BIO_get_num_renegotiates(b) \ |
|||
BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL) |
|||
# define BIO_set_ssl_renegotiate_timeout(b,seconds) \ |
|||
BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL) |
|||
|
|||
/* defined in evp.h */ |
|||
/* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */ |
|||
|
|||
# define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp) |
|||
# define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm) |
|||
# define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp) |
|||
# define BIO_set_mem_eof_return(b,v) \ |
|||
BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL) |
|||
|
|||
/* For the BIO_f_buffer() type */ |
|||
# define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL) |
|||
# define BIO_set_buffer_size(b,size) BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL) |
|||
# define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0) |
|||
# define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1) |
|||
# define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf) |
|||
|
|||
/* Don't use the next one unless you know what you are doing :-) */ |
|||
# define BIO_dup_state(b,ret) BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret)) |
|||
|
|||
# define BIO_reset(b) (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL) |
|||
# define BIO_eof(b) (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL) |
|||
# define BIO_set_close(b,c) (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL) |
|||
# define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL) |
|||
# define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL) |
|||
# define BIO_wpending(b) (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL) |
|||
/* ...pending macros have inappropriate return type */ |
|||
size_t BIO_ctrl_pending(BIO *b); |
|||
size_t BIO_ctrl_wpending(BIO *b); |
|||
# define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL) |
|||
# define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \ |
|||
cbp) |
|||
# define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb) |
|||
|
|||
/* For the BIO_f_buffer() type */ |
|||
# define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL) |
|||
|
|||
/* For BIO_s_bio() */ |
|||
# define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL) |
|||
# define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL) |
|||
# define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2) |
|||
# define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL) |
|||
# define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL) |
|||
/* macros with inappropriate type -- but ...pending macros use int too: */ |
|||
# define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL) |
|||
# define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL) |
|||
size_t BIO_ctrl_get_write_guarantee(BIO *b); |
|||
size_t BIO_ctrl_get_read_request(BIO *b); |
|||
int BIO_ctrl_reset_read_request(BIO *b); |
|||
|
|||
/* ctrl macros for dgram */ |
|||
# define BIO_ctrl_dgram_connect(b,peer) \ |
|||
(int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer) |
|||
# define BIO_ctrl_set_connected(b, state, peer) \ |
|||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer) |
|||
# define BIO_dgram_recv_timedout(b) \ |
|||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL) |
|||
# define BIO_dgram_send_timedout(b) \ |
|||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL) |
|||
# define BIO_dgram_get_peer(b,peer) \ |
|||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)peer) |
|||
# define BIO_dgram_set_peer(b,peer) \ |
|||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer) |
|||
# define BIO_dgram_get_mtu_overhead(b) \ |
|||
(unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL) |
|||
|
|||
/* These two aren't currently implemented */ |
|||
/* int BIO_get_ex_num(BIO *bio); */ |
|||
/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */ |
|||
int BIO_set_ex_data(BIO *bio, int idx, void *data); |
|||
void *BIO_get_ex_data(BIO *bio, int idx); |
|||
int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
|||
CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); |
|||
unsigned long BIO_number_read(BIO *bio); |
|||
unsigned long BIO_number_written(BIO *bio); |
|||
|
|||
/* For BIO_f_asn1() */ |
|||
int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix, |
|||
asn1_ps_func *prefix_free); |
|||
int BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix, |
|||
asn1_ps_func **pprefix_free); |
|||
int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix, |
|||
asn1_ps_func *suffix_free); |
|||
int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix, |
|||
asn1_ps_func **psuffix_free); |
|||
|
|||
# ifndef OPENSSL_NO_FP_API |
|||
BIO_METHOD *BIO_s_file(void); |
|||
BIO *BIO_new_file(const char *filename, const char *mode); |
|||
BIO *BIO_new_fp(FILE *stream, int close_flag); |
|||
# define BIO_s_file_internal BIO_s_file |
|||
# endif |
|||
BIO *BIO_new(BIO_METHOD *type); |
|||
int BIO_set(BIO *a, BIO_METHOD *type); |
|||
int BIO_free(BIO *a); |
|||
void BIO_vfree(BIO *a); |
|||
int BIO_read(BIO *b, void *data, int len); |
|||
int BIO_gets(BIO *bp, char *buf, int size); |
|||
int BIO_write(BIO *b, const void *data, int len); |
|||
int BIO_puts(BIO *bp, const char *buf); |
|||
int BIO_indent(BIO *b, int indent, int max); |
|||
long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg); |
|||
long BIO_callback_ctrl(BIO *b, int cmd, |
|||
void (*fp) (struct bio_st *, int, const char *, int, |
|||
long, long)); |
|||
char *BIO_ptr_ctrl(BIO *bp, int cmd, long larg); |
|||
long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg); |
|||
BIO *BIO_push(BIO *b, BIO *append); |
|||
BIO *BIO_pop(BIO *b); |
|||
void BIO_free_all(BIO *a); |
|||
BIO *BIO_find_type(BIO *b, int bio_type); |
|||
BIO *BIO_next(BIO *b); |
|||
BIO *BIO_get_retry_BIO(BIO *bio, int *reason); |
|||
int BIO_get_retry_reason(BIO *bio); |
|||
BIO *BIO_dup_chain(BIO *in); |
|||
|
|||
int BIO_nread0(BIO *bio, char **buf); |
|||
int BIO_nread(BIO *bio, char **buf, int num); |
|||
int BIO_nwrite0(BIO *bio, char **buf); |
|||
int BIO_nwrite(BIO *bio, char **buf, int num); |
|||
|
|||
long BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi, |
|||
long argl, long ret); |
|||
|
|||
BIO_METHOD *BIO_s_mem(void); |
|||
BIO *BIO_new_mem_buf(const void *buf, int len); |
|||
BIO_METHOD *BIO_s_socket(void); |
|||
BIO_METHOD *BIO_s_connect(void); |
|||
BIO_METHOD *BIO_s_accept(void); |
|||
BIO_METHOD *BIO_s_fd(void); |
|||
# ifndef OPENSSL_SYS_OS2 |
|||
BIO_METHOD *BIO_s_log(void); |
|||
# endif |
|||
BIO_METHOD *BIO_s_bio(void); |
|||
BIO_METHOD *BIO_s_null(void); |
|||
BIO_METHOD *BIO_f_null(void); |
|||
BIO_METHOD *BIO_f_buffer(void); |
|||
# ifdef OPENSSL_SYS_VMS |
|||
BIO_METHOD *BIO_f_linebuffer(void); |
|||
# endif |
|||
BIO_METHOD *BIO_f_nbio_test(void); |
|||
# ifndef OPENSSL_NO_DGRAM |
|||
BIO_METHOD *BIO_s_datagram(void); |
|||
# ifndef OPENSSL_NO_SCTP |
|||
BIO_METHOD *BIO_s_datagram_sctp(void); |
|||
# endif |
|||
# endif |
|||
|
|||
/* BIO_METHOD *BIO_f_ber(void); */ |
|||
|
|||
int BIO_sock_should_retry(int i); |
|||
int BIO_sock_non_fatal_error(int error); |
|||
int BIO_dgram_non_fatal_error(int error); |
|||
|
|||
int BIO_fd_should_retry(int i); |
|||
int BIO_fd_non_fatal_error(int error); |
|||
int BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u), |
|||
void *u, const char *s, int len); |
|||
int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u), |
|||
void *u, const char *s, int len, int indent); |
|||
int BIO_dump(BIO *b, const char *bytes, int len); |
|||
int BIO_dump_indent(BIO *b, const char *bytes, int len, int indent); |
|||
# ifndef OPENSSL_NO_FP_API |
|||
int BIO_dump_fp(FILE *fp, const char *s, int len); |
|||
int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent); |
|||
# endif |
|||
int BIO_hex_string(BIO *out, int indent, int width, unsigned char *data, |
|||
int datalen); |
|||
|
|||
struct hostent *BIO_gethostbyname(const char *name); |
|||
/*-
|
|||
* We might want a thread-safe interface too: |
|||
* struct hostent *BIO_gethostbyname_r(const char *name, |
|||
* struct hostent *result, void *buffer, size_t buflen); |
|||
* or something similar (caller allocates a struct hostent, |
|||
* pointed to by "result", and additional buffer space for the various |
|||
* substructures; if the buffer does not suffice, NULL is returned |
|||
* and an appropriate error code is set). |
|||
*/ |
|||
int BIO_sock_error(int sock); |
|||
int BIO_socket_ioctl(int fd, long type, void *arg); |
|||
int BIO_socket_nbio(int fd, int mode); |
|||
int BIO_get_port(const char *str, unsigned short *port_ptr); |
|||
int BIO_get_host_ip(const char *str, unsigned char *ip); |
|||
int BIO_get_accept_socket(char *host_port, int mode); |
|||
int BIO_accept(int sock, char **ip_port); |
|||
int BIO_sock_init(void); |
|||
void BIO_sock_cleanup(void); |
|||
int BIO_set_tcp_ndelay(int sock, int turn_on); |
|||
|
|||
BIO *BIO_new_socket(int sock, int close_flag); |
|||
BIO *BIO_new_dgram(int fd, int close_flag); |
|||
# ifndef OPENSSL_NO_SCTP |
|||
BIO *BIO_new_dgram_sctp(int fd, int close_flag); |
|||
int BIO_dgram_is_sctp(BIO *bio); |
|||
int BIO_dgram_sctp_notification_cb(BIO *b, |
|||
void (*handle_notifications) (BIO *bio, |
|||
void |
|||
*context, |
|||
void *buf), |
|||
void *context); |
|||
int BIO_dgram_sctp_wait_for_dry(BIO *b); |
|||
int BIO_dgram_sctp_msg_waiting(BIO *b); |
|||
# endif |
|||
BIO *BIO_new_fd(int fd, int close_flag); |
|||
BIO *BIO_new_connect(const char *host_port); |
|||
BIO *BIO_new_accept(const char *host_port); |
|||
|
|||
int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, |
|||
BIO **bio2, size_t writebuf2); |
|||
/*
|
|||
* If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints. |
|||
* Otherwise returns 0 and sets *bio1 and *bio2 to NULL. Size 0 uses default |
|||
* value. |
|||
*/ |
|||
|
|||
void BIO_copy_next_retry(BIO *b); |
|||
|
|||
/*
|
|||
* long BIO_ghbn_ctrl(int cmd,int iarg,char *parg); |
|||
*/ |
|||
|
|||
# ifdef __GNUC__ |
|||
# define __bio_h__attr__ __attribute__ |
|||
# else |
|||
# define __bio_h__attr__(x) |
|||
# endif |
|||
int BIO_printf(BIO *bio, const char *format, ...) |
|||
__bio_h__attr__((__format__(__printf__, 2, 3))); |
|||
int BIO_vprintf(BIO *bio, const char *format, va_list args) |
|||
__bio_h__attr__((__format__(__printf__, 2, 0))); |
|||
int BIO_snprintf(char *buf, size_t n, const char *format, ...) |
|||
__bio_h__attr__((__format__(__printf__, 3, 4))); |
|||
int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args) |
|||
__bio_h__attr__((__format__(__printf__, 3, 0))); |
|||
# undef __bio_h__attr__ |
|||
|
|||
/* 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_BIO_strings(void); |
|||
|
|||
/* Error codes for the BIO functions. */ |
|||
|
|||
/* Function codes. */ |
|||
# define BIO_F_ACPT_STATE 100 |
|||
# define BIO_F_BIO_ACCEPT 101 |
|||
# define BIO_F_BIO_BER_GET_HEADER 102 |
|||
# define BIO_F_BIO_CALLBACK_CTRL 131 |
|||
# define BIO_F_BIO_CTRL 103 |
|||
# define BIO_F_BIO_GETHOSTBYNAME 120 |
|||
# define BIO_F_BIO_GETS 104 |
|||
# define BIO_F_BIO_GET_ACCEPT_SOCKET 105 |
|||
# define BIO_F_BIO_GET_HOST_IP 106 |
|||
# define BIO_F_BIO_GET_PORT 107 |
|||
# define BIO_F_BIO_MAKE_PAIR 121 |
|||
# define BIO_F_BIO_NEW 108 |
|||
# define BIO_F_BIO_NEW_FILE 109 |
|||
# define BIO_F_BIO_NEW_MEM_BUF 126 |
|||
# define BIO_F_BIO_NREAD 123 |
|||
# define BIO_F_BIO_NREAD0 124 |
|||
# define BIO_F_BIO_NWRITE 125 |
|||
# define BIO_F_BIO_NWRITE0 122 |
|||
# define BIO_F_BIO_PUTS 110 |
|||
# define BIO_F_BIO_READ 111 |
|||
# define BIO_F_BIO_SOCK_INIT 112 |
|||
# define BIO_F_BIO_WRITE 113 |
|||
# define BIO_F_BUFFER_CTRL 114 |
|||
# define BIO_F_CONN_CTRL 127 |
|||
# define BIO_F_CONN_STATE 115 |
|||
# define BIO_F_DGRAM_SCTP_READ 132 |
|||
# define BIO_F_DGRAM_SCTP_WRITE 133 |
|||
# define BIO_F_FILE_CTRL 116 |
|||
# define BIO_F_FILE_READ 130 |
|||
# define BIO_F_LINEBUFFER_CTRL 129 |
|||
# define BIO_F_MEM_READ 128 |
|||
# define BIO_F_MEM_WRITE 117 |
|||
# define BIO_F_SSL_NEW 118 |
|||
# define BIO_F_WSASTARTUP 119 |
|||
|
|||
/* Reason codes. */ |
|||
# define BIO_R_ACCEPT_ERROR 100 |
|||
# define BIO_R_BAD_FOPEN_MODE 101 |
|||
# define BIO_R_BAD_HOSTNAME_LOOKUP 102 |
|||
# define BIO_R_BROKEN_PIPE 124 |
|||
# define BIO_R_CONNECT_ERROR 103 |
|||
# define BIO_R_EOF_ON_MEMORY_BIO 127 |
|||
# define BIO_R_ERROR_SETTING_NBIO 104 |
|||
# define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105 |
|||
# define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106 |
|||
# define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107 |
|||
# define BIO_R_INVALID_ARGUMENT 125 |
|||
# define BIO_R_INVALID_IP_ADDRESS 108 |
|||
# define BIO_R_IN_USE 123 |
|||
# define BIO_R_KEEPALIVE 109 |
|||
# define BIO_R_NBIO_CONNECT_ERROR 110 |
|||
# define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111 |
|||
# define BIO_R_NO_HOSTNAME_SPECIFIED 112 |
|||
# define BIO_R_NO_PORT_DEFINED 113 |
|||
# define BIO_R_NO_PORT_SPECIFIED 114 |
|||
# define BIO_R_NO_SUCH_FILE 128 |
|||
# define BIO_R_NULL_PARAMETER 115 |
|||
# define BIO_R_TAG_MISMATCH 116 |
|||
# define BIO_R_UNABLE_TO_BIND_SOCKET 117 |
|||
# define BIO_R_UNABLE_TO_CREATE_SOCKET 118 |
|||
# define BIO_R_UNABLE_TO_LISTEN_SOCKET 119 |
|||
# define BIO_R_UNINITIALIZED 120 |
|||
# define BIO_R_UNSUPPORTED_METHOD 121 |
|||
# define BIO_R_WRITE_TO_READ_ONLY_BIO 126 |
|||
# define BIO_R_WSASTARTUP 122 |
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
#endif |
@ -1,130 +0,0 @@ |
|||
/* crypto/bf/blowfish.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_BLOWFISH_H |
|||
# define HEADER_BLOWFISH_H |
|||
|
|||
# include <openssl/e_os2.h> |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
# ifdef OPENSSL_NO_BF |
|||
# error BF is disabled. |
|||
# endif |
|||
|
|||
# define BF_ENCRYPT 1 |
|||
# define BF_DECRYPT 0 |
|||
|
|||
/*-
|
|||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|||
* ! BF_LONG has to be at least 32 bits wide. If it's wider, then ! |
|||
* ! BF_LONG_LOG2 has to be defined along. ! |
|||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|||
*/ |
|||
|
|||
# if defined(__LP32__) |
|||
# define BF_LONG unsigned long |
|||
# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) |
|||
# define BF_LONG unsigned long |
|||
# define BF_LONG_LOG2 3 |
|||
/*
|
|||
* _CRAY note. I could declare short, but I have no idea what impact |
|||
* does it have on performance on none-T3E machines. I could declare |
|||
* int, but at least on C90 sizeof(int) can be chosen at compile time. |
|||
* So I've chosen long... |
|||
* <appro@fy.chalmers.se> |
|||
*/ |
|||
# else |
|||
# define BF_LONG unsigned int |
|||
# endif |
|||
|
|||
# define BF_ROUNDS 16 |
|||
# define BF_BLOCK 8 |
|||
|
|||
typedef struct bf_key_st { |
|||
BF_LONG P[BF_ROUNDS + 2]; |
|||
BF_LONG S[4 * 256]; |
|||
} BF_KEY; |
|||
|
|||
# ifdef OPENSSL_FIPS |
|||
void private_BF_set_key(BF_KEY *key, int len, const unsigned char *data); |
|||
# endif |
|||
void BF_set_key(BF_KEY *key, int len, const unsigned char *data); |
|||
|
|||
void BF_encrypt(BF_LONG *data, const BF_KEY *key); |
|||
void BF_decrypt(BF_LONG *data, const BF_KEY *key); |
|||
|
|||
void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, |
|||
const BF_KEY *key, int enc); |
|||
void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, |
|||
const BF_KEY *schedule, unsigned char *ivec, int enc); |
|||
void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, |
|||
long length, const BF_KEY *schedule, |
|||
unsigned char *ivec, int *num, int enc); |
|||
void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, |
|||
long length, const BF_KEY *schedule, |
|||
unsigned char *ivec, int *num); |
|||
const char *BF_options(void); |
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
|
|||
#endif |
@ -1,951 +0,0 @@ |
|||
/* 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 <limits.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 |
|||
|
|||
# define BN_DEFAULT_BITS 1280 |
|||
|
|||
# define BN_FLG_MALLOCED 0x01 |
|||
# define BN_FLG_STATIC_DATA 0x02 |
|||
|
|||
/*
|
|||
* 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. |
|||
*/ |
|||
# define BN_FLG_CONSTTIME 0x04 |
|||
|
|||
# ifdef OPENSSL_NO_DEPRECATED |
|||
/* deprecated name for the flag */ |
|||
# define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME |
|||
/*
|
|||
* 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. |
|||
*/ |
|||
|
|||
/*
|
|||
* r = a + b |
|||
*/ |
|||
int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); |
|||
# define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b) |
|||
/*
|
|||
* r=a mod p |
|||
*/ |
|||
int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p); |
|||
/* r = (a * b) mod p */ |
|||
int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
|||
const BIGNUM *p, BN_CTX *ctx); |
|||
/* r = (a * a) mod p */ |
|||
int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); |
|||
/* r = (1 / b) mod p */ |
|||
int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx); |
|||
/* r = (a / 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 = sqrt(a) mod p */ |
|||
int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
|||
BN_CTX *ctx); |
|||
/* r^2 + r = a mod p */ |
|||
int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
|||
BN_CTX *ctx); |
|||
# 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. |
|||
*/ |
|||
/* r = a mod p */ |
|||
int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]); |
|||
/* r = (a * b) mod p */ |
|||
int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
|||
const int p[], BN_CTX *ctx); |
|||
/* r = (a * a) mod p */ |
|||
int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[], |
|||
BN_CTX *ctx); |
|||
/* r = (1 / b) mod p */ |
|||
int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[], |
|||
BN_CTX *ctx); |
|||
/* r = (a / 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 = sqrt(a) mod p */ |
|||
int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, |
|||
const int p[], BN_CTX *ctx); |
|||
/* r^2 + r = a mod p */ |
|||
int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a, |
|||
const int p[], BN_CTX *ctx); |
|||
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 > (INT_MAX - BN_BITS2 + 1) ? \ |
|||
NULL \ |
|||
: \ |
|||
(((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*)); \ |
|||
/* Debug only - safe to ignore error return */ \ |
|||
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); \ |
|||
/* avoid unused variable warning with NDEBUG */ \ |
|||
(void)(_bnum2); \ |
|||
} 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; \ |
|||
} \ |
|||
if ((a)->top == 0) \ |
|||
(a)->neg = 0; \ |
|||
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_LSHIFT 145 |
|||
# 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_RSHIFT 146 |
|||
# 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_BITS_TOO_SMALL 118 |
|||
# 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_INVALID_SHIFT 119 |
|||
# 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 |
@ -1,125 +0,0 @@ |
|||
/* crypto/buffer/buffer.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_BUFFER_H |
|||
# define HEADER_BUFFER_H |
|||
|
|||
# include <openssl/ossl_typ.h> |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
# include <stddef.h> |
|||
|
|||
# if !defined(NO_SYS_TYPES_H) |
|||
# include <sys/types.h> |
|||
# endif |
|||
|
|||
/* Already declared in ossl_typ.h */ |
|||
/* typedef struct buf_mem_st BUF_MEM; */ |
|||
|
|||
struct buf_mem_st { |
|||
size_t length; /* current number of bytes */ |
|||
char *data; |
|||
size_t max; /* size of buffer */ |
|||
}; |
|||
|
|||
BUF_MEM *BUF_MEM_new(void); |
|||
void BUF_MEM_free(BUF_MEM *a); |
|||
int BUF_MEM_grow(BUF_MEM *str, size_t len); |
|||
int BUF_MEM_grow_clean(BUF_MEM *str, size_t len); |
|||
size_t BUF_strnlen(const char *str, size_t maxlen); |
|||
char *BUF_strdup(const char *str); |
|||
|
|||
/*
|
|||
* Like strndup, but in addition, explicitly guarantees to never read past the |
|||
* first |siz| bytes of |str|. |
|||
*/ |
|||
char *BUF_strndup(const char *str, size_t siz); |
|||
|
|||
void *BUF_memdup(const void *data, size_t siz); |
|||
void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz); |
|||
|
|||
/* safe string functions */ |
|||
size_t BUF_strlcpy(char *dst, const char *src, size_t siz); |
|||
size_t BUF_strlcat(char *dst, const char *src, size_t siz); |
|||
|
|||
/* 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_BUF_strings(void); |
|||
|
|||
/* Error codes for the BUF functions. */ |
|||
|
|||
/* Function codes. */ |
|||
# define BUF_F_BUF_MEMDUP 103 |
|||
# define BUF_F_BUF_MEM_GROW 100 |
|||
# define BUF_F_BUF_MEM_GROW_CLEAN 105 |
|||
# define BUF_F_BUF_MEM_NEW 101 |
|||
# define BUF_F_BUF_STRDUP 102 |
|||
# define BUF_F_BUF_STRNDUP 104 |
|||
|
|||
/* Reason codes. */ |
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
#endif |
@ -1,132 +0,0 @@ |
|||
/* crypto/camellia/camellia.h */ |
|||
/* ====================================================================
|
|||
* Copyright (c) 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. |
|||
* ==================================================================== |
|||
* |
|||
*/ |
|||
|
|||
#ifndef HEADER_CAMELLIA_H |
|||
# define HEADER_CAMELLIA_H |
|||
|
|||
# include <openssl/opensslconf.h> |
|||
|
|||
# ifdef OPENSSL_NO_CAMELLIA |
|||
# error CAMELLIA is disabled. |
|||
# endif |
|||
|
|||
# include <stddef.h> |
|||
|
|||
# define CAMELLIA_ENCRYPT 1 |
|||
# define CAMELLIA_DECRYPT 0 |
|||
|
|||
/*
|
|||
* Because array size can't be a const in C, the following two are macros. |
|||
* Both sizes are in bytes. |
|||
*/ |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
/* This should be a hidden type, but EVP requires that the size be known */ |
|||
|
|||
# define CAMELLIA_BLOCK_SIZE 16 |
|||
# define CAMELLIA_TABLE_BYTE_LEN 272 |
|||
# define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4) |
|||
|
|||
typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match
|
|||
* with WORD */ |
|||
|
|||
struct camellia_key_st { |
|||
union { |
|||
double d; /* ensures 64-bit align */ |
|||
KEY_TABLE_TYPE rd_key; |
|||
} u; |
|||
int grand_rounds; |
|||
}; |
|||
typedef struct camellia_key_st CAMELLIA_KEY; |
|||
|
|||
# ifdef OPENSSL_FIPS |
|||
int private_Camellia_set_key(const unsigned char *userKey, const int bits, |
|||
CAMELLIA_KEY *key); |
|||
# endif |
|||
int Camellia_set_key(const unsigned char *userKey, const int bits, |
|||
CAMELLIA_KEY *key); |
|||
|
|||
void Camellia_encrypt(const unsigned char *in, unsigned char *out, |
|||
const CAMELLIA_KEY *key); |
|||
void Camellia_decrypt(const unsigned char *in, unsigned char *out, |
|||
const CAMELLIA_KEY *key); |
|||
|
|||
void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out, |
|||
const CAMELLIA_KEY *key, const int enc); |
|||
void Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out, |
|||
size_t length, const CAMELLIA_KEY *key, |
|||
unsigned char *ivec, const int enc); |
|||
void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out, |
|||
size_t length, const CAMELLIA_KEY *key, |
|||
unsigned char *ivec, int *num, const int enc); |
|||
void Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out, |
|||
size_t length, const CAMELLIA_KEY *key, |
|||
unsigned char *ivec, int *num, const int enc); |
|||
void Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out, |
|||
size_t length, const CAMELLIA_KEY *key, |
|||
unsigned char *ivec, int *num, const int enc); |
|||
void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out, |
|||
size_t length, const CAMELLIA_KEY *key, |
|||
unsigned char *ivec, int *num); |
|||
void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out, |
|||
size_t length, const CAMELLIA_KEY *key, |
|||
unsigned char ivec[CAMELLIA_BLOCK_SIZE], |
|||
unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE], |
|||
unsigned int *num); |
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
|
|||
#endif /* !HEADER_Camellia_H */ |
@ -1,107 +0,0 @@ |
|||
/* crypto/cast/cast.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_CAST_H |
|||
# define HEADER_CAST_H |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
# include <openssl/opensslconf.h> |
|||
|
|||
# ifdef OPENSSL_NO_CAST |
|||
# error CAST is disabled. |
|||
# endif |
|||
|
|||
# define CAST_ENCRYPT 1 |
|||
# define CAST_DECRYPT 0 |
|||
|
|||
# define CAST_LONG unsigned int |
|||
|
|||
# define CAST_BLOCK 8 |
|||
# define CAST_KEY_LENGTH 16 |
|||
|
|||
typedef struct cast_key_st { |
|||
CAST_LONG data[32]; |
|||
int short_key; /* Use reduced rounds for short key */ |
|||
} CAST_KEY; |
|||
|
|||
# ifdef OPENSSL_FIPS |
|||
void private_CAST_set_key(CAST_KEY *key, int len, const unsigned char *data); |
|||
# endif |
|||
void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data); |
|||
void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, |
|||
const CAST_KEY *key, int enc); |
|||
void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key); |
|||
void CAST_decrypt(CAST_LONG *data, const CAST_KEY *key); |
|||
void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, |
|||
long length, const CAST_KEY *ks, unsigned char *iv, |
|||
int enc); |
|||
void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out, |
|||
long length, const CAST_KEY *schedule, |
|||
unsigned char *ivec, int *num, int enc); |
|||
void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, |
|||
long length, const CAST_KEY *schedule, |
|||
unsigned char *ivec, int *num); |
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
|
|||
#endif |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue