APIdia Launch Partner
Top Description Fields Constructors Methods
sun.security.ssl

public final Class RSASignature

extends SignatureSpi
Class Inheritance
Imports
java.security.*, java.security.spec.AlgorithmParameterSpec

Signature implementation for the SSL/TLS RSA Signature variant with both MD5 and SHA-1 MessageDigests. Used for explicit RSA server authentication (RSA signed server key exchange for RSA_EXPORT and DHE_RSA) and RSA client authentication (RSA signed certificate verify message). It conforms to the standard JCA Signature API. It is registered in the SunJSSE provider to avoid more complicated getInstance() code and negative interaction with the JCA mechanisms for hardware providers. The class should be instantiated via the getInstance() method in this class, which returns the implementation from the preferred provider. The internal implementation allows the hashes to be explicitly set, which is required for RSA client authentication. It can be obtained via the getInternalInstance() method. This class is not thread safe.

Field Summary

Modifier and TypeField and Description
private final MessageDigest
private final MessageDigest
private final Signature
Inherited from java.security.SignatureSpi:
appRandom

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected Object
engineGetParameter(String param)

Implements abstract java.security.SignatureSpi.engineGetParameter.

Gets the value of the specified algorithm parameter.

protected AlgorithmParameters
engineGetParameters()

Overrides java.security.SignatureSpi.engineGetParameters.

Returns the parameters used with this Signature object.

protected void
engineInitSign(PrivateKey privateKey)

Implements abstract java.security.SignatureSpi.engineInitSign.

Initializes this Signature object with the specified private key for signing operations.

protected void
engineInitSign(PrivateKey privateKey, SecureRandom random)

Overrides java.security.SignatureSpi.engineInitSign.

Initializes this Signature object with the specified private key and source of randomness for signing operations.

protected void
engineInitVerify(PublicKey publicKey)

Implements abstract java.security.SignatureSpi.engineInitVerify.

Initializes this Signature object with the specified public key for verification operations.

protected void
engineSetParameter(String param, Object value)

Implements abstract java.security.SignatureSpi.engineSetParameter.

Sets the specified algorithm parameter to the specified value.

protected void
engineSetParameter(AlgorithmParameterSpec params)

Overrides java.security.SignatureSpi.engineSetParameter.

Initializes this Signature object with the specified parameter values.

protected byte[]
engineSign()

Implements abstract java.security.SignatureSpi.engineSign.

Returns the signature bytes of all the data updated so far.

protected void
engineUpdate(byte b)

Implements abstract java.security.SignatureSpi.engineUpdate.

Updates the data to be signed or verified using the specified byte.

protected void
engineUpdate(byte[] b, int off, int len)

Implements abstract java.security.SignatureSpi.engineUpdate.

Updates the data to be signed or verified, using the specified array of bytes, starting at the specified offset.

protected boolean
engineVerify(byte[] sigBytes)

Implements abstract java.security.SignatureSpi.engineVerify.

Verifies the passed-in signature.

protected boolean
engineVerify(byte[] sigBytes, int offset, int length)

Overrides java.security.SignatureSpi.engineVerify.

Verifies the passed-in signature in the specified array of bytes, starting at the specified offset.

private byte[]
pack-priv static Signature
getInstance()

Get an implementation for the RSA signature.

Inherited from java.security.SignatureSpi:
cloneengineSignengineUpdate

Field Detail

mdMD5back to summary
private final MessageDigest mdMD5
mdSHAback to summary
private final MessageDigest mdSHA
rawRsaback to summary
private final Signature rawRsa

Constructor Detail

RSASignatureback to summary
public RSASignature() throws NoSuchAlgorithmException

Method Detail

engineGetParameterback to summary
protected Object engineGetParameter(String param) throws InvalidParameterException

Implements abstract java.security.SignatureSpi.engineGetParameter.

Doc from java.security.SignatureSpi.engineGetParameter.

Gets the value of the specified algorithm parameter. This method supplies a general-purpose mechanism through which it is possible to get the various parameters of this object. A parameter may be any settable parameter for the algorithm, such as a parameter size, or a source of random bits for signature generation (if appropriate), or an indication of whether to perform a specific but optional computation. A uniform algorithm-specific naming scheme for each parameter is desirable but left unspecified at this time.

Annotations
@Override
@SuppressWarnings:deprecation
Exceptions
InvalidParameterException:
if param is an invalid parameter for this engine, or another exception occurs while trying to get this parameter.
engineGetParametersback to summary
protected AlgorithmParameters engineGetParameters()

Overrides java.security.SignatureSpi.engineGetParameters.

Doc from java.security.SignatureSpi.engineGetParameters.

Returns the parameters used with this Signature object.

The returned parameters may be the same that were used to initialize this Signature object, or may contain additional default or random parameter values used by the underlying signature scheme. If the required parameters were not supplied and can be generated by the Signature object, the generated parameters are returned; otherwise null is returned.

