|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectds.ov2.util.Misc
public class Misc
Collection of miscellaneous methods that do not fit anywhere else, most of them abstracting from differences between standard Java and Java Card.
Static class.
| Constructor Summary | |
|---|---|
protected |
Misc()
Static class, object creation disabled. |
| Method Summary | |
|---|---|
static byte[] |
allocate_transient_byte_array(short size)
Portable RAM allocation. |
static void |
array_copy(byte[] src,
short src_off,
byte[] dest,
short dest_off,
short len)
Portable array copy. |
static void |
begin_transaction()
Portable transaction start call. |
static void |
commit_transaction()
Portable transaction end call. |
static MessageDigest |
get_message_digest()
Portable way of creating a portable message digest instance computing SHA 160 bit digests. |
static RandomData |
get_new_rand()
Portable way to get an instance of a random number generator. |
static short |
length_of_serializable_array(APDU_Serializable[] a)
Total size of an APDU_Serializable array. |
static void |
myassert(boolean condition,
short tag)
Implementation of the ASSERT and ASSERT_TAG macros. |
static void |
rand_data_int(RandomData rand,
int[] ba,
short start,
int len)
Fill an integer array with random data. |
static void |
rand_data(RandomData rand,
byte[] ba,
short start,
short len)
Portable way to fill a byte array with random data. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected Misc()
| Method Detail |
|---|
public static void myassert(boolean condition,
short tag)
condition is false.
On the card (if JAVACARD_APPLET
is defined) this is done by throwing an ISOException
with status Response_status.OV_ASSERTION_00, where
tag is or-ed into the lower 8 bits of the response
status. On the host (if JAVACARD_APPLET
is undefined) it does simply assert false.
A list with all currently used assert tag is contained in the
overview page.
condition - abort computation if condition is falsetag - 1-byte tag providing additional information about
the assertion
ISOException - with Response_status.OV_ASSERTION_00 on the card, if the
condition is false
AssertionError - on the host, if the condition is false
public static final void array_copy(byte[] src,
short src_off,
byte[] dest,
short dest_off,
short len)
Behaves either like
arrayCopyNonAtomic
or System.arraycopy depending on
whether JAVACARD_APPLET
is defined.
src - the source arraysrc_off - starting position in the source arraydest - the destination arraydest_off - starting position in the destination arraylen - the number of elements to be copied
public static byte[] allocate_transient_byte_array(short size)
size - length of the byte array
JCSystem.makeTransientByteArraypublic static short length_of_serializable_array(APDU_Serializable[] a)
APDU_Serializable array.
a - the array, might be a null reference
a
NullPointerException - if one of the elements in a is nullpublic static RandomData get_new_rand()
RandomData.getInstance(RandomData.ALG_SECURE_RANDOM) on the card (if JAVACARD_APPLET
is defined) and new Random on the host
(if JAVACARD_APPLET
is undefined).
The return type is RANDOM, which
expands to RandomData on the card and Random on the host.
public static void rand_data(RandomData rand,
byte[] ba,
short start,
short len)
generateData on the card (if JAVACARD_APPLET
is defined) and nextBytes on
the host (if JAVACARD_APPLET
is undefined).
rand - the random number instance of type RANDOMba - the byte array to fill with random datastart - starting index in balen - number of random bytes to store in ba
starting at start
public static void rand_data_int(RandomData rand,
int[] ba,
short start,
int len)
rand_data but for an integer array.
Only available if JAVACARD_APPLET
is undefined (there are no ints on Java Card anyway).
rand - the random number instance of type RANDOMba - the int array to fill with random datastart - starting index in balen - number of random ints to store in ba
starting at start
public static MessageDigest get_message_digest()
MessageDigest.getInstance(MessageDigest.ALG_SHA) on the card
(if JAVACARD_APPLET
is defined) and new Message_digest_wrapper
on the host (if JAVACARD_APPLET
is undefined).
Only available if MESSAGE_DIGEST
is defined to avoid needing Message_digest_wrapper
in all host side programs.
MessageDigest on the card and
Message_digest_wrapper on the host.public static void begin_transaction()
JCSystem.beginTransaction() on the card (if JAVACARD_APPLET
is defined) and nothing on the host (if JAVACARD_APPLET
is undefined). So on the host no transaction is
started. Needed for the APPLET_TESTFRAME.
public static void commit_transaction()
JCSystem.commitTransaction() on the card (if JAVACARD_APPLET
is defined) and nothing on the host (if JAVACARD_APPLET
is undefined). So on the host no transaction is
done. Needed for the APPLET_TESTFRAME.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||