|
IAIK ECC version 2.18 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.security.SignatureSpi java.security.Signature iaik.security.ecc.ecdsa.RawECDSA
This class implements the "Raw" ECDSA signature algorithm. That is, it expects its input to be already hashed with eg. SHA-1, SHA-256, etc.
Use it like any other signature algorithm, but supply the hashed data to
the update()
methods instead of the original data to be signed.
You can call all of the update methods in any combination.
You have to ensure that the length of the hashed bytes in the update methods
fits the parameters of the curve.
If you are going to sign some yet not hashed data (respectively verify the
corresponding signature), you can use the ECDSA
implemetation
which automatically hashes the supplied data according the SHA algorithm
before processing it with the RawDSA algorithm.
ECDSASignature
,
Signature
Field Summary | |
protected java.io.ByteArrayOutputStream |
dataBuffer_
Data buffer to which the DigestInfo is written when supplied via an update method. |
protected ECPrivateKey |
privateKey_
The private key, used for signing. |
protected ECPublicKey |
publicKey_
The public key used for verification. |
protected java.security.SecureRandom |
secureRandom_
Source of randomness. |
Fields inherited from class java.security.Signature |
SIGN, state, UNINITIALIZED, VERIFY |
Fields inherited from class java.security.SignatureSpi |
appRandom |
Constructor Summary | |
RawECDSA()
The default constructor. |
Method Summary | |
protected java.lang.Object |
engineGetParameter(java.lang.String param)
Method not implemented. |
protected void |
engineInitSign(java.security.PrivateKey privateKey)
Initializes the engine for signature creation. |
protected void |
engineInitSign(java.security.PrivateKey privateKey,
java.security.SecureRandom random)
SPI: Initializes this Signature object with the given ECDSA private key and the given SecureRandom generator for going to sign some data. |
protected void |
engineInitVerify(java.security.PublicKey publicKey)
Initializes the engine for signature verification. |
protected void |
engineSetParameter(java.lang.String param,
java.lang.Object value)
Method not implemented. |
protected byte[] |
engineSign()
Implements the sign algorithm according to the rules: k = random([1,n-1]) kP = (x1,y1) r = x1 mod n e = H(M) s = k1(e+dr) mod n Signature: (r,s) |
protected void |
engineUpdate(byte b)
SPI: Updates the data to be signed or verified with the specified byte. |
protected void |
engineUpdate(byte[] b,
int off,
int len)
SPI: Updates the data to be signed or verified with the specified number of hashed bytes, beginning at the specified offset within the given byte array. |
protected boolean |
engineVerify(byte[] sigBytes)
Verifies a given signature according to the following rules: extract r and s from the given byte[] if r is not an integer in the interval [1, n-1] reject sig. |
Methods inherited from class java.security.Signature |
clone, getAlgorithm, getInstance, getInstance, getInstance, getParameter, getParameters, getProvider, initSign, initSign, initVerify, initVerify, setParameter, setParameter, sign, sign, toString, update, update, update, verify, verify |
Methods inherited from class java.security.SignatureSpi |
engineGetParameters, engineSetParameter, engineSign, engineVerify |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.io.ByteArrayOutputStream dataBuffer_
protected ECPrivateKey privateKey_
protected ECPublicKey publicKey_
protected java.security.SecureRandom secureRandom_
Constructor Detail |
public RawECDSA()
Applications use Signature.getInstance("RawECDSA");
for creating a
RawECDSA Signature object.
Signature.getInstance(java.lang.String)
Method Detail |
protected java.lang.Object engineGetParameter(java.lang.String param) throws java.security.InvalidParameterException
java.security.InvalidParameterException
protected void engineInitSign(java.security.PrivateKey privateKey) throws java.security.InvalidKeyException
privateKey
- the ECDSA private key used for signing.
java.security.InvalidKeyException
- if a key encoding error occurs.protected void engineInitSign(java.security.PrivateKey privateKey, java.security.SecureRandom random) throws java.security.InvalidKeyException
Note that this method is not available for JDK versions prior JDK 1.2. When using JDK 1.1 a SecureRandom object may be supplied as by calling method setParameter. If a SecureRandom never has been supplied by the application, the signature engine will use a default SecureRandom, if required.
privateKey
- the ECDSDSA private key to be used for signing.random
- the random number generator
java.security.InvalidKeyException
- if a key decoding error occursprotected void engineInitVerify(java.security.PublicKey publicKey) throws java.security.InvalidKeyException
publicKey
- the ECDSA public key used for the signature verification.
java.security.InvalidKeyException
- if a key encoding error occurs.protected void engineSetParameter(java.lang.String param, java.lang.Object value) throws java.security.InvalidParameterException
java.security.InvalidParameterException
protected byte[] engineSign() throws java.security.SignatureException
java.security.SignatureException
protected void engineUpdate(byte b)
b
- the hash byte to be used for updating.
java.security.SignatureException
- if the engine has not been properly initializedprotected void engineUpdate(byte[] b, int off, int len)
b
- the byte array holding the already hashed data to be used for this update operation.off
- the offset, indicating the start position within the given byte array.len
- the number of bytes to be obtained from the given byte array, starting at the given position.
java.security.SignatureException
- if the engine has not been properly initialized.protected boolean engineVerify(byte[] sigBytes) throws java.security.SignatureException
sigBytes
- the encoded r and s values of the signature.
java.security.SignatureException
- if an error occurs when verifying the signature.
|
IAIK ECC version 2.18 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |