Skip to content

Commit

Permalink
SQLCipher for Android 3.5.9 Gradle reference
Browse files Browse the repository at this point in the history
Now works on cordova-android@7

Ref: #62
Fixes #64
  • Loading branch information
Christopher J. Brody committed Jan 24, 2018
1 parent d863850 commit 05a9166
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 21 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changes

## cordova-sqlcipher-adapter 0.1.12-pre2
## cordova-sqlcipher-adapter 0.1.12-rc1

- SQLCipher for Android 3.5.9 Gradle reference
- SQLCipher 3.4.2 for iOS/macOS
- Windows platform build disabled (no longer tested in this plugin version; CRYPTO no longer enabled in Windows SQLite3 library build; unwanted libTomCrypt provider completely removed)

Expand Down
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,35 +120,42 @@ See the [Sample section](#sample) for a sample with a more detailed explanation
- _Windows platform support is now disabled in this plugin version, with CRYPTO provider (libTomCrypt) completely removed (ref: [litehelpers / Cordova-sqlcipher-adapter#63](https://github.com/litehelpers/Cordova-sqlcipher-adapter/issues/63)). For future consideration: enable Windows build again with encryption using a recent build of the OpenSSL crypto library ref: [litehelpers/Cordova-sqlcipher-adapter#30](https://github.com/litehelpers/Cordova-sqlcipher-adapter/issues/30)_
- __Alpha version:__
- SQLCipher `3.4.2` for iOS/macOS~~/Windows~~
- SQLCipher `3.5.6` for Android built from [brodybits / android-database-sqlcipher-build-fix](https://github.com/brodybits/android-database-sqlcipher-build-fix), now with 64-bit CPU support
- SQLCipher `3.5.9` for Android (Gradle reference)
- `SQLITE_DEFAULT_PAGE_SIZE=1024` and `SQLITE_DEFAULT_CACHE_SIZE=2000` to avoid "potentially distruptive change(s)" from SQLite 3.12.0 in unencrypted databases ref: <http://sqlite.org/pgszchng2016.html>
- with OpenSSL libcrypto for Android
- using CommonCrypto framework for iOS/macOS
- _NO ENCRYPTION ENABLED (completely removed)_ for Windows
- for future consideration: embed OpenSSL libcrypto for all target platforms
- This plugin is NOT supported by PhoneGap Developer App or PhoneGap Desktop App.
- This plugin will NOT work on `cordova-android@7` due to issue with JAR and NDK library files as discussed in [litehelpers / Cordova-sqlcipher-adapter/issues/64](https://github.com/litehelpers/Cordova-sqlcipher-adapter/issues/64) and [litehelpers/Cordova-sqlite-storage#729](https://github.com/litehelpers/Cordova-sqlite-storage/issues/729).
- A recent version of the Cordova CLI (such as `6.5.0` / `7.1.0`) is recommended. (Cordova CLI 8.x includes `cordova-android@7`, NOT supported by this plugin due to [litehelpers / Cordova-sqlcipher-adapter/issues/64](https://github.com/litehelpers/Cordova-sqlcipher-adapter/issues/64) / [litehelpers/Cordova-sqlite-storage#729](https://github.com/litehelpers/Cordova-sqlite-storage/issues/729).) Cordova versions older than `6.0.0` are missing the `[email protected]` security fixes. In addition it is *required* to use `cordova prepare` in case of cordova-ios older than `4.3.0` (Cordova CLI `6.4.0`).
- _This plugin version will NOT work on `cordova-android@7` due to [litehelpers / Cordova-sqlcipher-adapter/issues/64](https://github.com/litehelpers/Cordova-sqlcipher-adapter/issues/64) / [litehelpers/Cordova-sqlite-storage#729](https://github.com/litehelpers/Cordova-sqlite-storage/issues/729)._
- A recent version of the Cordova CLI (such as `6.5.0` / `7.1.0` / `8.0.0`) is recommended. Cordova versions older than `6.0.0` are missing the `[email protected]` security fixes. In addition it is *required* to use `cordova prepare` in case of cordova-ios older than `4.3.0` (Cordova CLI `6.4.0`).
- SQLCipher build settings used:
- `SQLITE_HAS_CODEC` _(no longer enabled in Windows SQLite3 library build)_
- `SQLITE_SOUNDEX` (Android only)
- `SQLITE_MAX_VARIABLE_NUMBER=99999` (Android only)
- `SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576` (Android only)
- `HAVE_USLEEP=1`
- `SQLITE_TEMP_STORE=3`
- `SQLCIPHER_CRYPTO_CC` (iOS/macOS only)
- `SQLITE_LOCKING_STYLE=1` (iOS/macOS only)
- `DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576` (Android only)
- `NDEBUG` (`NDEBUG=1` on Android)
- `SQLITE_THREADSAFE=1` (`SQLITE_THREADSAFE=2` on iOS/macOS)
- `SQLITE_DEFAULT_MEMSTATUS=0`
- `SQLITE_OMIT_DECLTYPE`
- `DSQLITE_ENABLE_MEMORY_MANAGEMENT=1` (Android only)
- `SQLITE_DEFAULT_MEMSTATUS=0` (iOS/macOS/...)
- `SQLITE_OMIT_DECLTYPE` (iOS/macOS/...)
- _~~`SQLITE_OMIT_DEPRECATED`~~ (FUTURE TODO)_
- `SQLITE_OMIT_PROGRESS_CALLBACK`
- `SQLITE_OMIT_SHARED_CACHE`
- `SQLITE_OMIT_LOAD_EXTENSION`
- `SQLITE_OMIT_PROGRESS_CALLBACK` (iOS/macOS/...)
- `SQLITE_OMIT_SHARED_CACHE` (iOS/macOS/...)
- `SQLITE_ENABLE_LOAD_EXTENSION` (Android only)
- `SQLITE_OMIT_LOAD_EXTENSION` (iOS/macOS/...)
- `SQLITE_ENABLE_COLUMN_METADATA` (Android only)
- `SQLITE_ENABLE_UNLOCK_NOTIFY` (Android only)
- `SQLITE_ENABLE_FTS3` (iOS/macOS/Windows)
- `SQLITE_ENABLE_FTS3_PARENTHESIS`
- `SQLITE_ENABLE_FTS4`
- `SQLITE_ENABLE_RTREE`
- `SQLITE_ENABLE_STAT3` (Android only)
- `SQLITE_ENABLE_STAT4` (Android only)
- `SQLITE_ENABLE_FTS5`
- `SQLITE_ENABLE_JSON1`
- `SQLITE_DEFAULT_PAGE_SIZE=1024` (all platforms) and `SQLITE_DEFAULT_CACHE_SIZE=2000` (iOS/macOS/Windows) to avoid "potentially distruptive change(s)" from SQLite 3.12.0 ref: <http://sqlite.org/pgszchng2016.html>
Expand Down Expand Up @@ -471,7 +478,6 @@ See **Security of sensitive data** in the [Security](#security) section above.

## Known issues

- This plugin will NOT work on `cordova-android@7` due to issue with JAR and NDK library files as discussed in [litehelpers / Cordova-sqlcipher-adapter/issues/64](https://github.com/litehelpers/Cordova-sqlcipher-adapter/issues/64) and [litehelpers/Cordova-sqlite-storage#729](https://github.com/litehelpers/Cordova-sqlite-storage/issues/729).
- The iOS/macOS platform versions do not support certain rapidly repeated open-and-close or open-and-delete test scenarios due to how the implementation handles background processing
- ~~The Android platform version does not always handle four-byte UTF-8 characters emoji characters such as `\u1F603` (SMILING FACE, MOUTH OPEN) correctly ref: [litehelpers/Cordova-sqlite-storage#564](https://github.com/litehelpers/Cordova-sqlite-storage/issues/564). It is sometimes possible to store and retrieve such characters but certain operations such as hex conversions do not work properly when using the default [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) database implementation. It is suspected that such characters would be stored incorrectly by the default Android platform version. Note that this is not an issue in case the built-in Android database is used (using the `androidDatabaseImplementation: 2` setting in `window.sqlitePlugin.openDatabase`)~~ _(NOT an issue in this plugin version)_
- Cannot read encrypted database with CORRECT password directly after attempt to open with INCORRECT password ref: [litehelpers/Cordova-sqlcipher-adapter#43](https://github.com/litehelpers/Cordova-sqlcipher-adapter/issues/43)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-sqlcipher-adapter",
"version": "0.1.12-pre2",
"version": "0.1.12-rc1",
"description": "SQLCipher database adapter for PhoneGap/Cordova, based on cordova-sqlite-storage",
"cordova": {
"id": "cordova-sqlcipher-adapter",
Expand Down
16 changes: 8 additions & 8 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-sqlcipher-adapter"
version="0.1.12-pre2">
version="0.1.12-rc1">

<name>Cordova sqlcipher adapter</name>

Expand Down Expand Up @@ -43,13 +43,13 @@
...
-->

<!-- SQLCipher distribution for Android [jar & native libs]: -->
<source-file src="src/android/sqlcipher/libs/sqlcipher.jar" target-dir="libs" />
<source-file src="src/android/sqlcipher/libs/armeabi/libsqlcipher.so" target-dir="libs/armeabi" />
<source-file src="src/android/sqlcipher/libs/armeabi-v7a/libsqlcipher.so" target-dir="libs/armeabi-v7a" />
<source-file src="src/android/sqlcipher/libs/x86/libsqlcipher.so" target-dir="libs/x86" />
<source-file src="src/android/sqlcipher/libs/arm64-v8a/libsqlcipher.so" target-dir="libs/arm64-v8a" />
<source-file src="src/android/sqlcipher/libs/x86_64/libsqlcipher.so" target-dir="libs/x86_64" />
<!-- THANKS to @jcesarmobile for GUIDANCE in accepted answer:
https://stackoverflow.com/questions/34115571/add-external-jar-library-to-build-cordova-plugin-ionic-framework/34129929#34129929
-->
<!-- SQLCipher distribution for Android
[sqlcipher.jar & ndk objects in aar (modified reference for Buildr)] from:
https://mvnrepository.com/artifact/net.zetetic/android-database-sqlcipher/3.5.9 -->
<framework src="net.zetetic:android-database-sqlcipher:3.5.9" />
</platform>

<!-- iOS -->
Expand Down
2 changes: 1 addition & 1 deletion spec/www/spec/sqlite-version-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var mytests = function() {
expect(rs.rows.item(0).myResult).toMatch(/3\.[0-9]+\.[0-9]+/);
// Check specific [plugin only]:
if (!isWebSql /*&& !(!isWindows && isAndroid && isImpl2)*/)
expect(rs.rows.item(0).myResult).toBe(isAndroid ? '3.15.2' : '3.20.1');
expect(rs.rows.item(0).myResult).toBe('3.20.1');

// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
Expand Down
Binary file removed src/android/sqlcipher/libs/arm64-v8a/libsqlcipher.so
Binary file not shown.
Binary file not shown.
Binary file removed src/android/sqlcipher/libs/armeabi/libsqlcipher.so
Binary file not shown.
Binary file removed src/android/sqlcipher/libs/sqlcipher.jar
Binary file not shown.
Binary file removed src/android/sqlcipher/libs/x86/libsqlcipher.so
Binary file not shown.
Binary file removed src/android/sqlcipher/libs/x86_64/libsqlcipher.so
Binary file not shown.

0 comments on commit 05a9166

Please sign in to comment.