diff --git a/CMakeLists.txt b/CMakeLists.txt index 0be41a2..cc50e11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,6 @@ OPTION(SQLITE3MC_USE_SQLCIPHER_LEGACY "Use sqlcipher legacy mode as default" OFF # Additional memory security (filling freed memory allocations with zeros or random data) OPTION(SQLITE3MC_SECURE_MEMORY "Enable pragma to secure freed memory" OFF) -OPTION(SQLITE3MC_USE_RANDOM_FILL_MEMORY "Fill freed memory with random data" OFF) # Omit AES hardware support OPTION(SQLITE3MC_OMIT_AES_HARDWARE_SUPPORT "Omit AES hardware support" OFF) @@ -163,12 +162,6 @@ if(SQLITE3MC_SECURE_MEMORY) SQLITE3MC_SECURE_MEMORY=1 ) endif() -if(SQLITE3MC_USE_RANDOM_FILL_MEMORY) - set(SQLITE3MC_BASE_DEFINITIONS - ${SQLITE3MC_BASE_DEFINITIONS} - SQLITE3MC_USE_RANDOM_FILL_MEMORY=1 - ) -endif() if(SQLITE3MC_USE_MINIZ OR _SQLITE3MC_REQUIRE_ZLIB) if(_SQLITE3MC_REQUIRE_ZLIB) diff --git a/build/config.gcc b/build/config.gcc index eaafed4..92f39a9 100644 --- a/build/config.gcc +++ b/build/config.gcc @@ -27,7 +27,4 @@ SQLITE3MC_USE_MINIZ ?= 0 # Set to 1 to enable the PRAGMA SQLITE3MC_SECURE_MEMORY ?= 0 -# Optionally fill freed memory with random data instead of zeros (Default: 0) -#SQLITE3MC_USE_RANDOM_FILL_MEMORY ?= 0 - ### Configuration dependent settings diff --git a/build/wx_setup.props b/build/wx_setup.props index 8542573..1417fd8 100644 --- a/build/wx_setup.props +++ b/build/wx_setup.props @@ -5,9 +5,6 @@ 0 1 0 - diff --git a/premake5.lua b/premake5.lua index 4fc8ad1..2c27a68 100644 --- a/premake5.lua +++ b/premake5.lua @@ -92,7 +92,6 @@ project "sqlite3mc_lib" -- "SQLITE_ENABLE_SQLAR=1" -- "SQLITE_ENABLE_ZIPFILE=1" "SQLITE3MC_SECURE_MEMORY=$(SQLITE3MC_SECURE_MEMORY)", --- "SQLITE3MC_USE_RANDOM_FILL_MEMORY=$(SQLITE3MC_USE_RANDOM_FILL_MEMORY)", "SQLITE_TEMP_STORE=2", "SQLITE_USE_URI=1", "SQLITE_USER_AUTHENTICATION=0", @@ -190,7 +189,6 @@ project "sqlite3mc_dll" -- "SQLITE_ENABLE_SQLAR=1" -- "SQLITE_ENABLE_ZIPFILE=1" "SQLITE3MC_SECURE_MEMORY=$(SQLITE3MC_SECURE_MEMORY)", --- "SQLITE3MC_USE_RANDOM_FILL_MEMORY=$(SQLITE3MC_USE_RANDOM_FILL_MEMORY)", "SQLITE_TEMP_STORE=2", "SQLITE_USE_URI=1", "SQLITE_USER_AUTHENTICATION=0" @@ -342,7 +340,6 @@ project "sqlite3mc_libicu" -- "SQLITE_ENABLE_SQLAR=1" -- "SQLITE_ENABLE_ZIPFILE=1" "SQLITE3MC_SECURE_MEMORY=$(SQLITE3MC_SECURE_MEMORY)", --- "SQLITE3MC_USE_RANDOM_FILL_MEMORY=$(SQLITE3MC_USE_RANDOM_FILL_MEMORY)", "SQLITE_TEMP_STORE=2", "SQLITE_USE_URI=1", "SQLITE_USER_AUTHENTICATION=0", @@ -453,7 +450,6 @@ project "sqlite3mc_dllicu" -- "SQLITE_ENABLE_SQLAR=1" -- "SQLITE_ENABLE_ZIPFILE=1" "SQLITE3MC_SECURE_MEMORY=$(SQLITE3MC_SECURE_MEMORY)", --- "SQLITE3MC_USE_RANDOM_FILL_MEMORY=$(SQLITE3MC_USE_RANDOM_FILL_MEMORY)", "SQLITE_TEMP_STORE=2", "SQLITE_USE_URI=1", "SQLITE_USER_AUTHENTICATION=0" diff --git a/src/memory_secure.c b/src/memory_secure.c index 171e2c6..ee82bca 100644 --- a/src/memory_secure.c +++ b/src/memory_secure.c @@ -44,38 +44,6 @@ static volatile int mcSecureMemoryFlag = 0; /* Map of default memory allocation methods */ static volatile sqlite3_mem_methods mcDefaultMemoryMethods; -#if SQLITE3MC_ENABLE_RANDOM_FILL_MEMORY - -/* -** Fill a buffer with pseudo-random bytes. This is used to preset -** the content of a new memory allocation to unpredictable values and -** to clear the content of a freed allocation to unpredictable values. -*/ -static void mcRandomFill(char* pBuf, int nByte) -{ - unsigned int x, y, r; - x = SQLITE_PTR_TO_INT(pBuf); - y = nByte | 1; - while( nByte >= 4 ) - { - x = (x>>1) ^ (-(int)(x&1) & 0xd0000001); - y = y*1103515245 + 12345; - r = x ^ y; - *(int*)pBuf = r; - pBuf += 4; - nByte -= 4; - } - while( nByte-- > 0 ) - { - x = (x>>1) ^ (-(int)(x&1) & 0xd0000001); - y = y*1103515245 + 12345; - r = x ^ y; - *(pBuf++) = r & 0xff; - } -} - -#endif - /* ** Return the size of an allocation */ @@ -99,13 +67,8 @@ static void mcMemoryFree(void* pPrior) { if (mcSecureMemoryFlag) { -#if SQLITE3MC_USE_RANDOM_FILL_MEMORY - int nSize = mcMemorySize(pPrior); - mcRandomFill((char*) pPrior, nSize) -#else int nSize = mcMemorySize(pPrior); sqlite3mcSecureZeroMemory(pPrior, 0, nSize); -#endif } mcDefaultMemoryMethods.xFree(pPrior); } diff --git a/src/sqlite3mc.c b/src/sqlite3mc.c index ebffc98..43e9378 100644 --- a/src/sqlite3mc.c +++ b/src/sqlite3mc.c @@ -160,10 +160,6 @@ sqlite3mcVersion(sqlite3_context* context, int argc, sqlite3_value** argv) SQLITE_PRIVATE void sqlite3mcSetMemorySecurity(int value); SQLITE_PRIVATE int sqlite3mcGetMemorySecurity(); -#ifndef SQLITE3MC_USE_RANDOM_FILL_MEMORY -#define SQLITE3MC_USE_RANDOM_FILL_MEMORY 0 -#endif - /* Memory locking is currently not supported */ #ifdef SQLITE3MC_ENABLE_MEMLOCK #undef SQLITE3MC_ENABLE_MEMLOCK