Top Description Fields Constructors Methods
sun.security.rsa

public final Class RSAPrivateCrtKeyImpl

extends PKCS8Key
implements RSAPrivateCrtKey
Class Inheritance
All Implemented Interfaces
java.security.interfaces.RSAPrivateCrtKey, java.security.interfaces.RSAPrivateKey, java.security.interfaces.RSAKey, java.security.PrivateKey, javax.security.auth.Destroyable, java.security.AsymmetricKey, java.security.Key, java.io.Serializable
Imports
java.io.IOException, .InvalidObjectException, .ObjectInputStream, java.math.BigInteger, java.security.*, java.security.spec.*, java.security.interfaces.*, java.util.Arrays, sun.security.util.*, sun.security.pkcs.PKCS8Key, sun.security.rsa.RSAUtil.KeyType

RSA private key implementation for "RSA", "RSASSA-PSS" algorithms in CRT form. For non-CRT private keys, see RSAPrivateKeyImpl. We need separate classes to ensure correct behavior in instanceof checks, etc.

Note

RSA keys must be at least 512 bits long

Author
Andreas Sterbenz
Since
1.5
See Also
RSAPrivateKeyImpl, RSAKeyFactory

Field Summary

Modifier and TypeField and Description
private BigInteger
private BigInteger
d

private BigInteger
e

private final transient AlgorithmParameterSpec
private BigInteger
n

private BigInteger
p

private BigInteger
private BigInteger
q

private BigInteger
private static final long
private final transient RSAUtil.KeyType
Inherited from sun.security.pkcs.PKCS8Key:
algidencodedKeykey

Constructor Summary

AccessConstructor and Description
private
RSAPrivateCrtKeyImpl(byte[] encoded)

Construct a key from its encoding.

pack-priv
RSAPrivateCrtKeyImpl(RSAUtil.KeyType type, AlgorithmParameterSpec keyParams, BigInteger n, BigInteger e, BigInteger d, BigInteger p, BigInteger q, BigInteger pe, BigInteger qe, BigInteger coeff)

Construct an RSA key from its components.

Method Summary

Modifier and TypeMethod and Description
pack-priv static boolean
checkComponents(RSAPrivateCrtKey key)

Validate if all CRT-specific components are available.

public String
getAlgorithm()

Overrides sun.security.pkcs.PKCS8Key.getAlgorithm.

Implements java.security.Key.getAlgorithm.

Returns the standard algorithm name for this key.
public BigInteger
public BigInteger
getModulus()

Implements java.security.interfaces.RSAKey.getModulus.

Returns the modulus.
public AlgorithmParameterSpec
getParams()

Overrides default java.security.interfaces.RSAPrivateKey.getParams, java.security.AsymmetricKey.getParams.

Returns the parameters associated with this key.
public BigInteger
public BigInteger
public BigInteger
public BigInteger
public BigInteger
public BigInteger
public static RSAPrivateKey
newKey(RSAUtil.KeyType type, String format, byte[] encoded)

Generate a new RSAPrivate(Crt)Key from the specified type, format and encoding.

public static RSAPrivateKey
newKey(RSAUtil.KeyType type, AlgorithmParameterSpec params, BigInteger n, BigInteger e, BigInteger d, BigInteger p, BigInteger q, BigInteger pe, BigInteger qe, BigInteger coeff)

Generate a new key from the specified type and components.

private static BigInteger[]
parseASN1(byte[] raw)

private void
private void
readObject(ObjectInputStream
the ObjectInputStream from which data is read
stream
)

Hides sun.security.pkcs.PKCS8Key.readObject.

Restores the state of this object from the stream.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from sun.security.pkcs.PKCS8Key:
clearequalsgetAlgorithmIdgetEncodedgetFormathashCodeparseKeywriteReplace

Field Detail

coeffback to summary
private BigInteger coeff
dback to summary
private BigInteger d
eback to summary
private BigInteger e
keyParamsback to summary
private final transient AlgorithmParameterSpec keyParams
nback to summary
private BigInteger n
pback to summary
private BigInteger p
peback to summary
private BigInteger pe
qback to summary
private BigInteger q
qeback to summary
private BigInteger qe
serialVersionUIDback to summary
private static final long serialVersionUID

Hides sun.security.pkcs.PKCS8Key.serialVersionUID, java.security.interfaces.RSAPrivateCrtKey.serialVersionUID, java.security.PrivateKey.serialVersionUID.

Annotations
@Serial
typeback to summary
private final transient RSAUtil.KeyType type

Constructor Detail

RSAPrivateCrtKeyImplback to summary
private RSAPrivateCrtKeyImpl(byte[] encoded) throws InvalidKeyException

Construct a key from its encoding. Called from newKey above.

RSAPrivateCrtKeyImplback to summary
pack-priv RSAPrivateCrtKeyImpl(RSAUtil.KeyType type, AlgorithmParameterSpec keyParams, BigInteger n, BigInteger e, BigInteger d, BigInteger p, BigInteger q, BigInteger pe, BigInteger qe, BigInteger coeff) throws InvalidKeyException

Construct an RSA key from its components. Used by the RSAKeyFactory and the RSAKeyPairGenerator.

