All Projects → Mauin → Rxfingerprint

Mauin / Rxfingerprint

Licence: apache-2.0
Android Fingerprint authentication and encryption with RxJava

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Rxfingerprint

Fingerprintmanager
A small library to handle Android fingerprint API.
Stars: ✭ 560 (+50.13%)
Mutual labels:  encryption, fingerprint, fingerprint-authentication
Rxbiometric
☝️ RxJava and RxKotlin bindings for Biometric Prompt (Fingerprint Scanner) on Android
Stars: ✭ 295 (-20.91%)
Mutual labels:  rxjava, rxjava2, fingerprint
Android Goldfinger
Android library to simplify Biometric authentication implementation.
Stars: ✭ 608 (+63%)
Mutual labels:  encryption, fingerprint, fingerprint-authentication
Reprint
A unified fingerprint library for android.
Stars: ✭ 467 (+25.2%)
Mutual labels:  rxjava, fingerprint, fingerprint-authentication
fingerprint-gui
Use fingerprint readers with a Linux desktop environment
Stars: ✭ 47 (-87.4%)
Mutual labels:  fingerprint, fingerprint-authentication
RxRetroAPICall
API call example using Retrofit and RxJava2
Stars: ✭ 16 (-95.71%)
Mutual labels:  rxjava, rxjava2
Androidproject
Android 技术中台,但愿人长久,搬砖不再有
Stars: ✭ 4,398 (+1079.09%)
Mutual labels:  rxjava, rxjava2
Rxanime
Visualizer to understand RxJava operators
Stars: ✭ 261 (-30.03%)
Mutual labels:  rxjava, rxjava2
Rxandroidble
An Android Bluetooth Low Energy (BLE) Library with RxJava2 interface
Stars: ✭ 3,025 (+710.99%)
Mutual labels:  rxjava, rxjava2
Nybus
NYBus (RxBus) - A pub-sub library for Android and Java applications
Stars: ✭ 283 (-24.13%)
Mutual labels:  rxjava, rxjava2
Freezer
A simple & fluent Android ORM, how can it be easier ? RxJava2 compatible
Stars: ✭ 326 (-12.6%)
Mutual labels:  rxjava, rxjava2
RxWebView
RxJava2 binding APIs for Android's WebView
Stars: ✭ 22 (-94.1%)
Mutual labels:  rxjava, rxjava2
sourceafis-net
Fingerprint recognition engine for .NET that takes a pair of human fingerprint images and returns their similarity score. Supports efficient 1:N search.
Stars: ✭ 43 (-88.47%)
Mutual labels:  fingerprint, fingerprint-authentication
T Mvp
Android AOP Architecture by Apt, AspectJ, Javassisit, based on Realm+Databinding+MVP+Retrofit+Rxjava2
Stars: ✭ 2,740 (+634.58%)
Mutual labels:  rxjava, rxjava2
RxFbLiveVideoEmoticons
Demo of Fb Live Video Reactions using RxJava2
Stars: ✭ 93 (-75.07%)
Mutual labels:  rxjava, rxjava2
android-online-course
Android Online Course
Stars: ✭ 22 (-94.1%)
Mutual labels:  rxjava, rxjava2
Swipe
👉 detects swipe events on Android
Stars: ✭ 324 (-13.14%)
Mutual labels:  rxjava, rxjava2
Apollo
🚀 Awesome EventBus by RxJava.
Stars: ✭ 329 (-11.8%)
Mutual labels:  rxjava, rxjava2
Grox
Grox helps to maintain the state of Java / Android apps.
Stars: ✭ 336 (-9.92%)
Mutual labels:  rxjava, rxjava2
RxCamera2
Rx Java 2 wrapper for Camera2 google API
Stars: ✭ 27 (-92.76%)
Mutual labels:  rxjava, rxjava2

RxFingerprint: Android Fingerprint Authentication and Encryption in RxJava2

RxFingerprint wraps the Android Fingerprint APIs (introduced in Android Marshmallow) and makes it easy to:

  • Authenticate your users with their fingerprint
  • Encrypt and decrypt their data with fingerprint authentication

Learn more about the Android Fingerprint APIs at developer.android.com.

This library has a minSdkVersion of 15, but will only really work on API level 23. Below that it will provide no functionality due to the missing APIs.

Usage

To use RxFingerprint in your project, add the library as a dependency in your build.gradle file:

dependencies {
    compile 'com.mtramin:rxfingerprint:2.2.1'
}

Furthermore, you have to declare the Fingerprint permission in your AndroidManifest.xml:

<uses-permission android:name="android.permission.USE_FINGERPRINT" />

Checking for availability

Before using any fingerprint related operations it should be verified that RxFingerprint can be used by calling:

if (RxFingerprint.isAvailable(this)) {
    // proceed with fingerprint operation
} else {
    // fingerprint is not available
}

Reasons for RxFingerprint to report that it is not available include:

  • The current device doesn't have a fingerprint sensor
  • The user is not using the fingerprint sensor of the device
  • The device is running an Android version that doesn't support the Android Fingerprint APIs

Authenticating a user with their fingerprint

To authenticate the user with their fingerprint, call the following:

Disposable disposable = RxFingerprint.authenticate(this)
                .subscribe(fingerprintAuthenticationResult -> {
                    switch (fingerprintAuthenticationResult.getResult()) {
                        case FAILED:
                            setStatusText("Fingerprint not recognized, try again!");
                            break;
                        case HELP:
                            setStatusText(fingerprintAuthenticationResult.getMessage());
                            break;
                        case AUTHENTICATED:
                            setStatusText("Successfully authenticated!");
                            break;
                    }
                }, throwable -> {
                    Log.e("ERROR", "authenticate", throwable);
                });

