Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidAlgorithmParmeterException in createKey() causes crash #4

Closed
scottmcnab opened this issue Jun 28, 2016 · 5 comments
Closed

InvalidAlgorithmParmeterException in createKey() causes crash #4

scottmcnab opened this issue Jun 28, 2016 · 5 comments

Comments

@scottmcnab
Copy link

While testing this plugin on Android 6 emulator, I get unexpected app termination attempting to call FingerprintAuth.show() (after a successful call to FingerprintAuth.isAvailable() that indicates fingerprints are available and enrolled):

V/FingerprintAuth: Init FingerprintAuth
V/FingerprintAuth: FingerprintAuth action: availability
W/CordovaPlugin: Attempted to send a second callback for ID: FingerprintAuth1796866245
Result was: "OK"
V/FingerprintAuth: FingerprintAuth action: authenticate
W/CordovaPlugin: Attempted to send a second callback for ID: FingerprintAuth1796866267
Result was: "Error"
W/CordovaPlugin: Attempted to send a second callback for ID: FingerprintAuth1796866267
Result was: "InvalidKeyException"
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp, PID: 1019
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.cordova.plugin.android.fingerprintauth.FingerprintAuthenticationDialogFragment.setCryptoObject(android.hardware.fingerprint.FingerprintManager$CryptoObject)' on a null object reference
at com.cordova.plugin.android.fingerprintauth.FingerprintAuth$1.run(FingerprintAuth.java:196)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Details:

Investigating with debugger shows InvalidAlgorithmParameterException raised (and caught) in createKey() method with this message (when executing the "authenticate" action):

"java.lang.IllegalStateException: At least one fingerprint must be enrolled to create keys requiring user authentication for every use"

Since this error case is never acted on to abort the call, this in turn causes initCipher() to fail with InvalidKeyException (message "Unsupported key: null"), falling through to the "else" statement, whereby mFragment is null as it is never initialised (hence crash).

Any idea what is causing this or how to fix it? Thanks!

@scottmcnab
Copy link
Author

FYI to reproduce this bug:

  • Launch a standard Android emulator with API 23 (e.g. Nexus_5_API_23_x86)
  • Enable fingerprints in the Settings menu and set an unlock PIN code
  • Kill and relaunch the emulator
  • Unlock the emulator using the PIN code (as needed for first boot)
  • Run a cordova application that calls FingerprintAuth.show()
  • *** CRASH ***

NOTE: if you then simulate locking and unlocking the emulator with the fingerprint (instead of PIN) then the plugin works fine!

@rakeshpalivela
Copy link

Hi @scottmcnab did you get any solutions?
I am also facing same issue.

@mjwheatley
Copy link
Owner

Is this an emulator only error, or is it showing up on hardware devices as well?

Shall I then abort the call upon catching that exception to prevent the crash, or would that just be masking the problem? It would not change the fact that you would be unable to use fingerprint authentication.

@rakeshpalivela
Copy link

Hi @mjwheatley I am facing this in Hardware device (Samsung S6 Edge Device).

@mjwheatley
Copy link
Owner

I have published v0.0.8 to improve the error handling in order to prevent the plugin from causing the application to crash. Now if the cipher fails to initialize the backup activity will be launched and ask for the backup pin, password, or pattern. If you validate using a fingerprint on this screen it seems to resolve the issue with the key being permanently revoked which seemed to be causing the cipher from being initialized.

Please test it out and let me know if it helps resolve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants