Problem Description
% ./kinit -E 1 -d ./libtodos_ag.so itoi@UMICH.EDUkinit sends the following APDU to the card:
03 10 00 00 lenWhere len is the length of the encrypted AS_REP, and the data is the encrypted AS_REP itself. Your applet should decrypt this data with key number 6 in the key file (3f00/0011), and return the plain text AS_REP to the host. kinit will then obtain the response via the get_response APDU.
data
Caution
Allocate all the objects in the constructor, not in process() or any methods called by process(). Applets are initialized (constructed) only when they are installed on the card. They are not initialized on card reset. Therefore, if you have new operations in process() method, they are called every time APDU is sent to the card. This leads to memory leak because there is no garbage collector in Java Cards.
Using DES in Cyberflex Access is at least tricky. Some advices:- Construct the DES key object with key number, e.g., deskey = new DES_Key((short)6);
- Always initialize the initialization vector of DES, e.g.,
IV = new byte[64]; // This must be 64, not 8, because of a bug of the card. Some folks say this bug is already fixed, but I am not sure.
IV[0] = (byte)0x0;
IV[1] = (byte)0x0;
IV[2] = (byte)0x0;
IV[3] = (byte)0x0;
IV[4] = (byte)0x0;
IV[5] = (byte)0x0;
IV[6] = (byte)0x0;
IV[7] = (byte)0x0;
deskey.setICV (IV, (short)0); // allocate the ICV location
deskey.clearICV();
- Allocate the DES key in the constructor, not in process() method. Otherwise, it will leak memory (see above).
pay> 2To unelect your applet (and therefore reselect the default loader), use jq command in pay .
pay> jq
pay> ju
pay> jl Krb.bin
pay> jq
pay> f 3f.00
pay> f 77.78
pay> js
pay> q
xor% kinit -K itoi@UMICH.EDUThen load the printed key into the card with "jk" command of pay.
Password for itoi@UMICH.EDU:
key:
11 22 33 44 55 66 77 88
pay> jk 1
class F0
Verify key: 90 00 ok
ca_load_key buf=jk 1
key 0 : <- paste the 8 byte key here
xor% pwdIf you want to try, you can use aklog to convert the K5 ticket to AFS token, and krb524init to Krb4 ticket (to use kpop, for example).
/afs/engin.umich.edu/u/i/t/itoi/sc_seminar/bin
xor% ./kinit -d ./libtodos_ag.so -E 1 itoi@UMICH.EDU
decrypt TGS_REP (224)
xor% ./klist
Ticket cache: /tmp/tkt10698020706m.oA_
Default principal: itoi@UMICH.EDU
Valid starting Expires Service principal
06 Nov 00 15:37:04 06 Nov 00 16:02:03 krbtgt/UMICH.EDU@UMICH.EDU
Reference
All right, another assignment is done. As always, send questions to smartcards@umich.edu. If you want to do more development / research on the project, please let us know.