2016-10-18 13:16:35 +00:00
|
|
|
/*
|
2018-03-20 13:00:17 +00:00
|
|
|
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
2016-10-18 13:16:35 +00:00
|
|
|
*
|
2018-12-06 12:05:25 +00:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-10-18 13:16:35 +00:00
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <openssl/opensslv.h>
|
2017-05-05 21:39:13 +00:00
|
|
|
#include <openssl/ssl.h>
|
|
|
|
#include <openssl/ossl_typ.h>
|
2018-03-23 00:05:23 +00:00
|
|
|
#include "internal/dso_conf.h"
|
2017-05-05 21:39:13 +00:00
|
|
|
#include "testutil.h"
|
2016-10-18 13:16:35 +00:00
|
|
|
|
2018-03-19 17:37:46 +00:00
|
|
|
typedef void DSO;
|
|
|
|
|
2016-10-18 13:16:35 +00:00
|
|
|
typedef const SSL_METHOD * (*TLS_method_t)(void);
|
|
|
|
typedef SSL_CTX * (*SSL_CTX_new_t)(const SSL_METHOD *meth);
|
|
|
|
typedef void (*SSL_CTX_free_t)(SSL_CTX *);
|
|
|
|
typedef unsigned long (*ERR_get_error_t)(void);
|
Switch to MAJOR.MINOR.PATCH versioning and version 3.0.0-dev
We're strictly use version numbers of the form MAJOR.MINOR.PATCH.
Letter releases are things of days past.
The most central change is that we now express the version number with
three macros, one for each part of the version number:
OPENSSL_VERSION_MAJOR
OPENSSL_VERSION_MINOR
OPENSSL_VERSION_PATCH
We also provide two additional macros to express pre-release and build
metadata information (also specified in semantic versioning):
OPENSSL_VERSION_PRE_RELEASE
OPENSSL_VERSION_BUILD_METADATA
To get the library's idea of all those values, we introduce the
following functions:
unsigned int OPENSSL_version_major(void);
unsigned int OPENSSL_version_minor(void);
unsigned int OPENSSL_version_patch(void);
const char *OPENSSL_version_pre_release(void);
const char *OPENSSL_version_build_metadata(void);
Additionally, for shared library versioning (which is out of scope in
semantic versioning, but that we still need):
OPENSSL_SHLIB_VERSION
We also provide a macro that contains the release date. This is not
part of the version number, but is extra information that we want to
be able to display:
OPENSSL_RELEASE_DATE
Finally, also provide the following convenience functions:
const char *OPENSSL_version_text(void);
const char *OPENSSL_version_text_full(void);
The following macros and functions are deprecated, and while currently
existing for backward compatibility, they are expected to disappear:
OPENSSL_VERSION_NUMBER
OPENSSL_VERSION_TEXT
OPENSSL_VERSION
OpenSSL_version_num()
OpenSSL_version()
Also, this function is introduced to replace OpenSSL_version() for all
indexes except for OPENSSL_VERSION:
OPENSSL_info()
For configuration, the option 'newversion-only' is added to disable all
the macros and functions that are mentioned as deprecated above.
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7724)
2018-09-27 13:56:35 +00:00
|
|
|
typedef unsigned long (*OPENSSL_version_major_t)(void);
|
|
|
|
typedef unsigned long (*OPENSSL_version_minor_t)(void);
|
|
|
|
typedef unsigned long (*OPENSSL_version_patch_t)(void);
|
2018-03-30 17:17:39 +00:00
|
|
|
typedef DSO * (*DSO_dsobyaddr_t)(void (*addr)(void), int flags);
|
2018-03-19 17:37:46 +00:00
|
|
|
typedef int (*DSO_free_t)(DSO *dso);
|
2016-10-18 13:16:35 +00:00
|
|
|
|
2017-05-06 11:59:18 +00:00
|
|
|
typedef enum test_types_en {
|
|
|
|
CRYPTO_FIRST,
|
|
|
|
SSL_FIRST,
|
2018-03-19 17:37:46 +00:00
|
|
|
JUST_CRYPTO,
|
|
|
|
DSO_REFTEST
|
2017-05-06 11:59:18 +00:00
|
|
|
} TEST_TYPE;
|
|
|
|
|
|
|
|
static TEST_TYPE test_type;
|
|
|
|
static const char *path_crypto;
|
|
|
|
static const char *path_ssl;
|
|
|
|
|
2016-10-18 13:16:35 +00:00
|
|
|
#ifdef DSO_DLFCN
|
|
|
|
|
|
|
|
# include <dlfcn.h>
|
|
|
|
|
2017-05-06 11:59:18 +00:00
|
|
|
# define SHLIB_INIT NULL
|
|
|
|
|
2017-05-05 21:39:13 +00:00
|
|
|
typedef void *SHLIB;
|
|
|
|
typedef void *SHLIB_SYM;
|
2016-10-18 13:16:35 +00:00
|
|
|
|
2016-11-03 17:48:23 +00:00
|
|
|
static int shlib_load(const char *filename, SHLIB *lib)
|
2016-10-18 13:16:35 +00:00
|
|
|
{
|
2018-06-15 10:36:03 +00:00
|
|
|
int dl_flags = (RTLD_GLOBAL|RTLD_LAZY);
|
|
|
|
#ifdef _AIX
|
|
|
|
if (filename[strlen(filename) - 1] == ')')
|
|
|
|
dl_flags |= RTLD_MEMBER;
|
|
|
|
#endif
|
|
|
|
*lib = dlopen(filename, dl_flags);
|
2017-05-05 21:39:13 +00:00
|
|
|
return *lib == NULL ? 0 : 1;
|
2016-10-18 13:16:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int shlib_sym(SHLIB lib, const char *symname, SHLIB_SYM *sym)
|
|
|
|
{
|
|
|
|
*sym = dlsym(lib, symname);
|
|
|
|
return *sym != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int shlib_close(SHLIB lib)
|
|
|
|
{
|
2017-05-05 21:39:13 +00:00
|
|
|
return dlclose(lib) != 0 ? 0 : 1;
|
2016-10-18 13:16:35 +00:00
|
|
|
}
|
2017-05-05 21:39:13 +00:00
|
|
|
#endif
|
2016-10-18 13:16:35 +00:00
|
|
|
|
2017-05-05 21:39:13 +00:00
|
|
|
#ifdef DSO_WIN32
|
2016-10-18 13:16:35 +00:00
|
|
|
|
|
|
|
# include <windows.h>
|
|
|
|
|
2017-05-06 11:59:18 +00:00
|
|
|
# define SHLIB_INIT 0
|
|
|
|
|
2016-10-18 13:16:35 +00:00
|
|
|
typedef HINSTANCE SHLIB;
|
2017-05-05 21:39:13 +00:00
|
|
|
typedef void *SHLIB_SYM;
|
2016-10-18 13:16:35 +00:00
|
|
|
|
2016-11-03 17:48:23 +00:00
|
|
|
static int shlib_load(const char *filename, SHLIB *lib)
|
2016-10-18 13:16:35 +00:00
|
|
|
{
|
|
|
|
*lib = LoadLibraryA(filename);
|
2017-05-05 21:39:13 +00:00
|
|
|
return *lib == NULL ? 0 : 1;
|
2016-10-18 13:16:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int shlib_sym(SHLIB lib, const char *symname, SHLIB_SYM *sym)
|
|
|
|
{
|
|
|
|
*sym = (SHLIB_SYM)GetProcAddress(lib, symname);
|
|
|
|
return *sym != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int shlib_close(SHLIB lib)
|
|
|
|
{
|
2017-05-05 21:39:13 +00:00
|
|
|
return FreeLibrary(lib) == 0 ? 0 : 1;
|
2016-10-18 13:16:35 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2017-05-06 11:59:18 +00:00
|
|
|
#if defined(DSO_DLFCN) || defined(DSO_WIN32)
|
2017-05-05 21:39:13 +00:00
|
|
|
|
|
|
|
static int test_lib(void)
|
2016-10-18 13:16:35 +00:00
|
|
|
{
|
2017-05-05 21:39:13 +00:00
|
|
|
SHLIB ssllib = SHLIB_INIT;
|
|
|
|
SHLIB cryptolib = SHLIB_INIT;
|
2016-10-18 13:16:35 +00:00
|
|
|
SSL_CTX *ctx;
|
|
|
|
union {
|
2017-05-05 21:39:13 +00:00
|
|
|
void (*func)(void);
|
2016-10-18 13:16:35 +00:00
|
|
|
SHLIB_SYM sym;
|
Switch to MAJOR.MINOR.PATCH versioning and version 3.0.0-dev
We're strictly use version numbers of the form MAJOR.MINOR.PATCH.
Letter releases are things of days past.
The most central change is that we now express the version number with
three macros, one for each part of the version number:
OPENSSL_VERSION_MAJOR
OPENSSL_VERSION_MINOR
OPENSSL_VERSION_PATCH
We also provide two additional macros to express pre-release and build
metadata information (also specified in semantic versioning):
OPENSSL_VERSION_PRE_RELEASE
OPENSSL_VERSION_BUILD_METADATA
To get the library's idea of all those values, we introduce the
following functions:
unsigned int OPENSSL_version_major(void);
unsigned int OPENSSL_version_minor(void);
unsigned int OPENSSL_version_patch(void);
const char *OPENSSL_version_pre_release(void);
const char *OPENSSL_version_build_metadata(void);
Additionally, for shared library versioning (which is out of scope in
semantic versioning, but that we still need):
OPENSSL_SHLIB_VERSION
We also provide a macro that contains the release date. This is not
part of the version number, but is extra information that we want to
be able to display:
OPENSSL_RELEASE_DATE
Finally, also provide the following convenience functions:
const char *OPENSSL_version_text(void);
const char *OPENSSL_version_text_full(void);
The following macros and functions are deprecated, and while currently
existing for backward compatibility, they are expected to disappear:
OPENSSL_VERSION_NUMBER
OPENSSL_VERSION_TEXT
OPENSSL_VERSION
OpenSSL_version_num()
OpenSSL_version()
Also, this function is introduced to replace OpenSSL_version() for all
indexes except for OPENSSL_VERSION:
OPENSSL_info()
For configuration, the option 'newversion-only' is added to disable all
the macros and functions that are mentioned as deprecated above.
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7724)
2018-09-27 13:56:35 +00:00
|
|
|
} symbols[4];
|
2017-05-05 21:39:13 +00:00
|
|
|
TLS_method_t myTLS_method;
|
|
|
|
SSL_CTX_new_t mySSL_CTX_new;
|
|
|
|
SSL_CTX_free_t mySSL_CTX_free;
|
|
|
|
ERR_get_error_t myERR_get_error;
|
Switch to MAJOR.MINOR.PATCH versioning and version 3.0.0-dev
We're strictly use version numbers of the form MAJOR.MINOR.PATCH.
Letter releases are things of days past.
The most central change is that we now express the version number with
three macros, one for each part of the version number:
OPENSSL_VERSION_MAJOR
OPENSSL_VERSION_MINOR
OPENSSL_VERSION_PATCH
We also provide two additional macros to express pre-release and build
metadata information (also specified in semantic versioning):
OPENSSL_VERSION_PRE_RELEASE
OPENSSL_VERSION_BUILD_METADATA
To get the library's idea of all those values, we introduce the
following functions:
unsigned int OPENSSL_version_major(void);
unsigned int OPENSSL_version_minor(void);
unsigned int OPENSSL_version_patch(void);
const char *OPENSSL_version_pre_release(void);
const char *OPENSSL_version_build_metadata(void);
Additionally, for shared library versioning (which is out of scope in
semantic versioning, but that we still need):
OPENSSL_SHLIB_VERSION
We also provide a macro that contains the release date. This is not
part of the version number, but is extra information that we want to
be able to display:
OPENSSL_RELEASE_DATE
Finally, also provide the following convenience functions:
const char *OPENSSL_version_text(void);
const char *OPENSSL_version_text_full(void);
The following macros and functions are deprecated, and while currently
existing for backward compatibility, they are expected to disappear:
OPENSSL_VERSION_NUMBER
OPENSSL_VERSION_TEXT
OPENSSL_VERSION
OpenSSL_version_num()
OpenSSL_version()
Also, this function is introduced to replace OpenSSL_version() for all
indexes except for OPENSSL_VERSION:
OPENSSL_info()
For configuration, the option 'newversion-only' is added to disable all
the macros and functions that are mentioned as deprecated above.
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7724)
2018-09-27 13:56:35 +00:00
|
|
|
OPENSSL_version_major_t myOPENSSL_version_major;
|
|
|
|
OPENSSL_version_minor_t myOPENSSL_version_minor;
|
|
|
|
OPENSSL_version_patch_t myOPENSSL_version_patch;
|
2017-05-05 21:39:13 +00:00
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
switch (test_type) {
|
|
|
|
case JUST_CRYPTO:
|
|
|
|
if (!TEST_true(shlib_load(path_crypto, &cryptolib)))
|
|
|
|
goto end;
|
|
|
|
break;
|
|
|
|
case CRYPTO_FIRST:
|
|
|
|
if (!TEST_true(shlib_load(path_crypto, &cryptolib))
|
|
|
|
|| !TEST_true(shlib_load(path_ssl, &ssllib)))
|
|
|
|
goto end;
|
2017-06-16 20:10:11 +00:00
|
|
|
break;
|
2017-05-05 21:39:13 +00:00
|
|
|
case SSL_FIRST:
|
|
|
|
if (!TEST_true(shlib_load(path_ssl, &ssllib))
|
|
|
|
|| !TEST_true(shlib_load(path_crypto, &cryptolib)))
|
|
|
|
goto end;
|
|
|
|
break;
|
2018-03-19 17:37:46 +00:00
|
|
|
case DSO_REFTEST:
|
|
|
|
if (!TEST_true(shlib_load(path_crypto, &cryptolib)))
|
|
|
|
goto end;
|
|
|
|
break;
|
2016-10-18 13:16:35 +00:00
|
|
|
}
|
|
|
|
|
2018-03-19 17:37:46 +00:00
|
|
|
if (test_type != JUST_CRYPTO && test_type != DSO_REFTEST) {
|
2017-05-05 21:39:13 +00:00
|
|
|
if (!TEST_true(shlib_sym(ssllib, "TLS_method", &symbols[0].sym))
|
|
|
|
|| !TEST_true(shlib_sym(ssllib, "SSL_CTX_new", &symbols[1].sym))
|
|
|
|
|| !TEST_true(shlib_sym(ssllib, "SSL_CTX_free", &symbols[2].sym)))
|
|
|
|
goto end;
|
|
|
|
myTLS_method = (TLS_method_t)symbols[0].func;
|
|
|
|
mySSL_CTX_new = (SSL_CTX_new_t)symbols[1].func;
|
|
|
|
mySSL_CTX_free = (SSL_CTX_free_t)symbols[2].func;
|
|
|
|
if (!TEST_ptr(ctx = mySSL_CTX_new(myTLS_method())))
|
|
|
|
goto end;
|
|
|
|
mySSL_CTX_free(ctx);
|
2016-10-18 13:16:35 +00:00
|
|
|
}
|
|
|
|
|
2017-05-05 21:39:13 +00:00
|
|
|
if (!TEST_true(shlib_sym(cryptolib, "ERR_get_error", &symbols[0].sym))
|
Switch to MAJOR.MINOR.PATCH versioning and version 3.0.0-dev
We're strictly use version numbers of the form MAJOR.MINOR.PATCH.
Letter releases are things of days past.
The most central change is that we now express the version number with
three macros, one for each part of the version number:
OPENSSL_VERSION_MAJOR
OPENSSL_VERSION_MINOR
OPENSSL_VERSION_PATCH
We also provide two additional macros to express pre-release and build
metadata information (also specified in semantic versioning):
OPENSSL_VERSION_PRE_RELEASE
OPENSSL_VERSION_BUILD_METADATA
To get the library's idea of all those values, we introduce the
following functions:
unsigned int OPENSSL_version_major(void);
unsigned int OPENSSL_version_minor(void);
unsigned int OPENSSL_version_patch(void);
const char *OPENSSL_version_pre_release(void);
const char *OPENSSL_version_build_metadata(void);
Additionally, for shared library versioning (which is out of scope in
semantic versioning, but that we still need):
OPENSSL_SHLIB_VERSION
We also provide a macro that contains the release date. This is not
part of the version number, but is extra information that we want to
be able to display:
OPENSSL_RELEASE_DATE
Finally, also provide the following convenience functions:
const char *OPENSSL_version_text(void);
const char *OPENSSL_version_text_full(void);
The following macros and functions are deprecated, and while currently
existing for backward compatibility, they are expected to disappear:
OPENSSL_VERSION_NUMBER
OPENSSL_VERSION_TEXT
OPENSSL_VERSION
OpenSSL_version_num()
OpenSSL_version()
Also, this function is introduced to replace OpenSSL_version() for all
indexes except for OPENSSL_VERSION:
OPENSSL_info()
For configuration, the option 'newversion-only' is added to disable all
the macros and functions that are mentioned as deprecated above.
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7724)
2018-09-27 13:56:35 +00:00
|
|
|
|| !TEST_true(shlib_sym(cryptolib, "OPENSSL_version_major",
|
|
|
|
&symbols[1].sym))
|
|
|
|
|| !TEST_true(shlib_sym(cryptolib, "OPENSSL_version_minor",
|
|
|
|
&symbols[2].sym))
|
|
|
|
|| !TEST_true(shlib_sym(cryptolib, "OPENSSL_version_patch",
|
|
|
|
&symbols[3].sym)))
|
2017-05-05 21:39:13 +00:00
|
|
|
goto end;
|
|
|
|
myERR_get_error = (ERR_get_error_t)symbols[0].func;
|
|
|
|
if (!TEST_int_eq(myERR_get_error(), 0))
|
|
|
|
goto end;
|
2018-03-14 16:31:20 +00:00
|
|
|
|
Switch to MAJOR.MINOR.PATCH versioning and version 3.0.0-dev
We're strictly use version numbers of the form MAJOR.MINOR.PATCH.
Letter releases are things of days past.
The most central change is that we now express the version number with
three macros, one for each part of the version number:
OPENSSL_VERSION_MAJOR
OPENSSL_VERSION_MINOR
OPENSSL_VERSION_PATCH
We also provide two additional macros to express pre-release and build
metadata information (also specified in semantic versioning):
OPENSSL_VERSION_PRE_RELEASE
OPENSSL_VERSION_BUILD_METADATA
To get the library's idea of all those values, we introduce the
following functions:
unsigned int OPENSSL_version_major(void);
unsigned int OPENSSL_version_minor(void);
unsigned int OPENSSL_version_patch(void);
const char *OPENSSL_version_pre_release(void);
const char *OPENSSL_version_build_metadata(void);
Additionally, for shared library versioning (which is out of scope in
semantic versioning, but that we still need):
OPENSSL_SHLIB_VERSION
We also provide a macro that contains the release date. This is not
part of the version number, but is extra information that we want to
be able to display:
OPENSSL_RELEASE_DATE
Finally, also provide the following convenience functions:
const char *OPENSSL_version_text(void);
const char *OPENSSL_version_text_full(void);
The following macros and functions are deprecated, and while currently
existing for backward compatibility, they are expected to disappear:
OPENSSL_VERSION_NUMBER
OPENSSL_VERSION_TEXT
OPENSSL_VERSION
OpenSSL_version_num()
OpenSSL_version()
Also, this function is introduced to replace OpenSSL_version() for all
indexes except for OPENSSL_VERSION:
OPENSSL_info()
For configuration, the option 'newversion-only' is added to disable all
the macros and functions that are mentioned as deprecated above.
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7724)
2018-09-27 13:56:35 +00:00
|
|
|
/* Make sure the libraries are a compatible version */
|
|
|
|
myOPENSSL_version_major = (OPENSSL_version_major_t)symbols[1].func;
|
|
|
|
myOPENSSL_version_minor = (OPENSSL_version_minor_t)symbols[2].func;
|
|
|
|
myOPENSSL_version_patch = (OPENSSL_version_patch_t)symbols[3].func;
|
|
|
|
if (!TEST_int_eq(myOPENSSL_version_major(), OPENSSL_VERSION_MAJOR))
|
2018-03-14 16:31:20 +00:00
|
|
|
goto end;
|
Switch to MAJOR.MINOR.PATCH versioning and version 3.0.0-dev
We're strictly use version numbers of the form MAJOR.MINOR.PATCH.
Letter releases are things of days past.
The most central change is that we now express the version number with
three macros, one for each part of the version number:
OPENSSL_VERSION_MAJOR
OPENSSL_VERSION_MINOR
OPENSSL_VERSION_PATCH
We also provide two additional macros to express pre-release and build
metadata information (also specified in semantic versioning):
OPENSSL_VERSION_PRE_RELEASE
OPENSSL_VERSION_BUILD_METADATA
To get the library's idea of all those values, we introduce the
following functions:
unsigned int OPENSSL_version_major(void);
unsigned int OPENSSL_version_minor(void);
unsigned int OPENSSL_version_patch(void);
const char *OPENSSL_version_pre_release(void);
const char *OPENSSL_version_build_metadata(void);
Additionally, for shared library versioning (which is out of scope in
semantic versioning, but that we still need):
OPENSSL_SHLIB_VERSION
We also provide a macro that contains the release date. This is not
part of the version number, but is extra information that we want to
be able to display:
OPENSSL_RELEASE_DATE
Finally, also provide the following convenience functions:
const char *OPENSSL_version_text(void);
const char *OPENSSL_version_text_full(void);
The following macros and functions are deprecated, and while currently
existing for backward compatibility, they are expected to disappear:
OPENSSL_VERSION_NUMBER
OPENSSL_VERSION_TEXT
OPENSSL_VERSION
OpenSSL_version_num()
OpenSSL_version()
Also, this function is introduced to replace OpenSSL_version() for all
indexes except for OPENSSL_VERSION:
OPENSSL_info()
For configuration, the option 'newversion-only' is added to disable all
the macros and functions that are mentioned as deprecated above.
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7724)
2018-09-27 13:56:35 +00:00
|
|
|
if (!TEST_int_ge(myOPENSSL_version_minor(), OPENSSL_VERSION_MINOR))
|
|
|
|
goto end;
|
|
|
|
if (myOPENSSL_version_minor() == OPENSSL_VERSION_MINOR
|
|
|
|
&& !TEST_int_ge(myOPENSSL_version_patch(), OPENSSL_VERSION_PATCH))
|
2017-05-05 21:39:13 +00:00
|
|
|
goto end;
|
|
|
|
|
2018-03-19 17:37:46 +00:00
|
|
|
if (test_type == DSO_REFTEST) {
|
|
|
|
# ifdef DSO_DLFCN
|
2018-03-23 13:18:16 +00:00
|
|
|
DSO_dsobyaddr_t myDSO_dsobyaddr;
|
|
|
|
DSO_free_t myDSO_free;
|
|
|
|
|
2018-03-19 17:37:46 +00:00
|
|
|
/*
|
|
|
|
* This is resembling the code used in ossl_init_base() and
|
|
|
|
* OPENSSL_atexit() to block unloading the library after dlclose().
|
|
|
|
* We are not testing this on Windows, because it is done there in a
|
|
|
|
* completely different way. Especially as a call to DSO_dsobyaddr()
|
|
|
|
* will always return an error, because DSO_pathbyaddr() is not
|
|
|
|
* implemented there.
|
|
|
|
*/
|
|
|
|
if (!TEST_true(shlib_sym(cryptolib, "DSO_dsobyaddr", &symbols[0].sym))
|
|
|
|
|| !TEST_true(shlib_sym(cryptolib, "DSO_free",
|
|
|
|
&symbols[1].sym)))
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
myDSO_dsobyaddr = (DSO_dsobyaddr_t)symbols[0].func;
|
|
|
|
myDSO_free = (DSO_free_t)symbols[1].func;
|
|
|
|
|
|
|
|
{
|
|
|
|
DSO *hndl;
|
|
|
|
/* use known symbol from crypto module */
|
2018-03-30 17:17:39 +00:00
|
|
|
if (!TEST_ptr(hndl = myDSO_dsobyaddr((void (*)(void))ERR_get_error, 0)))
|
2018-03-19 17:37:46 +00:00
|
|
|
goto end;
|
2018-03-23 00:05:41 +00:00
|
|
|
myDSO_free(hndl);
|
2018-03-19 17:37:46 +00:00
|
|
|
}
|
|
|
|
# endif /* DSO_DLFCN */
|
|
|
|
}
|
|
|
|
|
2017-05-05 21:39:13 +00:00
|
|
|
switch (test_type) {
|
|
|
|
case JUST_CRYPTO:
|
|
|
|
if (!TEST_true(shlib_close(cryptolib)))
|
|
|
|
goto end;
|
|
|
|
break;
|
|
|
|
case CRYPTO_FIRST:
|
|
|
|
if (!TEST_true(shlib_close(cryptolib))
|
|
|
|
|| !TEST_true(shlib_close(ssllib)))
|
|
|
|
goto end;
|
2017-06-16 20:10:11 +00:00
|
|
|
break;
|
2017-05-05 21:39:13 +00:00
|
|
|
case SSL_FIRST:
|
|
|
|
if (!TEST_true(shlib_close(ssllib))
|
|
|
|
|| !TEST_true(shlib_close(cryptolib)))
|
|
|
|
goto end;
|
|
|
|
break;
|
2018-03-19 17:37:46 +00:00
|
|
|
case DSO_REFTEST:
|
|
|
|
if (!TEST_true(shlib_close(cryptolib)))
|
|
|
|
goto end;
|
|
|
|
break;
|
2016-10-18 13:16:35 +00:00
|
|
|
}
|
|
|
|
|
2017-05-05 21:39:13 +00:00
|
|
|
result = 1;
|
|
|
|
end:
|
|
|
|
return result;
|
|
|
|
}
|
2017-05-06 11:59:18 +00:00
|
|
|
#endif
|
|
|
|
|
2016-10-18 13:16:35 +00:00
|
|
|
|
2017-07-18 01:48:27 +00:00
|
|
|
int setup_tests(void)
|
2017-05-05 21:39:13 +00:00
|
|
|
{
|
2017-07-18 01:48:27 +00:00
|
|
|
const char *p = test_get_argument(0);
|
2016-10-18 13:16:35 +00:00
|
|
|
|
2017-07-18 01:48:27 +00:00
|
|
|
if (strcmp(p, "-crypto_first") == 0) {
|
2017-05-05 21:39:13 +00:00
|
|
|
test_type = CRYPTO_FIRST;
|
2017-07-18 01:48:27 +00:00
|
|
|
} else if (strcmp(p, "-ssl_first") == 0) {
|
2017-05-05 21:39:13 +00:00
|
|
|
test_type = SSL_FIRST;
|
2017-07-18 01:48:27 +00:00
|
|
|
} else if (strcmp(p, "-just_crypto") == 0) {
|
2017-05-05 21:39:13 +00:00
|
|
|
test_type = JUST_CRYPTO;
|
2018-03-19 17:37:46 +00:00
|
|
|
} else if (strcmp(p, "-dso_ref") == 0) {
|
|
|
|
test_type = JUST_CRYPTO;
|
2017-05-05 21:39:13 +00:00
|
|
|
} else {
|
|
|
|
TEST_error("Unrecognised argument");
|
2017-07-18 01:48:27 +00:00
|
|
|
return 0;
|
2016-10-18 13:16:35 +00:00
|
|
|
}
|
2017-07-18 01:48:27 +00:00
|
|
|
if (!TEST_ptr(path_crypto = test_get_argument(1))
|
|
|
|
|| !TEST_ptr(path_ssl = test_get_argument(2)))
|
|
|
|
return 0;
|
2016-10-18 13:16:35 +00:00
|
|
|
|
2017-05-06 11:59:18 +00:00
|
|
|
#if defined(DSO_DLFCN) || defined(DSO_WIN32)
|
2017-05-05 21:39:13 +00:00
|
|
|
ADD_TEST(test_lib);
|
2017-05-06 11:59:18 +00:00
|
|
|
#endif
|
2017-07-18 01:48:27 +00:00
|
|
|
return 1;
|
2016-10-18 13:16:35 +00:00
|
|
|
}
|