guardianproject / notecipher

a simple notepad with all stored encrypted using SQLCipher and Cacheword
https://dev.guardianproject.info/projects/notecipher/wiki
Apache License 2.0
103 stars 46 forks source link

notecipher ignores existing notes on upgrade, then freaks out #28

Open eighthave opened 10 years ago

eighthave commented 10 years ago

On a Samsung Galaxy Note II running CM10.1, upgrading fails. I made a note store with the version in Google Play, then the current version didn't find it and asked me to set a new passphrase. Then it was crashy, so I think it was partially detecting the old note store. I'm using the latest nightly build from today.

Here's how to reproduce:

  1. install NoteCipher from Play
  2. set passphrase
  3. create a couple notes
  4. upgrade to this APK: https://guardianproject.info/builds/release-staging/NoteCipher-release.apk
  5. start app, (prompts to set passphrase)
eighthave commented 10 years ago

I just tried the process again, when I upgrade the app, then it takes me directly to the "Change Passphrase" screen, so it seems its not seeing the existing notes db. Here's the logcat:

  5383   PackageAddRemoveRe..  D  onReceive() action=android.intent.action.PACKAGE_REMOVED
  5383   PackageAddRemoveRe..  D  PACKAGE_ADDED intent data: package:info.guardianproject.notepadbot
  5398                  Trace  W  error opening trace file: No such file or directory (2)
  5412                  Trace  W  error opening trace file: No such file or directory (2)
  3137   PackageBroadcastSe..  D  Received broadcast action=android.intent.action.PACKAGE_ADDED and uri=info.guardianproject.notepadbot
 18076                 Finsky  D  [1] DetailsFragment.requestData: Using current account [nveGHmb-L0Qijf9pU71x8Q8qRIs] to fetch social details for info.guardianproject.notepadbot
  3137     PeopleContactsSync  I  CP2 sync disabled
  1354   Icing.InternalIcin..  I  Updating corpora: A: info.guardianproject.notepadbot, C: MAYBE
  5366                 FDroid  D  PackageReceiver received info.guardianproject.notepadbot
  5366                 FDroid  D  Invalidating info.guardianproject.notepadbot
 22876            DeepLinking  W  no deep link install data found for info.guardianproject.notepadbot
  5383   PackageAddRemoveRe..  D  onReceive() action=android.intent.action.PACKAGE_ADDED
  5383   PackageAddRemoveRe..  D  PACKAGE_ADDED intent data: package:info.guardianproject.notepadbot
  3137   PackageBroadcastSe..  D  Received broadcast action=android.intent.action.PACKAGE_REPLACED and uri=info.guardianproject.notepadbot
  3137     PeopleContactsSync  I  CP2 sync disabled
  5438                  Trace  W  error opening trace file: No such file or directory (2)
 18076                 Finsky  D  [1] DetailsDataBasedFragment.rebindViews: Page [class=DetailsFragment] loaded in [7096782 ms] (hasDetailsDataLoaded? true)
  5438       AutosyncReceiver  I  [main] got broadcast: Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:info.guardianproject.notepadbot flg=0x8000010 cmp=de.schildbach.wallet/.service.AutosyncReceiver (has extras) }
  5457                  Trace  W  error opening trace file: No such file or directory (2)
  5457               Database  I  JNI_OnLoad called
  5457               Database  I  JNI_OnLoad register methods
  5457                 libEGL  D  loaded /system/lib/egl/libEGL_mali.so
  5457                 libEGL  D  loaded /system/lib/egl/libGLESv1_CM_mali.so
  5457                 libEGL  D  loaded /system/lib/egl/libGLESv2_mali.so
  5457                         E  Device driver API match
  5457                         E  Device driver API version: 17
  5457                         E  User space API version: 17
  5457                         E  mali: REVISION=Linux-r3p1-01rel1 BUILD_DATE=Tue Jul  2 15:06:24 KST 2013
  5457         OpenGLRenderer  D  Enabling debug mode 0
  5457       CacheWordService  D  onCreate
  5457       CacheWordService  D  onStart: null action
  5457       CacheWordHandler  D  onServiceConnected
  5457        CacheWordBinder  D  giving service
  5457       CacheWordService  D  attachSubscriber(): 1
  5457       CacheWordService  D  timeout enabled: true, minutes=5
  5457       CacheWordService  D  mSubscriberCount: 1
  5457       CacheWordService  D  disabled timeout alarm
  5457       CacheWordHandler  D  checkCacheWordState: STATE_UNINITIALIZED
  5457             NoteCipher  D  onCacheWordUninitialized
  5457       CacheWordService  D  detachSubscriber(): 0
  5457       CacheWordService  D  timeout enabled: true, minutes=5
  5457       CacheWordService  D  mSubscriberCount: 0
  5457       CacheWordService  D  starting timeout: 300000
  5457       CacheWordService  D  timeout enabled: true, minutes=5
  5457       CacheWordService  D  mSubscriberCount: 0
  5457       CacheWordService  D  starting timeout: 300000
  5457       CacheWordService  D  onStart: null action
  5457       CacheWordHandler  D  onServiceConnected
  5457        CacheWordBinder  D  giving service
  5457       CacheWordService  D  attachSubscriber(): 1
  5457       CacheWordService  D  timeout enabled: true, minutes=5
  5457       CacheWordService  D  mSubscriberCount: 1
  5457       CacheWordService  D  disabled timeout alarm
  5457       CacheWordHandler  D  checkCacheWordState: STATE_UNINITIALIZED
