Top Description Inners Fields Constructors Methods
sun.security.rsa

pack-priv abstract Class RSASignature

extends SignatureSpi
Class Inheritance
Known Direct Subclasses
sun.security.rsa.RSASignature.MD2withRSA, sun.security.rsa.RSASignature.MD5withRSA, sun.security.rsa.RSASignature.SHA1withRSA, sun.security.rsa.RSASignature.SHA224withRSA, sun.security.rsa.RSASignature.SHA256withRSA, sun.security.rsa.RSASignature.SHA384withRSA, sun.security.rsa.RSASignature.SHA512withRSA, sun.security.rsa.RSASignature.SHA512_224withRSA, sun.security.rsa.RSASignature.SHA512_256withRSA, sun.security.rsa.RSASignature.SHA3_224withRSA, sun.security.rsa.RSASignature.SHA3_256withRSA, sun.security.rsa.RSASignature.SHA3_384withRSA, sun.security.rsa.RSASignature.SHA3_512withRSA
Imports
java.nio.ByteBuffer, java.security.*, java.security.interfaces.*, java.security.spec.AlgorithmParameterSpec, sun.security.rsa.RSAUtil.KeyType, sun.security.util.*, sun.security.x509.AlgorithmId

PKCS#1 v1.5 RSA signatures with the various message digest algorithms. This file contains an abstract base class with all the logic plus a nested static class for each of the message digest algorithms (see end of the file). We support MD2, MD5, SHA-1, SHA2 family ( SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, and SHA-512/256), and SHA3 family (SHA3-224, SHA3-256, SHA3-384, SHA3-512) of digests.
Author
Andreas Sterbenz
Since
1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class

Field Summary

Modifier and TypeField and Description
private static final int
private final ObjectIdentifier
private boolean
private final int
private final MessageDigest
private RSAPadding
private RSAPrivateKey
private RSAPublicKey
Inherited from java.security.SignatureSpi:
appRandom

Constructor Summary

AccessConstructor and Description
pack-priv
RSASignature(String algorithm, ObjectIdentifier digestOID, int oidLength)

Construct a new RSASignature.

Method Summary

Modifier and TypeMethod and Description
protected Object
engineGetParameter(String
the string name of the parameter.
param
)

Implements abstract java.security.SignatureSpi.engineGetParameter.

Deprecated
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
the private key of the identity whose signature will be generated.
privateKey
)

Implements abstract java.security.SignatureSpi.engineInitSign.

Initializes this Signature object with the specified private key for signing operations.
protected void
engineInitSign(PrivateKey
the private key of the identity whose signature will be generated.
privateKey
,
SecureRandom
the source of randomness
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
the public key of the identity whose signature is going to be verified.
publicKey
)

Implements abstract java.security.SignatureSpi.engineInitVerify.

Initializes this Signature object with the specified public key for verification operations.
protected void
engineSetParameter(String
the string identifier of the parameter.
param
,
Object
the parameter value.
value
)

Implements abstract java.security.SignatureSpi.engineSetParameter.

Deprecated
Sets the specified algorithm parameter to the specified value.
protected void
engineSetParameter(AlgorithmParameterSpec
the parameters
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
the byte to use for the update.
b
)

Implements abstract java.security.SignatureSpi.engineUpdate.

