diff options
author | lloyd <[email protected]> | 2012-06-17 18:44:17 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-06-17 18:44:17 +0000 |
commit | 413246d555f9dcc0bac1cefe73bb141f0d8f14f5 (patch) | |
tree | bfef76cf5c1f437bfbb35f63e4b3fa96c66b36b6 /src | |
parent | aa858fa5e0b5127c1900574379a66f2668d85702 (diff) |
Update to rev 924b482d25 from https://github.com/OlivierJG/botansqlite3
Diffstat (limited to 'src')
-rw-r--r-- | src/wrap/sqlite/codec.cpp | 2 | ||||
-rw-r--r-- | src/wrap/sqlite/codecext.c | 4 | ||||
-rw-r--r-- | src/wrap/sqlite/readme.txt | 44 | ||||
-rw-r--r-- | src/wrap/sqlite/test_sqlite.cpp | 2 |
4 files changed, 28 insertions, 24 deletions
diff --git a/src/wrap/sqlite/codec.cpp b/src/wrap/sqlite/codec.cpp index 9799b058f..70519ccfa 100644 --- a/src/wrap/sqlite/codec.cpp +++ b/src/wrap/sqlite/codec.cpp @@ -176,7 +176,7 @@ void SetReadIsWrite(void *codec) { ((Codec*)codec)->SetReadIsWrite(); } unsigned char* Encrypt(void *codec, int page, unsigned char *data, Bool useWriteKey) { - ((Codec*)codec)->Encrypt(page, data, useWriteKey); + return ((Codec*)codec)->Encrypt(page, data, useWriteKey); } void Decrypt(void *codec, int page, unsigned char *data) { ((Codec*)codec)->Decrypt(page, data); diff --git a/src/wrap/sqlite/codecext.c b/src/wrap/sqlite/codecext.c index 66f13b9b6..e32d60dc2 100644 --- a/src/wrap/sqlite/codecext.c +++ b/src/wrap/sqlite/codecext.c @@ -177,7 +177,7 @@ int sqlite3_rekey(sqlite3 *db, const void *zKey, int nKey) { // Rewrite all pages using the new encryption key (if specified) int nPageCount = -1; - int rc = sqlite3PagerPagecount(pPager, &nPageCount); + sqlite3PagerPagecount(pPager, &nPageCount); Pgno nPage = (Pgno) nPageCount; Pgno nSkip = PAGER_MJ_PGNO(pPager); @@ -225,7 +225,7 @@ int sqlite3_rekey(sqlite3 *db, const void *zKey, int nKey) else { // Rollback, rekey failed - sqlite3BtreeRollback(pbt); + sqlite3BtreeRollback(pbt, SQLITE_ERROR); // go back to read key if (HasReadKey(pCodec)) diff --git a/src/wrap/sqlite/readme.txt b/src/wrap/sqlite/readme.txt index b692aec9b..4971fd44b 100644 --- a/src/wrap/sqlite/readme.txt +++ b/src/wrap/sqlite/readme.txt @@ -1,31 +1,35 @@ -Build instructions for Botan SQLite3 codec +Build instructions for BotanSqlite3 --- -1. Requires Botan 1.9.0 or later +Requirements: + 1. Botan 1.9.0 or later + 2. SQLite3 amalgamation source, version 3.7.12.1 or later (previous versions may work, some will need minor changes) -2. Download and extract SQLite3 version 3.7.0.1 or later (previous - versions may work, untested) -3. From the extracted sqlite folder, apply the patch "sqlite3.diff": - $ patch -p0 < ../sqlite.diff - patching file Makefile.in - patching file sqlite3.c +Building: - If the patch to fails for some reason (ie, changes in SQLite3), it - should be trivial to do it manually. +1. Extract sqlite3 amalgamation to a directory and add BotanSqlite3 source files -4. Copy all files inside the "src" directory into the Sqlite3 directory - (codec.cpp, codec.h, codec_c_interface.h, codecext.c) + If desired, codec.h can be modified to tweak the encryption algothrithms and parameters. (Defaults to Twofish/XTS with 256 bit key) -5. As desired, edit the constants in codec.h to tweak the encryption - type to your needs. (Currently, Twofish/XTS with 256 bit key) +2. Apply the patch "sqlite3.diff": + $ patch -p0 < sqlite3-amalgamation.patch -6. "./configure" and "make" Sqlite3 + If the patching fails for some reason (ie, changes in SQLite3), it should be trivial to do it manually. -And to make sure it all worked... +3. Compile the sqlite3 library with Botan encryption support: + $ gcc -c sqlite3.c -o botansqlite3.o && gcc -c codec.cpp -o codec.o `pkg-config --cflags botan-1.10` && ar rcs libbotansqlite3.a botansqlite3.o codec.o + + (replace "botan-1.10" with appropriate version) -7. Make the test_sqlite.cpp file: - $ g++ test_sqlite.cpp -o test_sqlite -lbotan /path/to/libsqlite3.a -8. Run it +Testing: + +1. Build the test: + $ g++ test_sqlite.cpp -o test_sqlite `botan-config-1.10 --libs` ./libbotansqlite3.a + + (replace botan-config-1.10 w/ appropriate version) + +2. Run the test $ ./test_sqlite -9. Look for "All seems good"
\ No newline at end of file + +3. Look for "All seems good" diff --git a/src/wrap/sqlite/test_sqlite.cpp b/src/wrap/sqlite/test_sqlite.cpp index 6a22cd612..a516fd82b 100644 --- a/src/wrap/sqlite/test_sqlite.cpp +++ b/src/wrap/sqlite/test_sqlite.cpp @@ -47,7 +47,7 @@ static int callback(void *NotUsed, int argc, char **argv, char **azColName){ int main(int argc, char** argv) { sqlite3 * db; - const char * key = "testkey"; + const char * key = "anotherkey"; const char * dbname = "./testdb"; int keylen = 7; char * error=0; |