eighthave commented 10 years ago

Next up, I set a new passphrase, then it says I can't open the notes, even though I set the new passphrase the same as the old (my guess is the actual key is different because cacheword is making a new one). Here's the logcat:

  5457       CacheWordService  D  setCachedSecrets()
  5457       CacheWordService  D  goBackground()
  5457       CacheWordService  D  timeout enabled: true, minutes=5
  5457       CacheWordService  D  mSubscriberCount: 1
  5457       CacheWordService  D  disabled timeout alarm
  5457       CacheWordHandler  D  checkCacheWordState: STATE_UNLOCKED
  2306        ActivityManager  I  START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x34000000 pkg=info.guardianproject.notepadbot cmp=info.guardianproject.notepadbot/.NoteCipher} from pid 5457
  5457       CacheWordService  D  detachSubscriber(): 0
  5457       CacheWordService  D  timeout enabled: true, minutes=5
  5457       CacheWordService  D  mSubscriberCount: 0
  5457       CacheWordService  D  starting timeout: 300000
  5457       CacheWordService  D  onStart: null action
  5457       CacheWordHandler  D  onServiceConnected
  5457        CacheWordBinder  D  giving service
  5457       CacheWordService  D  attachSubscriber(): 1
  5457       CacheWordService  D  timeout enabled: true, minutes=5
  5457       CacheWordService  D  mSubscriberCount: 1
  5457       CacheWordService  D  disabled timeout alarm
  5457       CacheWordHandler  D  checkCacheWordState: STATE_UNLOCKED
  5457             NoteCipher  D  onCacheWordOpened
  5457         NotesDbAdapter  E  opening with cacheword
  5457    SQLCipherOpenHelper  D  sqlcipher uses native method to set key
  5457               Database  I  sqlite returned: error code = 26, msg = statement aborts at 1: [PRAGMA user_version;] file is encrypted or is not a database
  5457               Database  I  sqlite returned: error code = 26, msg = statement aborts at 1: [PRAGMA user_version;] file is encrypted or is not a database
  5457               Database  I  sqlite returned: error code = 26, msg = statement aborts at 1: [PRAGMA user_version;] file is encrypted or is not a database
  5457               Database  I  sqlite returned: error code = 26, msg = file is encrypted or is not a database
  5457               Database  E  CREATE TABLE android_metadata failed
  5457               Database  E  Failed to setLocale() when constructing, closing the database
  5457               Database  E  net.sqlcipher.database.SQLiteException: file is encrypted or is not a database
  5457               Database  E  at net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method)
  5457               Database  E  at net.sqlcipher.database.SQLiteDatabase.setLocale(SQLiteDatabase.java:2072)
  5457               Database  E  at net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:1938)
  5457               Database  E  at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:871)
  5457               Database  E  at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:899)
  5457               Database  E  at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:127)
  5457               Database  E  at info.guardianproject.cacheword.SQLCipherOpenHelper.getWritableDatabase(SQLCipherOpenHelper.java:60)
  5457               Database  E  at info.guardianproject.notepadbot.NotesDbAdapter.open(NotesDbAdapter.java:130)
  5457               Database  E  at info.guardianproject.notepadbot.NoteCipher.unlockDatabase(NoteCipher.java:162)
  5457               Database  E  at info.guardianproject.notepadbot.NoteCipher.onCacheWordOpened(NoteCipher.java:506)
  5457               Database  E  at info.guardianproject.cacheword.CacheWordHandler.checkCacheWordState(CacheWordHandler.java:310)
  5457               Database  E  at info.guardianproject.cacheword.CacheWordHandler.access$100(CacheWordHandler.java:24)
  5457               Database  E  at info.guardianproject.cacheword.CacheWordHandler$2.onServiceConnected(CacheWordHandler.java:361)
  5457               Database  E  at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1101)
  5457               Database  E  at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1118)
  5457               Database  E  at android.os.Handler.handleCallback(Handler.java:725)
  5457               Database  E  at android.os.Handler.dispatchMessage(Handler.java:92)
  5457               Database  E  at android.os.Looper.loop(Looper.java:137)
  5457               Database  E  at android.app.ActivityThread.main(ActivityThread.java:5227)
  5457               Database  E  at java.lang.reflect.Method.invokeNative(Native Method)
  5457               Database  E  at java.lang.reflect.Method.invoke(Method.java:511)
  5457               Database  E  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
  5457               Database  E  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
  5457               Database  E  at dalvik.system.NativeStart.main(Native Method)
  5457             System.err  W  net.sqlcipher.database.SQLiteException: file is encrypted or is not a database
  5457             System.err  W  at net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method)
  5457             System.err  W  at net.sqlcipher.database.SQLiteDatabase.setLocale(SQLiteDatabase.java:2072)
  5457             System.err  W  at net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:1938)
  5457             System.err  W  at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:871)
  5457             System.err  W  at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:899)
  5457             System.err  W  at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:127)
  5457             System.err  W  at info.guardianproject.cacheword.SQLCipherOpenHelper.getWritableDatabase(SQLCipherOpenHelper.java:60)
  5457             System.err  W  at info.guardianproject.notepadbot.NotesDbAdapter.open(NotesDbAdapter.java:130)
  5457             System.err  W  at info.guardianproject.notepadbot.NoteCipher.unlockDatabase(NoteCipher.java:162)
  5457             System.err  W  at info.guardianproject.notepadbot.NoteCipher.onCacheWordOpened(NoteCipher.java:506)
  5457             System.err  W  at info.guardianproject.cacheword.CacheWordHandler.checkCacheWordState(CacheWordHandler.java:310)
  5457             System.err  W  at info.guardianproject.cacheword.CacheWordHandler.access$100(CacheWordHandler.java:24)
  5457             System.err  W  at info.guardianproject.cacheword.CacheWordHandler$2.onServiceConnected(CacheWordHandler.java:361)
  5457             System.err  W  at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1101)
  5457             System.err  W  at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1118)
  5457             System.err  W  at android.os.Handler.handleCallback(Handler.java:725)
  5457             System.err  W  at android.os.Handler.dispatchMessage(Handler.java:92)
  5457             System.err  W  at android.os.Looper.loop(Looper.java:137)
  5457             System.err  W  at android.app.ActivityThread.main(ActivityThread.java:5227)
  5457             System.err  W  at java.lang.reflect.Method.invokeNative(Native Method)
  5457             System.err  W  at java.lang.reflect.Method.invoke(Method.java:511)
  5457             System.err  W  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
  5457             System.err  W  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
  5457             System.err  W  at dalvik.system.NativeStart.main(Native Method)
  5457          Choreographer  I  Skipped 78 frames!  The application may be doing too much work on its main thread.
  2306        ActivityManager  I  Displayed info.guardianproject.notepadbot/.NoteCipher: +1s419ms
