void CRYPTO_secure_clear_free(void *ptr, size_t num, const char *file, int line) { #ifdef IMPLEMENTED size_t actual_size; if (ptr == NULL) return; if (!CRYPTO_secure_allocated(ptr)) { OPENSSL_cleanse(ptr, num); CRYPTO_free(ptr, file, line); return; } CRYPTO_THREAD_write_lock(sec_malloc_lock); actual_size = sh_actual_size(ptr); CLEAR(ptr, actual_size); secure_mem_used -= actual_size; sh_free(ptr); CRYPTO_THREAD_unlock(sec_malloc_lock); #else if (ptr == NULL) return; OPENSSL_cleanse(ptr, num); CRYPTO_free(ptr, file, line); #endif /* IMPLEMENTED */ }
size_t CRYPTO_secure_actual_size(void *ptr) { #ifdef IMPLEMENTED size_t actual_size; CRYPTO_THREAD_write_lock(sec_malloc_lock); actual_size = sh_actual_size(ptr); CRYPTO_THREAD_unlock(sec_malloc_lock); return actual_size; #else return 0; #endif }
size_t CRYPTO_secure_actual_size(void *ptr) { #ifdef OPENSSL_SECURE_MEMORY size_t actual_size; CRYPTO_THREAD_write_lock(sec_malloc_lock); actual_size = sh_actual_size(ptr); CRYPTO_THREAD_unlock(sec_malloc_lock); return actual_size; #else return 0; #endif }
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 }
void *CRYPTO_secure_malloc(size_t num, const char *file, int line) { #ifdef IMPLEMENTED void *ret; size_t actual_size; if (!secure_mem_initialized) { return CRYPTO_malloc(num, file, line); } CRYPTO_THREAD_write_lock(sec_malloc_lock); ret = sh_malloc(num); actual_size = ret ? sh_actual_size(ret) : 0; secure_mem_used += actual_size; CRYPTO_THREAD_unlock(sec_malloc_lock); return ret; #else return CRYPTO_malloc(num, file, line); #endif /* IMPLEMENTED */ }
void *CRYPTO_secure_malloc(int num, const char *file, int line) { #ifdef IMPLEMENTED void *ret; size_t actual_size; if (!secure_mem_initialized) { too_late = 1; return CRYPTO_malloc(num, file, line); } LOCK(); ret = sh_malloc(num); actual_size = ret ? sh_actual_size(ret) : 0; secure_mem_used += actual_size; UNLOCK(); return ret; #else return CRYPTO_malloc(num, file, line); #endif /* IMPLEMENTED */ }
void CRYPTO_secure_free(void *ptr, const char *file, int line) { #ifdef OPENSSL_SECURE_MEMORY size_t actual_size; if (ptr == NULL) return; if (!CRYPTO_secure_allocated(ptr)) { CRYPTO_free(ptr, file, line); return; } CRYPTO_THREAD_write_lock(sec_malloc_lock); actual_size = sh_actual_size(ptr); CLEAR(ptr, actual_size); secure_mem_used -= actual_size; sh_free(ptr); CRYPTO_THREAD_unlock(sec_malloc_lock); #else CRYPTO_free(ptr, file, line); #endif /* OPENSSL_SECURE_MEMORY */ }
void CRYPTO_secure_free(void *ptr) { #ifdef IMPLEMENTED size_t actual_size; if (ptr == NULL) return; if (!secure_mem_initialized) { CRYPTO_free(ptr); return; } LOCK(); actual_size = sh_actual_size(ptr); CLEAR(ptr, actual_size); secure_mem_used -= actual_size; sh_free(ptr); UNLOCK(); #else CRYPTO_free(ptr); #endif /* IMPLEMENTED */ }