de.flexiprovider.core.rsa
Class SSLSignature

java.lang.Object
  |
  +--java.security.SignatureSpi
        |
        +--de.flexiprovider.api.Signature
              |
              +--de.flexiprovider.core.rsa.SSLSignature

public class SSLSignature
extends Signature

This class implements the RSA signature algorithm as defined in SSL. Note that this is a special version of a RSA signature that does not use a PKCS#1-compliant DigestInfo structure!


Fields inherited from class java.security.SignatureSpi
appRandom
 
Constructor Summary
SSLSignature()
           
 
Method Summary
 void initSign(PrivateKey privateKey, SecureRandom secureRandom)
          Initializes the signature algorithm for signing a message.
 void initVerify(PublicKey publicKey)
          Initializes the signature algorithm for verifying a signature.
 void setParameters(AlgorithmParameterSpec params)
          Set parameters for the signature (not used).
 byte[] sign()
          Signs a message.
 void update(byte b)
          Passes a message byte to the message digest.
 void update(byte[] b, int offset, int length)
          Passes message bytes to the message digest.
 boolean verify(byte[] signature)
          Verifies a signature.
 
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

SSLSignature

public SSLSignature()
Method Detail

initSign

public void initSign(PrivateKey privateKey,
                     SecureRandom secureRandom)
              throws InvalidKeyException
Initializes the signature algorithm for signing a message.
Overrides:
initSign in class Signature
Parameters:
privateKey - the private key of the signer.
secureRandom - the source of randomness.
Throws:
InvalidKeyException - if the key is not an instance of RSAPrivKey.

initVerify

public void initVerify(PublicKey publicKey)
                throws InvalidKeyException
Initializes the signature algorithm for verifying a signature.
Overrides:
initVerify in class Signature
Parameters:
publicKey - the public key of the signer.
Throws:
InvalidKeyException - if the public key is not an instance of RSAPubKey.

setParameters

public void setParameters(AlgorithmParameterSpec params)
Set parameters for the signature (not used).
Overrides:
setParameters in class Signature
Parameters:
params - the parameters (not used)

update

public void update(byte[] b,
                   int offset,
                   int length)
Passes message bytes to the message digest.
Overrides:
update in class Signature
Parameters:
b - The message byte.
offset - The index, where the message bytes starts.
length - The number of message bytes.

update

public void update(byte b)
Passes a message byte to the message digest.
Overrides:
update in class Signature
Parameters:
b - the message byte.

sign

public byte[] sign()
            throws SignatureException
Signs a message.
Overrides:
sign in class Signature
Returns:
the signature.
Throws:
SignatureException - if the signature is not initialized properly.

verify

public boolean verify(byte[] signature)
Verifies a signature.
Overrides:
verify in class Signature
Parameters:
signature - the signature to be verified
Returns:
true if the signature is correct - false otherwise.