sjlombardo/sqlcipher — Issue #14: getting unencrypted database..
Author: MoathOthman
Created: 2011-11-02 07:17:02+00:00
State: open

hey,
am trying to use sqlcipher for encrypted my unencrypted database ,
I followed the tutorial on sqcipher.net ,,,
and every thing looks ok with no obvious issues
but when I try to encrypt the db using the attached approach or sqlite_key..
I get the same original db with no encryption at all ...
I am using Xcode 4.1 with MAC OS X Lion V10.7
I tried and got the following
ddadmac1:sqlcipher apple$ make clean
rm -f *.lo *.la *.o sqlite3 libsqlite3.la
rm -f sqlite3.h opcodes.*
rm -rf .libs .deps
rm -f lemon lempar.c parse.* sqlite*.tar.gz
rm -f mkkeywordhash keywordhash.h
rm -f
rm -f *.da *.bb *.bbg gmon.out
rm -rf tsrc .target_source
rm -f testfixture test.db
rm -f sqlite3.dll sqlite3.lib sqlite3.def
rm -f sqlite3.c
ddadmac1:sqlcipher apple$ ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC-SQLITE_TEMP_STORE=2" LDFLAGS="/users/apple/desktop/arabicnames/lib/libcrypto.a"
checking build system type... i386-apple-darwin11.0.0
checking host system type... i386-apple-darwin11.0.0
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld
checking if the linker (/usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm
checking the name lister (/usr/bin/nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 196608
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld option to reload object files... -r
checking for objdump... no
checking how to recognize dependent libraries... pass_all
checking for ar... ar
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm output from gcc object... ok
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... no
checking for -exported_symbols_list linker flag... yes
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin11.0.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking for int8_t... yes
checking for int16_t... yes
checking for int32_t... yes
checking for int64_t... yes
checking for intptr_t... yes
checking for uint8_t... yes
checking for uint16_t... yes
checking for uint32_t... yes
checking for uint64_t... yes
checking for uintptr_t... yes
checking for sys/types.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for stdint.h... (cached) yes
checking for inttypes.h... (cached) yes
checking for usleep... yes
checking for fdatasync... yes
checking for localtime_r... yes
checking for gmtime_r... yes
checking for localtime_s... no
checking for tclsh8.5... tclsh8.5
configure: Version set to 3.7
configure: Release set to 3.7.2
configure: Version number set to 3007002
checking whether to support threadsafe operation... yes
checking for library containing pthread_create... none required
checking whether to allow connections to be shared across threads... no
checking whether threads can override each others locks... no
checking whether to support shared library linked as release mode or not... no
checking whether to use an in-ram database for temporary tables... yes
checking if executables have the .exe suffix... unknown
checking host system type... (cached) i386-apple-darwin11.0.0
checking for Tcl configuration... found /usr/lib/tclConfig.sh
checking for existence of /usr/lib/tclConfig.sh... loading
checking for library containing tgetent... -lncurses
checking for readline in -lreadline... yes
checking readline.h usability... no
checking readline.h presence... no
checking for readline.h... no
checking for /usr/include/readline.h... no
checking for /usr/include/readline/readline.h... yes
checking for library containing fdatasync... none required
configure: creating ./config.status
config.status: creating Makefile
config.status: creating sqlite3.pc
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing libtool commands
ddadmac1:sqlcipher apple$ make
tclsh ./tool/mksqlite3h.tcl . >sqlite3.h
gcc -DSQLITE_HAS_CODEC-SQLITE_TEMP_STORE=2 -o mkkeywordhash -DSQLITE_OMIT_LOAD_EXTENSION=1 ./tool/mkkeywordhash.c
: warning: missing whitespace after the macro name
./mkkeywordhash >keywordhash.h
gcc -DSQLITE_HAS_CODEC-SQLITE_TEMP_STORE=2 -o lemon ./tool/lemon.c
: warning: missing whitespace after the macro name
cp ./src/lempar.c .
cp ./src/parse.y .
rm -f parse.h
./lemon -DSQLITE_OMIT_LOAD_EXTENSION=1 parse.y
mv parse.h parse.h.temp
awk -f ./addopcodes.awk parse.h.temp >parse.h
cat parse.h ./src/vdbe.c | awk -f ./mkopcodeh.awk >opcodes.h
sort -n -b -k 3 opcodes.h | awk -f ./mkopcodec.awk >opcodes.c
rm -rf tsrc
mkdir tsrc
cp -f ./src/crypto.h ./src/crypto.c ./src/alter.c ./src/analyze.c ./src/attach.c ./src/auth.c ./src/backup.c ./src/bitvec.c ./src/btmutex.c ./src/btree.c ./src/btree.h ./src/btreeInt.h ./src/build.c ./src/callback.c ./src/complete.c ./src/ctime.c ./src/date.c ./src/delete.c ./src/expr.c ./src/fault.c ./src/fkey.c ./src/func.c ./src/global.c ./src/hash.c ./src/hash.h ./src/hwtime.h ./src/insert.c ./src/journal.c ./src/legacy.c ./src/loadext.c ./src/main.c ./src/malloc.c ./src/mem0.c ./src/mem1.c ./src/mem2.c ./src/mem3.c ./src/mem5.c ./src/memjournal.c ./src/mutex.c ./src/mutex.h ./src/mutex_noop.c ./src/mutex_os2.c ./src/mutex_unix.c ./src/mutex_w32.c ./src/notify.c ./src/os.c ./src/os.h ./src/os_common.h ./src/os_os2.c ./src/os_unix.c ./src/os_win.c ./src/pager.c ./src/pager.h ./src/parse.y ./src/pcache.c ./src/pcache.h ./src/pcache1.c ./src/pragma.c ./src/prepare.c ./src/printf.c ./src/random.c ./src/resolve.c ./src/rowset.c ./src/select.c ./src/status.c ./src/shell.c ./src/sqlite.h.in ./src/sqlite3ext.h ./src/sqliteInt.h ./src/sqliteLimit.h ./src/table.c ./src/tclsqlite.c ./src/tokenize.c ./src/trigger.c ./src/utf.c ./src/update.c ./src/util.c ./src/vacuum.c ./src/vdbe.c ./src/vdbe.h ./src/vdbeapi.c ./src/vdbeaux.c ./src/vdbeblob.c ./src/vdbemem.c ./src/vdbetrace.c ./src/vdbeInt.h ./src/vtab.c ./src/wal.c ./src/wal.h ./src/walker.c ./src/where.c ./ext/fts1/fts1.c ./ext/fts1/fts1.h ./ext/fts1/fts1_hash.c ./ext/fts1/fts1_hash.h ./ext/fts1/fts1_porter.c ./ext/fts1/fts1_tokenizer.h ./ext/fts1/fts1_tokenizer1.c ./ext/fts2/fts2.c ./ext/fts2/fts2.h ./ext/fts2/fts2_hash.c ./ext/fts2/fts2_hash.h ./ext/fts2/fts2_icu.c ./ext/fts2/fts2_porter.c ./ext/fts2/fts2_tokenizer.h ./ext/fts2/fts2_tokenizer.c ./ext/fts2/fts2_tokenizer1.c ./ext/fts3/fts3.c ./ext/fts3/fts3.h ./ext/fts3/fts3Int.h ./ext/fts3/fts3_expr.c ./ext/fts3/fts3_hash.c ./ext/fts3/fts3_hash.h ./ext/fts3/fts3_icu.c ./ext/fts3/fts3_porter.c ./ext/fts3/fts3_snippet.c ./ext/fts3/fts3_tokenizer.h ./ext/fts3/fts3_tokenizer.c ./ext/fts3/fts3_tokenizer1.c ./ext/fts3/fts3_write.c ./ext/icu/sqliteicu.h ./ext/icu/icu.c ./ext/rtree/rtree.h ./ext/rtree/rtree.c keywordhash.h opcodes.c opcodes.h parse.c parse.h config.h sqlite3.h tsrc
rm tsrc/sqlite.h.in tsrc/parse.y
tclsh8.5 ./tool/vdbe-compress.tcl vdbe.new
mv vdbe.new tsrc/vdbe.c
touch .target_source
tclsh8.5 ./tool/mksqlite3c.tcl
./libtool --mode=compile --tag=CC gcc -DSQLITE_HAS_CODEC-SQLITE_TEMP_STORE=2 -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -I/System/Library/Frameworks/Tcl.framework/Versions/8.5/Headers -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_TEMP_STORE=2 -c sqlite3.c
libtool: compile: gcc -DSQLITE_HAS_CODEC-SQLITE_TEMP_STORE=2 -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -I/System/Library/Frameworks/Tcl.framework/Versions/8.5/Headers -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_TEMP_STORE=2 -c sqlite3.c -fno-common -DPIC -o .libs/sqlite3.o
: warning: missing whitespace after the macro name
sqlite3.c: In function ‘activate_openssl’:
sqlite3.c:11783: warning: ‘EVP_get_cipherbyname’ is deprecated (declared at /usr/include/openssl/evp.h:848)
sqlite3.c:11784: warning: ‘OPENSSL_add_all_algorithms_noconf’ is deprecated (declared at /usr/include/openssl/evp.h:828)
sqlite3.c: In function ‘codec_key_derive’:
sqlite3.c:11948: warning: ‘PKCS5_PBKDF2_HMAC_SHA1’ is deprecated (declared at /usr/include/openssl/evp.h:920)
sqlite3.c: In function ‘codec_cipher’:
sqlite3.c:11981: warning: ‘RAND_pseudo_bytes’ is deprecated (declared at /usr/include/openssl/rand.h:105)
sqlite3.c:11986: warning: ‘EVP_CipherInit’ is deprecated (declared at /usr/include/openssl/evp.h:598)
sqlite3.c:11987: warning: ‘EVP_CIPHER_CTX_set_padding’ is deprecated (declared at /usr/include/openssl/evp.h:641)
sqlite3.c:11988: warning: ‘EVP_CipherInit’ is deprecated (declared at /usr/include/openssl/evp.h:598)
sqlite3.c:11989: warning: ‘EVP_CipherUpdate’ is deprecated (declared at /usr/include/openssl/evp.h:603)
sqlite3.c:11992: warning: ‘EVP_CipherFinal’ is deprecated (declared at /usr/include/openssl/evp.h:604)
sqlite3.c:11994: warning: ‘EVP_CIPHER_CTX_cleanup’ is deprecated (declared at /usr/include/openssl/evp.h:637)
sqlite3.c: In function ‘codec_set_cipher_name’:
sqlite3.c:12035: warning: ‘EVP_get_cipherbyname’ is deprecated (declared at /usr/include/openssl/evp.h:848)
sqlite3.c:12036: warning: ‘EVP_CIPHER_key_length’ is deprecated (declared at /usr/include/openssl/evp.h:494)
sqlite3.c:12037: warning: ‘EVP_CIPHER_iv_length’ is deprecated (declared at /usr/include/openssl/evp.h:495)
sqlite3.c: In function ‘sqlite3CodecAttach’:
sqlite3.c:12163: warning: ‘RAND_pseudo_bytes’ is deprecated (declared at /usr/include/openssl/rand.h:105)
sqlite3.c: In function ‘sqlite3_rekey’:
sqlite3.c:12253: warning: ‘RAND_pseudo_bytes’ is deprecated (declared at /usr/include/openssl/rand.h:105)
libtool: compile: gcc -DSQLITE_HAS_CODEC-SQLITE_TEMP_STORE=2 -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -I/System/Library/Frameworks/Tcl.framework/Versions/8.5/Headers -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_TEMP_STORE=2 -c sqlite3.c -o sqlite3.o >/dev/null 2>&1
./libtool --mode=link gcc -DSQLITE_HAS_CODEC-SQLITE_TEMP_STORE=2 -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -I/System/Library/Frameworks/Tcl.framework/Versions/8.5/Headers -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 /users/apple/desktop/arabicnames/lib/libcrypto.a -o libsqlite3.la sqlite3.lo \
-rpath "/usr/local/lib" -version-info "8:6:8"

*** Warning: Linking the shared library libsqlite3.la against the
*** static library /users/apple/desktop/arabicnames/lib/libcrypto.a is not portable!
libtool: link: gcc -dynamiclib -Wl,-undefined -Wl,dynamic_lookup -o .libs/libsqlite3.0.dylib .libs/sqlite3.o /users/apple/desktop/arabicnames/lib/libcrypto.a -install_name /usr/local/lib/libsqlite3.0.dylib -compatibility_version 9 -current_version 9.6
libtool: link: dsymutil .libs/libsqlite3.0.dylib || :
warning: no debug symbols in executable (-arch x86_64)
libtool: link: (cd ".libs" && rm -f "libsqlite3.dylib" && ln -s "libsqlite3.0.dylib" "libsqlite3.dylib")
libtool: link: ar cru .libs/libsqlite3.a /users/apple/desktop/arabicnames/lib/libcrypto.a sqlite3.o
libtool: link: ranlib .libs/libsqlite3.a
libtool: link: ( cd ".libs" && rm -f "libsqlite3.la" && ln -s "../libsqlite3.la" "libsqlite3.la" )
./libtool --mode=link gcc -DSQLITE_HAS_CODEC-SQLITE_TEMP_STORE=2 -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -I/System/Library/Frameworks/Tcl.framework/Versions/8.5/Headers -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 /users/apple/desktop/arabicnames/lib/libcrypto.a -DHAVE_READLINE=1 -I/usr/include/readline \
-o sqlite3 ./src/shell.c libsqlite3.la \
-lreadline -lncurses -rpath "/usr/local/lib"
libtool: link: gcc -DSQLITE_HAS_CODEC-SQLITE_TEMP_STORE=2 -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -I/System/Library/Frameworks/Tcl.framework/Versions/8.5/Headers -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DHAVE_READLINE=1 -I/usr/include/readline -o .libs/sqlite3 ./src/shell.c /users/apple/desktop/arabicnames/lib/libcrypto.a ./.libs/libsqlite3.dylib -lreadline -lncurses
: warning: missing whitespace after the macro name
./libtool --mode=compile --tag=CC gcc -DSQLITE_HAS_CODEC-SQLITE_TEMP_STORE=2 -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -I/System/Library/Frameworks/Tcl.framework/Versions/8.5/Headers -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_TCL_STUBS=1 -c ./src/tclsqlite.c
libtool: compile: gcc -DSQLITE_HAS_CODEC-SQLITE_TEMP_STORE=2 -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -I/System/Library/Frameworks/Tcl.framework/Versions/8.5/Headers -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_TCL_STUBS=1 -c ./src/tclsqlite.c -fno-common -DPIC -o .libs/tclsqlite.o
: warning: missing whitespace after the macro name
./src/tclsqlite.c: In function ‘DbObjCmd’:
./src/tclsqlite.c:2326: warning: passing argument 3 of ‘tclStubsPtr->tcl_GetWideIntFromObj’ from incompatible pointer type
libtool: compile: gcc -DSQLITE_HAS_CODEC-SQLITE_TEMP_STORE=2 -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -I/System/Library/Frameworks/Tcl.framework/Versions/8.5/Headers -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_TCL_STUBS=1 -c ./src/tclsqlite.c -o tclsqlite.o >/dev/null 2>&1
./libtool --mode=link gcc -DSQLITE_HAS_CODEC-SQLITE_TEMP_STORE=2 -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -I/System/Library/Frameworks/Tcl.framework/Versions/8.5/Headers -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 /users/apple/desktop/arabicnames/lib/libcrypto.a -o libtclsqlite3.la tclsqlite.lo \
libsqlite3.la -L/System/Library/Frameworks/Tcl.framework/Versions/8.5 -ltclstub8.5 \
-rpath "/System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/sqlite3" \
-version-info "8:6:8" \
-avoid-version

*** Warning: Linking the shared library libtclsqlite3.la against the
*** static library /users/apple/desktop/arabicnames/lib/libcrypto.a is not portable!
libtool: link: gcc -dynamiclib -Wl,-undefined -Wl,dynamic_lookup -o .libs/libtclsqlite3.dylib .libs/tclsqlite.o /users/apple/desktop/arabicnames/lib/libcrypto.a ./.libs/libsqlite3.dylib -L/System/Library/Frameworks/Tcl.framework/Versions/8.5 -ltclstub8.5 -install_name /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/sqlite3/libtclsqlite3.dylib
libtool: link: dsymutil .libs/libtclsqlite3.dylib || :
warning: no debug symbols in executable (-arch x86_64)
libtool: link: ar cru .libs/libtclsqlite3.a /users/apple/desktop/arabicnames/lib/libcrypto.a tclsqlite.o
libtool: link: ranlib .libs/libtclsqlite3.a
libtool: link: ( cd ".libs" && rm -f "libtclsqlite3.la" && ln -s "../libtclsqlite3.la" "libtclsqlite3.la" )
ddadmac1:sqlcipher apple$ sqlite3 test.db
SQLite version 3.7.5
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table t1(a,b);
sqlite> insrt into t1 values(1,2);
Error: near "insrt": syntax error
sqlite> insert into t1 values(1,2);
sqlite> attach database 'enc.db' as enc key 'secret';
sqlite> create table enc.t1(a,b);
sqlite> insert into enc.t1 select * from main.t1;
sqlite> select * from enc.t1;
1|2
sqlite> .schema
CREATE TABLE t1(a,b);
sqlite> .quit

ddadmac1:sqlcipher apple$ sqlite3 enc.db
SQLite version 3.7.5
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .schema
CREATE TABLE t1(a,b);//still not encrypted!!!
sqlite> select * from t1;
1|2

I hope u can see where is my problem located ,,, I am sure it worked with many but i just dunno why its not working with me :(

thnx alot ,,, I hope my issue is clear !!