kamal kumar schrieb:
Hi,
I am trying to find the size needs during
instantiation to manage allocation.
I took this sample from javacard toolkit. Can you
please tell me how to calculate the size needed during
instantiation to manage allocation in
the below sample.
Count the used bytes and estimate the internal usage of the used
objects. This is quite coarse. You can try to limit the size further by
trial and error. I f want to know it exactly you have to study your
compiled class and read the Java Card specification what it says.
Regards,
Karsten
========================================================================================================================================================
public class Wallet extends javacard.framework.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 Deposit = (byte) 0x10;
final static byte Debit = (byte) 0x20;
final static byte Balance = (byte) 0x30;
final static byte Validate = (byte) 0x40;
final static byte Encrypt = (byte) 0x50;
final static byte PinChange = (byte) 0x60;
// maximum number of incorrect tries before the PIN
is blocked
final static byte PinTryLimit =(byte)0x03;
// maximum size PIN
final static byte MaxPinSize =(byte)0x04;
// status word (SW1-SW2) to signal that the balance
becomes negative;
final static short SW_NEGATIVE_BALANCE = (short)
0x6910;
final static short SW_WRONG_PIN = (short) 0x6300;
/* instance variables declaration */
OwnerPIN pin;
static byte base_balance = (byte) 0x20;
byte balance;
DESKey key;
Signature signature;
private Wallet(byte buffer[],short offset,byte
length) {
// It is good programming practice to allocate
// all the memory that an applet needs during its
// lifetime inside the constructor
pin = new OwnerPIN(PinTryLimit, MaxPinSize);
balance = (byte) 0;
key =
(DESKey)KeyBuilder.buildKey(KeyBuilder.TYPE_DES_TRANSIENT_RESET,KeyBuilder.LENGTH_DES,false);
signature =
Signature.getInstance(Signature.ALG_DES_MAC8_ISO9797_M1,false);
signature.init(key,Signature.MODE_SIGN);
if (buffer[offset] == (byte)0) {
register();
}
else {
register(buffer, (short)(offset+1)
,(byte)(buffer[offset]));
}
} // end of the constructor
============================================================================
Regards,
Kamal.
--- sferey <[EMAIL PROTECTED]> wrote:
kamal kumar a écrit :
HI all,
I don't know whether it is right forum to ask.
you can try here or at alt.technology.smartcards
newgroup.
I am new to java card applet development. I have
written one sample applet. and loaded the applet
using
sclumberger toolkit. But while installing the
applet I
am facing problem. I need to tell the applet size
required for install. I don't know how to find the
required size required for the installation.
option 1: bad card domain, change card domain (or
card).
the CAP file's size should be used if:
- "installing" means "loading the CAP file" and
- "applet size" means "size need to store that
library".
(if so, the card is quite stupid, since this
information
is usually in the first 256 bytes of the CAP file)
option 2: card domain with memory allocation
controls
OOH, if
- "installing" means "instantiating the applet" or
- "applet size" means "size needs during
instantiation
to manage allocation in its constructor", the
response
is up to you and only defined by what you have
insert
in your applet constructor.
(of course if instance, array, ..., instantiation
is
also required during the applet's life you want
take
such figures into account when computing that
"needed
size").
and such information makes sense for a card domain.
Sylvain.
_______________________________________________
Muscle mailing list
[email protected]
http://lists.drizzle.com/mailman/listinfo/muscle
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
_______________________________________________
Muscle mailing list
[email protected]
http://lists.drizzle.com/mailman/listinfo/muscle
_______________________________________________
Muscle mailing list
[email protected]
http://lists.drizzle.com/mailman/listinfo/muscle