Our Online Store have the new products: RFID antenna board. Currently it can work with JC10M24R and JCOP4 card chips.
Compared with normal cards, the antenna board module has a smaller size and fixed holes, which is easy to integrate in the IOT(Internet Of Things) project.

wallet applet: how does the pin work ?

JavaCard Applet Development Related Questions and Answers.
KevinAli
Posts: 24
Joined: Fri Aug 21, 2015 3:38 am
Points :104
Contact:

wallet applet: how does the pin work ?

Post by KevinAli » Tue Aug 25, 2015 10:41 pm

The code below is part of wallet sample applet.

Code: Select all

package com.sun.javacard.samples.wallet;
import javacard.framework.*;

public class Wallet extends Applet {

    /* constants declaration */
   
    // code of CLA byte in the command APDU header
    final static byte Wallet_CLA =(byte)0x80;
   
    // codes of INS byte in the command APDU header
    final static byte VERIFY = (byte) 0x20;
    final static byte CREDIT = (byte) 0x30;
    final static byte DEBIT = (byte) 0x40;
    final static byte GET_BALANCE = (byte) 0x50;
   
    // maximum balance
    final static short MAX_BALANCE = 0x7FFF;
    // maximum transaction amount
    final static byte MAX_TRANSACTION_AMOUNT = 127;
   
    // maximum number of incorrect tries before the
    // PIN is blocked
    final static byte PIN_TRY_LIMIT =(byte)0x03;
    // maximum size PIN
    final static byte MAX_PIN_SIZE =(byte)0x08;
   
    // signal that the PIN verification failed
    final static short SW_VERIFICATION_FAILED =
    0x6300;
    // signal the the PIN validation is required
    // for a credit or a debit transaction
    final static short SW_PIN_VERIFICATION_REQUIRED =
                                            0x6301;
    // signal invalid transaction amount
    // amount > MAX_TRANSACTION_AMOUNT or amount < 0
    final static short SW_INVALID_TRANSACTION_AMOUNT = 0x6A83;
   
    // signal that the balance exceed the maximum
    final static short SW_EXCEED_MAXIMUM_BALANCE = 0x6A84;
    // signal the the balance becomes negative
    final static short SW_NEGATIVE_BALANCE = 0x6A85;
   
    /* instance variables declaration */
    OwnerPIN pin;
    short balance;
   
    private Wallet (byte[] bArray,short bOffset,byte bLength) {
     
        // It is good programming practice to allocate
        // all the memory that an applet needs during
        // its lifetime inside the constructor
        pin = new OwnerPIN(PIN_TRY_LIMIT,   MAX_PIN_SIZE);
       
        byte iLen = bArray[bOffset]; // aid length
        bOffset = (short) (bOffset+iLen+1);
        byte cLen = bArray[bOffset]; // info length
        bOffset = (short) (bOffset+cLen+1);
        byte aLen = bArray[bOffset]; // applet data length
       
        // The installation parameters contain the PIN
        // initialization value
        pin.update(bArray, (short)(bOffset+1), aLen);
        register();
   
    } // end of the constructor
   
    public static void install(byte[] bArray, short bOffset, byte bLength) {
        // create a Wallet applet instance
        new Wallet(bArray, bOffset, bLength);
    } // end of install method
   
    public boolean select() {
       
        // The applet declines to be selected
        // if the pin is blocked.
        if ( pin.getTriesRemaining() == 0 )
           return false;
       
        return true;
       
    }// end of select method
   
    public void deselect() {
       
        // reset the pin value
        pin.reset();
       
    }


I have doubts about how the pin works. When and where do you set the pin?
Any answer is appreciated.

User avatar
Tolice
Posts: 40
Joined: Wed May 20, 2015 2:41 am
Points :254
Contact:

Re: wallet applet: how does the pin work ?

Post by Tolice » Tue Nov 03, 2015 9:01 am

The PIN is using in this function: private Wallet (byte[] bArray,short bOffset,byte bLength), and it is incoming through the installation parameters.

User avatar
UNKNwYSHSA
Posts: 630
Joined: Thu May 21, 2015 4:05 am
Points :3053
Contact:

Re: wallet applet: how does the pin work ?

Post by UNKNwYSHSA » Thu Nov 12, 2015 10:46 pm

1 You can debug the install process using a debugger (JCOP or JCIDE), debug each step, and look the data you passed as applet install parameter is correct or not;
2 The applet install parameters shall be formatted as the GP specification says.
You do not have the required permissions to view the files attached to this post. Please login first.
sense and simplicity

amrsalah
Posts: 5
Joined: Thu Dec 03, 2015 3:01 pm
Points :54
Contact:

Re: wallet applet: how does the pin work ?

Post by amrsalah » Sat Dec 05, 2015 10:50 am

Hi UNKNwYSHSA, Can you refer to me the link that I can download the document which describe the INSTALL Command Data Field, Thanks.

User avatar
UNKNwYSHSA
Posts: 630
Joined: Thu May 21, 2015 4:05 am
Points :3053
Contact:

Re: wallet applet: how does the pin work ?

Post by UNKNwYSHSA » Sun Dec 06, 2015 10:45 pm

Here's links for v2.2 and v2.1.1, i found from google.
http://www.win.tue.nl/pinpasjc/docs/GPCardSpec_v2.2.pdf
http://www.win.tue.nl/pinpasjc/docs/Car ... 0v0303.pdf

You can find the description of install command by search keyword "install command".
sense and simplicity

amrsalah
Posts: 5
Joined: Thu Dec 03, 2015 3:01 pm
Points :54
Contact:

Re: wallet applet: how does the pin work ?

Post by amrsalah » Thu Dec 10, 2015 6:17 pm

Thanks for your kind Support!

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 62 guests

JavaCard OS : Disclaimer