DEV Community

Julio Chinchilla
Julio Chinchilla

Posted on

Biometric fingerprint authentication on SmartCard Chips

SEP7US MatchOnCard Auxiliary

SEP7US

During the years 2013 to 2018, in my early programming journey, I worked on projects related to smart cards based on ISO/IEC 7816-4 smart card chips. Below, I present SEP7US, a library I implemented that was used for biometric match-on-card verification, following NIST’s MINEX guidelines.


Author

Project Repository

You can find the full project here: GitHub - SEP7US

I consider it very important to briefly explain how this library works, since there is very little public documentation available about biometric standards.


Disclaimer

SEP7US Match on Card 0x7E3

Any modification made without proper supervision or consent is at your own risk. Changing the code will drastically alter verification results on any PIV Smart Card application.


Languages and Tools

  • C++
  • Java Native Interface (JNI)

Purpose

SEP7US provides an auxiliary library for converting biometric minutiae templates:

  • ISO/IEC 19794-2:2005
  • ANSI INCITS 378-2004

into the ISOCC format required for biometric match-on-card verification of chips based on ISO/IEC 7816-4 standards.


Internal Process

  1. Minutiae Counting
  2. Spatial Requantization
  3. Angular Requantization
  4. Minutiae Sorting

Template Identification

It is important to define the starting position of minutiae data depending on the template type:

ISO/IEC 19794-2:2005

posDataTemplate = 0x12; // DEC=18
Enter fullscreen mode Exit fullscreen mode

ANSI INCITS 378-2004

posDataTemplate = 0x14; // DEC=20
Enter fullscreen mode Exit fullscreen mode

Minutiae Counting

short numMinutiae = (short) fTemplate[posDataTemplate+9] & 0xFF;
Enter fullscreen mode Exit fullscreen mode

The array size for the ISOCC template will be determined by:

// numMinutiae
short sizeISOCC = numMinutiae * 3;  // (X, Y, T|A)
Enter fullscreen mode Exit fullscreen mode

Spatial Requantization

This process expresses minutiae coordinates in terms of 0.1mm.

Base Formula:

CoordMM      = 10 * Coord / RES
CoordUNITS   = CoordMM / 0.1
CoordCC      = 0.5 + CoordUNITS
Enter fullscreen mode Exit fullscreen mode

Template Resolution Calculation:

short xres = (short) (fTemplate[posDataTemplate+0] << 8 | fTemplate[posDataTemplate+1]) & 0xFF;
short yres = (short) (fTemplate[posDataTemplate+2] << 8 | fTemplate[posDataTemplate+3]) & 0xFF;
Enter fullscreen mode Exit fullscreen mode

X Coordinate:

*pcoordmmX    = 10.0 * (double) *ptmpx / xres;
*pcoordunitsX = *pcoordmmX / 0.1;
*pcoordccX    = (short)(.5 + *pcoordunitsX);
Enter fullscreen mode Exit fullscreen mode

Y Coordinate:

*pcoordmmY    = 10.0 * (double) *ptmpy / yres;
*pcoordunitsY = *pcoordmmY / 0.1;
*pcoordccY    = (short)(.5 + *pcoordunitsY);
Enter fullscreen mode Exit fullscreen mode

Angular Requantization

The angular requantization represents minutiae angles in 6 bits (0–63), considering that the maximum value is 360°.

ISOCC angle resolution:

360/64 = 5.625°
Enter fullscreen mode Exit fullscreen mode
float ISOCC_ANGLE_RESOLUTION = 5.625f;
Enter fullscreen mode Exit fullscreen mode

For ISO/IEC 19794-2:2005:

360/256 = 1.40625°
Enter fullscreen mode Exit fullscreen mode
ANGLE_RESOLUTION = 1.40625f;
Enter fullscreen mode Exit fullscreen mode

For ANSI INCITS 378-2004:

360/180 = 2°
Enter fullscreen mode Exit fullscreen mode
ANGLE_RESOLUTION = 2;
Enter fullscreen mode Exit fullscreen mode

Final Computation:

tmpCAngle = ANGLE_RESOLUTION * (*ptmpa);
tmpFAngle = tmpCAngle / ISOCC_ANGLE_RESOLUTION;
short t   = (*ptmpt | tmpFAngle) & 0xFF;
Enter fullscreen mode Exit fullscreen mode

Minutiae Sorting

Although some smart cards do not require sorting, SEP7US provides four main sorting functions:

void XYAsc(unsigned char *a, short n);  // X ascending
void XYDsc(unsigned char *a, short n);  // X descending
void YXAsc(unsigned char *a, short n);  // Y ascending
void YXDsc(unsigned char *a, short n);  // Y descending
Enter fullscreen mode Exit fullscreen mode

External Methods

ISOCC

Generates an ISO Compact Card template.

__declspec(dllexport) unsigned char *ISOCC(
    unsigned char templateFormat,
    unsigned char *fTemplate,
    unsigned char sorting
);
Enter fullscreen mode Exit fullscreen mode

Parameters:

  • templateFormat: 0xFF for ISO/IEC 19794-2:2005, 0x7F for ANSI INCITS 378-2004
  • fTemplate: Pointer to the original template
  • sorting: Sorting option (0x00, 0x0F, 0x10, 0x1F)

Verify

Generates an ISOCC template with ISO/IEC 7816-4 APDU headers for PIV verification.

__declspec(dllexport) unsigned char *Verify(
    unsigned char CLA,
    unsigned char INS,
    unsigned char P1,
    unsigned char P2,
    unsigned char templateFormat,
    unsigned char *fTemplate,
    unsigned char sorting
);
Enter fullscreen mode Exit fullscreen mode

Default APDU Command: 0x00 0x21

Headers added:

7F2E : "Biometric Data Template"
Enter fullscreen mode Exit fullscreen mode

License

MIT

Top comments (0)