However, if the signature scheme does not support returning the parameters as AlgorithmParameters, null is always returned.

Annotations
@Override
engineInitSignback to summary
protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException

Implements abstract java.security.SignatureSpi.engineInitSign.

Doc from java.security.SignatureSpi.engineInitSign.

Initializes this Signature object with the specified private key for signing operations.

Annotations
@Override
Exceptions
InvalidKeyException:
if the key is improperly encoded, parameters are missing, and so on.
engineInitSignback to summary
protected void engineInitSign(PrivateKey privateKey, SecureRandom random) throws InvalidKeyException

Overrides java.security.SignatureSpi.engineInitSign.

Doc from java.security.SignatureSpi.engineInitSign.

Initializes this Signature object with the specified private key and source of randomness for signing operations.

This concrete method has been added to this previously-defined abstract class. (For backwards compatibility, it cannot be abstract.)

Annotations
@Override
Exceptions
InvalidKeyException:
if the key is improperly encoded, parameters are missing, and so on.
engineInitVerifyback to summary
protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException

Implements abstract java.security.SignatureSpi.engineInitVerify.

Doc from java.security.SignatureSpi.engineInitVerify.

Initializes this Signature object with the specified public key for verification operations.

Annotations
@Override
Exceptions
InvalidKeyException:
if the key is improperly encoded, parameters are missing, and so on.
engineSetParameterback to summary
protected void engineSetParameter(String param, Object value) throws InvalidParameterException

Implements abstract java.security.SignatureSpi.engineSetParameter.

Doc from java.security.SignatureSpi.engineSetParameter.

Sets the specified algorithm parameter to the specified value. This method supplies a general-purpose mechanism through which it is possible to set the various parameters of this object. A parameter may be any settable parameter for the algorithm, such as a parameter size, or a source of random bits for signature generation (if appropriate), or an indication of whether to perform a specific but optional computation. A uniform algorithm-specific naming scheme for each parameter is desirable but left unspecified at this time.

Annotations
@Override
@SuppressWarnings:deprecation
Exceptions
InvalidParameterException:
if param is an invalid parameter for this Signature object, the parameter is already set and cannot be set again, a security exception occurs, and so on.
engineSetParameterback to summary
protected void engineSetParameter(AlgorithmParameterSpec params) throws InvalidAlgorithmParameterException

Overrides java.security.SignatureSpi.engineSetParameter.

Doc from java.security.SignatureSpi.engineSetParameter.

Initializes this Signature object with the specified parameter values.

Annotations
@Override
Exceptions
InvalidAlgorithmParameterException:
if this method is overridden by a provider and the given parameters are inappropriate for this Signature object
engineSignback to summary
protected byte[] engineSign() throws SignatureException

Implements abstract java.security.SignatureSpi.engineSign.

Doc from java.security.SignatureSpi.engineSign.

Returns the signature bytes of all the data updated so far. The format of the signature depends on the underlying signature scheme.

Annotations
@Override
Exceptions
SignatureException:
if the engine is not initialized properly or if this signature algorithm is unable to process the input data provided.
engineUpdateback to summary
protected void engineUpdate(byte b)

Implements abstract java.security.SignatureSpi.engineUpdate.

Doc from java.security.SignatureSpi.engineUpdate.

Updates the data to be signed or verified using the specified byte.

Annotations
@Override
engineUpdateback to summary
protected void engineUpdate(byte[] b, int off, int len)

Implements abstract java.security.SignatureSpi.engineUpdate.

Doc from java.security.SignatureSpi.engineUpdate.

Updates the data to be signed or verified, using the specified array of bytes, starting at the specified offset.

Annotations
@Override
engineVerifyback to summary
protected boolean engineVerify(byte[] sigBytes) throws SignatureException

Implements abstract java.security.SignatureSpi.engineVerify.

Doc from java.security.SignatureSpi.engineVerify.

Verifies the passed-in signature.

Annotations
@Override
Exceptions
SignatureException:
if the engine is not initialized properly, the passed-in signature is improperly encoded or of the wrong type, if this signature algorithm is unable to process the input data provided, etc.
engineVerifyback to summary
protected boolean engineVerify(byte[] sigBytes, int offset, int length) throws SignatureException

Overrides java.security.SignatureSpi.engineVerify.

Doc from java.security.SignatureSpi.engineVerify.

Verifies the passed-in signature in the specified array of bytes, starting at the specified offset.

Note

Subclasses should overwrite the default implementation.

Annotations
@Override
Exceptions
SignatureException:
if the engine is not initialized properly, the passed-in signature is improperly encoded or of the wrong type, if this signature algorithm is unable to process the input data provided, etc.
getDigestback to summary
private byte[] getDigest() throws SignatureException
getInstanceback to summary
pack-priv static Signature getInstance() throws NoSuchAlgorithmException

Get an implementation for the RSA signature. Follows the standard JCA getInstance() model, so it returns the implementation from the provider with the highest precedence, which may be this class.