Skip to Main Content

Java Card

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

install applet oncard successfull but run command error

843851Jul 9 2008 — edited Jul 27 2008
Anyone can help me?
I wrote an javacard applet and install on card using JCOP and eclipse. The installation was sucessfull. When I send commands to test the functions, error occurs.
My applet was:
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;


public class TestST extends Applet {
	final static byte demo_cla = (byte)0x80;
	final static byte SetStr = (byte)0x10;
	final static byte GetStr = (byte)0x20;
	
	byte[] oldStr;
	byte[] newStr;
	
	private TestST(byte[] bArr, short bOff, byte l)
	{
		oldStr= new byte[100];
		newStr= new byte[100]; 
		if (bArr[bOff]==(byte)0)
		{
			register();
		}
		else register(bArr, (short)(bOff+1) ,(byte)(bArr[bOff]));
	}
	
	public static void install(byte[] bArray, short bOffset, byte bLength) {
		// GP-compliant JavaCard applet registration
		new TestST(bArray, (short) (bOffset + 1), bArray[bOffset]);
	}

	public void process(APDU apdu) {
		// Good practice: Return 9000 on SELECT
		if (selectingApplet()) {
			return;
		}

		byte[] buf = apdu.getBuffer();
		byte cla=buf[ISO7816.OFFSET_CLA];
		if (cla!=demo_cla) ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
		
		switch (buf[ISO7816.OFFSET_INS]) {
		case (byte) 0x00:
			break;
		case SetStr:
			 SetString(apdu);
			 break;
		case GetStr:
			 GetString(apdu);
			 break;
		default:
			// good practice: If you don't know the INStruction, say so:
			ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
		}
	}
	private void SetString(APDU apdu)
	{
		byte buffer[] = apdu.getBuffer();

		byte size = (byte)(apdu.setIncomingAndReceive());

		byte i;

		//  Store the length of the string and the string itself

		oldStr[0] = size;

		for (i = 0; i< size; i++) 
			oldStr[(byte)(i+1)] = buffer[(byte)(ISO7816.OFFSET_CDATA+i)];
		return;
	}
	private byte[] GetString(APDU apdu)	{
		byte buffer1[] = apdu.getBuffer();

		byte numBytes = buffer1[ISO7816.OFFSET_LC];


		if (numBytes == (byte)0) {
			ISOException.throwIt((short)(0x6200));
		}

		apdu.setOutgoing();
		apdu.setOutgoingLength(numBytes);		

		byte index;

		for (index = 0; index <= numBytes; index++) 
			buffer1[index] = oldStr[(byte)(index + 1)];
		return buffer1;
	}
}
the installation:
??>  /term "Remote|localhost:1834"
--Opening terminal
/card -a a000000003000000 -c com.ibm.jc.CardManager
--Waiting for card... ATR=3B E9 00 00 81 31 FE 45 4A 43 4F 50 34 31 56 32 ;....1.EJCOP41V2 32 A7 2. ATR: T=1, N=0, IFSC=254, BWI=4/CWI=5, Hist="JCOP41V22" => 00 A4 04 00 08 A0 00 00 00 03 00 00 00 00 .............. (2271 usec) <= 6F 10 84 08 A0 00 00 00 03 00 00 00 A5 04 9F 65 o..............e 01 FF 90 00 .... Status: No Error cm> set-key 255/1/DES-ECB/404142434445464748494a4b4c4d4e4f 255/2/DES-ECB/404142434445464748494a4b4c4d4e4f 255/3/DES-ECB/404142434445464748494a4b4c4d4e4f cm> init-update 255 => 80 50 00 00 08 65 05 35 59 DA 53 F0 C9 00 .P...e.5Y.S... (38691 usec) <= 00 00 C6 D8 6A 1C B2 02 14 13 FF 02 00 00 93 73 ....j..........s 3A B8 2C 0F 1B 19 F2 88 37 3D 18 99 90 00 :.,.....7=.... Status: No Error cm> ext-auth plain => 84 82 00 00 10 2C 46 8D E7 A0 52 43 0E 92 13 2F .....,F...RC.../ FB 08 67 7A 79 ..gzy (2736 usec) <= 90 00 .. Status: No Error cm> delete 000102030405 => 80 E4 00 00 08 4F 06 00 01 02 03 04 05 00 .....O........ (1561 usec) <= 6A 88 j. Status: Reference data not found jcshell: Error code: 6a88 (Reference data not found) jcshell: Wrong response APDU: 6A88 Ignoring expected error cm> delete 0001020304 => 80 E4 00 00 07 4F 05 00 01 02 03 04 00 .....O....... (1329 usec) <= 6A 88 j. Status: Reference data not found jcshell: Error code: 6a88 (Reference data not found) jcshell: Wrong response APDU: 6A88 Ignoring expected error cm> upload "D:\Projects\TestSTCard\TestST\bin\testST\javacard\testST.cap" => 80 E6 02 00 12 05 00 01 02 03 04 08 A0 00 00 00 ................ 03 00 00 00 00 00 00 00 ........ (2425 usec) <= 00 90 00 ... Status: No Error => 80 E8 00 00 FF C4 82 01 CA 01 00 16 DE CA FF ED ................ 02 02 04 00 01 05 00 01 02 03 04 06 74 65 73 74 ............test 53 54 02 00 21 00 16 00 21 00 0A 00 0B 00 3E 00 ST..!...!.....>. 0E 00 F3 00 0A 00 1A 00 00 00 8B 03 B2 00 00 00 ................ 00 00 00 01 01 00 04 00 0B 01 02 01 07 A0 00 00 ................ 00 62 01 01 03 00 0A 01 06 00 01 02 03 04 05 00 .b.............. 2C 06 00 0E 00 00 00 80 03 02 00 02 07 01 00 00 ,............... 00 3C 07 00 F3 00 05 40 18 8C 00 0E 18 10 64 90 .<.....@......d. 0B 87 01 18 10 64 90 0B 87 00 19 1E 25 61 08 18 .....d......%a.. 8B 00 0A 70 0D 18 19 1E 04 41 19 1E 25 8B 00 0C ...p.....A..%... 7A 05 30 8F 00 04 18 1D 04 41 18 1D 25 8C 00 06 z.0......A..%... 7A 02 22 18 8B 00 03 60 03 7A 19 8B 00 07 2D 1A z."....`.z....-. 03 25 32 1F 10 80 6A 08 11 6E 00 8D 00 09 1A 04 .%2...j..n...... 25 75 00 20 00 03 00 00 00 26 00 10 00 11 00 20 %u. .....&..... 00 18 18 19 8C 00 02 70 10 18 19 8C 00 0B 3B 70 .......p......;p 08 11 6D 00 8D 00 09 7A 05 23 19 8B 00 07 2D 19 ..m....z.#....-. 8B 00 08 5B 00 ...[. (5226 usec) <= 00 90 00 ... Status: No Error => 80 E8 80 01 CF 32 AD 01 03 1F 38 03 29 04 70 18 .....2....8.).p. AD 01 16 04 04 41 5B 1A 08 16 04 41 5B 25 38 16 .....A[....A[%8. 04 04 41 5B 29 04 16 04 1F 6C E7 7A 05 23 19 8B ..A[)....l.z.#.. 00 07 2D 1A 07 25 32 1F 61 08 11 62 00 8D 00 09 ..-..%2.a..b.... 19 8B 00 0D 3B 19 1F 8B 00 05 03 29 04 70 15 1A ....;......).p.. 16 04 AD 01 16 04 04 41 5B 25 38 16 04 04 41 5B .......A[%8...A[ 29 04 16 04 1F 6F EA 1A 77 08 00 0A 00 00 00 00 )....o..w....... 00 00 00 00 00 00 05 00 3E 00 0F 02 00 02 01 02 ........>....... 00 02 00 06 00 00 83 03 80 03 03 01 00 02 00 03 ................ 80 0A 09 06 00 00 01 03 80 0A 01 03 80 0A 06 06 ................ 80 07 01 03 80 03 01 06 00 00 B6 03 80 03 02 03 ................ 80 0A 07 06 80 03 00 09 00 1A 00 05 0D 07 7D 0A ..............}. 42 00 11 05 17 0D 06 0A 07 07 10 19 07 09 07 05 B............... 2E 0E 04 06 00 ..... (14567 usec) <= 00 90 00 ... Status: No Error Load report: 462 bytes loaded in 0.0 seconds effective code size on card: + package AID 5 + applet AIDs 13 + classes 17 + methods 246 + statics 0 + exports 0 ------------------------------ overall 281 bytes cm> install -i 000102030405 -q C9#() 0001020304 000102030405 => 80 E6 0C 00 1A 05 00 01 02 03 04 06 00 01 02 03 ................ 04 05 06 00 01 02 03 04 05 01 00 02 C9 00 00 00 ................ (3678 usec) <= 90 00 .. Status: No Error cm> card-info => 80 F2 80 00 02 4F 00 00 .....O.. (1561 usec) <= 08 A0 00 00 00 03 00 00 00 01 9E 90 00 ............. Status: No Error => 80 F2 40 00 02 4F 00 00 ..@..O.. (1335 usec) <= 06 00 01 02 03 04 05 07 00 90 00 ........... Status: No Error => 80 F2 10 00 02 4F 00 00 .....O.. (1806 usec) <= 07 A0 00 00 00 03 53 50 01 00 01 08 A0 00 00 00 ......SP........ 03 53 50 41 05 00 01 02 03 04 01 00 01 06 00 01 .SPA............ 02 03 04 05 90 00 ...... Status: No Error Card Manager AID : A000000003000000 Card Manager state : OP_READY Application: SELECTABLE (--------) 000102030405 Load File : LOADED (--------) A0000000035350 (Security Domain) Module : A000000003535041 Load File : LOADED (--------) 0001020304 Module : 000102030405{code} My test commands: {code}cm> init-update 255 => 80 50 00 00 08 4F B8 3E 1A 7A FC CF 1E 00 .P...O.>.z.... (4606 usec) <= 00 00 C6 D8 6A 1C B2 02 14 13 FF 02 00 01 26 F7 ....j.........&. 25 4D B0 B9 44 D6 8F 5E 7D 12 3B 9D 90 00 %M..D..^}.;... Status: No Error cm> ext-auth plain => 84 82 00 00 10 E6 62 48 6E 46 E1 41 2D F3 36 16 ......bHnF.A-.6. AA B5 A5 9B AF ..... (2903 usec) <= 90 00 .. Status: No Error cm> send 8010000003010203 => 80 10 00 00 03 01 02 03 ........ (13051 usec) <= 6D 00 m. Status: INS value not supported cm> send 80100003010203 => 80 10 00 03 01 02 03 ....... (1197 usec) <= 6D 00 m. Status: INS value not supported cm> 80200001 jcshell: No such command: 80200001 cm> send 80200001 jcshell: Error code: -3 (Invalid API parameter) jcshell: Command failed: APDU too short/long cm> send 802001 jcshell: Error code: -3 (Invalid API parameter) jcshell: Command failed: APDU too short/long cm> send 8020000001 => 80 20 00 00 01 . ... (1314 usec) <= 67 00 g. Status: Wrong length cm> send 8020000003 => 80 20 00 00 03 . ... (1438 usec) <= 67 00 g. Status: Wrong length cm> send 8020000008 => 80 20 00 00 08 . ... (1048 usec) <= 67 00 g. Status: Wrong length cm> send 80200003010203 => 80 20 00 03 01 02 03 . ..... (1168 usec) <= 6D 00 m. Status: INS value not supported cm> send 80200003 jcshell: Error code: -3 (Invalid API parameter) jcshell: Command failed: APDU too short/long cm> send 8020000064 => 80 20 00 00 64 . ..d (1628 usec) <= 67 00 g. Status: Wrong length cm> send 8010000300010203 jcshell: Error code: -3 (Invalid API parameter) jcshell: Command failed: LC and APDU data length inconsistent cm> send 80100003010203 => 80 10 00 03 01 02 03 ....... (18584 usec) <= 6D 00 m. Status: INS value not supported{code} Where am i wrong? Thanks in advance!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 24 2008
Added on Jul 9 2008
3 comments
540 views