Updates the data to be signed or verified using the specified byte.
protected void
engineUpdate(byte[]
the array of bytes
b
,
int
the offset to start from in the array of bytes
off
,
int
the number of bytes to use, starting at offset
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 void
engineUpdate(ByteBuffer
the ByteBuffer
b
)

Overrides java.security.SignatureSpi.engineUpdate.

Updates the data to be signed or verified using the specified ByteBuffer.
protected boolean
engineVerify(byte[]
the signature bytes to be verified.
sigBytes
)

Implements abstract java.security.SignatureSpi.engineVerify.

Verifies the passed-in signature.
private byte[]
getDigestValue()

Return the message digest value.

private void
initCommon(RSAKey rsaKey, SecureRandom random)

Init code common to sign and verify.

private void
resetDigest()

Reset the message digest if it is not already reset.

Inherited from java.security.SignatureSpi:
cloneengineSignengineVerify

Field Detail

baseLengthback to summary
private static final int baseLength
digestOIDback to summary
private final ObjectIdentifier digestOID
digestResetback to summary
private boolean digestReset
encodedLengthback to summary
private final int encodedLength
mdback to summary
private final MessageDigest md
paddingback to summary
private RSAPadding padding
privateKeyback to summary
private RSAPrivateKey privateKey
publicKeyback to summary
private RSAPublicKey publicKey

Constructor Detail

RSASignatureback to summary
pack-priv RSASignature(String algorithm, ObjectIdentifier digestOID, int oidLength)

Construct a new RSASignature. Used by subclasses.

Method Detail

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

Implements abstract java.security.SignatureSpi.engineGetParameter.

Doc from java.security.SignatureSpi.engineGetParameter.

Deprecated

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.

Parameters
param:String

the string name of the parameter.

Returns:Object

the object that represents the parameter value, or null if there is none.

Annotations
@Deprecated
@Override
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.

Returns:AlgorithmParameters

the parameters used with this Signature object, or null

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.

Parameters
privateKey:PrivateKey

the private key of the identity whose signature will be generated.

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

Parameters
privateKey:PrivateKey

the private key of the identity whose signature will be generated.

random:SecureRandom

the source of randomness

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.

Parameters
publicKey:PublicKey

the public key of the identity whose signature is going to be verified.

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.

Deprecated

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.

Parameters
param:String

the string identifier of the parameter.

value:Object

the parameter value.

Annotations
@Deprecated
@Override
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.

Parameters
params:AlgorithmParameterSpec

the parameters

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.

Returns:byte[]

the signature bytes of the signing operation's result.

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) throws SignatureException

Implements abstract java.security.SignatureSpi.engineUpdate.

Doc from java.security.SignatureSpi.engineUpdate.

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

Parameters
b:byte

the byte to use for the update.

Annotations
@Override
Exceptions
SignatureException:
if the engine is not initialized properly.
engineUpdateback to summary
protected void engineUpdate(byte[] b, int off, int len) throws SignatureException

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.

Parameters
b:byte[]

the array of bytes

off:int

the offset to start from in the array of bytes

len:int

the number of bytes to use, starting at offset

Annotations
@Override
Exceptions
SignatureException:
if the engine is not initialized properly
engineUpdateback to summary
protected void engineUpdate(ByteBuffer b)

Overrides java.security.SignatureSpi.engineUpdate.

Doc from java.security.SignatureSpi.engineUpdate.

Updates the data to be signed or verified using the specified ByteBuffer. Processes the data.remaining() bytes starting at data.position(). Upon return, the buffer's position will be equal to its limit; its limit will not have changed.

Parameters
b:ByteBuffer

the ByteBuffer

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.

Parameters
sigBytes:byte[]

the signature bytes to be verified.

Returns:boolean

true if the signature was verified, false if not.

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.
getDigestValueback to summary
private byte[] getDigestValue()

Return the message digest value.

initCommonback to summary
private void initCommon(RSAKey rsaKey, SecureRandom random) throws InvalidKeyException

Init code common to sign and verify.

resetDigestback to summary
private void resetDigest()

Reset the message digest if it is not already reset.

sun.security.rsa back to summary

public final Class RSASignature.MD2withRSA

extends RSASignature
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from sun.security.rsa.RSASignature:
engineGetParameterengineGetParametersengineInitSignengineInitSignengineInitVerifyengineSetParameterengineSetParameterengineSignengineUpdateengineUpdateengineUpdateengineVerify

Constructor Detail

MD2withRSAback to summary
public MD2withRSA()
sun.security.rsa back to summary

public final Class RSASignature.MD5withRSA

extends RSASignature
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from sun.security.rsa.RSASignature:
engineGetParameterengineGetParametersengineInitSignengineInitSignengineInitVerifyengineSetParameterengineSetParameterengineSignengineUpdateengineUpdateengineUpdateengineVerify

Constructor Detail

MD5withRSAback to summary
public MD5withRSA()
sun.security.rsa back to summary

public final Class RSASignature.SHA1withRSA

extends RSASignature
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from sun.security.rsa.RSASignature:
engineGetParameterengineGetParametersengineInitSignengineInitSignengineInitVerifyengineSetParameterengineSetParameterengineSignengineUpdateengineUpdateengineUpdateengineVerify

Constructor Detail

SHA1withRSAback to summary
public SHA1withRSA()
sun.security.rsa back to summary

public final Class RSASignature.SHA224withRSA

extends RSASignature
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from sun.security.rsa.RSASignature:
engineGetParameterengineGetParametersengineInitSignengineInitSignengineInitVerifyengineSetParameterengineSetParameterengineSignengineUpdateengineUpdateengineUpdateengineVerify

Constructor Detail

SHA224withRSAback to summary
public SHA224withRSA()
sun.security.rsa back to summary

public final Class RSASignature.SHA256withRSA

extends RSASignature
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from sun.security.rsa.RSASignature:
engineGetParameterengineGetParametersengineInitSignengineInitSignengineInitVerifyengineSetParameterengineSetParameterengineSignengineUpdateengineUpdateengineUpdateengineVerify

Constructor Detail

SHA256withRSAback to summary
public SHA256withRSA()
sun.security.rsa back to summary

public final Class RSASignature.SHA384withRSA

extends RSASignature
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from sun.security.rsa.RSASignature:
engineGetParameterengineGetParametersengineInitSignengineInitSignengineInitVerifyengineSetParameterengineSetParameterengineSignengineUpdateengineUpdateengineUpdateengineVerify

Constructor Detail

SHA384withRSAback to summary
public SHA384withRSA()
sun.security.rsa back to summary

public final Class RSASignature.SHA3_224withRSA

extends RSASignature
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from sun.security.rsa.RSASignature:
engineGetParameterengineGetParametersengineInitSignengineInitSignengineInitVerifyengineSetParameterengineSetParameterengineSignengineUpdateengineUpdateengineUpdateengineVerify

Constructor Detail

SHA3_224withRSAback to summary
public SHA3_224withRSA()
sun.security.rsa back to summary

public final Class RSASignature.SHA3_256withRSA

extends RSASignature
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from sun.security.rsa.RSASignature:
engineGetParameterengineGetParametersengineInitSignengineInitSignengineInitVerifyengineSetParameterengineSetParameterengineSignengineUpdateengineUpdateengineUpdateengineVerify

Constructor Detail

SHA3_256withRSAback to summary
public SHA3_256withRSA()
sun.security.rsa back to summary

public final Class RSASignature.SHA3_384withRSA

extends RSASignature
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from sun.security.rsa.RSASignature:
engineGetParameterengineGetParametersengineInitSignengineInitSignengineInitVerifyengineSetParameterengineSetParameterengineSignengineUpdateengineUpdateengineUpdateengineVerify

Constructor Detail

SHA3_384withRSAback to summary
public SHA3_384withRSA()
sun.security.rsa back to summary

public final Class RSASignature.SHA3_512withRSA

extends RSASignature
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from sun.security.rsa.RSASignature:
engineGetParameterengineGetParametersengineInitSignengineInitSignengineInitVerifyengineSetParameterengineSetParameterengineSignengineUpdateengineUpdateengineUpdateengineVerify

Constructor Detail

SHA3_512withRSAback to summary
public SHA3_512withRSA()
sun.security.rsa back to summary

public final Class RSASignature.SHA512_224withRSA

extends RSASignature
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from sun.security.rsa.RSASignature:
engineGetParameterengineGetParametersengineInitSignengineInitSignengineInitVerifyengineSetParameterengineSetParameterengineSignengineUpdateengineUpdateengineUpdateengineVerify

Constructor Detail

SHA512_224withRSAback to summary
public SHA512_224withRSA()
sun.security.rsa back to summary

public final Class RSASignature.SHA512_256withRSA

extends RSASignature
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from sun.security.rsa.RSASignature:
engineGetParameterengineGetParametersengineInitSignengineInitSignengineInitVerifyengineSetParameterengineSetParameterengineSignengineUpdateengineUpdateengineUpdateengineVerify

Constructor Detail

SHA512_256withRSAback to summary
public SHA512_256withRSA()
sun.security.rsa back to summary

public final Class RSASignature.SHA512withRSA

extends RSASignature
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from sun.security.rsa.RSASignature:
engineGetParameterengineGetParametersengineInitSignengineInitSignengineInitVerifyengineSetParameterengineSetParameterengineSignengineUpdateengineUpdateengineUpdateengineVerify

Constructor Detail

SHA512withRSAback to summary
public SHA512withRSA()