|
SunSPOT host API V4.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
privateKey in preparation for digital signing. |
void |
init(ECPublicKey publicKey)
Initializes the Signature object with the appropriate
publicKey in preparation for digital signature verification. |
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
privateKey in preparation for digital signing.
privateKey - the privateKey object to use for signing
CryptoException - with the following reason codes:
CryptoException.UNINITIALIZED_KEY
if privateKey instance is uninitialized.
public void init(ECPublicKey publicKey)
throws CryptoException
Signature object with the appropriate
publicKey in preparation for digital signature verification.
publicKey - the publicKey object to use for verification
CryptoException - with the following reason codes:
CryptoException.UNINITIALIZED_KEY
if publicKey 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.
Note:
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.
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.
|
SunSPOT host API V4.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||