# # GPShell script to load and personalise the MuscleCard applet # on a Gemalto Cyberflex Access 64k V2c (Pegasus) card. # Iain MacDonnell # establish_context card_connect # Enable trace so we have something to watch while we wait :) enable_trace # Select Card Manager select -AID a0000000030000 # Open a secure channel using SDK keys open_sc -scp 1 -scpimpl 5 -security 1 -keyind 0 -keyver 0 -enc_key 404142434445464748494a4b4c4d4e4f -mac_key 404142434445464748494a4b4c4d4e4f # List what's already there get_status -element e0 delete -AID A00000000101 delete -AID A000000001 # Install and instantiate... 34k of data space # Cyberflex 64k V2 cards seem to be picky about the ordering of the APDU data, so do it manually... install_for_load -pkgAID A000000001 -sdAID a000000003000000 -nvCodeLimit 13500 load -file MCardApplet.bin send_apdu -sc 1 -APDU 80E60C002005A00000000106A0000000010106A00000000101010208EF04C8028800C9000000 # List applets/instances to see if it installed get_status -element e0 # Select the new MCardApplet instance select -AID A00000000101 # Format (personalise) the new MCardApplet instance - APDU break-down: # B0 <- CLA # 2A <- INS_WRITE_FRAMEWORK # # 0000 <- Nothing important # # 38 <- Length of the data (everything after this) # # 08 <- transport key length # 4D7573636C653030 <- existing transport key # # 04 <- Admin PIN attempts # 01 <- Admin unblock attempts # 08 <- Admin PIN length # 3030303030303030 <- Admin PIN (replaces transport key???) ASCII for '00000000' # 08 <- Admin unblock code length # 3030303030303030 <- Admin unblock code # # 05 <- User PIN attempts # 02 <- User unblock attempts # 08 <- User PIN length # 3030303030303030 <- User PIN # 08 <- User unblock code length # 3030303030303030 <- User unblock code # # 00007FFF <- Object store size = 32767 bytes # # 00 <- ACLs - Anyone can create objects # 02 <- Keys only after user pin verified # 01 <- Pins only after admin pin verified send_apdu -sc 0 -APDU B02A000038084D7573636C6530300401083030303030303030083030303030303030050208303030303030303008303030303030303000007FFF000201 card_disconnect release_context