Page 2 of 2

Re: javacard ndef applet

Posted: Tue Oct 18, 2016 4:40 am
by shimizus3106
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

Re: javacard ndef applet

Posted: Tue Oct 18, 2016 6:13 am
by mabel
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.


Re: javacard ndef applet

Posted: Tue Oct 18, 2016 6:20 am
by mabel
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.

Re: javacard ndef applet

Posted: Wed Oct 19, 2016 12:42 am
by shimizus3106
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

Re: javacard ndef applet

Posted: Wed Oct 19, 2016 2:54 am
by mabel
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);
        }
    }


Re: javacard ndef applet

Posted: Wed Oct 19, 2016 3:23 am
by shimizus3106
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

Re: javacard ndef applet

Posted: Wed Oct 19, 2016 5:38 am
by mabel
Not at all.

Re: javacard ndef applet

Posted: Mon Dec 17, 2018 7:10 am
by sdellava
Hi,

I've a similar error but the card is this one: https://www.javacardos.com/store/products/10002

It should be compliant with the NDEF.

Any suggestion ?

Re: javacard ndef applet

Posted: Wed Dec 19, 2018 11:58 am
by sdellava
Solved. The problem was the wrong AID.

But I need support on a different point: how to install the STUB version on a javacard?

I suppose I've to create two applet, one is the NDEF Stub and the second is my applet. But how my applet can call the STUB ?

In addition, the STUP version has two java file. How I have to manage the second (the service)?

Thanks, Stefao