Make some more API types opaquely available from ossl_typ.h, meaning the

corresponding headers are only required for API functions or structure
details. This now includes the bignum types and BUF_MEM. Subsequent commits
will remove various dependencies on bn.h and buffer.h and update the
makefile dependencies.
This commit is contained in:
Geoff Thorpe 2004-05-15 18:32:08 +00:00
parent 7771b6c5b5
commit d6dda126b7
3 changed files with 39 additions and 18 deletions

View File

@ -76,6 +76,7 @@
#ifndef OPENSSL_NO_FP_API #ifndef OPENSSL_NO_FP_API
#include <stdio.h> /* FILE */ #include <stdio.h> /* FILE */
#endif #endif
#include <openssl/ossl_typ.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -248,10 +249,6 @@ extern "C" {
#define BN_DEFAULT_BITS 1280 #define BN_DEFAULT_BITS 1280
#ifdef BIGNUM
#undef BIGNUM
#endif
#define BN_FLG_MALLOCED 0x01 #define BN_FLG_MALLOCED 0x01
#define BN_FLG_STATIC_DATA 0x02 #define BN_FLG_STATIC_DATA 0x02
#ifndef OPENSSL_NO_DEPRECATED #ifndef OPENSSL_NO_DEPRECATED
@ -260,7 +257,18 @@ extern "C" {
#define BN_set_flags(b,n) ((b)->flags|=(n)) #define BN_set_flags(b,n) ((b)->flags|=(n))
#define BN_get_flags(b,n) ((b)->flags&(n)) #define BN_get_flags(b,n) ((b)->flags&(n))
typedef struct bignum_st /* 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. */ BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */
int top; /* Index of last used d +1. */ int top; /* Index of last used d +1. */
@ -268,12 +276,9 @@ typedef struct bignum_st
int dmax; /* Size of the d array. */ int dmax; /* Size of the d array. */
int neg; /* one if the number is negative */ int neg; /* one if the number is negative */
int flags; int flags;
} BIGNUM; };
/* Used for temp variables (declaration hidden in bn_lcl.h) */ struct bn_blinding_st
typedef struct bignum_ctx BN_CTX;
typedef struct bn_blinding_st
{ {
int init; int init;
BIGNUM *A; BIGNUM *A;
@ -281,10 +286,10 @@ typedef struct bn_blinding_st
BIGNUM *mod; /* just a reference */ BIGNUM *mod; /* just a reference */
unsigned long thread_id; /* added in OpenSSL 0.9.6j and 0.9.7b; unsigned long thread_id; /* added in OpenSSL 0.9.6j and 0.9.7b;
* used only by crypto/rsa/rsa_eay.c, rsa_lib.c */ * used only by crypto/rsa/rsa_eay.c, rsa_lib.c */
} BN_BLINDING; };
/* Used for montgomery multiplication */ /* Used for montgomery multiplication */
typedef struct bn_mont_ctx_st struct bn_mont_ctx_st
{ {
int ri; /* number of bits in R */ int ri; /* number of bits in R */
BIGNUM RR; /* used to convert to montgomery form */ BIGNUM RR; /* used to convert to montgomery form */
@ -293,22 +298,21 @@ typedef struct bn_mont_ctx_st
* (Ni is only stored for bignum algorithm) */ * (Ni is only stored for bignum algorithm) */
BN_ULONG n0; /* least significant word of Ni */ BN_ULONG n0; /* least significant word of Ni */
int flags; int flags;
} BN_MONT_CTX; };
/* Used for reciprocal division/mod functions /* Used for reciprocal division/mod functions
* It cannot be shared between threads * It cannot be shared between threads
*/ */
typedef struct bn_recp_ctx_st struct bn_recp_ctx_st
{ {
BIGNUM N; /* the divisor */ BIGNUM N; /* the divisor */
BIGNUM Nr; /* the reciprocal */ BIGNUM Nr; /* the reciprocal */
int num_bits; int num_bits;
int shift; int shift;
int flags; int flags;
} BN_RECP_CTX; };
/* Used for slow "generation" functions. */ /* Used for slow "generation" functions. */
typedef struct bn_gencb_st BN_GENCB;
struct bn_gencb_st struct bn_gencb_st
{ {
unsigned int ver; /* To handle binary (in)compatibility */ unsigned int ver; /* To handle binary (in)compatibility */

View File

@ -59,6 +59,8 @@
#ifndef HEADER_BUFFER_H #ifndef HEADER_BUFFER_H
#define HEADER_BUFFER_H #define HEADER_BUFFER_H
#include <openssl/ossl_typ.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -69,12 +71,15 @@ extern "C" {
#include <sys/types.h> #include <sys/types.h>
#endif #endif
typedef struct buf_mem_st /* Already declared in ossl_typ.h */
/* typedef struct buf_mem_st BUF_MEM; */
struct buf_mem_st
{ {
int length; /* current number of bytes */ int length; /* current number of bytes */
char *data; char *data;
int max; /* size of buffer */ int max; /* size of buffer */
} BUF_MEM; };
BUF_MEM *BUF_MEM_new(void); BUF_MEM *BUF_MEM_new(void);
void BUF_MEM_free(BUF_MEM *a); void BUF_MEM_free(BUF_MEM *a);

View File

@ -101,6 +101,18 @@ typedef int ASN1_NULL;
#undef PKCS7_ISSUER_AND_SERIAL #undef PKCS7_ISSUER_AND_SERIAL
#endif #endif
#ifdef BIGNUM
#undef BIGNUM
#endif
typedef struct bignum_st BIGNUM;
typedef struct bignum_ctx BN_CTX;
typedef struct bn_blinding_st BN_BLINDING;
typedef struct bn_mont_ctx_st BN_MONT_CTX;
typedef struct bn_recp_ctx_st BN_RECP_CTX;
typedef struct bn_gencb_st BN_GENCB;
typedef struct buf_mem_st BUF_MEM;
typedef struct evp_cipher_st EVP_CIPHER; typedef struct evp_cipher_st EVP_CIPHER;
typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;
typedef struct env_md_st EVP_MD; typedef struct env_md_st EVP_MD;