|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectds.ov2.util.Serializable_array
ds.ov2.bignat.Host_vector
public class Host_vector
Host counterpart of Vector
. Used to send and receive
vectors (i.e., arrays of Bignat
) to and from the card.
Contains convenience methods to set up arrays of montgomerized
numbers, to prepare the factors array needed for Vector.exponent_mod
and for creating arrays
with montgomery correction factors.
Provides a BigInteger
interface to the outside. Internally
APDU_BigInteger
is used for the conversion from BigInteger
to Bignat
.
Objects of this class only contain BigIntegers
,
which are variables sized. When sent to the card the numbers are
converted to Bignats
, which have a fixed size. The
conversion to Bignats can only succeed if all the BigIntegers fit
into the size of the Bignats. This size constraint is checked in
the compatibility
check and in APDU_BigInteger.to_byte_array
. But for these checks it is
necessary to specify the size of the Bignats on the card in advance
in bignat_size
arguments of the various constructors. This
size is called the configured size hereafter. The
BigIntegers that end up in the host vector must be less than 2^(bignat_size * 8)
.
Host data type. Compatible with nothing. Vector
is
compatible to this class if Bignat size and length match.
For a number of general topics see also the package description.
Field Summary | |
---|---|
BigInteger[] |
a
BigInteger contents. |
int |
bignat_size
Configured size (in bytes) of the numbers. |
private APDU_BigInteger[] |
sa
Array for the transmission to and from the card. |
Constructor Summary | |
---|---|
Host_vector(int bignat_size,
BigInteger[] args)
Constructor for sending. |
|
Host_vector(int bignat_size,
int length)
Constructor for receiving. |
Method Summary | |
---|---|
short |
from_byte_array(short len,
short this_index,
byte[] byte_array,
short byte_index)
Deserialization of this object for the OV-chip protocol layer. |
protected APDU_Serializable[] |
get_array()
Return the APDU_BigInteger array sa in support
for abstract Serializable_array . |
static Host_vector |
make_montgomerized_factors(int bignat_size,
BigInteger[] args,
Host_modulus mod)
Make montgomerized base factors for Vector.exponent_mod . |
static Host_vector |
make_montgomerized_vector(int bignat_size,
BigInteger[] args,
Host_modulus mod)
Constructor for sending montgomerized numbers to the card. |
static Host_vector |
make_montgomery_corrections(int bignat_size,
int len,
Host_modulus mod)
Make Montgomery corrections. |
Methods inherited from class ds.ov2.util.Serializable_array |
---|
get_length, is_compatible_with, size, to_byte_array |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface ds.ov2.util.APDU_Serializable |
---|
is_compatible_with, size, to_byte_array |
Field Detail |
---|
public final BigInteger[] a
public final int bignat_size
private final APDU_BigInteger[] sa
Constructor Detail |
---|
public Host_vector(int bignat_size, BigInteger[] args)
args
. The configured size of the numbers will be
bignat_size
. Only Vectors
with the same
length (the same number of elements) and where the elements
have size bignat_size
are compatible to the newly
created object.
The elements of args
must not be negative and they must
fit into bignat_size
bytes, i.e., be lesser than
2^(bignat_size * 8).
bignat_size
- configured maximal size of the numbers in bytesargs
- contentspublic Host_vector(int bignat_size, int length)
length
for receiving Bignats
of
size bignat_size
. After receiving the numbers are
available in the array a
.
bignat_size
- configured Bignat sizelength
- array sizeMethod Detail |
---|
public static Host_vector make_montgomerized_vector(int bignat_size, BigInteger[] args, Host_modulus mod)
args
and turns them into a Host_vector
of configured size bignat_size
.
This is a static method, because of the stupid restriction that a call to a different constructor must be the first statement.
bignat_size
- configured maximal size of the numbers in
bytesargs
- not yet montgomerized numbersmod
- modulus
args
and configured size bignat_size
public static Host_vector make_montgomerized_factors(int bignat_size, BigInteger[] args, Host_modulus mod)
Vector.exponent_mod
. Computes all productes of numbers in args
and returns them in montgomerized
form in a Host_vector of size 2^args.length -1
(the
empty product is excluded). The products are ordered as
described for Vector.exponent_mod
.
The returned Host_vector has configured size bignat_size
.
This is a static method for the same stupid reason as make_montgomerized_vector(int, java.math.BigInteger[], ds.ov2.bignat.Host_modulus)
.
bignat_size
- configured maximal sizeargs
- base array to compute the factors formod
- modulus
Vector.exponent_mod
public static Host_vector make_montgomery_corrections(int bignat_size, int len, Host_modulus mod)
len
Montgomery corrections, that is with
mod.mont_fac^1 mod.mont_fac^2 mod.mont_fac^3 ....Everything modulo
mod.m
of course.
This is a static method for the same stupid reason as make_montgomerized_vector(int, java.math.BigInteger[], ds.ov2.bignat.Host_modulus)
.
bignat_size
- configured size of the returned Host_vector.len
- length of the returned Host_vectormod
- modulus
len
montgomery
corrections.protected APDU_Serializable[] get_array()
APDU_BigInteger
array sa
in support
for abstract Serializable_array
.
get_array
in class Serializable_array
public short from_byte_array(short len, short this_index, byte[] byte_array, short byte_index)
APDU_Serializable.from_byte_array
.
Overridden here to initialize the array a
after
receipt.
from_byte_array
in interface APDU_Serializable
from_byte_array
in class Serializable_array
len
- available data in byte_array
this_index
- number of bytes that
have already been read in preceeding callsbyte_array
- data array to deserialize frombyte_index
- index in byte_array
len
bytes, in this case len + 1
is
returned.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |