0

I'm experimenting with applet for JavaCard - it's very simple SCWS serverlet(basically template from Gemalto Dev Suite). I want it to store some data on card - how to do it? I found only some theoretical materials about linear and cyclical files.

//EDIT

I managed to find something like this:

private byte createfile()
    {
        try{
            AdminFileView uiccAdminFileView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET);
            if(uiccAdminFileView == null){
                return 'a';
            }
            uiccAdminFileView.select((short)0x7F60);
            EditHandler editHandler = (EditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER,
                    (short) 50);
            editHandler.clear();
            editHandler.appendArray(CreateEF, (short) 0,(short) CreateEF.length);
            uiccAdminFileView.createFile(editHandler);
            data[0] = (byte) 0x12;
            data[1] = (byte) 0x34;
            data[2] = (byte) 0x56;
            uiccAdminFileView.select((short)0xEE00);
            uiccAdminFileView.updateBinary((short) 0, data, (short)0, (short)3);
        } catch(UICCException e){

            return (byte)e.getReason();
        }
        return 'b';
    }

But at this point it returns "a" every time - as far as I know it has something to do with access rights for applet.

DzikiMarian
  • 423
  • 3
  • 14

3 Answers3

1

Once there was an ISO 7816-4 file based API in Java Card, but that has been sunk a long long time ago. Now you just have to program it yourself. You need at least the ISO 7816-4 (2005) standard handy to make anything remotely compatible with file based cards.

The real "fun" starts when you have to send file data from an offset of over 32K over a secure messaging channel while keeping an eye on file selection and access rights. For anybody reading the answer to this old question: good luck - and know it can be done.

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
  • _The real "fun" starts when you have ...._ Why? Excuse me, I didn't understand your answer. Would you please explain it more please? – Ebrahim Ghasemi Apr 10 '15 at 14:39
  • Doesn't we have ISO 7816 API on JavaCards now? – Ebrahim Ghasemi Apr 10 '15 at 14:39
  • 1
    ISO 7816 contains a lot of things, but if you mean a file system API then no. That's why it is *fun* to get things like that working. – Maarten Bodewes Apr 10 '15 at 21:09
  • @MaartenBodewes why didn't you just get share the source code that handles that thing? So, you know that the issue to develop this function exists, you developed the working code(_I guess_) and you didn't share it in any way - is this correct? Please, post the solution or even some clues of how to resolve the question, in case you've _really_ solved this yourself. – im_infamous Jan 13 '16 at 21:43
  • @im_infamous I've not implemented it for myself, im. Not for sharing - sorry. – Maarten Bodewes Jan 13 '16 at 22:58
  • @MaartenBodewes ok, I got It, but can you post some key points for me and community or at leas verify algorithm that is written here? http://stackoverflow.com/a/20779657/3441253 – im_infamous Jan 13 '16 at 23:04
0

For a "real" smart card, you create/edit/delete data either via something standard called APDU command. For this to work, there must be an OS installed on the card capable of handling the APDU to create/update/read files, etc. If the card is totally virgin (i.e. it has really nothing inside), you have to use the card's API or read the spec and do everything yourself (very likely you'll deal with assembly). I don't know what your card is so I can't give specific instructions, read your manual.

LeleDumbo
  • 9,192
  • 4
  • 24
  • 38
  • Currently I'm working on simulator from Gemalto package. It simulates whole chain in 3G mobile network, with USIM card labeled as "NFC with standarized SCWS" it normally works in cell phone simulator so I assume its not completly clear. I'll check if I can find more about it. – DzikiMarian Nov 10 '11 at 16:52
0

It seems that your issue is answered here: http://developer.gemalto.com/nc/forums.html?view=single_thread&cat_uid=3&conf_uid=2&thread_uid=154

dim
  • 1,697
  • 2
  • 13
  • 21
  • Thanks, but I've seen it. First line of code I'm using(It has been found at gemalto forum too) is virtually identical - problem is it returns null every time and I cannot create instance of AdminFileView. – DzikiMarian Mar 22 '12 at 20:41