Top Description Fields Constructors Methods
sun.security.rsa

public final Class RSAPublicKeyImpl

extends X509Key
implements RSAPublicKey
Class Inheritance
All Implemented Interfaces
java.security.interfaces.RSAPublicKey, java.security.interfaces.RSAKey, java.security.PublicKey, 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.*, sun.security.util.*, sun.security.x509.X509Key, sun.security.rsa.RSAUtil.KeyType

RSA public key implementation for "RSA", "RSASSA-PSS" algorithms.

Note

RSA keys must be at least 512 bits long

Author
Andreas Sterbenz
Since
1.5
See Also
RSAPrivateCrtKeyImpl, RSAPrivateKeyImpl, RSAKeyFactory

Field Summary

Modifier and TypeField and Description
private BigInteger
e

private final transient AlgorithmParameterSpec
private BigInteger
n

private static final long
private static final BigInteger
private final transient RSAUtil.KeyType
Inherited from sun.security.x509.X509Key:
algidencodedKeykey

Constructor Summary

AccessConstructor and Description
pack-priv
RSAPublicKeyImpl(RSAUtil.KeyType type, AlgorithmParameterSpec keyParams, BigInteger n, BigInteger e)

Construct an RSA key from the specified type and components.

private
RSAPublicKeyImpl(byte[] encoded)

Construct a key from its encoding.

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
public String
getAlgorithm()

Overrides sun.security.x509.X509Key.getAlgorithm.

Implements java.security.Key.getAlgorithm.

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

Implements java.security.interfaces.RSAKey.getModulus.

Returns the modulus.
public AlgorithmParameterSpec
getParams()

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

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

Generate a new RSAPublicKey from the specified type, format, and encoding.

public static RSAPublicKey
newKey(RSAUtil.KeyType type, AlgorithmParameterSpec params, BigInteger n, BigInteger e)

Generate a new RSAPublicKey from the specified type and components.

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

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

Hides sun.security.x509.X509Key.readObject.

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

Overrides sun.security.x509.X509Key.toString.

Returns a string representation of the object.
private Object
Inherited from sun.security.x509.X509Key:
decodeencodeencodeequalsgetAlgorithmIdgetEncodedgetEncodedInternalgetFormatgetKeyhashCodeparsesetKey

Field Detail

eback to summary
private BigInteger e
keyParamsback to summary
private final transient AlgorithmParameterSpec keyParams
nback to summary
private BigInteger n
serialVersionUIDback to summary
private static final long serialVersionUID

Hides sun.security.x509.X509Key.serialVersionUID, java.security.interfaces.RSAPublicKey.serialVersionUID, java.security.PublicKey.serialVersionUID.

Annotations
@Serial
THREEback to summary
private static final BigInteger THREE
typeback to summary
private final transient RSAUtil.KeyType type

Constructor Detail

RSAPublicKeyImplback to summary
pack-priv RSAPublicKeyImpl(RSAUtil.KeyType type, AlgorithmParameterSpec keyParams, BigInteger n, BigInteger e) throws InvalidKeyException

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

RSAPublicKeyImplback to summary
private RSAPublicKeyImpl(byte[] encoded) throws InvalidKeyException

Construct a key from its encoding.

Method Detail

checkExponentRangeback to summary
pack-priv static void checkExponentRange(BigInteger mod, BigInteger exp) throws InvalidKeyException
getAlgorithmback to summary
public String getAlgorithm()

Overrides sun.security.x509.X509Key.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
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.RSAPublicKey.getParams, java.security.AsymmetricKey.getParams.

Doc from java.security.interfaces.RSAPublicKey.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
getPublicExponentback to summary
public BigInteger getPublicExponent()

Implements java.security.interfaces.RSAPublicKey.getPublicExponent.

Doc from java.security.interfaces.RSAPublicKey.getPublicExponent.

Returns the public exponent.

Returns:BigInteger

the public exponent

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

Generate a new RSAPublicKey from the specified type, format, and encoding. Also used by SunPKCS11 provider.

newKeyback to summary
public static RSAPublicKey newKey(RSAUtil.KeyType type, AlgorithmParameterSpec params, BigInteger n, BigInteger e) throws InvalidKeyException

Generate a new RSAPublicKey from the specified type and components. Also used by SunPKCS11 provider.

parseASN1back to summary
private static BigInteger[] parseASN1(byte[] raw) throws IOException
parseKeyBitsback to summary
protected void parseKeyBits() throws InvalidKeyException

Overrides sun.security.x509.X509Key.parseKeyBits.

Parse the key. Called by X509Key.

Exceptions
InvalidKeyException:

Doc from sun.security.x509.X509Key.parseKeyBits.

on invalid key encodings.

readObjectback to summary
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException

Hides sun.security.x509.X509Key.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 sun.security.x509.X509Key.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
writeReplaceback to summary
private Object writeReplace() throws ObjectStreamException
Annotations
@Serial