de.flexiprovider.core.rsa
Class RSASignaturePSS
java.lang.Object
|
+--java.security.SignatureSpi
|
+--de.flexiprovider.api.Signature
|
+--de.flexiprovider.core.rsa.RSASignaturePSS
- public class RSASignaturePSS
- extends Signature
RSASSA-PSS (RSA Signature Scheme with Appendix - Probabilistic Signature
Scheme) is an asymmetric signature scheme with appendix combining the RSA
algorithm with the PSS encoding method. The PSS encoding method was invented
by Mihir Bellare and Phillip Rogaway.
This class implements RSASSA-PSS as defined per PKCS#1 version
2.1 and will produce signatures as ASN.1 DigestInfo
structures. Please note that we are not supporting multiprime RSA at the
moment.
- Author:
- Ralf-Philipp Weinmann
|
Field Summary |
static java.lang.String |
OID
The OID of RSASSA-PSS (defined by PKCS #1 v2.1). |
| Fields inherited from class java.security.SignatureSpi |
appRandom |
| 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 |
OID
public static final java.lang.String OID
- The OID of RSASSA-PSS (defined by PKCS #1 v2.1).
RSASignaturePSS
public RSASignaturePSS()
- Constructor. Generate the default parameters. Failure to achieve this is
fatal and will result in a
RuntimeException.
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 signerrandom - the source of randomness- Throws:
InvalidKeyException - if the key is not an instance of RSAPrivateKey or
RSAPrivateCrtKey.
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.