|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javacard.security.Signature com.licel.jcardsim.crypto.SymmetricSignatureImpl
public class SymmetricSignatureImpl
Implementation Signature
with symmetric keys based
on BouncyCastle CryptoAPI
Signature
Field Summary |
---|
Constructor Summary | |
---|---|
SymmetricSignatureImpl(byte algorithm)
|
Method Summary | |
---|---|
byte |
getAlgorithm()
Gets the Signature algorithm. |
short |
getLength()
Returns the byte length of the signature data. |
void |
init(Key theKey,
byte theMode)
Initializes the Signature object with the appropriate Key . |
void |
init(Key theKey,
byte theMode,
byte[] bArray,
short bOff,
short bLen)
Initializes the Signature object with the appropriate Key and algorithm specific
parameters. |
short |
sign(byte[] inBuff,
short inOffset,
short inLength,
byte[] sigBuff,
short sigOffset)
Generates the signature of all/last input data. |
void |
update(byte[] inBuff,
short inOffset,
short inLength)
Accumulates a signature of the input data. |
boolean |
verify(byte[] inBuff,
short inOffset,
short inLength,
byte[] sigBuff,
short sigOffset,
short sigLength)
Verifies the signature of all/last input data against the passed in signature. |
Methods inherited from class javacard.security.Signature |
---|
getInstance |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SymmetricSignatureImpl(byte algorithm)
Method Detail |
---|
public void init(Key theKey, byte theMode) throws CryptoException
Signature
Signature
object with the appropriate Key
.
This method should be used
for algorithms which do not need initialization parameters or use default parameter
values.
init()
must be used to update the Signature
object with a new key.
If the Key
object is modified after invoking the init()
method,
the behavior of the update()
, sign()
, and verify()
methods is unspecified.
Note:
theKey
- the key object to use for signing or verifyingtheMode
- one of MODE_SIGN
or MODE_VERIFY
CryptoException
- with the following reason codes:CryptoException.ILLEGAL_VALUE
if theMode
option is an undefined value or
if the Key
is inconsistent with theMode
or with the Signature
implementation.
CryptoException.UNINITIALIZED_KEY
if theKey
instance is uninitialized.
public void init(Key theKey, byte theMode, byte[] bArray, short bOff, short bLen) throws CryptoException
Signature
Signature
object with the appropriate Key
and algorithm specific
parameters.
init()
must be used to update the Signature
object with a new key.
If the Key
object is modified after invoking the init()
method,
the behavior of the update()
, sign()
, and verify()
methods is unspecified.
Note:
bArray
.
bArray
.
CryptoException.ILLEGAL_VALUE
.
theKey
- the key object to use for signingtheMode
- one of MODE_SIGN
or MODE_VERIFY
bArray
- byte array containing algorithm specific initialization informationbOff
- offset within bArray
where the algorithm specific data beginsbLen
- byte length of algorithm specific parameter data
CryptoException
- with the following reason codes:CryptoException.ILLEGAL_VALUE
if theMode
option is an undefined value
or if a byte array parameter option is not supported by the algorithm or if
the bLen
is an incorrect byte length for the algorithm specific data or
if the Key
is inconsistent with theMode
or with the Signature
implementation.
CryptoException.UNINITIALIZED_KEY
if theKey
instance is uninitialized.
public short getLength() throws CryptoException
Signature
CryptoException
- with the following reason codes:CryptoException.INVALID_INIT
if this Signature
object is
not initialized.
CryptoException.UNINITIALIZED_KEY
if key not initialized.
public byte getAlgorithm()
Signature
getAlgorithm
in class Signature
public void update(byte[] inBuff, short inOffset, short inLength) throws CryptoException
Signature
sign()
or verify()
method is recommended. The sign()
or verify()
method must be called to complete processing of input data accumulated by one or more
calls to the update()
method.
Note:
inLength
is 0 this method does nothing.
inBuff
- the input buffer of data to be signedinOffset
- the offset into the input buffer at which to begin signature generationinLength
- the byte length to sign
CryptoException
- with the following reason codes:CryptoException.UNINITIALIZED_KEY
if key not initialized.
CryptoException.INVALID_INIT
if this Signature
object is
not initialized.
Signature.sign(byte[], short, short, byte[], short)
public short sign(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset) throws CryptoException
Signature
A call to this method also resets this Signature
object to the state it was in
when previously initialized via a call to init()
.
That is, the object is reset and available to sign another message.
In addition, note that the initial vector(IV) used in AES and DES algorithms
in CBC mode will be reset to 0.
Note:
init(Key, byte, byte[], short, short)
method.
The input and output buffer data may overlap.
inBuff
- the input buffer of data to be signedinOffset
- the offset into the input buffer at which to begin signature generationinLength
- the byte length to signsigBuff
- the output buffer to store signature datasigOffset
- the offset into sigBuff at which to begin signature data
CryptoException
- with the following reason codes:CryptoException.UNINITIALIZED_KEY
if key not initialized.
CryptoException.INVALID_INIT
if this Signature
object is
not initialized or initialized for signature verify mode.
CryptoException.ILLEGAL_USE
if one of the following conditions is met:Signature
algorithm
does not pad the message and the message is not block aligned.
Signature
algorithm
does not pad the message and no input
data has been provided in inBuff
or via the update()
method.
public boolean verify(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset, short sigLength) throws CryptoException
Signature
A call to this method also resets this Signature
object to the state it was in
when previously initialized via a call to init()
.
That is, the object is reset and available to verify another message.
In addition, note that the initial vector(IV) used in AES and DES algorithms
in CBC mode will be reset to 0.
Note:
init(Key, byte, byte[], short, short)
method.
inBuff
- the input buffer of data to be verifiedinOffset
- the offset into the input buffer at which to begin signature generationinLength
- the byte length to verifysigBuff
- the input buffer containing signature datasigOffset
- the offset into sigBuff
where signature data beginssigLength
- the byte length of the signature data
true
if the signature verifies, false
otherwise
Note, if sigLength
is inconsistent with this Signature
algorithm, false
is returned.
CryptoException
- with the following reason codes:CryptoException.UNINITIALIZED_KEY
if key not initialized.
CryptoException.INVALID_INIT
if this Signature
object is
not initialized or initialized for signature sign mode.
CryptoException.ILLEGAL_USE
if one of the following conditions is met:Signature
algorithm
does not pad the message and the message is not block aligned.
Signature
algorithm
does not pad the message and no input
data has been provided in inBuff
or via the update()
method.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |