RT41897: Add an CRYPTO_secure_actual_size
authorRich Salz <rsalz@akamai.com>
Thu, 7 Jan 2016 21:05:45 +0000 (16:05 -0500)
committerRich Salz <rsalz@openssl.org>
Sun, 10 Jan 2016 00:13:15 +0000 (19:13 -0500)
This is already documented, I just forgot to include the code :)

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
crypto/mem_sec.c
include/openssl/crypto.h
util/libeay.num

index 5f4f733fd06f3f11f5871be37a7c25e39d5cd224..9adc124e36bd41f1204bd371f3c8b90faa0e6456 100644 (file)
@@ -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 */
index e8b9fcbf600ac60000ea4979f05ef6d709797330..2d1a98327a4904ffd816b003f8cf22f115d5e654 100644 (file)
@@ -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);
index d71e980ef0132840fe86bd03c247ffe4a759d33d..1af1a2e633dc2e4ebc10e693ca2b7c888fbbc00e 100755 (executable)
@@ -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: