de.flexiprovider.core.mersa
Class MeRSASignaturePSS

java.lang.Object
  |
  +--java.security.SignatureSpi
        |
        +--de.flexiprovider.api.Signature
              |
              +--de.flexiprovider.core.mersa.MeRSASignaturePSS

public class MeRSASignaturePSS
extends Signature

MeRSASSA-PSS (MeRSA Signature Scheme with Appendix - Probabilistic Signature Scheme) is an asymmetric signature scheme with appendix combining the MeRSA algorithm with the PSS encoding method. The PSS encoding method was invented by Mihir Bellare and Phillip Rogaway.

Author:
Erik Dahmen, Paul Nguentcheu

Field Summary
(package private)  SecureRandom random
          source of randomness
 
Fields inherited from class java.security.SignatureSpi
appRandom
 
Constructor Summary
MeRSASignaturePSS()
          The default constructor generates an AlgorithmIdentifier object for MeRSASSA-PSS with OID 1.2.840.113549.1.1.10.
 
Method Summary
protected  void engineSetParameter(AlgorithmParameterSpec params)
          Set the algorithm parameters.
 void initSign(PrivateKey privateKey, SecureRandom random)
          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)
          Writes a byte into the ByteArrayOutputStream.
 void update(byte[] b, int offset, int length)
          Writes length bytes beginning at offset into the ByteArrayOutputStream.
 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
 

Field Detail

random

SecureRandom random
source of randomness
Constructor Detail

MeRSASignaturePSS

public MeRSASignaturePSS()
The default constructor generates an AlgorithmIdentifier object for MeRSASSA-PSS with OID 1.2.840.113549.1.1.10. Failure to achieve this is fatal and will result in a RuntimeException
Method Detail

engineSetParameter

protected final void engineSetParameter(AlgorithmParameterSpec params)
                                 throws InvalidAlgorithmParameterException
Set the algorithm parameters.
Parameters:
params - the algorithm parameters
Throws:
InvalidAlgorithmParameterException - if params is not an instance of PSSParameterSpec.

initSign

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

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 RSAPublicKey.

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)
Writes a byte into the ByteArrayOutputStream.
Overrides:
update in class Signature
Parameters:
b - the message byte.

update

public void update(byte[] b,
                   int offset,
                   int length)
Writes length bytes beginning at offset into the ByteArrayOutputStream.
Overrides:
update in class Signature
Parameters:
b - The message byte.
offset - The index, where the message bytes starts.
length - The number of message bytes.

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.