Difference between revisions of "Android Software Card Emulation"
Jump to navigation
Jump to search
(Created page with "==Software Card Emulation on Android== Software CE is not possible yet on stock Android but patches have been made for CyanogenMod and they are integrated in the official rele...") |
m |
||
Line 1: | Line 1: | ||
==Software Card Emulation on Android== |
==Software Card Emulation on Android== |
||
Software CE is not possible yet on stock Android but patches have been made for CyanogenMod and they are integrated in the official release since v10.1. |
Software CE is not possible yet on stock Android but patches have been made for CyanogenMod and they are integrated in the official release since v10.1. |
||
− | ===Resources=== |
||
===Requirements=== |
===Requirements=== |
||
Android phone with a PN544 NFC chipset |
Android phone with a PN544 NFC chipset |
||
Line 12: | Line 11: | ||
Following instructions [[Android_SDK#Android_application_in_command-line|how to compile Android app in command line]] |
Following instructions [[Android_SDK#Android_application_in_command-line|how to compile Android app in command line]] |
||
<source lang=bash> |
<source lang=bash> |
||
+ | git clone https://github.com/nelenkov/virtual-pki-card |
||
cd virtual-pki-card/se-emulator |
cd virtual-pki-card/se-emulator |
||
JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.26/ |
JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.26/ |
Revision as of 09:20, 9 September 2013
Software Card Emulation on Android
Software CE is not possible yet on stock Android but patches have been made for CyanogenMod and they are integrated in the official release since v10.1.
Requirements
Android phone with a PN544 NFC chipset
Installation
Easiest is to install cyanogenmod 10.1 (or more recent if available), see instructions
Example
This example is taken from this very interesting post and its source code, adapted for CyanogenMod 10.1 and compiled under Linux in command line.
It's a small example emulating a card able to do a PIN verify then a signature, a bit like some eIDs.
Compile application
Following instructions how to compile Android app in command line
git clone https://github.com/nelenkov/virtual-pki-card
cd virtual-pki-card/se-emulator
JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.26/
ANDROID_HOME=/your_path_to/android-sdk-linux_x86/
PACKAGE=org.nick.se.emulator
PACKAGE_SLASH=${PACKAGE//.//}
DEV_HOME=$(pwd)
TARGET=android-17
mkdir -p $DEV_HOME/obj
mkdir -p $DEV_HOME/bin
mkdir -p $DEV_HOME/lib
Create dummy keystore
$JAVA_HOME/bin/keytool -genkeypair \
-validity 10000 \
-dname "CN=company name,
OU=organisational unit,
O=organisation,
L=location,
S=state,
C=country code" \
-keystore $DEV_HOME/AndroidTest.keystore \
-storepass password \
-keypass password \
-alias AndroidTestKey \
-keyalg RSA \
-v
Create R.java
$ANDROID_HOME/platform-tools/aapt package -v -f -m \
-S $DEV_HOME/res -J $DEV_HOME/src -M $DEV_HOME/AndroidManifest.xml \
-I $ANDROID_HOME/platforms/$TARGET/android.jar || exit 1
Compile Java
$JAVA_HOME/bin/javac -verbose -d $DEV_HOME/obj \
-classpath "$ANDROID_HOME/platforms/$TARGET/android.jar:$DEV_HOME/obj" \
-sourcepath $DEV_HOME/src \
$DEV_HOME/src/$PACKAGE_SLASH/*.java || exit 1
Create DEX
$ANDROID_HOME/platform-tools/dx --dex --verbose \
--output=$DEV_HOME/bin/classes.dex \
$DEV_HOME/obj $DEV_HOME/lib || exit 1
Create APK
$ANDROID_HOME/platform-tools/aapt package -v -f \
-S $DEV_HOME/res -M $DEV_HOME/AndroidManifest.xml \
-I $ANDROID_HOME/platforms/$TARGET/android.jar \
-F $DEV_HOME/bin/AndroidTest.unsigned.apk \
$DEV_HOME/bin || exit 1
Sign APK
$JAVA_HOME/bin/jarsigner -verbose \
-keystore $DEV_HOME/AndroidTest.keystore \
-storepass password \
-keypass password \
-signedjar $DEV_HOME/bin/AndroidTest.signed.apk \
$DEV_HOME/bin/AndroidTest.unsigned.apk \
AndroidTestKey || exit 1
Zip-align APK
$ANDROID_HOME/tools/zipalign -v -f 4 \
$DEV_HOME/bin/AndroidTest.signed.apk \
$DEV_HOME/bin/AndroidTest.apk || exit 1