|
SunSPOT host API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.squawk.security.signing.ECDSASignature
public class ECDSASignature
Signature algorithm ALG_ECDSA_SHA
generates a 20-byte SHA
digest and signs/verifies the digest using ECDSA. The signature is encoded as
an ASN.1 sequence of two INTEGER values, r and s, in that order:
SEQUENCE ::= { r INTEGER, s INTEGER }
Constructor Summary | |
---|---|
ECDSASignature()
|
Method Summary | |
---|---|
int |
getLength()
Returns the byte length of the signature data. |
void |
init(ECPrivateKey privateKey)
Initializes the Signature object with the appropriate
Key . |
void |
init(ECPublicKey publicKey)
Initializes the Signature object with the appropriate
Key . |
int |
sign(byte[] inBuff,
int inOffset,
int inLength,
byte[] sigBuff,
int sigOffset)
Generates the signature of all/last input data. |
void |
update(byte[] inBuff,
int inOffset,
int inLength)
Accumulates a signature of the input data. |
boolean |
verify(byte[] inBuff,
int inOffset,
int inLength,
byte[] sigBuff,
int sigOffset,
int sigLength)
Verifies the signature of all/last input data against the passed in signature. |
boolean |
verifyMessageDigest(byte[] digestBuf,
byte[] sigBuff,
int sigOffset,
int sigLength)
Verifies the signature with an externally computed sha1 hash. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ECDSASignature() throws CryptoException
CryptoException
Method Detail |
---|
public int getLength() throws CryptoException
CryptoException
- with the following reason codes:
CryptoException.INVALID_INIT
if
this Signature object is not initialized.CryptoException.UNINITIALIZED_KEY
if key not initialized.public void init(ECPrivateKey privateKey) throws CryptoException
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(ECPublicKey publicKey) throws CryptoException
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 int sign(byte[] inBuff, int inOffset, int inLength, byte[] sigBuff, int sigOffset) throws CryptoException
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.
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
sigBuff
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 void update(byte[] inBuff, int inOffset, int inLength) throws CryptoException
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 signed/verifiedinOffset
- the offset into the input buffer at which to begin
signature generation/verificationinLength
- 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.sign(byte[], int, int, byte[], int)
,
verify(byte[], int, int, byte[], int, int)
public boolean verify(byte[] inBuff, int inOffset, int inLength, byte[] sigBuff, int sigOffset, int sigLength) throws CryptoException
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 signsigBuff
- 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.public boolean verifyMessageDigest(byte[] digestBuf, byte[] sigBuff, int sigOffset, int sigLength) throws CryptoException
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.
To use this method Signature.init has to be called before to initialize the key, while calling Signature.update does not have any effect on the result.
Note:
init(Key, byte, byte[], short, short)
method.
digestBuf
- The externally compute sha1 hash to be verifiedsigBuff
- 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.
|
SunSPOT host API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |