Reduce header interdependencies, initially in engine.h (the rest of the
authorGeoff Thorpe <geoff@openssl.org>
Mon, 19 Apr 2004 17:46:04 +0000 (17:46 +0000)
committerGeoff Thorpe <geoff@openssl.org>
Mon, 19 Apr 2004 17:46:04 +0000 (17:46 +0000)
changes are the fallout). As this could break source code that doesn't
directly include headers for interfaces it uses, changes to recursive
includes are covered by the OPENSSL_NO_DEPRECATED symbol. It's better to
define this when building and using openssl, and then adapt code where
necessary - this is how to stay current. However the mechanism exists for
the lethargic.

25 files changed:
CHANGES
crypto/dh/dh.h
crypto/dsa/dsa.h
crypto/ecdh/ecdh.h
crypto/ecdsa/ecdsa.h
crypto/ecdsa/ecdsatest.c
crypto/engine/eng_openssl.c
crypto/engine/eng_table.c
crypto/engine/engine.h
crypto/err/err.h
crypto/err/err_all.c
crypto/evp/evp_enc.c
crypto/ossl_typ.h
crypto/rand/rand.h
crypto/rsa/rsa.h
crypto/store/store.h
crypto/ui/ui.h
engines/e_4758_cca.c
engines/e_aep.c
engines/e_atalla.c
engines/e_cswift.c
engines/e_ncipher.c
engines/e_nuron.c
engines/e_sureware.c
engines/e_ubsec.c

diff --git a/CHANGES b/CHANGES
index baa2a8afea30331676547c7ae592fb8daf91f8bb..5dd7a41b51cd5d8bc9308a67937e5359a1f28263 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,15 @@
 
  Changes between 0.9.7c and 0.9.8  [xx XXX xxxx]
 
+  *) Reduced header interdepencies by declaring more opaque objects in
+     ossl_typ.h. As a consequence, including some headers (eg. engine.h) will
+     give fewer recursive includes, which could break lazy source code - so
+     this change is covered by the OPENSSL_NO_DEPRECATED symbol. As always,
+     developers should define this symbol when building and using openssl to
+     ensure they track the recommended behaviour, interfaces, [etc], but
+     backwards-compatible behaviour prevails when this isn't defined.
+     [Geoff Thorpe]
+
   *) New function X509_POLICY_NODE_print() which prints out policy nodes.
      [Steve Henson]
 