Method Detail

checkComponentsback to summary
pack-priv static boolean checkComponents(RSAPrivateCrtKey key)

Validate if all CRT-specific components are available.

getAlgorithmback to summary
public String getAlgorithm()

Overrides sun.security.pkcs.PKCS8Key.getAlgorithm.

Implements java.security.Key.getAlgorithm.

Doc from java.security.Key.getAlgorithm.

Returns the standard algorithm name for this key. For example, "DSA" would indicate that this key is a DSA key. See the key related sections (KeyFactory, KeyGenerator, KeyPairGenerator, and SecretKeyFactory) in the Java Security Standard Algorithm Names Specification for information about standard key algorithm names.

Returns:String

the name of the algorithm associated with this key.

Annotations
@Override
getCrtCoefficientback to summary
public BigInteger getCrtCoefficient()

Implements java.security.interfaces.RSAPrivateCrtKey.getCrtCoefficient.

Doc from java.security.interfaces.RSAPrivateCrtKey.getCrtCoefficient.

Returns the crtCoefficient.

Returns:BigInteger

the crtCoefficient

Annotations
@Override
getModulusback to summary
public BigInteger getModulus()

Implements java.security.interfaces.RSAKey.getModulus.

Doc from java.security.interfaces.RSAKey.getModulus.

Returns the modulus.

Returns:BigInteger

the modulus

Annotations
@Override
getParamsback to summary
public AlgorithmParameterSpec getParams()

Overrides default java.security.interfaces.RSAPrivateKey.getParams, java.security.AsymmetricKey.getParams.

Doc from java.security.interfaces.RSAPrivateKey.getParams.

Returns the parameters associated with this key. The parameters are optional and may be either explicitly specified or implicitly created during key pair generation.

Returns:AlgorithmParameterSpec

the associated parameters, may be null

Annotations
@Override
getPrimeExponentPback to summary
public BigInteger getPrimeExponentP()

Implements java.security.interfaces.RSAPrivateCrtKey.getPrimeExponentP.

Doc from java.security.interfaces.RSAPrivateCrtKey.getPrimeExponentP.

Returns the primeExponentP.

Returns:BigInteger

the primeExponentP

Annotations
@Override
getPrimeExponentQback to summary
public BigInteger getPrimeExponentQ()

Implements java.security.interfaces.RSAPrivateCrtKey.getPrimeExponentQ.

Doc from java.security.interfaces.RSAPrivateCrtKey.getPrimeExponentQ.

Returns the primeExponentQ.

Returns:BigInteger

the primeExponentQ

Annotations
@Override
getPrimePback to summary
public BigInteger getPrimeP()

Implements java.security.interfaces.RSAPrivateCrtKey.getPrimeP.

Doc from java.security.interfaces.RSAPrivateCrtKey.getPrimeP.

Returns the primeP.

Returns:BigInteger

the primeP

Annotations
@Override
getPrimeQback to summary
public BigInteger getPrimeQ()

Implements java.security.interfaces.RSAPrivateCrtKey.getPrimeQ.

Doc from java.security.interfaces.RSAPrivateCrtKey.getPrimeQ.

Returns the primeQ.

Returns:BigInteger

the primeQ

Annotations
@Override
getPrivateExponentback to summary
public BigInteger getPrivateExponent()

Implements java.security.interfaces.RSAPrivateKey.getPrivateExponent.

Doc from java.security.interfaces.RSAPrivateKey.getPrivateExponent.

Returns the private exponent.

Returns:BigInteger

the private exponent

Annotations
@Override
getPublicExponentback to summary
public BigInteger getPublicExponent()

Implements java.security.interfaces.RSAPrivateCrtKey.getPublicExponent.

Doc from java.security.interfaces.RSAPrivateCrtKey.getPublicExponent.

Returns the public exponent.

Returns:BigInteger

the public exponent

Annotations
@Override
newKeyback to summary
public static RSAPrivateKey newKey(RSAUtil.KeyType type, String format, byte[] encoded) throws InvalidKeyException

Generate a new RSAPrivate(Crt)Key from the specified type, format and encoding. Returns a CRT key if possible and a non-CRT key otherwise. Also used by SunPKCS11 provider.

newKeyback to summary
public static RSAPrivateKey newKey(RSAUtil.KeyType type, AlgorithmParameterSpec params, BigInteger n, BigInteger e, BigInteger d, BigInteger p, BigInteger q, BigInteger pe, BigInteger qe, BigInteger coeff) throws InvalidKeyException

Generate a new key from the specified type and components. Returns a CRT key if possible and a non-CRT key otherwise. Used by SunPKCS11 provider.

parseASN1back to summary
private static BigInteger[] parseASN1(byte[] raw) throws IOException
parseKeyBitsback to summary
private void parseKeyBits() throws InvalidKeyException
readObjectback to summary
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException

Hides sun.security.pkcs.PKCS8Key.readObject.

Restores the state of this object from the stream.

Deserialization of this object is not supported.

Parameters
stream:ObjectInputStream

the ObjectInputStream from which data is read

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs
ClassNotFoundException:
if a serialized class cannot be loaded
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override