uberspot commented 10 years ago

These seem possibly related https://groups.google.com/forum/#!topic/sqlcipher/0kIJoM11QoE https://groups.google.com/forum/#!topic/sqlcipher/XqAqyzN0dfw

Also the release note for 3.0.1 mentions a migration issue. http://sqlcipher.net/blog/2013/12/6/sqlcipher-301-release.html

eighthave commented 10 years ago

yeah, looks related. cacheword gives the raw key to sqlcipher, that's mentioned as an issue area. So this release can't go into the Play Store until this is fixed, since it'll kill everyone's notes. But it does seem to work fine on new installs, for anyone who wants to try it: https://guardianproject.info/releases/NoteCipher-beta-0.1.apk

Sojeph-Serrot commented 9 years ago

I am experiencing a similar scenario: My phone went missing(gallaxy noteII). After offering $20, waiting,.. nothing_.. then $200... suffice to say; some innocent street urchin managed, for his girlfriend.. to sell it back to us after a wld goose chase, for $20!

Anyways, aside the miracle story involving prayers to both the ascended self in time, as well as root coriographers of the universal construct... my phone had a recovey option from the factory reset boot window. Using recovery, we managed to salvage nearly all apps file folders on both the native; and ectended memory key. The .apks' themselves had to be recovered from the Google play repository. Most of the apps re-adopted the saved work folders on disk. Alas; NoteCipher has not as of yet been one of them.

When i reinstalled it.. did not re-adopt... even after entering the exact same password to spring it into action. I had half of a short novel started, and various synopsiss' for other works in those AES 256 encrypted files, and would so like to find them, and gain re-entry!

Lot of work in there ... hoping all is not lost. . . do they have a recogniseable file extention? Can anyone suggest a course of action to help us?