index db4e11090db403f2154becb0c54e01be11bd640c..28a1b4208df1dbe8a103f4af71db90018964c083 100644 (file)
 extern "C" {
 #endif
 
-typedef struct dh_st DH;
+/* Already defined in ossl_typ.h */
+/* typedef struct dh_st DH; */
+/* typedef struct dh_method DH_METHOD; */
 
-typedef struct dh_method {
+struct dh_method
+       {
        const char *name;
        /* Methods here */
        int (*generate_key)(DH *dh);
@@ -95,7 +98,7 @@ typedef struct dh_method {
        char *app_data;
        /* If this is non-NULL, it will be used to generate parameters */
        int (*generate_params)(DH *dh, int prime_len, int generator, BN_GENCB *cb);
-} DH_METHOD;
+       };
 
 struct dh_st
        {
index 651add43ae3e417fb33ac52011a92803f9dab8e2..d54c5d59bc1040b76a1095bcacb8bb28527b78a6 100644 (file)
@@ -87,7 +87,9 @@
 extern "C" {
 #endif
 
-typedef struct dsa_st DSA;
+/* Already defined in ossl_typ.h */
+/* typedef struct dsa_st DSA; */
+/* typedef struct dsa_method DSA_METHOD; */
 
 typedef struct DSA_SIG_st
        {
@@ -95,7 +97,8 @@ typedef struct DSA_SIG_st
        BIGNUM *s;
        } DSA_SIG;
 
-typedef struct dsa_method {
+struct dsa_method
+       {
        const char *name;
        DSA_SIG * (*dsa_do_sign)(const unsigned char *dgst, int dlen, DSA *dsa);
        int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
@@ -119,7 +122,7 @@ typedef struct dsa_method {
                        BN_GENCB *cb);
        /* If this is non-NULL, it is used to generate DSA keys */
        int (*dsa_keygen)(DSA *dsa);
-} DSA_METHOD;
+       };
 
 struct dsa_st
        {
index db6fd487010d53ea134524c2ad9a2a10e6bcb850..1a62a214b3d4bc3403168851668aec63050e7e05 100644 (file)
 extern "C" {
 #endif
 
-typedef struct ecdh_method 
-{
+/* Already defined in ossl_typ.h */
+/* typedef struct ecdh_method ECDH_METHOD; */
+
+struct ecdh_method 
+       {
        const char *name;
        int (*compute_key)(void *key, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh,
                           void *(*KDF)(void *in, size_t inlen, void *out, size_t outlen));
@@ -94,7 +97,7 @@ typedef struct ecdh_method
 #endif
        int flags;
        char *app_data;
-} ECDH_METHOD;
+       };
 
 typedef struct ecdh_data_st {
        /* EC_KEY_METH_DATA part */
index 3e6abd26f6a22a3e2110ab6d3340ddaf4b5ee4b6..a57ba0f14f2065d227d9f380da0ade762c829595 100644 (file)
 extern "C" {
 #endif
 
+/* Already defined in ossl_typ.h */
+/* typedef struct ecdsa_method ECDSA_METHOD; */
+
 typedef struct ECDSA_SIG_st
-{
+       {
        BIGNUM *r;
        BIGNUM *s;
-} ECDSA_SIG;
+       } ECDSA_SIG;
 
-typedef struct ecdsa_method 
-{
+struct ecdsa_method 
+       {
        const char *name;
        ECDSA_SIG *(*ecdsa_do_sign)(const unsigned char *dgst, int dgst_len, 
                        EC_KEY *eckey);
@@ -94,7 +97,7 @@ typedef struct ecdsa_method
 #endif
        int flags;
        char *app_data;
-} ECDSA_METHOD;
+       };
 
 typedef struct ecdsa_data_st {
        /* EC_KEY_METH_DATA part */
index d58e9a63f0581183f5cf276b858070836b7757f4..f3371e4229b90f4ad0b8a361564f5bfd630f69a3 100644 (file)
@@ -95,6 +95,7 @@ int main(int argc, char * argv[])
 #include <openssl/ecdsa.h>
 #include <openssl/engine.h>
 #include <openssl/err.h>
+#include <openssl/rand.h>
 
 static const char rnd_seed[] = "string to make the random number generator "
        "think it has entropy";
index 09d281c19d977e96972dc296e83c59ed09d67d98..4b9cc0a83dc4f4da87cf27ea567d6e8e9f4cdf29 100644 (file)
@@ -69,6 +69,7 @@
 #include <openssl/dso.h>
 #include <openssl/pem.h>
 #include <openssl/evp.h>
+#include <openssl/rand.h>
 
 /* This testing gunk is implemented (and explained) lower down. It also assumes
  * the application explicitly calls "ENGINE_load_openssl()" because this is no
index c69a84a8bf4c26422dfc70504454016bef35852d..23e41110cbbcbfa459627f042d32edaf7adc2430 100644 (file)
@@ -52,8 +52,9 @@
  *
  */
 
+#include "cryptlib.h"
 #include <openssl/evp.h>
-#include <openssl/engine.h>
+#include <openssl/lhash.h>
 #include "eng_int.h"
 
 /* This is the type of item in the 'implementation' table. Each 'nid' hashes to
index bcbec5162cd29093f6f5c090242a33ec2c5ed579..712687ea401c3c1ed988e70c5eeba1bf04a69579 100644 (file)
@@ -3,7 +3,7 @@
  * project 2000.
  */
 /* ====================================================================
- * Copyright (c) 1999-2001 The OpenSSL Project.  All rights reserved.
+ * Copyright (c) 1999-2004 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
@@ -70,7 +70,7 @@
 #error ENGINE is disabled.
 #endif
 
-#include <openssl/ossl_typ.h>
+#ifndef OPENSSL_NO_DEPRECATED
 #include <openssl/bn.h>
 #ifndef OPENSSL_NO_RSA
 #include <openssl/rsa.h>
 #include <openssl/rand.h>
 #include <openssl/store.h>
 #include <openssl/ui.h>
-#include <openssl/symhacks.h>
 #include <openssl/err.h>
+#endif
+
+#include <openssl/ossl_typ.h>
+#include <openssl/symhacks.h>
 
 #ifdef  __cplusplus
 extern "C" {
index d893f60bb7abe971562ac0e562eabaa5edaadae8..b723cd977a44f12161b2e9de4f12acb5d758b269 100644 (file)
@@ -66,6 +66,7 @@
 #include <stdlib.h>
 #endif
 
+#include <openssl/ossl_typ.h>
 #ifndef OPENSSL_NO_BIO
 #include <openssl/bio.h>
 #endif
@@ -301,8 +302,8 @@ int ERR_get_next_error_library(void);
 int ERR_set_mark(void);
 int ERR_pop_to_mark(void);
 
-/* This opaque type encapsulates the low-level error-state functions */
-typedef struct st_ERR_FNS ERR_FNS;
+/* Already defined in ossl_typ.h */
+/* typedef struct st_ERR_FNS ERR_FNS; */
 /* An application can use this function and provide the return value to loaded
  * modules that should use the application's ERR state/functionality */
 const ERR_FNS *ERR_get_implementation(void);
index 6da4326b2a051e1f2f6801d9319a6ca4a3a25d05..bfb4c1ab12ba4664698d67d8d2ed245f892693b9 100644 (file)
@@ -91,6 +91,7 @@
 #ifndef OPENSSL_NO_ENGINE
 #include <openssl/engine.h>
 #endif
+#include <openssl/ui.h>
 #include <openssl/ocsp.h>
 #include <openssl/err.h>
 
index b5236b976631f59904ff5db20d7b1bc5ad97ec0a..c49520028214243af4faf8fb36dbd4f565d5b490 100644 (file)
@@ -60,6 +60,7 @@
 #include "cryptlib.h"
 #include <openssl/evp.h>
 #include <openssl/err.h>
+#include <openssl/rand.h>
 #ifndef OPENSSL_NO_ENGINE
 #include <openssl/engine.h>
 #endif
index 2977b108279f0ffd4a29b283049da8228b65ec60..41a055861746962b8297a50b07b580c7235834f8 100644 (file)
@@ -107,6 +107,20 @@ typedef struct env_md_st EVP_MD;
 typedef struct env_md_ctx_st EVP_MD_CTX;
 typedef struct evp_pkey_st EVP_PKEY;
 
+typedef struct dh_st DH;
+typedef struct dh_method DH_METHOD;
+
+typedef struct dsa_st DSA;
+typedef struct dsa_method DSA_METHOD;
+
+typedef struct rsa_st RSA;
+typedef struct rsa_meth_st RSA_METHOD;
+
+typedef struct rand_meth_st RAND_METHOD;
+
+typedef struct ecdh_method ECDH_METHOD;
+typedef struct ecdsa_method ECDSA_METHOD;
+
 typedef struct x509_st X509;
 typedef struct X509_algor_st X509_ALGOR;
 typedef struct X509_crl_st X509_CRL;
@@ -117,6 +131,14 @@ typedef struct x509_store_ctx_st X509_STORE_CTX;
 typedef struct v3_ext_ctx X509V3_CTX;
 typedef struct conf_st CONF;
 
+typedef struct store_st STORE;
+typedef struct store_method_st STORE_METHOD;
+
+typedef struct ui_st UI;
+typedef struct ui_method_st UI_METHOD;
+
+typedef struct st_ERR_FNS ERR_FNS;
+
 typedef struct engine_st ENGINE;
 
 typedef struct X509_POLICY_NODE_st X509_POLICY_NODE;
index 606382dd211c2dadd2a85a03b53f80b801ca68e9..6f544994ce2ed3a31cac921a2ff5632daad28248 100644 (file)
 extern "C" {
 #endif
 
-typedef struct rand_meth_st
+/* Already defined in ossl_typ.h */
+/* typedef struct rand_meth_st RAND_METHOD; */
+
+struct rand_meth_st
        {
        void (*seed)(const void *buf, int num);
        int (*bytes)(unsigned char *buf, int num);
@@ -79,7 +82,7 @@ typedef struct rand_meth_st
        void (*add)(const void *buf, int num, double entropy);
        int (*pseudorand)(unsigned char *buf, int num);
        int (*status)(void);
-       } RAND_METHOD;
+       };
 
 #ifdef BN_DEBUG
 extern int rand_predictable;
index b3ed1edd3fc213b0155d6803788760ae9be7b7a8..f82d493f952711728c25e04c48d0f8743fbc3e2b 100644 (file)
 extern "C" {
 #endif
 
-typedef struct rsa_st RSA;
+/* Declared already in ossl_typ.h */
+/* typedef struct rsa_st RSA; */
+/* typedef struct rsa_meth_st RSA_METHOD; */
 
-typedef struct rsa_meth_st
+struct rsa_meth_st
        {
        const char *name;
        int (*rsa_pub_enc)(int flen,const unsigned char *from,
@@ -119,7 +121,7 @@ typedef struct rsa_meth_st
  * it would be nice to assume there are no such things as "builtin software"
  * implementations. */
        int (*rsa_keygen)(RSA *rsa, int bits, unsigned long e, BN_GENCB *cb);
-       } RSA_METHOD;
+       };
 
 struct rsa_st
        {
index 314f2162830c2d65c7f933ca68709344f39ce86d..40fb38fc43932f13a81332a6fb55c145d7460b72 100644 (file)
@@ -59,6 +59,7 @@
 #ifndef HEADER_STORE_H
 #define HEADER_STORE_H
 
+#include <openssl/ossl_typ.h>
 #include <openssl/x509.h>
 #include <openssl/evp.h>
 #include <openssl/bn.h>
 extern "C" {
 #endif
 
-/* The STORE type is a per-store context that holds all the necessary data
-   to perform all the supported storage operations. */
-typedef struct store_st STORE;
-
-/* All instances of STORE have a reference to a method structure, which is a
-   ordered vector of functions that implement the lower level things to do.
-   There is an instruction on the implementation further down, in the section
-   for method implementors. */
-typedef struct store_method_st STORE_METHOD;
+/* Already defined in ossl_typ.h */
+/* typedef struct store_st STORE; */
+/* typedef struct store_method_st STORE_METHOD; */
 
 
 /* All the following functions return 0, a negative number or NULL on error.
index 735a2d988e84e9eaefc2f273d5544bb0d9ce9f19..f7c3054d8c20788558c1bad0ef3f9ca81bb16206 100644 (file)
 
 #include <openssl/crypto.h>
 #include <openssl/safestack.h>
+#include <openssl/ossl_typ.h>
 
 #ifdef  __cplusplus
 extern "C" {
 #endif
 
-/* The UI type is a holder for a specific user interface session.  It can
-   contain an illimited number of informational or error strings as well
-   as things to prompt for, both passwords (noecho mode) and others (echo
-   mode), and verification of the same.  All of these are called strings,
-   and are further described below. */
-typedef struct ui_st UI;
-
-/* All instances of UI have a reference to a method structure, which is a
-   ordered vector of functions that implement the lower level things to do.
-   There is an instruction on the implementation further down, in the section
-   for method implementors. */
-typedef struct ui_method_st UI_METHOD;
+/* Declared already in ossl_typ.h */
+/* typedef struct ui_st UI; */
+/* typedef struct ui_method_st UI_METHOD; */
 
 
 /* All the following functions return -1 or NULL on error and in some cases
index b006ed876373b933f0eb0c0ad056cf24773cc9f7..3c8e5f6193b25e9b6828a8a6fb79b3376a1e2c47 100644 (file)
 #include <stdio.h>
 #include <string.h>
 #include <openssl/crypto.h>
-/* #include <openssl/pem.h> */
 #include <openssl/dso.h>
 #include <openssl/x509.h>
 #include <openssl/objects.h>
 #include <openssl/engine.h>
+#include <openssl/rand.h>
 
 #ifndef OPENSSL_NO_HW
 #ifndef OPENSSL_NO_HW_4758_CCA
index aa4fe7570483686736d5431a52782d9aa3b268fd..5e66fb1f837ca1181b4aa7f3c0b4675052086ea8 100644 (file)
@@ -1,6 +1,3 @@
-/* crypto/engine/hw_aep.c */
-/*
- */
 /* ====================================================================
  * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
  *
@@ -72,6 +69,8 @@ typedef int pid_t;
 #include <openssl/dso.h>
 #include <openssl/engine.h>
 #include <openssl/buffer.h>
+#include <openssl/rsa.h>
+#include <openssl/dsa.h>
 
 #ifndef OPENSSL_NO_HW
 #ifndef OPENSSL_NO_HW_AEP
index cc6c9695f0d2e4ab1cce15d8125cd2664a02f3d7..82dae4586754cddce949b9e5850dc684b404ed29 100644 (file)
@@ -62,6 +62,9 @@
 #include <openssl/buffer.h>
 #include <openssl/dso.h>
 #include <openssl/engine.h>
+#include <openssl/rsa.h>
+#include <openssl/dsa.h>
+#include <openssl/dh.h>
 
 #ifndef OPENSSL_NO_HW
 #ifndef OPENSSL_NO_HW_ATALLA
index cc39cd4947395f55f748bb15ff8f83afdf59ea68..b73126b0376bc928a7bf4b1109dd3f2c80370357 100644 (file)
 #include <openssl/buffer.h>
 #include <openssl/dso.h>
 #include <openssl/engine.h>
+#include <openssl/rsa.h>
+#include <openssl/dsa.h>
+#include <openssl/dh.h>
+#include <openssl/rand.h>
 
 #ifndef OPENSSL_NO_HW
 #ifndef OPENSSL_NO_HW_CSWIFT
index e075d1b459abb870a8c10804b5268987aa3205ca..481c9b099782a03524246c511e5952be47d5292c 100644 (file)
@@ -64,6 +64,7 @@
 #include <openssl/dso.h>
 #include <openssl/engine.h>
 #include <openssl/ui.h>
+#include <openssl/rand.h>
 
 #ifndef OPENSSL_NO_HW
 #ifndef OPENSSL_NO_HW_NCIPHER
index 4df6f0495a58c50b452c065a4deee724d31cd44c..3ddbf594dfa9c646e47f474cb8f70ff2b8c79a58 100644 (file)
@@ -62,7 +62,9 @@
 #include <openssl/buffer.h>
 #include <openssl/dso.h>
 #include <openssl/engine.h>
-
+#include <openssl/rsa.h>
+#include <openssl/dsa.h>
+#include <openssl/dh.h>
 
 #ifndef OPENSSL_NO_HW
 #ifndef OPENSSL_NO_HW_NURON
index 8e77e5c282fb05dbddbcb619200a84f505a6c34e..654f41031abc3c75a475b4c4236bae1696960bff 100644 (file)
@@ -56,6 +56,7 @@
 #include <openssl/pem.h>
 #include <openssl/dso.h>
 #include <openssl/engine.h>
+#include <openssl/rand.h>
 
 #ifndef OPENSSL_NO_HW
 #ifndef OPENSSL_NO_HW_SUREWARE
index 5aa29f1c5361a0ef69508658f55308cb36a86a84..37c22638ffd237764dad7ffae597d3779abc0553 100644 (file)
@@ -64,6 +64,9 @@
 #include <openssl/buffer.h>
 #include <openssl/dso.h>
 #include <openssl/engine.h>
+#include <openssl/rsa.h>
+#include <openssl/dsa.h>
+#include <openssl/dh.h>
 
 #ifndef OPENSSL_NO_HW
 #ifndef OPENSSL_NO_HW_UBSEC