Skip to content

Commit c93192d

Browse files
authored
Merge latest from 'cipher-ext-master' at litehelpers/cordova-sqlcipher-adapter
Synchronize with the source branch
2 parents c6623fc + 382891d commit c93192d

10 files changed

Lines changed: 66 additions & 55 deletions

File tree

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changes
22

3+
## cordova-sqlcipher-adapter 0.1.7
4+
5+
- Fix Windows build
6+
- SQLCipher prerelease fix to use append mode for cipher_profile
7+
- SQLCipher for Android updates
8+
39
## cordova-sqlcipher-adapter 0.1.6
410

511
- SQLCipher for Android with API 23 fixes from: https://github.com/litehelpers/android-database-sqlcipher-api-fix

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ License for iOS version: MIT only
88

99
|Android Circle-CI (**full** suite)|iOS Travis-CI (*very* limited suite)|
1010
|-----------------------|----------------------|
11-
|[![Circle CI](https://circleci.com/gh/litehelpers/Cordova-sqlcipher-adapter.svg?style=svg)](https://circleci.com/gh/litehelpers/Cordova-sqlcipher-adapter)|[![Build Status](https://travis-ci.org/litehelpers/Cordova-sqlcipher-adapter.svg?branch=core-master)](https://travis-ci.org/litehelpers/Cordova-sqlcipher-adapter)|
11+
|[![Circle CI](https://circleci.com/gh/litehelpers/Cordova-sqlcipher-adapter.svg?style=svg)](https://circleci.com/gh/litehelpers/Cordova-sqlcipher-adapter)|[![Build Status](https://travis-ci.org/litehelpers/Cordova-sqlcipher-adapter.svg)](https://travis-ci.org/litehelpers/Cordova-sqlcipher-adapter)|
1212

1313
**WARNING:** In case you lose the database password you have no way to recover the data.
1414

@@ -72,7 +72,7 @@ Some other projects by [@brodybits](https://github.com/brodybits):
7272
- Uses libTomCrypt for encryption which *may* be inferior to OpenSSL for encryption and apparently runs much more slowly
7373
- WAL/MMAP *disabled* for Windows Phone 8.1
7474
- JSON1 not working for Windows
75-
- with a minor adjustment in [litehelpers / sqlcipher-winrt-fix](https://github.com/litehelpers/sqlcipher-winrt-fix) to use `fopen_s` instead of `fopen` for WinRT (Windows 8.1/Windows Phone 8.1/Windows 10)
75+
- **NOTE:** libTomCrypt may have inferior entropy (randomness) for encryption. It is desired to replace libTomCrypt with a recent build of the OpenSSL crypto library.
7676
- Android version:
7777
- Build from [litehelpers / android-database-sqlcipher-api-fix](https://github.com/litehelpers/android-database-sqlcipher-api-fix), now supports Android N (preview) and fixed for Android API 23
7878
- ARM (v5/v6/v7/v7a) and x86 CPUs
@@ -414,7 +414,7 @@ db.transaction(function(tx) {
414414
tx.executeSql('INSERT INTO MyTable VALUES (?)', ['test-value'], function(tx, resultSet) {
415415
console.log('resultSet.insertId: ' + resultSet.insertId);
416416
console.log('resultSet.rowsAffected: ' + resultSet.rowsAffected);
417-
}, function(error) {
417+
}, function(tx, error) {
418418
console.log('INSERT error: ' + error.message);
419419
});
420420
}, function(error) {
@@ -433,7 +433,7 @@ db.readTransaction(function(tx) {
433433
}, function(error) {
434434
console.log('SELECT error: ' + error.message);
435435
});
436-
}, function(error) {
436+
}, function(tx, error) {
437437
console.log('transaction error: ' + error.message);
438438
}, function() {
439439
console.log('transaction ok');

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cordova-sqlcipher-adapter",
3-
"version": "0.1.6",
3+
"version": "0.1.7",
44
"description": "SQLCipher database adapter for PhoneGap/Cordova, based on cordova-sqlite-storage",
55
"cordova": {
66
"id": "cordova-sqlcipher-adapter",

plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
id="cordova-sqlcipher-adapter"
5-
version="0.1.6">
5+
version="0.1.7">
66

77
<name>Cordova sqlcipher adapter</name>
88

108 Bytes
Binary file not shown.
108 Bytes
Binary file not shown.
528 Bytes
Binary file not shown.
108 Bytes
Binary file not shown.

src/common/sqlite3.c

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16009,7 +16009,6 @@ static int codec_set_pass_key(sqlite3* db, int nDb, const void *zKey, int nKey,
1600916009
}
1601016010

1601116011
int sqlcipher_codec_pragma(sqlite3* db, int iDb, Parse *pParse, const char *zLeft, const char *zRight) {
16012-
char *pragma_cipher_deprecated_msg = "PRAGMA cipher command is deprecated, please remove from usage.";
1601316012
struct Db *pDb = &db->aDb[iDb];
1601416013
codec_ctx *ctx = NULL;
1601516014
int rc;
@@ -16074,10 +16073,11 @@ int sqlcipher_codec_pragma(sqlite3* db, int iDb, Parse *pParse, const char *zLef
1607416073
if( sqlite3StrICmp(zLeft, "cipher")==0 ){
1607516074
if(ctx) {
1607616075
if( zRight ) {
16077-
sqlcipher_codec_ctx_set_cipher(ctx, zRight, 2); // change cipher for both
16076+
rc = sqlcipher_codec_ctx_set_cipher(ctx, zRight, 2); // change cipher for both
16077+
char *pragma_cipher_deprecated_msg = "PRAGMA cipher command is deprecated, please remove from usage.";
1607816078
codec_vdbe_return_static_string(pParse, "cipher", pragma_cipher_deprecated_msg);
1607916079
sqlite3_log(SQLITE_WARNING, pragma_cipher_deprecated_msg);
16080-
return SQLITE_ERROR;
16080+
return rc;
1608116081
}else {
1608216082
codec_vdbe_return_static_string(pParse, "cipher",
1608316083
sqlcipher_codec_ctx_get_cipher(ctx, 2));
@@ -16295,7 +16295,11 @@ SQLITE_PRIVATE int sqlite3CodecAttach(sqlite3* db, int nDb, const void *zKey, in
1629516295
/* point the internal codec argument against the contet to be prepared */
1629616296
rc = sqlcipher_codec_ctx_init(&ctx, pDb, pDb->pBt->pBt->pPager, fd, zKey, nKey);
1629716297

16298-
if(rc != SQLITE_OK) return rc; /* initialization failed, do not attach potentially corrupted context */
16298+
if(rc != SQLITE_OK) {
16299+
/* initialization failed, do not attach potentially corrupted context */
16300+
sqlite3_mutex_leave(db->mutex);
16301+
return rc;
16302+
}
1629916303

1630016304
sqlite3pager_sqlite3PagerSetCodec(sqlite3BtreePager(pDb->pBt), sqlite3Codec, NULL, sqlite3FreeCodecArg, (void *) ctx);
1630116305

@@ -17224,8 +17228,11 @@ int sqlcipher_codec_ctx_set_cipher(codec_ctx *ctx, const char *cipher_name, int
1722417228
cipher_ctx *c_ctx = for_ctx ? ctx->write_ctx : ctx->read_ctx;
1722517229
int rc;
1722617230

17227-
c_ctx->provider->set_cipher(c_ctx->provider_ctx, cipher_name);
17228-
17231+
rc = c_ctx->provider->set_cipher(c_ctx->provider_ctx, cipher_name);
17232+
if(rc != SQLITE_OK){
17233+
sqlcipher_codec_ctx_set_error(ctx, rc);
17234+
return rc;
17235+
}
1722917236
c_ctx->key_sz = c_ctx->provider->get_key_sz(c_ctx->provider_ctx);
1723017237
c_ctx->iv_sz = c_ctx->provider->get_iv_sz(c_ctx->provider_ctx);
1723117238
c_ctx->block_sz = c_ctx->provider->get_block_sz(c_ctx->provider_ctx);
@@ -17939,23 +17946,22 @@ int sqlcipher_codec_add_random(codec_ctx *ctx, const char *zRight, int random_sz
1793917946

1794017947
int sqlcipher_cipher_profile(sqlite3 *db, const char *destination){
1794117948
FILE *f;
17942-
if( strcmp(destination,"stdout")==0 ){
17949+
if(sqlite3StrICmp(destination, "stdout") == 0){
1794317950
f = stdout;
17944-
}else if( strcmp(destination, "stderr")==0 ){
17951+
}else if(sqlite3StrICmp(destination, "stderr") == 0){
1794517952
f = stderr;
17946-
}else if( strcmp(destination, "off")==0 ){
17953+
}else if(sqlite3StrICmp(destination, "off") == 0){
1794717954
f = 0;
1794817955
}else{
17949-
#ifdef SQLITE_OS_WINRT
17950-
if( fopen_s(&f, destination, "wb")!=0 ){
17951-
return SQLITE_ERROR;
17952-
}
17956+
#if defined(_WIN32) && (__STDC_VERSION__ > 199901L) || defined(SQLITE_OS_WINRT)
17957+
if(fopen_s(&f, destination, "a") != 0){
1795317958
#else
17954-
f = fopen(destination, "wb");
17955-
if( f==0 ){
17956-
return SQLITE_ERROR;
17957-
}
17958-
#endif
17959+
f = fopen(destination, "a");
17960+
if(f == 0){
17961+
#endif
17962+
return SQLITE_ERROR;
17963+
}
17964+
1795917965
}
1796017966
sqlite3_profile(db, sqlcipher_profile_callback, f);
1796117967
return SQLITE_OK;
@@ -17964,7 +17970,7 @@ int sqlcipher_cipher_profile(sqlite3 *db, const char *destination){
1796417970
static void sqlcipher_profile_callback(void *file, const char *sql, sqlite3_uint64 run_time){
1796517971
FILE *f = (FILE*)file;
1796617972
double elapsed = run_time/1000000.0;
17967-
if( f ) fprintf(f, "Elapsed time:%.3f ms - %s\n", elapsed, sql);
17973+
if(f) fprintf(f, "Elapsed time:%.3f ms - %s\n", elapsed, sql);
1796817974
}
1796917975

1797017976
int sqlcipher_codec_fips_status(codec_ctx *ctx) {
@@ -18580,12 +18586,11 @@ static const char* sqlcipher_cc_get_provider_name(void *ctx) {
1858018586

1858118587
static const char* sqlcipher_cc_get_provider_version(void *ctx) {
1858218588
#if TARGET_OS_MAC
18583-
CFTypeRef version;
1858418589
CFBundleRef bundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.security"));
1858518590
if(bundle == NULL) {
1858618591
return "unknown";
1858718592
}
18588-
version = CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("CFBundleShortVersionString"));
18593+
CFTypeRef version = CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("CFBundleShortVersionString"));
1858918594
return CFStringGetCStringPtr(version, kCFStringEncodingUTF8);
1859018595
#else
1859118596
return "unknown";
@@ -18618,7 +18623,7 @@ static int sqlcipher_cc_cipher(void *ctx, int mode, unsigned char *key, int key_
1861818623
CCCryptorFinal(cryptor, out, in_sz - csz, &tmp_csz);
1861918624
csz += tmp_csz;
1862018625
CCCryptorRelease(cryptor);
18621-
assert(size == csz);
18626+
assert(in_sz == csz);
1862218627

1862318628
return SQLITE_OK;
1862418629
}

src/windows/SQLite3-Win-RT/SQLite3/SQLite3.Shared.vcxitems

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,85 +27,85 @@
2727
<ClCompile Include="$(MSBuildThisFileDirectory)Constants.cpp" />
2828
<ClCompile Include="$(MSBuildThisFileDirectory)Database.cpp" />
2929
<ClCompile Include="$(MSBuildThisFileDirectory)Statement.cpp" />
30-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\common\sqlite3.c">
30+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\common\sqlite3.c">
3131
<CompileAsWinRT>false</CompileAsWinRT>
3232
</ClCompile>
33-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\cbc_encrypt.c">
33+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\cbc_encrypt.c">
3434
<CompileAsWinRT>false</CompileAsWinRT>
3535
</ClCompile>
36-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\cbc_decrypt.c">
36+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\cbc_decrypt.c">
3737
<CompileAsWinRT>false</CompileAsWinRT>
3838
</ClCompile>
39-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\cbc_start.c">
39+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\cbc_start.c">
4040
<CompileAsWinRT>false</CompileAsWinRT>
4141
</ClCompile>
42-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\cbc_done.c">
42+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\cbc_done.c">
4343
<CompileAsWinRT>false</CompileAsWinRT>
4444
</ClCompile>
45-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\crypt_find_cipher.c">
45+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\crypt_find_cipher.c">
4646
<CompileAsWinRT>false</CompileAsWinRT>
4747
</ClCompile>
48-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\crypt_find_hash.c">
48+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\crypt_find_hash.c">
4949
<CompileAsWinRT>false</CompileAsWinRT>
5050
</ClCompile>
51-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\crypt_register_hash.c">
51+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\crypt_register_hash.c">
5252
<CompileAsWinRT>false</CompileAsWinRT>
5353
</ClCompile>
54-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\crypt_register_cipher.c">
54+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\crypt_register_cipher.c">
5555
<CompileAsWinRT>false</CompileAsWinRT>
5656
</ClCompile>
57-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\crypt_register_prng.c">
57+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\crypt_register_prng.c">
5858
<CompileAsWinRT>false</CompileAsWinRT>
5959
</ClCompile>
60-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\crypt_argchk.c">
60+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\crypt_argchk.c">
6161
<CompileAsWinRT>false</CompileAsWinRT>
6262
</ClCompile>
63-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\crypt_cipher_is_valid.c">
63+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\crypt_cipher_is_valid.c">
6464
<CompileAsWinRT>false</CompileAsWinRT>
6565
</ClCompile>
66-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\crypt_cipher_descriptor.c">
66+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\crypt_cipher_descriptor.c">
6767
<CompileAsWinRT>false</CompileAsWinRT>
6868
</ClCompile>
69-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\crypt_prng_descriptor.c">
69+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\crypt_prng_descriptor.c">
7070
<CompileAsWinRT>false</CompileAsWinRT>
7171
</ClCompile>
72-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\crypt_hash_is_valid.c">
72+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\crypt_hash_is_valid.c">
7373
<CompileAsWinRT>false</CompileAsWinRT>
7474
</ClCompile>
75-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\crypt_hash_descriptor.c">
75+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\crypt_hash_descriptor.c">
7676
<CompileAsWinRT>false</CompileAsWinRT>
7777
</ClCompile>
78-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\hash_memory.c">
78+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\hash_memory.c">
7979
<CompileAsWinRT>false</CompileAsWinRT>
8080
</ClCompile>
81-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\zeromem.c">
81+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\zeromem.c">
8282
<CompileAsWinRT>false</CompileAsWinRT>
8383
</ClCompile>
84-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\pkcs_5_2.c">
84+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\pkcs_5_2.c">
8585
<CompileAsWinRT>false</CompileAsWinRT>
8686
</ClCompile>
87-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\aes.c">
87+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\aes.c">
8888
<CompileAsWinRT>false</CompileAsWinRT>
8989
</ClCompile>
90-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\sha1.c">
90+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\sha1.c">
9191
<CompileAsWinRT>false</CompileAsWinRT>
9292
</ClCompile>
93-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\hmac_init.c">
93+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\hmac_init.c">
9494
<CompileAsWinRT>false</CompileAsWinRT>
9595
</ClCompile>
96-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\hmac_memory.c">
96+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\hmac_memory.c">
9797
<CompileAsWinRT>false</CompileAsWinRT>
9898
</ClCompile>
99-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\hmac_process.c">
99+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\hmac_process.c">
100100
<CompileAsWinRT>false</CompileAsWinRT>
101101
</ClCompile>
102-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\hmac_done.c">
102+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\hmac_done.c">
103103
<CompileAsWinRT>false</CompileAsWinRT>
104104
</ClCompile>
105-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\fortuna.c">
105+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\fortuna.c">
106106
<CompileAsWinRT>false</CompileAsWinRT>
107107
</ClCompile>
108-
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\external\libTomCrypt\sha256.c">
108+
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\libTomCrypt\sha256.c">
109109
<CompileAsWinRT>false</CompileAsWinRT>
110110
</ClCompile>
111111
<ClCompile Include="$(MSBuildThisFileDirectory)pch.cpp">

0 commit comments

Comments
 (0)