From d594199bb47362306060db0e185582ffcfd7b6a6 Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Thu, 7 Jan 2016 16:05:45 -0500 Subject: [PATCH] RT41897: Add an CRYPTO_secure_actual_size This is already documented, I just forgot to include the code :) Reviewed-by: Viktor Dukhovni --- crypto/mem_sec.c | 13 +++++++++++++ include/openssl/crypto.h | 5 +++++ util/libeay.num | 1 + 3 files changed, 19 insertions(+) diff --git a/crypto/mem_sec.c b/crypto/mem_sec.c index 5f4f733fd0..9adc124e36 100644 --- a/crypto/mem_sec.c +++ b/crypto/mem_sec.c @@ -157,6 +157,19 @@ size_t CRYPTO_secure_used() #endif /* IMPLEMENTED */ } +size_t CRYPTO_secure_actual_size(void *ptr) +{ +#ifdef IMPLEMENTED + size_t actual_size; + + LOCK(); + actual_size = sh_actual_size(ptr); + UNLOCK(); + return actual_size; +#else + return 0; +#endif +} /* END OF PAGE ... ... START OF PAGE */ diff --git a/include/openssl/crypto.h b/include/openssl/crypto.h index e8b9fcbf60..2d1a98327a 100644 --- a/include/openssl/crypto.h +++ b/include/openssl/crypto.h @@ -327,6 +327,8 @@ int CRYPTO_mem_ctrl(int mode); CRYPTO_secure_malloc(num, __FILE__, __LINE__) # define OPENSSL_secure_free(addr) \ CRYPTO_secure_free(addr) +# define OPENSSL_secure_actual_size(ptr) \ + CRYPTO_secure_actual_size(ptr) # else # define OPENSSL_malloc(num) \ CRYPTO_malloc(num, NULL, 0) @@ -350,6 +352,8 @@ int CRYPTO_mem_ctrl(int mode); CRYPTO_secure_malloc(num, NULL, 0) # define OPENSSL_secure_free(addr) \ CRYPTO_secure_free(addr) +# define OPENSSL_secure_actual_size(ptr) \ + CRYPTO_secure_actual_size(ptr) # endif @@ -490,6 +494,7 @@ void *CRYPTO_secure_malloc(size_t num, const char *file, int line); void CRYPTO_secure_free(void *ptr); int CRYPTO_secure_allocated(const void *ptr); int CRYPTO_secure_malloc_initialized(void); +size_t CRYPTO_secure_actual_size(void *ptr); size_t CRYPTO_secure_used(void); void OPENSSL_cleanse(void *ptr, size_t len); diff --git a/util/libeay.num b/util/libeay.num index d71e980ef0..1af1a2e633 100755 --- a/util/libeay.num +++ b/util/libeay.num @@ -4723,3 +4723,4 @@ CRYPTO_clear_realloc 5117 1_1_0 EXIST::FUNCTION: CRYPTO_mem_debug_push 5118 1_1_0 EXIST::FUNCTION:CRYPTO_MDEBUG CRYPTO_set_mem_debug 5119 1_1_0 EXIST::FUNCTION: CRYPTO_mem_debug_pop 5120 1_1_0 EXIST::FUNCTION:CRYPTO_MDEBUG +CRYPTO_secure_actual_size 5121 1_1_0 EXIST::FUNCTION: -- 2.25.1