In order to thank you for all members' support of our website, we are holding new events - Getting Free Samples by Paying Freight only.
Want to get free samples? Please check this post for more details.

javacard ndef applet

Collect and collate various open source JavaCard applets.
All applets are under the open source licenses.

Moderator: Ellisun

shimizus3106
Posts: 19
Joined: Thu Oct 06, 2016 10:05 pm
Points :226
Contact:

Re: javacard ndef applet

Post by shimizus3106 » Tue Oct 18, 2016 4:40 am

Hello.

Thanks to your confirmation.

Please let me ask about cap file size.

Depending on Javacard kit, the cap file size is different.
JavaCard Kit 304 - 18KB
222 - 9KB
wiht JCIDE.

Could you let me know how to build JavaCard Kit 212/221 beause I may have resoucue limitation ?

Regards,
Shige

User avatar
mabel
Posts: 228
Joined: Mon May 18, 2015 3:09 am
Points :1623
Contact:

Re: javacard ndef applet

Post by mabel » Tue Oct 18, 2016 6:13 am

In JCIDE, from the menu, select " Build-> Property ", a dialog box "Property Sheet" will pop up. Click "Local JCKit Configuration" in the side bar, and unfold "JCKit Option" and for first item "Java Card kit version", select java_card_kit version from dropdown list.

You do not have the required permissions to view the files attached to this post. Please login first.

User avatar
mabel
Posts: 228
Joined: Mon May 18, 2015 3:09 am
Points :1623
Contact:

Re: javacard ndef applet

Post by mabel » Tue Oct 18, 2016 6:20 am

Compare JC222 with JC304:



Label 1 and 2: The size of CAP component in CAP file is same.
Label 3: CAP file of JC304 has one more file - APPLET-INF than JC222.

So we can get that the content size uploaded to card of JC222 CAP file is the same with the size of JC304 CAP file.
You do not have the required permissions to view the files attached to this post. Please login first.

shimizus3106
Posts: 19
Joined: Thu Oct 06, 2016 10:05 pm
Points :226
Contact:

Re: javacard ndef applet

Post by shimizus3106 » Wed Oct 19, 2016 12:42 am

Hello.

Please see the attached image.

SELECT command is no problem.

>> /send 00a4040007D2760000850101
>> 00 A4 04 00 07 D2 76 00 00 85 01 01
<< 90 00

But, please see the next command

>> /send 00a4000c02e103
>> 00 A4 00 0C 02 E1 03

and see the buffer from apdu.getBuffer(),

buffer[0] = 0x00
buffer[1] = 0xA4
buffer[2] = 0x00
buffer[3] = 0x0C
buffer[4] = 0x02
buffer[5] = 0x00 <------- Why ??
buffer[6] = 0x00 <------- Why ??
.....

As a result, cannot get fileId and reply 6A82 = SW_FILE_NOT_FOUND.

This result of simulator is same as applet on my RealCard.

Please let me know the reason..

Regards,
Shige
You do not have the required permissions to view the files attached to this post. Please login first.

User avatar
mabel
Posts: 228
Joined: Mon May 18, 2015 3:09 am
Points :1623
Contact:

Re: javacard ndef applet

Post by mabel » Wed Oct 19, 2016 2:54 am

If you use T=0 protocol, you need to add apdu.setIncomingAndReceive() in your code.
"This method gets as many bytes as will fit without buffer overflow in the APDU buffer following the header. It gets all the incoming bytes if they fit."

Code: Select all

private void processSelect(APDU apdu) throws ISOException {
        byte[] buffer = apdu.getBuffer();
        apdu.setIncomingAndReceive(); //Add this command
        byte p1 = buffer[ISO7816.OFFSET_P1];
        byte p2 = buffer[ISO7816.OFFSET_P2];
        byte lc = buffer[ISO7816.OFFSET_LC];

        // we only support what the NDEF spec prescribes
        if(p1 != SELECT_P1_BY_FILEID) {
            ISOException.throwIt(ISO7816.SW_FUNC_NOT_SUPPORTED);
        }
        if(p2 != SELECT_P2_FIRST_OR_ONLY) {
            ISOException.throwIt(ISO7816.SW_FUNC_NOT_SUPPORTED);
        }

        // check length, must be for a file ID
        if(lc != 2) {
            ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
        }

        // retrieve the file ID
        short fileId = Util.getShort(buffer, ISO7816.OFFSET_CDATA);

        // perform selection if the ID is valid
        switch(fileId) {
            case FILEID_NDEF_CAPABILITIES:
            case FILEID_NDEF_DATA:
                selectedFile = fileId;
                break;
            default:
                ISOException.throwIt(ISO7816.SW_FILE_NOT_FOUND);
        }
    }


shimizus3106
Posts: 19
Joined: Thu Oct 06, 2016 10:05 pm
Points :226
Contact:

Re: javacard ndef applet

Post by shimizus3106 » Wed Oct 19, 2016 3:23 am

Hello.

Yes! applet start to work on real card, thanks!!

But I have another problem about tool - APDU - differnece between pyApdutool (Success) and GP tool (Error).

I will create new topic in appropriate room.

I really appreciate your kind advice and help.

Regards,
Shige

User avatar
mabel
Posts: 228
Joined: Mon May 18, 2015 3:09 am
Points :1623
Contact:

Re: javacard ndef applet

Post by mabel » Wed Oct 19, 2016 5:38 am

Not at all.

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 1 guest

JavaCard OS : Disclaimer