By subscribing to RxFingerprint.authenticate(Context) the fingerprint sensor of the device will be activated and it will wait for the user to touch it with one of their registered fingerprints. Should the device not contain a fingerprint sensor or the user has not enrolled any fingerprints, onError will be called.

After successful authentication or a recoverable error (e.g. the sensor could not read the fingerprint clearly) onNext will be called. You should check the result to see if the authentication was successful. In the case of a recoverable error the value provded to onNext contains a helpful message that can be shown to the user and the user can try again.

By disposing the Disposable, the fingerprint sensor will be disabled again with no result.

Encryption-and-decryption

Usage of the Encryption and decryption features of RxFingerprint are very similar to simple authentication calls.

RxFingerprint supports encryption with both the AES and RSA encryption standards. They differ in the way the user needs to interact with their fingerprint sensor. For encryption and decryption the same EncryptionMethod should be used. Otherwise the encrypted data cannot be decrypted.

Encryption and Decryption in RxFingerprint is backed by the Android KeyStore System.

After the encryption step all results will be Base64 encoded for easier transportation and storage.

AES

When choosing AES for encryption and decryption the user will have to approve both actions by authentication with their fingerprint by touching the fingerprint sensor. The encryption then relies on the Advanced Encryption Standard with a 256-bit keysize.

The usage flow for AES is as follows:

  • Call RxFingerprint.encrypt(EncryptionMethod.AES, ...) to initialize the encryption flow

  • User authenticates by touching the fingerprint sensor

  • Store the encrypted data returned in the onNext callback

  • Call RxFingerprint.decrypt(EncryptionMethod.AES, ...) to initialize the decryption flow

  • User authenticates by touching the fingerprint sensor

  • Receive the decrypted data in the onNext callback

RSA

RSA encryption allows you to encrypt a value without any user action. The data to encrypt can be encrypted and a user won't need to authenticate oneself by touching the fingerprint sensor. The encrypted data can only be decrypted again when the user authenticates by using the fingerprint sensor on their device.

The usage flow for AES is as follows:

  • Call RxFingerprint.encrypt(EncryptionMethod.RSA, ...) to initialize the encryption flow

  • Store the encrypted data returned in the onNext callback

  • Call RxFingerprint.decrypt(EncryptionMethod.RSA, ...) to initialize the decryption flow

  • User authenticates by touching the fingerprint sensor

  • Receive the decrypted data in the onNext callback

Encrypting and decrypting values

Disposable disposable = RxFingerprint.encrypt(EncryptionMethod.RSA, this, keyName, stringToEncrypt)
                   .subscribe(encryptionResult -> {
                       switch (encryptionResult.getResult()) {
                           case FAILED:
                               setStatusText("Fingerprint not recognized, try again!");
                               break;
                           case HELP:
                               setStatusText(encryptionResult.getMessage());
                               break;
                           case AUTHENTICATED:
                               setStatusText("Successfully authenticated!");
                               break;
                       }
                   }, throwable -> {
                       Log.e("ERROR", "authenticate", throwable);
                       setStatusText(throwable.getMessage());
                   });

RxFingerprint.encrypt(EncryptionMethod, Context, String, String) takes the String you want to encrypt (which might be a token, user password, or any other String) and a key name. The given String will be encrypted with a key in the Android KeyStore and returns an encrypted String. The key used in the encryption is only accessible from your own app. Store the encrypted String anywhere and use it later to decrypt the original value by calling:

Disposable disposable = RxFingerprint.decrypt(EncryptionMethod.RSA, this, keyName, encryptedValue)
                    .subscribe(decryptionResult -> {
                        switch (decryptionResult.getResult()) {
                            case FAILED:
                                setStatusText("Fingerprint not recognized, try again!");
                                break;
                            case HELP:
                                setStatusText(decryptionResult.getMessage());
                                break;
                            case AUTHENTICATED:
                                setStatusText("decrypted:\n" + decryptionResult.getDecrypted());
                                break;
                        }
                    }, throwable -> {
                        //noinspection StatementWithEmptyBody
                        if (RxFingerprint.keyInvalidated(throwable)) {
                            // The keys you wanted to use are invalidated because the user has turned off his
                            // secure lock screen or changed the fingerprints stored on the device
                            // You have to re-encrypt the data to access it
                        }
                        Log.e("ERROR", "decrypt", throwable);
                        setStatusText(throwable.getMessage());
                    });

Be aware that all encryption keys will be invalidated once the user changes their lockscreen or changes any of their enrolled fingerprints. If you receive an onError event during decryption check if the keys were invalidated with RxFingerprint.keyInvalidated(Throwable) and prompt the user to encrypt their data again.

Once the encryption keys are invalidated RxFingerprint will delete and renew the keys in the Android Keystore on the next call to RxFingerprint.encrypt(...).

Best-practices

To prevent errors and ensure a good user experience, make sure to think of these cases:

  • Before calling any RxFingerprint authentication, check if the user can use fingerprint authentication by calling: RxFingerprint.isAvailable(Context) or RxFingerprint.isUnavailable(Context)
  • Always check for recoverable errors in any onNext events and provide the user with the given Error message in the result.
  • If keys were invalidated due to the user changing their lockscreen or enrolled fingerprints provide them with a way to encrypt their data again.

Dependencies

RxFingerprint brings the following dependencies:

  • RxJava2
  • Android Support Annotations

Bugs and Feedback

For bugs, questions and discussions please use the Github Issues.

LICENSE

Copyright 2015-2017 Marvin Ramin.

Licensed 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].