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

public abstract Class NamedSignature

extends SignatureSpi
Class Inheritance
Known Direct Subclasses
sun.security.provider.ML_DSA_Impls.SIG
Imports
sun.security.pkcs.NamedPKCS8Key, sun.security.x509.NamedX509Key, java.io.ByteArrayOutputStream, java.security.AlgorithmParameters, .InvalidAlgorithmParameterException, .InvalidKeyException, .InvalidParameterException, .PrivateKey, .ProviderException, .PublicKey, .SecureRandom, .SignatureException, .SignatureSpi, java.security.spec.AlgorithmParameterSpec

A base class for all Signature implementations that can be configured with a named parameter set. See NamedKeyPairGenerator for more details.

This class does not work with preHash signatures.

Field Summary

Modifier and TypeField and Description
private final ByteArrayOutputStream
private final NamedKeyFactory
private final String
private Object
private String
private byte[]
private byte[]
private Object
Inherited from java.security.SignatureSpi:
appRandom

Constructor Summary

AccessConstructor and Description
protected
NamedSignature(String
the family name
fname
,
NamedKeyFactory
the KeyFactory used to translate foreign keys and perform key validation
fac
)

Creates a new NamedSignature object.

Method Summary

Modifier and TypeMethod and Description
protected Object
engineGetParameter(String 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 privateKey)

Implements abstract java.security.SignatureSpi.engineInitSign.

Initializes this Signature object with the specified private key 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.

Deprecated

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[] sig)

Implements abstract java.security.SignatureSpi.engineVerify.

Verifies the passed-in signature.

protected Object

Returns:

a parsed key, null if none.
implCheckPrivateKey
(String
parameter name
pname
,
byte[]
private key in raw bytes
sk
)

User-defined function to validate a private key.

protected Object

Returns:

a parsed key, null if none.
implCheckPublicKey
(String
parameter name
pname
,
byte[]
public key in raw bytes
pk
)

User-defined function to validate a public key.

protected abstract byte[]

Returns:

the signature
implSign
(String
parameter name
pname
,
byte[]
private key in raw bytes
sk
,
Object
parsed private key, null if none. See implCheckPrivateKey.
sk2
,
byte[]
the message
msg
,
SecureRandom
SecureRandom object, null if not initialized
sr
)

User-defined sign function.

protected abstract boolean

Returns:

true if verified
implVerify
(String
parameter name
pname
,
byte[]
public key in raw bytes
pk
,
Object
parsed public key, null if none. See implCheckPublicKey.
pk2
,
byte[]
the message
msg
,
byte[]
the signature
sig
)

User-defined verify function.

Inherited from java.security.SignatureSpi:
cloneengineInitSignengineSignengineUpdateengineVerify

Field Detail

boutback to summary
private final ByteArrayOutputStream bout
facback to summary
private final NamedKeyFactory fac
fnameback to summary
private final String fname
pk2back to summary
private Object pk2
pnameback to summary
private String pname
pubKeyback to summary
private byte[] pubKey
secKeyback to summary
private byte[] secKey
sk2back to summary
private Object sk2

Constructor Detail

NamedSignatureback to summary
protected NamedSignature(String fname, NamedKeyFactory fac)

Creates a new NamedSignature object.

Parameters
fname:String

the family name

fac:NamedKeyFactory

the KeyFactory used to translate foreign keys and perform key validation

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.

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

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.

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

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.

Annotations
@Override
Exceptions
SignatureException:
if the engine is not initialized properly
engineVerifyback to summary
protected boolean engineVerify(byte[] sig) 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.
implCheckPrivateKeyback to summary
protected Object implCheckPrivateKey(String pname, byte[] sk) throws InvalidKeyException

User-defined function to validate a private key.

This method will be called in initSign. This gives the provider a chance to reject the key so an InvalidKeyException can be thrown earlier. An implementation can optionally return a "parsed key" as an Object value. This object will be passed into the implSign method along with the raw key.

The default implementation returns null.

Parameters
pname:String

parameter name

sk:byte[]

private key in raw bytes

Returns:Object

a parsed key, null if none.

Exceptions
InvalidKeyException:
if the key is invalid
implCheckPublicKeyback to summary
protected Object implCheckPublicKey(String pname, byte[] pk) throws InvalidKeyException

User-defined function to validate a public key.

This method will be called in initVerify. This gives the provider a chance to reject the key so an InvalidKeyException can be thrown earlier. An implementation can optionally return a "parsed key" as an Object value. This object will be passed into the implVerify method along with the raw key.

The default implementation returns null.

Parameters
pname:String

parameter name

pk:byte[]

public key in raw bytes

Returns:Object

a parsed key, null if none.

Exceptions
InvalidKeyException:
if the key is invalid
implSignback to summary
protected abstract byte[] implSign(String pname, byte[] sk, Object sk2, byte[] msg, SecureRandom sr) throws SignatureException

User-defined sign function.

Parameters
pname:String

parameter name

sk:byte[]

private key in raw bytes

sk2:Object

parsed private key, null if none. See implCheckPrivateKey.

msg:byte[]

the message

sr:SecureRandom

SecureRandom object, null if not initialized

Returns:byte[]

the signature

Exceptions
SignatureException:
if there is another error
ProviderException:
if there is an internal error
implVerifyback to summary
protected abstract boolean implVerify(String pname, byte[] pk, Object pk2, byte[] msg, byte[] sig) throws SignatureException

User-defined verify function.

Parameters
pname:String

parameter name

pk:byte[]

public key in raw bytes

pk2:Object

parsed public key, null if none. See implCheckPublicKey.

msg:byte[]

the message

sig:byte[]

the signature

Returns:boolean

true if verified

Exceptions
SignatureException:
if there is another error
ProviderException:
if there is an internal error