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

ILLEGAL_BLOCK_SIZE_EXCEPTION on authentication with Backup option using device PIN/Pattern #88

Closed
vandanaKumari89 opened this issue Jul 24, 2017 · 4 comments

Comments

@vandanaKumari89
Copy link

When I attempt to "USE BACKUP" option (device's PIN unlock) to authenticate instead of fingerprint, I get ILLEGAL_BLOCK_SIZE_EXCEPTION. I am running the code in Google Pixel 7.1.2

I am using plugin version 1.3.1

Log : 7-24 14:26:25.256 24976-24976/com.example.Fingerprint I/chromium: [INFO:CONSOLE(73)] "FingerprintAuth Error: ILLEGAL_BLOCK_SIZE_EXCEPTION", source: file:///android_asset/www/js/index.js (73)

Below is my code:
`/*

  • Licensed to the Apache Software Foundation (ASF) under one

  • or more contributor license agreements. See the NOTICE file

  • distributed with this work for additional information

  • regarding copyright ownership. The ASF licenses this file

  • to you under the Apache License, Version 2.0 (the

  • "License"); you may not use this file except in compliance

  • with the License. You may obtain a copy of the License at

  • http://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing,

  • software distributed under the License is distributed on an

  • "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

  • KIND, either express or implied. See the License for the

  • specific language governing permissions and limitations

  • under the License.
    */
    var app = {
    // Application Constructor
    initialize: function() {
    document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
    },

    // deviceready Event Handler
    //
    // Bind any cordova events here. Common events are:
    // 'pause', 'resume', etc.
    onDeviceReady: function() {
    this.receivedEvent('deviceready');

     // Check if device supports fingerprint
     /**
     * @return {
     *      isAvailable:boolean,
     *      isHardwareDetected:boolean,
     *      hasEnrolledFingerprints:boolean
     *   }
     */
     FingerprintAuth.isAvailable(function (result) {
    
         console.log("FingerprintAuth available: " + JSON.stringify(result));
    
         // If has fingerprint device and has fingerprints registered
         if (result.isAvailable == true && result.hasEnrolledFingerprints == true) {
    
             // Check the docs to know more about the encryptConfig object :)
             var encryptConfig = {
                 clientId: "myAppName",
                 username: "currentUser",
                 password: "currentUserPassword",
                 maxAttempts: 5,
                 locale: "en_US",
                 dialogTitle: "Hey dude, your finger",
                 dialogMessage: "Put your finger on the device",
                 dialogHint: "No one will steal your identity, promised"
             }; // See config object for required parameters
    
             // Set config and success callback
             FingerprintAuth.encrypt(encryptConfig, function(_fingerResult){
                 console.log("successCallback(): " + JSON.stringify(_fingerResult));
                 if (_fingerResult.withFingerprint) {
                     console.log("Successfully encrypted credentials.");
                     console.log("Encrypted credentials: " + result.token);
                 } else if (_fingerResult.withBackup) {
                     console.log("Authenticated with backup password");
                 }
             // Error callback
             }, function(err){
                     if (err === "Cancelled") {
                     console.log("FingerprintAuth Dialog Cancelled!");
                 } else {
                     console.log("FingerprintAuth Error: " + err);
                 }
             });
         }
    
     /**
     * @return {
     *      isAvailable:boolean,
     *      isHardwareDetected:boolean,
     *      hasEnrolledFingerprints:boolean
     *   }
     */
     }, function (message) {
         console.log("isAvailableError(): " + message);
     });
    

    },

    // Update DOM on a Received Event
    receivedEvent: function(id) {
    var parentElement = document.getElementById(id);
    var listeningElement = parentElement.querySelector('.listening');
    var receivedElement = parentElement.querySelector('.received');

     listeningElement.setAttribute('style', 'display:none;');
     receivedElement.setAttribute('style', 'display:block;');
    
     console.log('Received Event: ' + id);
    

    }
    };

app.initialize();`

Any idea how to fix this?

@ghost
Copy link

ghost commented Jul 26, 2017

Hi, I have the same problem. Any ideas how to fix this?

@ghost
Copy link

ghost commented Jul 26, 2017

According to #85 there is still an open issue if the backup code is used. For now, I have disabled the backup code, hopefully it get fixed.

@ghost
Copy link

ghost commented Aug 2, 2017

I'm getting the same problem as well when using the encrypt method (default options, except clientId, and locale set to 'pt').

@mjwheatley
Copy link
Owner

After debugging this issue with @walternicholas on issue#85 we discovered that different Android devices can handle the userAuthRequired differently. I have the default value for userAuthRequired set to true. Encrypting using the back up pick was working on my Nexus 6p, but not on his Nexus 5x. I also confirmed that it did not work on the Samsung S8. After changing the value for userAuthRequired to false and uninstalling and reinstalling the app (to insure that a new secret key is generated with the new setting) the app was able to encrypt using the backup.

I have decided to remove the userAuthRequired parameter and always default it to false. From our discussion, I also implemented a new parameter called encryptNoAuth that would allow you to request encryption without authenticating with fingerprint or backup. However, decryption still requires authentication. These changes will be available in version 1.4.0

For version prior to 1.4.0, this issue can be resolved by setting userAuthRequired to false and ensuring that a new secret key is generated by uninstalling and reinstalling your application.

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

2 participants