TeamAmaze / AmazeFileManager

Material design file manager for Android
https://teamamaze.xyz
GNU General Public License v3.0
5.32k stars 1.58k forks source link

Trying to connect to SMB fails #1244

Open EmmanuelMess opened 6 years ago

EmmanuelMess commented 6 years ago

AVD Pixel 2 with API 27. In commit 1d0f73ae (probably also master).

? E/TrustyKeymaster: calling trusty_keymaster_call insize 199 msg size 203
    Received 4 byte response
    Error: Response of size 4 contained error code -33
com.amaze.filemanager W/System.err: java.security.UnrecoverableKeyException: Failed to obtain information about key
com.amaze.filemanager W/System.err:     at android.security.keystore.AndroidKeyStoreProvider.loadAndroidKeyStoreSecretKeyFromKeystore(AndroidKeyStoreProvider.java:282)
        at android.security.keystore.AndroidKeyStoreSpi.engineGetKey(AndroidKeyStoreSpi.java:98)
        at java.security.KeyStore.getKey(KeyStore.java:1062)
        at com.amaze.filemanager.utils.files.CryptUtil.getSecretKey(CryptUtil.java:386)
        at com.amaze.filemanager.utils.files.CryptUtil.aesEncryptPassword(CryptUtil.java:276)
        at com.amaze.filemanager.utils.files.CryptUtil.encryptPassword(CryptUtil.java:478)
        at com.amaze.filemanager.utils.SmbUtil.getSmbEncryptedPath(SmbUtil.java:56)
        at com.amaze.filemanager.ui.dialogs.SmbConnectDialog.lambda$onCreateDialog$2$SmbConnectDialog(SmbConnectDialog.java:268)
        at com.amaze.filemanager.ui.dialogs.SmbConnectDialog$$Lambda$2.onClick(Unknown Source:62)
        at com.afollestad.materialdialogs.MaterialDialog.onClick(MaterialDialog.java:410)
        at android.view.View.performClick(View.java:6294)
        at android.view.View$PerformClick.run(View.java:24770)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
com.amaze.filemanager W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
? W/audio_hw_generic: Not supplying enough data to HAL, expected position 5063939 , only wrote 5063760
com.amaze.filemanager W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
com.amaze.filemanager W/System.err: Caused by: android.security.KeyStoreException: Invalid key blob
        at android.security.KeyStore.getKeyStoreException(KeyStore.java:697)
        at android.security.keystore.AndroidKeyStoreProvider.loadAndroidKeyStoreSecretKeyFromKeystore(AndroidKeyStoreProvider.java:283)
        ... 18 more
? W/audio_hw_generic: Not supplying enough data to HAL, expected position 5370045 , only wrote 5217840
system_process W/WindowManager: removeWindowToken: Attempted to remove non-existing token: android.os.Binder@5bf9659
TranceLove commented 6 years ago

Also tried with Pixel 2 emulator running Android 8.1 x86 (API 27), but couldn't reproduce the problem.

Seems the problem lies in the keystore but not our code. And as the problem seems to be within CryptUtil.encryptPassword() itself, I wrote a test case for help... see TranceLove/AmazeFileManager@966f865

Sorry for using the bloated Android's own test framework, but seems it is the easiest way to start debugging this - Robolectric doesn't provide Shadow for AndroidKeyStore.

Try run the test at the AVD you have problem with and see what happened.

In the long run we may want to help user to backup the keystore... (IIRC there was an issue to add support for import/export settings, but couldn't find it; it might be part of the effort too)

EmmanuelMess commented 6 years ago

You test is passed, and the device seems to work now. Weird.