«

»

Compiling NIST Biometric Image Software (NBIS) for Android

One of Dev Technology’s core competencies is in biometrics capture and data integration with external US governmental organizations, such as FBI, DoD, Department of State, and others. As such, Dev Technology is working to improve end-user experience and agility in the collection of biometric data, in harsh environmental conditions, on a wide variety of platforms and devices, including mobile. One such mobile platform that Dev Technology has been focused on lately is Android. One of our internal research efforts has sought to prove that one could run the NIST Biometric Image Software (NBIS) on the Android Platform. The answer to that question initially seemed to be an obvious ‘yes’ since NBIS is written in ANSI C and easily buildable on Linux; since Android is built atop the Linux kernel, we reasoned that NBIS should be buildable for Android as well. And in fact, this is indeed true, but the process is not very straight-forward and you won’t currently find the process for doing so on the NBIS web site. This blog post, therefore, distills the lessons we’ve learned building and running NBIS on Android down to the easy-to-follow steps found below.

What is NBIS?

When working with biometrics such as fingerprints, iris and face data, it is often necessary to convert these data formats to various other formats to correctly and efficiently share this information with key US government organizations, such as FBI and DHS. NIST has provided the Biometric Image Software (NBIS) as openly-available ANSI C utilities and documentation for this very purpose. One of Dev Technology’s objectives is to be able to use these free ANSI C utilities in Government Off-The-Shelf Software (GOTS) in capturing and packaging biometric data for faster and more cost-effective data sharing with US government stakeholders. More information about NBIS can be found here.

Building NBIS for Android

When you download the latest NBIS Reference Code, the build and installation instructions will clearly walk you through how to build and install these executables for Microsoft Windows, Linux and Mac OSX. Building and installing for Android, using the provided instructions as a baseline, is also possible, but requires additional steps not currently documented by NBIS.

Assumptions

In the interest of expediency, the following instructions make the following assumptions:

  1. You have access to a Linux environment. The instructions below were executed on an Ubuntu 16.04 Headless Server running on a Windows 10 host in Oracle Virtual Box.
  2. Your Linux environment has the GCC toolchain installed.
  3. You are comfortable with the Android SDK and Android Studio. The instructions below use Android Studio 2.2.1.
  4. You have an Android Device. The instructions below use a Chuwi Hi8 Dual-Boot Tablet running Android 5.1.
  5. You have a USB connection between your Android Device and your Desktop environment and can copy files between the two.

NBIS Compilation Steps:

  1. Download the Android NDK Toolset to your Linux environment and un-compress.
  2. Download and unzip the latest NBIS source code to your Linux environment (Release 5.0 or greater)
  3. Take a minute to identify the Android version and hardware architecture of your Android device. As mentioned above, the instructions from this point are geared toward a Chuwi Android 5.1 Platform running a 32-bit Intel Atom chipset. You can use ‘adb shell’ to query your device to accurately determine if it’s 32- or 64-bit.
  4. Now, we want to start configuring the NBIS build. When we run the NBIS setup.sh script, we want to make sure that the regular Linux GCC Toolchain is on our path. This is what my setup.sh command looks like:
    1. ./setup.sh /home/jcaple/NBIS_Android_blog/android_32 –without-X11 –STDLIBS –32
    2. This script will generate the Makefile and rules.mak files used to build the code
  5. We now want to setup and configure the Android toolchain we will use for building NBIS. To do this, navigate to the Android NDK directory created when you downloaded and uncompressed it. For me, the path is: /home/jcaple/android-ndk-r13.
    1. Change directory to build/tools and run the ./make_standalone_toolchain.py script to see what arguments is takes.
    2. Execute this script to generate the toolchain you will use to compile NBIS for your Android target. For my Android Tablet, I used the API version 21 for x86 architectures:
      1. ./make_standalone_toolchain.py –arch x86 –api 21 –install-dir /home/jcaple/android-toolchain
      2. This will install the Android toolchain in my /home/jcaple/android-toolchain directory
    3. Change to the bin directory of your Android toolchain:
      1. e.g., /home/jcaple/android-toolchain/bin
    4. Create a soft-link to i686-linux-android-gcc by ‘gcc’
      1. e.g., ln -s i686-linux-android-gcc gcc
      2. This is so we can temporarily trick the NBIS Makefile into thinking it’s using the regular Linux gcc compiler, but it will be using the Android one instead.
    5. Edit your .bash_profile to put this toolchain first on your path so that these tools will be found first when building NBIS:
      1. e.g.: export PATH=/home/jcaple/android-toolchain/bin:${PATH}
      2. If you type ‘which gcc’ at this point, the result should indicate that you are using the ‘gcc’ soft-link in your Android Toolchain. If so, we are almost ready to build NBIS for Android!
  6. Change your working directory back to the NBIS Source Code Distribution.
    1. Edit rules.mak per the following:
      1. The ARCH_FLAG should have these values: -fPIC -pie
    2. Now we need to make a small edit in one of the NBIS source files. The to_iafis.c source file uses a function that is not POSIX compliant: index() needs to be replaced with strchr().
      1. Edit ./an2k/src/lib/an2k/to_iafis.c
      2. Simply change ‘index’ to ‘strchr’ on line 1858 of the Rel_5.0.0 version of this file.
        1. e.g., if((cptr = strchr(nist_rc, ‘,’)) == NULL){
    3. At this point you should be able to follow the NBIS-provided instructions for building and installing the NBIS code:
      1. make it
      2. make install
    4. The resulting binaries probably will not work on your Linux OS, but they should work on your Android device.
  7. You can now use the Android ‘adb’ utility to push any of the NBIS binaries to your Android Device. The screenshot below shows the steps to get the NBIS executable on to your Android device:
    1. adb push txt2an2k /data/local/tmp
    2. adb shell
    3. cd /data/local/tmp
    4. su
    5. chmod 777 txt2an2k
    6. ./txt2an2k
    7. Now the NBIS txt2an2k executable can be invoked on your Android Device by your custom native Android APK.

2016-nist_nbis