CRYPTO_secure_malloc_init() fails without error message

Clay Shields clay at cs.georgetown.edu
Thu Feb 20 20:53:44 UTC 2020


Hi,

I am working on some server code that uses openssl libcrypto for AES encryption of files. Perhaps I am doing the wrong thing or the right thing the wrong way, but I am trying to use the OpenSSL secure heap for key storage. I created a small program that follow what I was trying to do, below, but the gist of it is that the CRYPTO_secure_malloc_init call returns 0 on my system, which means it has failed according to the man page at:

https://www.openssl.org/docs/man1.1.1/man3/CRYPTO_secure_malloc_init.html 

I tried to get an error message out to see why, but apparently one is not set. The output of the program is:

"failed to init openssl secure heap the error may be (null)"

I am using a Fedora linux system that is running as a VM under VMWare Fusion on Mac OS. 

Any clues as to why it might be failing? Am I doing the wrong thing by trying to use the secure heap for key storage? Any help is appreciated.

Thanks,

Clay

--------------------

#include <openssl/crypto.h>
#include <openssl/conf.h>
#include <openssl/evp.h>
#include <openssl/err.h>
#include <openssl/ssl.h>

#define OPENSSL_MIN_HEAP_SIZE 65536

int main(){

 SSL_load_error_strings();
 SSL_library_init ();
 OpenSSL_add_all_algorithms ();
 	
 // Initialize the OPENSSL secure heap space for key storage
 int ret = CRYPTO_secure_malloc_init(OPENSSL_MIN_HEAP_SIZE, OPENSSL_MIN_HEAP_SIZE);

 if (ret == 0){
   printf("failed to init openssl secure heap the error may be %s\n", ERR_reason_error_string(ERR_get_error()));
 }

}


More information about the openssl-users mailing list