Allow FIPS malloc callback setting. Automatically set some callbacks
in OPENSSL_init().
This commit is contained in:
parent
c4acfb1fd0
commit
8cf88778ea
@ -54,6 +54,9 @@
|
|||||||
|
|
||||||
#include <e_os.h>
|
#include <e_os.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
|
#ifdef OPENSSL_FIPS
|
||||||
|
#include <openssl/fips.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__GNUC__) && __GNUC__>=2
|
#if defined(__GNUC__) && __GNUC__>=2
|
||||||
void OPENSSL_init(void) __attribute__((constructor));
|
void OPENSSL_init(void) __attribute__((constructor));
|
||||||
@ -116,6 +119,11 @@ void OPENSSL_init(void)
|
|||||||
if (done)
|
if (done)
|
||||||
return;
|
return;
|
||||||
done = 1;
|
done = 1;
|
||||||
|
#ifdef OPENSSL_FIPS
|
||||||
|
FIPS_set_locking_callbacks(CRYPTO_lock, CRYPTO_add_lock);
|
||||||
|
FIPS_set_error_callbacks(ERR_put_error, ERR_add_error_vdata);
|
||||||
|
FIPS_set_malloc_callbacks(CRYPTO_malloc, CRYPTO_free);
|
||||||
|
#endif
|
||||||
#if 1
|
#if 1
|
||||||
fprintf(stderr, "Called OPENSSL_init\n");
|
fprintf(stderr, "Called OPENSSL_init\n");
|
||||||
#endif
|
#endif
|
||||||
|
@ -122,6 +122,10 @@ void FIPS_set_locking_callbacks(void (*func)(int mode, int type,
|
|||||||
int (*add_cb)(int *pointer, int amount,
|
int (*add_cb)(int *pointer, int amount,
|
||||||
int type, const char *file, int line));
|
int type, const char *file, int line));
|
||||||
|
|
||||||
|
void FIPS_set_malloc_callbacks(
|
||||||
|
void *(*malloc_cb)(int num, const char *file, int line),
|
||||||
|
void (*free_cb)(void *));
|
||||||
|
|
||||||
#define FIPS_ERROR_IGNORED(alg) OpenSSLDie(__FILE__, __LINE__, \
|
#define FIPS_ERROR_IGNORED(alg) OpenSSLDie(__FILE__, __LINE__, \
|
||||||
alg " previous FIPS forbidden algorithm error ignored");
|
alg " previous FIPS forbidden algorithm error ignored");
|
||||||
|
|
||||||
|
@ -84,3 +84,11 @@ void FIPS_free(void *x)
|
|||||||
{
|
{
|
||||||
fips_free_cb(x);
|
fips_free_cb(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FIPS_set_malloc_callbacks(
|
||||||
|
void *(*malloc_cb)(int num, const char *file, int line),
|
||||||
|
void (*free_cb)(void *))
|
||||||
|
{
|
||||||
|
fips_malloc_cb = malloc_cb;
|
||||||
|
fips_free_cb = free_cb;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user