|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectds.ov2.bignat.Resize
public class Resize
Centralized resizing of Bignats
, Bignat arrays
and RSA exponents
. The whole
resising functionality is meant for test frames only, see the general explanations for
resizing. Although on the card all arrays are allocated just
once, the three named data types have an optional interface for
virtual size and length changes. The interface is optional, because
it is only available when VARIABLE_SIZE_BIGNATS
is defined. The
length and size changes are only virtual, because the underlying
arrays do not change and resizing does therefore not cost any
memory. An exception is the resizing functionality of RSA_exponent
. There, with every init_key
operation, a new RSA key is created and probably some
memory lost.
This class offers the possibility for registering objects of the three named types for performing centralized resizing operations. One problem thereby is that because of the lack of an garbage collector the java card environment does not really provide the possibility of arrays that grow in size according to demand. Therefore, and for simplicity, the internal arrays that hold the registered objects are allocated just once, with a hardwired size. If one of the arrays turns out to be too small an assertion will fail.
Objects must be registered according to their type of course.
Bignats
can be registered as long, as short, or as
double-sized Bignats. Thereby, long, short and double-sized have no
particular meaning. It is only that the resize operation resize_bignats
takes three size arguments for
Bignats, one for the long ones, one for the short ones, and one for
the double-sized ones. The RSA exponents
are
neither long nor small for these purposes. They get their own
cipher_len
argument.
(The distinction in long and short comes from the OV-Chip 2.0
context. There bases are 1000-2000 bits long and exponents 150-200
bits. For multiplication of exponent (attribute) values also one
double-sized Bignat twice as long as the exponents are needed. The
RSA_exponent
even requires that the ``long'' bases are
longer than the ``short'' exponents.)
Their are two kinds of arrays distinguished here. The first kind
are the arrays of bases and exponents, that all have the same size,
around 2-15 elements. The second kind are the arrays of precomputed
base factors (see Vector.exponent_mod
) that grow
exponentially with the length of the bases. Therefore arrays can be
registered as either vectors (the first kind) or factor arrays (the
second kind). The length changing operation, resize_vectors
takes two length arguments and treats these two
kinds of arrays separately.
Types that wrap one or several Bignats typically offer some
register method, that registers all contained objects here, see for
instance Bignat_array.register_long_bignats()
, Bignat_array.register_short_bignats()
and Modulus.register_long_bignats()
.
This is a static class. All fields and methods are static, object
creation is disabled. The class must be initialized with init()
before using it.
For a number of general topics see also the package description.
Field Summary | |
---|---|
private static short |
double_bignat_index
Current index in the double_bignats array. |
private static Bignat[] |
double_bignats
Array of registered double-sized bignats. |
private static short |
factor_index
Current index in the factors array. |
private static Vector[] |
factors
Array of registered factor arrays. |
private static short |
long_bignat_index
Current index in the long_bignats array. |
private static Bignat[] |
long_bignats
Array of registered long bignats. |
private static RSA_exponent[] |
long_rsa
Array of registered RSA exponents. |
private static short |
long_rsa_index
Current index in the long_rsa array. |
private static short |
max_double_bignats
Maximal number of double-sized bignats, currently 1. |
private static short |
max_factors
Maximal number of factor arrays, currently 1. |
private static short |
max_long_bignats
Maximal number of long bignats, currently 50. |
private static short |
max_long_rsa
Maximal number of RSA exponents, currently 2. |
private static short |
max_short_bignats
Maximal number of short bignats, currently 7. |
private static short |
max_vectors
Maximal number of vectors, currently 2. |
private static short |
short_bignat_index
Current index in the short_bignats array. |
private static Bignat[] |
short_bignats
Array of registered short bignats. |
private static short |
vector_index
Current index in the vectors array. |
private static Vector[] |
vectors
Array of registered vectors. |
Constructor Summary | |
---|---|
protected |
Resize()
Static class, object creation disabled. |
Method Summary | |
---|---|
static void |
init()
Initializes all the arrays to their hardwired maximal size. |
static void |
register_double_bignat(Bignat b)
Register the double-sized bignat b . |
static void |
register_factor(Vector v)
Register the factor array v . |
static void |
register_long_bignat(Bignat b)
Register the long bignat b . |
static void |
register_long_rsa(RSA_exponent e)
Register the RSA exponent e . |
static void |
register_short_bignat(Bignat b)
Register the short bignat b . |
static void |
register_vector(Vector v)
Register the vector v . |
static void |
resize_bignats(short short_len,
short long_len,
short double_len,
short cipher_len)
Resize bignats and RSA exponents. |
static void |
resize_vectors(short vector_len,
short factors_len)
Resize arrays. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final short max_short_bignats
private static final short max_long_bignats
private static final short max_double_bignats
private static final short max_vectors
private static final short max_factors
private static final short max_long_rsa
private static Bignat[] short_bignats
private static Bignat[] long_bignats
private static Bignat[] double_bignats
private static Vector[] vectors
private static Vector[] factors
private static RSA_exponent[] long_rsa
RSA_exponent
does only exist there.
private static short short_bignat_index
short_bignats
array.
private static short long_bignat_index
long_bignats
array.
private static short double_bignat_index
double_bignats
array.
private static short vector_index
vectors
array.
private static short factor_index
factors
array.
private static short long_rsa_index
long_rsa
array.
Constructor Detail |
---|
protected Resize()
Method Detail |
---|
public static void init()
public static void register_short_bignat(Bignat b)
b
.
Asserts that the arrays have been allocated and that there is still space in the array for short bignats.
b
- bignat to registerpublic static void register_long_bignat(Bignat b)
b
.
Asserts that the arrays have been allocated and that there is still space in the array for long bignats.
b
- bignat to registerpublic static void register_double_bignat(Bignat b)
b
.
Asserts that the arrays have been allocated and that there is still space in the array for double-sized bignats.
b
- bignat to registerpublic static void register_vector(Vector v)
v
.
Asserts that the arrays have been allocated and that there is still space in the array for vectors.
v
- vector to registerpublic static void register_factor(Vector v)
v
.
Asserts that the arrays have been allocated and that there is still space in the array for factor arrays.
v
- vector of factors to registerpublic static void register_long_rsa(RSA_exponent e)
e
.
Asserts that the arrays have been allocated and that there is still space in the array for RSA exponents.
This method is only available if JAVACARD_APPLET is defined,
because RSA_exponent
is only available there.
e
- RSA exponent to registerpublic static void resize_bignats(short short_len, short long_len, short double_len, short cipher_len)
Bignat.resize
is called. On the RSA exponents RSA_exponent.init_key
is called.
If cipher_len
is 0 the RSA exponent size change is
skipped.
short_len
- new size for the short bignatslong_len
- new size for the long bignatscipher_len
- new size for the RSA exponentspublic static void resize_vectors(short vector_len, short factors_len)
Vector.set_length
method on them. Because the factor array
will always store all possible products of some number of
factors, its size will always be equal to 2^n - 1
,
where n is the number of factors (the -1
is there
because the array does not contain the empty product, see
Vector.exponent_mod
). The factors_len
argument gets the n
rather than the real
factor array size.
vector_len
- new length for the (normal) vectorsfactors_len
- base 2 log of the new length for the factor
arrays, i.e., if the factor array stores the products of 4
factors, its length would be 15 and factors_len
would
be 4.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |