OpenSC and MyKAD

I recently bought myself a smart-card reader in order to fool around with the MyKAD (Malaysian National Identity Card). The main reason for this is to figure out how to read the information contained within the MyKAD. I went online to find myself an OpenSC compatible reader and got myself one for just under RM 23. Next, I found some information about MyKAD APDU on a Lowyat forum along with the associated data file offsets.

The result is the following shell script that dumps all the MyKAD information onto the screen. OpenSC automatically detects the MyKAD as an EMV compatible card.

#!/bin/sh
AP_JPN="00:A4:04:00:0A:A0:00:00:00:74:4A:50:4E:00:10"

DF_PAGE1="C8:32:00:00:05:08:00:00:A0:00"
PR_PAGE1="CC:00:00:00:08:01:00:01:00:E9:00:A0:00"
SZ_PAGE1="CC:06:00:00:A0"

DF_PAGE4="C8:32:00:00:05:08:00:00:90:00"
PR_PAGE4="CC:00:00:00:08:04:00:01:00:03:00:90:00"
SZ_PAGE4="CC:06:00:00:90"

opensc-tool -v -s $AP_JPN \
-s $DF_PAGE1 -s $PR_PAGE1 -s $SZ_PAGE1 \
-s $DF_PAGE4 -s $PR_PAGE4 -s $SZ_PAGE4 2>/dev/null

All it took was 8 lines of shell script and it would dump all the MyKAD information onto the screen, raw. All that is needed now is some extra processing magic to slice up the data into its constituent parts. Imagine, all this without a single like of C/C++ code and under RM25!

Published by

Shawn Tan

Chip Doctor, Chartered/Professional Engineer, Entrepreneur, Law Graduate.

15 thoughts on “OpenSC and MyKAD”

  1. Hi sir,
    This is Mubashir Hussain from Pakistan , I’m IT student over here @ BMIC College Maluri, Cheras. Sir i want to submit my final assignment about Mycard EZ100PU with source code in vb 6.0, kindly you can help me out I’m will to pay you, i have already device i try my level best but fail

  2. the opensc link is invalid.
    i have scdump.c from lowyat but wanted to edit and compile again but gets error message. all i need is to read and store the details in a text file.

Leave a comment