From d6dda126b7921c1067cdc49845e4656c53a5c96b Mon Sep 17 00:00:00 2001 From: Geoff Thorpe Date: Sat, 15 May 2004 18:32:08 +0000 Subject: [PATCH] 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. --- crypto/bn/bn.h | 36 ++++++++++++++++++++---------------- crypto/buffer/buffer.h | 9 +++++++-- crypto/ossl_typ.h | 12 ++++++++++++ 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/crypto/bn/bn.h b/crypto/bn/bn.h index dac794b600..0f6373aea9 100644 --- a/crypto/bn/bn.h +++ b/crypto/bn/bn.h @@ -76,6 +76,7 @@ #ifndef OPENSSL_NO_FP_API #include /* FILE */ #endif +#include #ifdef __cplusplus extern "C" { @@ -248,10 +249,6 @@ extern "C" { #define BN_DEFAULT_BITS 1280 -#ifdef BIGNUM -#undef BIGNUM -#endif - #define BN_FLG_MALLOCED 0x01 #define BN_FLG_STATIC_DATA 0x02 #ifndef OPENSSL_NO_DEPRECATED @@ -260,7 +257,18 @@ extern "C" { #define BN_set_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. */ int top; /* Index of last used d +1. */ @@ -268,12 +276,9 @@ typedef struct bignum_st int dmax; /* Size of the d array. */ int neg; /* one if the number is negative */ int flags; - } BIGNUM; - -/* Used for temp variables (declaration hidden in bn_lcl.h) */ -typedef struct bignum_ctx BN_CTX; + }; -typedef struct bn_blinding_st +struct bn_blinding_st { int init; BIGNUM *A; @@ -281,10 +286,10 @@ typedef struct bn_blinding_st BIGNUM *mod; /* just a reference */ 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 */ - } BN_BLINDING; + }; /* Used for montgomery multiplication */ -typedef struct bn_mont_ctx_st +struct bn_mont_ctx_st { int ri; /* number of bits in R */ 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) */ BN_ULONG n0; /* least significant word of Ni */ int flags; - } BN_MONT_CTX; + }; /* Used for reciprocal division/mod functions * It cannot be shared between threads */ -typedef struct bn_recp_ctx_st +struct bn_recp_ctx_st { BIGNUM N; /* the divisor */ BIGNUM Nr; /* the reciprocal */ int num_bits; int shift; int flags; - } BN_RECP_CTX; + }; /* Used for slow "generation" functions. */ -typedef struct bn_gencb_st BN_GENCB; struct bn_gencb_st { unsigned int ver; /* To handle binary (in)compatibility */ diff --git a/crypto/buffer/buffer.h b/crypto/buffer/buffer.h index 7f557c21c3..4b8eb7119d 100644 --- a/crypto/buffer/buffer.h +++ b/crypto/buffer/buffer.h @@ -59,6 +59,8 @@ #ifndef HEADER_BUFFER_H #define HEADER_BUFFER_H +#include + #ifdef __cplusplus extern "C" { #endif @@ -69,12 +71,15 @@ extern "C" { #include #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 */ char *data; int max; /* size of buffer */ - } BUF_MEM; + }; BUF_MEM *BUF_MEM_new(void); void BUF_MEM_free(BUF_MEM *a); diff --git a/crypto/ossl_typ.h b/crypto/ossl_typ.h index 41a0558617..86399c4ec0 100644 --- a/crypto/ossl_typ.h +++ b/crypto/ossl_typ.h @@ -101,6 +101,18 @@ typedef int ASN1_NULL; #undef PKCS7_ISSUER_AND_SERIAL #endif +#ifdef BIGNUM +#undef BIGNUM +#endif +typedef struct bignum_st BIGNUM; +typedef struct bignum_ctx BN_CTX; +typedef struct bn_blinding_st BN_BLINDING; +typedef struct bn_mont_ctx_st BN_MONT_CTX; +typedef struct bn_recp_ctx_st BN_RECP_CTX; +typedef struct bn_gencb_st BN_GENCB; + +typedef struct buf_mem_st BUF_MEM; + typedef struct evp_cipher_st EVP_CIPHER; typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; typedef struct env_md_st EVP_MD; -- 2.25.1