Make CRYPTO_EX_DATA opaque

It is (almost) no longer referenced in public headers. It still
protrudes slightly into public headers to be a parameter of CRYPTO_EX_*
callbacks. But since you cannot do anything useful with that parameter,
we can probably remove that too later.

Bug: 412269080
Change-Id: I6e2ac4d0a0868d84bb6d721d0300f5c7b2a9fe63
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/79570
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
diff --git a/crypto/internal.h b/crypto/internal.h
index fec2542..a78338c 100644
--- a/crypto/internal.h
+++ b/crypto/internal.h
@@ -715,6 +715,10 @@
 
 // ex_data
 
+struct crypto_ex_data_st {
+  STACK_OF(void) *sk;
+} /* CRYPTO_EX_DATA */;
+
 typedef struct crypto_ex_data_func_st CRYPTO_EX_DATA_FUNCS;
 
 // CRYPTO_EX_DATA_CLASS tracks the ex_indices registered for a type which
diff --git a/include/openssl/ex_data.h b/include/openssl/ex_data.h
index 9ce1a93..55899df 100644
--- a/include/openssl/ex_data.h
+++ b/include/openssl/ex_data.h
@@ -17,8 +17,6 @@
 
 #include <openssl/base.h>   // IWYU pragma: export
 
-#include <openssl/stack.h>
-
 #if defined(__cplusplus)
 extern "C" {
 #endif
@@ -31,9 +29,6 @@
 // duplicated.
 
 
-typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
-
-
 // Type-specific functions.
 
 #if 0  // Sample
@@ -76,6 +71,11 @@
 
 // Callback types.
 
+// TODO(davidben): This is only declared in public headers to be a parameter of
+// |CRYPTO_EX_*| callbacks. Callers cannot do anything useful with it, so we may
+// as well pass NULL and use an internal type for the actual storage.
+typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
+
 // CRYPTO_EX_free is a callback function that is called when an object of the
 // class with extra data pointers is being destroyed. For example, if this
 // callback has been passed to |SSL_get_ex_new_index| then it may be called each
@@ -103,17 +103,10 @@
 typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from,
                           void **from_d, int index, long argl, void *argp);
 
-
-// Private structures.
-
 // CRYPTO_EX_unused is a placeholder for an unused callback. It is aliased to
 // int to ensure non-NULL callers fail to compile rather than fail silently.
 typedef int CRYPTO_EX_unused;
 
-struct crypto_ex_data_st {
-  STACK_OF(void) *sk;
-};
-
 
 #if defined(__cplusplus)
 }  // extern C