public abstract class

RSASignature

extends SignatureSpi
java.lang.Object
   ↳ java.security.SignatureSpi
     ↳ sun.security.rsa.RSASignature
Known Direct Subclasses

Class Overview

PKCS#1 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, SHA-256, SHA-384, and SHA-512.

Summary

Nested Classes
class RSASignature.MD2withRSA  
class RSASignature.MD5withRSA  
class RSASignature.SHA1withRSA  
class RSASignature.SHA256withRSA  
class RSASignature.SHA384withRSA  
class RSASignature.SHA512withRSA  
[Expand]
Inherited Fields
From class java.security.SignatureSpi
Public Methods
static byte[] decodeSignature(ObjectIdentifier oid, byte[] signature)
Decode the signature data.
static byte[] encodeSignature(ObjectIdentifier oid, byte[] digest)
Encode the digest, return the to-be-signed data.
Protected Methods
Object engineGetParameter(String param)
This method is deprecated. No replacement.
void engineInitSign(PrivateKey privateKey, SecureRandom random)
Initializes this signature object with the specified private key and source of randomness for signing operations.
void engineInitSign(PrivateKey privateKey)
Initializes this signature object with the specified private key for signing operations.
void engineInitVerify(PublicKey publicKey)
Initializes this signature object with the specified public key for verification operations.
void engineSetParameter(String param, Object value)
This method is deprecated. Replaced by engineSetParameter.
byte[] engineSign()
Returns the signature bytes of all the data updated so far.
void engineUpdate(byte[] b, int off, int len)
Updates the data to be signed or verified, using the specified array of bytes, starting at the specified offset.
void engineUpdate(byte b)
Updates the data to be signed or verified using the specified byte.
void engineUpdate(ByteBuffer b)
Updates the data to be signed or verified using the specified ByteBuffer.
boolean engineVerify(byte[] sigBytes)
Verifies the passed-in signature.
[Expand]
Inherited Methods
From class java.security.SignatureSpi
From class java.lang.Object

Public Methods

public static byte[] decodeSignature (ObjectIdentifier oid, byte[] signature)

Decode the signature data. Verify that the object identifier matches and return the message digest.

Throws
IOException

public static byte[] encodeSignature (ObjectIdentifier oid, byte[] digest)

Encode the digest, return the to-be-signed data. Also used by the PKCS#11 provider.

Throws
IOException

Protected Methods

protected Object engineGetParameter (String param)

This method is deprecated.
No replacement.

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 or not 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 the string name of the parameter.
Returns
  • the object that represents the parameter value, or null if there is none.

protected void engineInitSign (PrivateKey privateKey, SecureRandom random)

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 the private key of the identity whose signature will be generated.
random the source of randomness

protected void engineInitSign (PrivateKey privateKey)

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

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

protected void engineInitVerify (PublicKey publicKey)

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

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

protected void engineSetParameter (String param, Object value)

This method is deprecated.
Replaced by 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 or not 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 the string identifier of the parameter.
value the parameter value.

protected byte[] engineSign ()

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

Returns
  • the signature bytes of the signing operation's result.

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

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

Parameters
b the array of bytes
off the offset to start from in the array of bytes
len the number of bytes to use, starting at offset

protected void engineUpdate (byte b)

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

Parameters
b the byte to use for the update.

protected void engineUpdate (ByteBuffer b)

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

Parameters
b the ByteBuffer

protected boolean engineVerify (byte[] sigBytes)

Verifies the passed-in signature.

Parameters
sigBytes the signature bytes to be verified.
Returns
  • true if the signature was verified, false if not.