Add a CRYPTO_library_init and static-initializer-less build option. Chromium does not like static initializers, and the CPU logic uses one to initialize CPU bits. However, the crypto library lacks an explicit initialization function, which could complicate (no compile-time errors) porting existing code which uses crypto/, but not ssl/. Add an explicit CRYPTO_library_init function, but make it a no-op by default. It only does anything (and is required) if building with BORINGSSL_NO_STATIC_INITIALIZER. Change-Id: I6933bdc3447fb382b1f87c788e5b8142d6f3fe39 Reviewed-on: https://boringssl-review.googlesource.com/1770 Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/x509v3/tabtest.c b/crypto/x509v3/tabtest.c index 06a692e..f783938 100644 --- a/crypto/x509v3/tabtest.c +++ b/crypto/x509v3/tabtest.c
@@ -62,6 +62,7 @@ #include <stdio.h> +#include <openssl/crypto.h> #include <openssl/x509v3.h> #include "ext_dat.h" @@ -70,6 +71,7 @@ { int i, prev = -1, bad = 0; const X509V3_EXT_METHOD **tmp; + CRYPTO_library_init(); i = sizeof(standard_exts) / sizeof(X509V3_EXT_METHOD *); if(i != STANDARD_EXTENSION_COUNT) fprintf(stderr, "Extension number invalid expecting %d\n", i);
diff --git a/crypto/x509v3/v3nametest.c b/crypto/x509v3/v3nametest.c index 326b1f9..6a2ea85 100644 --- a/crypto/x509v3/v3nametest.c +++ b/crypto/x509v3/v3nametest.c
@@ -55,6 +55,7 @@ #include <string.h> #include <strings.h> +#include <openssl/crypto.h> #include <openssl/x509.h> #include <openssl/x509v3.h> @@ -391,6 +392,8 @@ int main(void) { + CRYPTO_library_init(); + const struct set_name_fn *pfn = name_fns; while (pfn->name) { const char *const *pname = names;