de.flexiprovider.nf.iq.iqdsa
Class IQDSASignature

java.lang.Object
  |
  +--java.security.SignatureSpi
        |
        +--de.flexiprovider.api.Signature
              |
              +--de.flexiprovider.nf.iq.iqdsa.IQDSASignature
Direct Known Subclasses:
IQDSASignature.RIPEMD160, IQDSASignature.SHA1

public abstract class IQDSASignature
extends Signature

This class implements the core parts of the IQDSA algorithm, namely the signature and the verification process.

Author:
Ralf-P. Weinmann

Inner Class Summary
static class IQDSASignature.RIPEMD160
          IQDSA with RIPEMD160 message digest.
static class IQDSASignature.SHA1
          IQDSA with SHA1 message digest.
 
Fields inherited from class java.security.SignatureSpi
appRandom
 
Constructor Summary
protected IQDSASignature(MessageDigest md)
          Constructor.
 
Method Summary
 void initSign(PrivateKey key, SecureRandom prng)
          Initializes engine for signing.
 void initVerify(PublicKey key)
          Initialized engine for verification process
protected  byte[] makeDigest(byte[] m)
          Calculates the digest value for a given octet string
 void setParameters(AlgorithmParameterSpec params)
          Set the parameters for the signature.
 byte[] sign()
          Generates an ASN.1 encoded object representing the signature of the data bytes digested by the message digest algorithm thus far.
 void update(byte b)
          Updates the data to be signed or verified using the specified byte.
 void update(byte[] b, int off, int len)
          Updates the data to be signed or verified, using the specified array of bytes, starting at the specified offset.
 boolean verify(byte[] sigBytes)
          Verifies the signature passed in as sigBytes
 
Methods inherited from class de.flexiprovider.api.Signature
engineGetParameter, engineInitSign, engineInitSign, engineInitVerify, engineSetParameter, engineSetParameter, engineSign, engineUpdate, engineUpdate, engineVerify, engineVerify, initSign, sign, update, verify, verify, verify
 
Methods inherited from class java.security.SignatureSpi
clone, engineSign
 
Methods inherited from class java.lang.Object
, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IQDSASignature

protected IQDSASignature(MessageDigest md)
Constructor. Set the message digest.
Parameters:
md - the message digest
Method Detail

initSign

public void initSign(PrivateKey key,
                     SecureRandom prng)
              throws InvalidKeyException
Initializes engine for signing.
Overrides:
initSign in class Signature
Parameters:
key - private key to be used for signing
prng - source of randomness
Throws:
InvalidKeyException - if the key is not an instance of IQDSAPrivateKey.
See Also:
sign()

initVerify

public void initVerify(PublicKey key)
                throws InvalidKeyException
Initialized engine for verification process
Overrides:
initVerify in class Signature
Parameters:
key - public key to be used for verification
Throws:
InvalidKeyException - if the key is not an instance of IQDSAPublicKey.
See Also:
verify(byte [])

update

public void update(byte b)
Updates the data to be signed or verified using the specified byte.
Overrides:
update in class Signature
Parameters:
b - the byte to be updated.

update

public void update(byte[] b,
                   int off,
                   int len)
Updates the data to be signed or verified, using the specified array of bytes, starting at the specified offset.
Overrides:
update in class Signature
Parameters:
b - the byte array
off - the offset to start from in the array of bytes
len - the number of bytes to use, starting at offset

makeDigest

protected byte[] makeDigest(byte[] m)
Calculates the digest value for a given octet string
Parameters:
m - array containing the data to be hashed
Returns:
the digest value represented as an octet string

sign

public byte[] sign()
Generates an ASN.1 encoded object representing the signature of the data bytes digested by the message digest algorithm thus far.
Overrides:
sign in class Signature
Returns:
signature of the data fed into the engine thus far

verify

public boolean verify(byte[] sigBytes)
               throws SignatureException
Verifies the signature passed in as sigBytes
Overrides:
verify in class Signature
Parameters:
sigBytes - the signature bytes to be verified.
Returns:
true if the signature was verified, false if not.
Throws:
SignatureException - if this signature object is not initialized properly.

setParameters

public void setParameters(AlgorithmParameterSpec params)
                   throws InvalidAlgorithmParameterException
Set the parameters for the signature.
Overrides:
setParameters in class Signature
Parameters:
params - the parameters
Throws:
InvalidAlgorithmParameterException - if the parameters are not an instance of IQDSAParameterSpec.