Awesome
JavaCard Tutorial
Examples from Eric VĂ©tillard's tutorial re-arranged in a Gradle project using JavaCard gradle plugin with additional tests
Each example is referenced as a Gradle module with :
- source under
main
sourceSet (sdk version can be selected from build.gradle) - simulation tests using JCardSim
- unit test using JUnit
- tests on smartcard device using jnasmartcardio with apdu4j logger
- quick testing scripts defining some gradle task to send defined apdu sequence
It's also possible :
- to use
GPTool
andGlobalPlatform
class undertest
which provide the same power as GlobalPlatformPro tool - to use
GPExec
gradle task to call GlobalPlatformPro from gradle to create custom tasks
Setup
git clone git@github.com:bertrandmartel/javacard-tutorial.git
cd javacard-tutorial
git submodule update --init
Build all examples
./gradlew build
jc101-1c : basic applet
http://javacard.vetilles.com/2006/09/17/hello-world-smart-card/
install
The following will build, delete applet if existing, install the applet :
./gradlew :jc101-1c:build :jc101-1c:installJavaCard
run simulation tests
./gradlew :jc101-1c:test
run tests on smartcard
./gradlew :jc101-1c:test -DtestMode=smartcard
send apdu
From gradle script task :
./gradlew :jc101-1c:sendHello
jc101-2c : a simple counter
http://javacard.vetilles.com/2006/10/30/jc101-2c-a-simple-counter-for-smart-card-developers/
install
The following will build, delete applet if existing, install the applet :
./gradlew :jc101-2c:build :jc101-2c:installJavaCard
run simulation tests
./gradlew :jc101-2c:test
run tests on smartcard
./gradlew :jc101-2c:test -DtestMode=smartcard
send apdu
From gradle script task :
- balance
./gradlew :jc101-2c:balance
- credit 5
./gradlew :jc101-2c:credit
- debit 5
./gradlew :jc101-2c:debit
jc101-password : password application
- http://javacard.vetilles.com/2006/11/07/jc101-3c-a-real-application/
- http://javacard.vetilles.com/2007/02/06/jc101-4c-a-basic-password-manager/
- http://javacard.vetilles.com/2008/01/07/jc101-5c-data-management-and-transactions/
- http://javacard.vetilles.com/2008/01/15/jc101-6c-specifying-the-apdus/
- http://javacard.vetilles.com/2008/04/05/jc101-7c-processing-apdus-12/
- http://javacard.vetilles.com/2008/04/09/jc101-8c-processing-apdu%E2%80%99s-22/
install
The following will build, delete applet if existing, install the applet :
./gradlew :jc101-password:build :jc101-password:installJavaCard
run simulation tests
./gradlew :jc101-password:test
run tests on smartcard
./gradlew :jc101-password:test -DtestMode=smartcard
send apdu
From gradle script task :
- add password entry
./gradlew :jc101-password:addPassword
- delete password entry
./gradlew :jc101-password:removePassword
- list identifiers
./gradlew :jc101-password:listPassword
jc101-password-pin : password application with PIN security
- http://javacard.vetilles.com/2008/04/16/jc101-9c-authentication-and-lifecycle/
- http://javacard.vetilles.com/2008/04/21/jc101-10c-adding-a-password-and-state-management/
install
The following will build, delete applet if existing, install the applet :
./gradlew :jc101-password-pin:build :jc101-password-pin:installJavaCard
run simulation tests
./gradlew :jc101-password-pin:test
run tests on smartcard
./gradlew :jc101-password-pin:test -DtestMode=smartcard
send pin code apdu
- set pin code
./gradlew :jc101-password-pin:setPinCode
send apdu
From gradle script task :
- add password entry
./gradlew :jc101-password-pin:addPassword
- delete password entry
./gradlew :jc101-password-pin:removePassword
- list identifiers
./gradlew :jc101-password-pin:listPassword