Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Fingerprint Authentication: Crypto primitive not initialized

I implemented Fingerprint authentication inside the application which was working fine a week ago. No changes to the code and I am now getting the following error:

FATAL EXCEPTION: main
    Caused by: java.lang.IllegalStateException: Crypto primitive not initialized

I'm not sure what's going on as nothing has been changed in the code, even verifying with a clean pull of the branch.

Below is a list of dependencies that I am using in the app.

compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.1.1'
compile 'com.android.support:design:23.+'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.6'
compile 'com.squareup.okhttp:okhttp:2.7.1'
compile 'org.jdeferred:jdeferred-android-aar:1.2.4'
compile 'com.google.code.gson:gson:1.7.2'
compile "com.mixpanel.android:mixpanel-android:4.6.4"
compile "com.google.android.gms:play-services:3.1+"
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
    transitive = true;
}
compile 'io.branch.sdk.android:library:1.+'
compile 'com.parse.bolts:bolts-applinks:1.4.0'
compile 'com.github.greenfrvr:rubber-loader:1.1.2@aar'
compile 'com.github.deano2390:MaterialShowcaseView:1.0.6@aar'

Is there anything I should be aware of in regards to these new-ish APIs?

like image 405
Mike Littman Avatar asked Feb 07 '23 19:02

Mike Littman


1 Answers

You need to initialize your cipher object for Encryption or Decryption

cipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7);

cipher.init(Cipher.ENCRYPT_MODE, key);

Depending on what you are trying to do, you may need to generate a SecretKey, KeyStore and KeyGenerator as well. I can elaborate further if needed.

like image 173
Caleb Avatar answered Feb 11 '23 00:02

Caleb