mjwheatley / cordova-plugin-android-fingerprint-auth

A cordova plugin for fingerprint authentication using the hardware fingerprint scanner on devices running Android 6+
Apache License 2.0
168 stars 131 forks source link

Error of IllegalBlockSizeException #16

Closed krunaltech closed 7 years ago

krunaltech commented 8 years ago

While trying to validate through fingerprint on device(Lenovo K5 note), it recognizes fingerprint but it give below error: "Authentication invalid Failed to encrypt the data with the generated key: IllegalBlockSizeException: null"

I have set clientid as alias of keystore and clientsecret as "android".

Please give some suggestion to resolve issue.

mjwheatley commented 8 years ago

Please uninstall and re-install your application. If it still persists, validate using the backup one time and try again. Reply with your results and we'll go from there.

krunaltech commented 8 years ago

I had tried many time to uninstall and re-install app but issue still persists. If I use backup method, it shows authentication successful message.

mjwheatley commented 8 years ago

I published v0.0.15 to fixed the error logging for the onAuthenticated catch block. I noticed it was printing null after IllegalBlockSizeException. Please update to use the new version so we can see the error that is being thrown.

Can I also see your javascript that is calling the plugin, including where you are setting the clientId and clientSecret. Also try changing those to different values to see if that helps.

krunaltech commented 8 years ago

I have re-downloaded the plugin and it show version 0.0.14. Now it shows error "Authentication invalid Failed to encrypt the data with the generated key: IllegalBlockSizeException: javax.crypto.IllegalBlockSizeException".

Below is the sample code which I am using:

angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope, $ionicPlatform) {
    $ionicPlatform.ready(function() {
         //Is available
         FingerprintAuth.isAvailable(isAvailableSuccess, isAvailableError);
         $scope.available = "Not checked";

         function isAvailableSuccess(result) {
              $scope.available = "Fingerprint available";
         }

         function isAvailableError(message) {
             $scope.available = "isAvailableError(): " + JSON.stringify(message);
             console.error(message);
        }
  });

  $scope.showAuth = function(){
        //Authenticate
        FingerprintAuth.show({
            clientId: "keystore_alias",
            clientSecret: "35BE57C2E91519178F23B046097541AE"
   }, successCallback, errorCallback);

   function successCallback(){
         alert("Authentication successfull");
   }

   function errorCallback(err){
       alert("Authentication invalid " + err);
   }
 };
});
krunaltech commented 8 years ago

I have noticed one thing just now that if within a backup mode I use fingerprint authentication, I get authentication successful message. Without backup mode, it give IllegalBlockSizeException.

mjwheatley commented 8 years ago

Ok, that changed didn't seem to provide the error message either. Are you able to open your app in Android Studio to debug? It would help to see the error message it is actually throwing.

Do you have a different device you can test on to see if it is a device specific error?

Unrelated, in isAvaiableSuccess() you need to check the result to see if it is actually available.

Change the following:

function isAvailableSuccess(result) {
              $scope.available = "Fingerprint available";
         }

to:

function isAvailableSuccess(result) {
              if (result.isAvailable) {
                  $scope.available = "Fingerprint available";
              }
         }
inexuscore commented 7 years ago

fingerprint is supported and available, but when I try to authenticate with my PIN code, i get the same error: IllegalBlockSizeException. any ideas?

D4rkMindz commented 7 years ago

Same error here on Samsung Galaxy S7 (Android 7). I am using Ionic Framework 3.6.0 Ionic App Scripts 2.1.3 Angular Core 4.1.3 (Same CLI) Node 6.11.2