|
||||||||||
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_modulus
public class Host_modulus
Host counterpart of Modulus
. Used to send and receive
objects of type Modulus
to and from the card. The
constructor conveniently computes auxiliary numbers from the pure
modulus that are needed on the card (Modulus.last_digit_inverse
) and on the host (mont_fac
,
demont_fac
).
This class can only be used for odd moduli, because it is designed to be used with Montgomery multiplication.
This class provides a BigInteger
interface to the outside.
When communicating with the card, conversion to and from Bignat
is done internally with the help of APDU_BigInteger
.
For checking compatibility
and sizes it is necessary to specify the size of the Bignat
inside the Modulus
on the card in advance. This size will
be called the configured size hereafter. The Modulus
must be less than 2^(bignat_size * 8)
.
This is a host data type. It is compatible with nothing. The card
data type Modulus
is compatible with this class.
For a number of general topics see also the package description.
Field Summary | |
---|---|
private APDU_short |
apdu_last_digit_inverse
APDU wrapper of type APDU_DOUBLE_DIGIT_TYPE for last_digit_inverse . |
private APDU_BigInteger |
apdu_m
APDU wrapper for the modulus m . |
int |
bignat_size
Configured Bignat size. |
BigInteger |
demont_fac
Demontgomerization factor. |
long |
last_digit_inverse
Negated modular inverse of the last digit of m . |
BigInteger |
m
Modulus. |
BigInteger |
mont_fac
Montgomerization factor. |
private APDU_Serializable[] |
serializable_array
Serializable array for the Serializable_array base
class. |
Constructor Summary | |
---|---|
Host_modulus(int bignat_size)
Constructor for receiving. |
|
Host_modulus(int bignat_size,
BigInteger m)
Constructor for sending. |
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 serializable_array in support for abstract
Serializable_array . |
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 int bignat_size
bignat_size
.
public BigInteger m
sending constructor
or after receipt.
public BigInteger mont_fac
sending constructor
.
To montgomerize a number x
on the host, compute
x.multiply(mod.mont_fac).mod(mod.m)
, where mod
is the Host_modulus.
public BigInteger demont_fac
sending constructor
.
To demontgomerize a number x
on the host, compute
x.multiply(mod.demont_fac).mod(mod.m)
, where mod
is the Host_modulus.
public long last_digit_inverse
m
. See Modulus.last_digit_inverse
. Initialized to the correct value
in the sending
constructor
. Left uninitialized by the receiving constructor
. Is set to the
received value after receipt.
private final APDU_BigInteger apdu_m
m
.
private final APDU_short apdu_last_digit_inverse
last_digit_inverse
.
private final APDU_Serializable[] serializable_array
Serializable_array
base
class. Will contain Modulus.serializable_contents_length
length elements, currently the modulus m
and apdu_last_digit_inverse
in this order. Must be compatible with
Modulus.serializable_contents
.
Constructor Detail |
---|
public Host_modulus(int bignat_size)
mont_fac
, demont_fac
and last_digit_inverse
. The two factors
remains invalid for ever, even after a complete receipt from
the card. Only the modulus m
and last_digit_inverse
will be initialized after
receipt.
Only a Modulus
of size bignat_size
is
compatible with an object created from this constructor.
bignat_size
- configured sizepublic Host_modulus(int bignat_size, BigInteger m)
Only a Modulus
of size bignat_size
is
compatible with an object created from this constructor.
bignat_size
- configured size in bytesm
- modulusMethod Detail |
---|
protected APDU_Serializable[] get_array()
serializable_array
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 set m
and last_digit_inverse
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 |