Skip to content

Commit e44f59f

Browse files
Add support for --with-crypto-lib from autoconf
The default configure script generated from autoconf will default to using OpenSSL as the crypto library. With the new --with-crypto-lib flag, users can specify libtomcrypto as an alternative crypto library.
1 parent f6e4ed4 commit e44f59f

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

Makefile.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ CRYPTOSRC = \
142142
$(TOP)/src/crypto.c \
143143
$(TOP)/src/crypto_impl.h \
144144
$(TOP)/src/crypto_impl.c \
145-
$(TOP)/src/crypto_libtomcrypt.c
146-
# $(TOP)/src/crypto_openssl.c
145+
$(TOP)/src/crypto_libtomcrypt.c \
146+
$(TOP)/src/crypto_openssl.c
147147

148148
# END CRYPTO
149149

configure.ac

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,23 @@ if test "$SQLITE_THREADSAFE" = "1"; then
253253
AC_SEARCH_LIBS(pthread_create, pthread)
254254
fi
255255

256+
##########
257+
# Which crypto library do we use
258+
#
259+
AC_ARG_WITH([crypto-lib],
260+
AC_HELP_STRING([--with-crypto-lib],[Specify which crypto library to use]),
261+
crypto_lib=$withval)
262+
AC_MSG_CHECKING([for crypto library to use])
263+
if test "$crypto_lib" = "libtomcrypto"; then
264+
CFLAGS+=" -DSQLCIPHER_CRYPTO_LIBTOMCRYPTO"
265+
BUILD_CFLAGS+=" -DSQLCIPHER_CRYPTO_LIBTOMCRYPTO"
266+
AC_MSG_RESULT([libtomcrypto])
267+
else
268+
CFLAGS+=" -DSQLCIPHER_CRYPTO_OPENSSL"
269+
BUILD_CFLAGS+=" -DSQLCIPHER_CRYPTO_OPENSSL"
270+
AC_MSG_RESULT([openssl])
271+
fi
272+
256273
##########
257274
# Do we want to allow a connection created in one thread to be used
258275
# in another thread. This does not work on many Linux systems (ex: RedHat 9)

src/crypto_libtomcrypt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#ifdef SQLCIPHER_CRYPTO_LIBTOMCRYPTO
12
#include <tomcrypt.h>
23

34
void sqlcipher_activate(void *ctx) {
@@ -105,3 +106,4 @@ int sqlcipher_ctx_init(void **ctx) {
105106
int sqlcipher_ctx_free(void **ctx) {
106107
return SQLITE_OK;
107108
}
109+
#endif

src/crypto_openssl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#ifdef SQLCIPHER_CRYPTO_OPENSSL
12
#include <openssl/rand.h>
23
#include <openssl/evp.h>
34
#include <openssl/hmac.h>
@@ -138,5 +139,4 @@ int sqlcipher_ctx_free(void **ctx) {
138139
sqlcipher_free(*ctx, sizeof(openssl_ctx));
139140
return SQLITE_OK;
140141
}
141-
142-
142+
#endif

tool/mksqlite3c.tcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,14 @@ proc copy_file {filename} {
222222
# used subroutines first in order to help the compiler find
223223
# inlining opportunities.
224224
#
225+
225226
foreach file {
226227
sqliteInt.h
227228

228229
crypto.c
229230
crypto_impl.c
230231
crypto_libtomcrypt.c
232+
crypto_openssl.c
231233

232234
global.c
233235
ctime.c

0 commit comments

Comments
 (0)