Overview | Package | Class | Tree | Deprecated | Index | Help
| Oracle Security Developer Tools Crypto Java API Reference 10g Release 3 (10.1.3) B25378-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.security.crypto.core
Class RSAPrivateKey

`java.lang.Object
oracle.security.crypto.core.RSAKey
oracle.security.crypto.core.RSAPrivateKey`

All Implemented Interfaces:
  ASN1Object, java.lang.Cloneable, java.io.Externalizable, Key, PrivateKey, java.io.Serializable, Streamable

Direct Known Subclasses:
  RSAPrivateKeyPKCS8

public class RSAPrivateKey
extends RSAKey
implements PrivateKey, java.io.Externalizable

An RSA private key.

RSA private keys are output in PKCS #8 PrivateKeyInfo format, and this is also the preferred format for input. However, for backwards compatibility reasons, the PKCS #1 RSAPrivateKey format is recognized for input as well.

See Also:
  Serialized Form

Constructor Summary
`RSAPrivateKey()` Creates a new, uninitialized RSA private key.
`RSAPrivateKey(java.math.BigInteger mod, java.math.BigInteger exp)` Construct a new `RSAPrivateKey` object with the given parameters.
`RSAPrivateKey(java.math.BigInteger mod, java.math.BigInteger exp, java.math.BigInteger e, java.math.BigInteger p, java.math.BigInteger q, java.math.BigInteger e1, java.math.BigInteger e2, java.math.BigInteger c)` Construct a new `RSAPrivateKey` object with the given parameters.
`RSAPrivateKey(byte[] encoded)` Makes a new RSA private key from a specified encoding.
`RSAPrivateKey(java.io.File f)` Construct a new `RSAPrivateKey` object from a file.
`RSAPrivateKey(java.io.InputStream is)` Initializes this RSA private key by reading its encoding from the given stream.

Method Summary
`java.lang.Object` | `clone()` Creates a deep copy of this `RSAPrivateKey` instance.
`void` | `erase()` Erases the key material making the key un-usable.
`void` | `finalize()` Erases this object prior to being reclaimed by the garbage collector.
`AlgorithmIdentifier` | `getAlgID()` Returns the algorithm identifier for this key.
`ASN1Object` | `getContents()` Returns this `RSAPrivateKey`'s contents in PKCS #1 privateKey format (as opposed to PKCS #8 privateKeyInfo format).
`java.math.BigInteger` | `getCrtCoefficient()`
`java.lang.String` | `getFormat()` Returns a string which indicates the format of this object's encoding.
`java.math.BigInteger` | `getPrimeExponentP()`
`java.math.BigInteger` | `getPrimeExponentQ()`
`java.math.BigInteger` | `getPrimeP()`
`java.math.BigInteger` | `getPrimeQ()`
`java.math.BigInteger` | `getPublicExponent()`
`RSAPublicKey` | `getPublicKey()` Get the public key from this private key.
`void` | `initialize(AlgorithmIdentifier algID, ASN1Object contents)` Initializes this instance from the given algorithm paramters and key contents.
`void` | `input(java.io.InputStream is)` Reads an RSA private key from the specified input stream.
`boolean` | `isPublic()` Indicates whether this is a public key.
`int` | `length()` Length of this object's encoding.
`void` | `output(java.io.OutputStream os)` Writes the DER encoding of this key in PKCS #8 privateKeyInfo format (as opposed to PKCS #1 privateKey format) to the given output stream.
`void` | `readExternal(java.io.ObjectInput is)`
`void` | `setModulusExponent(java.math.BigInteger modulus, java.math.BigInteger exponent)` Sets the modulus and (private) exponent.
`java.lang.String` | `toString()`
`void` | `writeExternal(java.io.ObjectOutput os)`

Methods inherited from class oracle.security.crypto.core.RSAKey
`getAlgorithm, getBitLength, getEncoded, getExponent, getModulus, modulusLength, setBytes`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface oracle.security.crypto.core.Key
`getAlgorithm, getBitLength, getEncoded`

Constructor Detail

### RSAPrivateKey

    public RSAPrivateKey()

  Creates a new, uninitialized RSA private key.

### RSAPrivateKey

    public RSAPrivateKey(java.math.BigInteger mod,
                         java.math.BigInteger exp)

  Construct a new `RSAPrivateKey` object with the given parameters.

  Note: A `RSAPrivateKey` constructed using only the modulus and private exponent cannot be used to derive the corresponding public key, nor can it be output to a DER-encoded ASN.1 representation.

Parameters:
  `mod` - the modulus
  `exp` - the private exponent

### RSAPrivateKey

    public RSAPrivateKey(java.math.BigInteger mod,
                         java.math.BigInteger exp,
                         java.math.BigInteger e,
                         java.math.BigInteger p,
                         java.math.BigInteger q,
                         java.math.BigInteger e1,
                         java.math.BigInteger e2,
                         java.math.BigInteger c)

  Construct a new `RSAPrivateKey` object with the given parameters.
Parameters:
  `mod` - the modulus
  `exp` - the private exponent
  `e` - the public exponent
  `p` - a big prime p
  `q` - a big prime q
  `e1` -
  `e2` -
  `c` -

### RSAPrivateKey

    public RSAPrivateKey(java.io.File f)
                  throws java.io.FileNotFoundException,
                         java.io.IOException

  Construct a new `RSAPrivateKey` object from a file.
Parameters:
  `f` - the file that stores the RSAPrivateKey
Throws:
  `java.io.FileNotFoundException` - If the file didn't exist.
  `java.io.IOException` - If the input or output exception occured.

### RSAPrivateKey

    public RSAPrivateKey(java.io.InputStream is)
                  throws java.io.IOException

  Initializes this RSA private key by reading its encoding from the given stream.

### RSAPrivateKey

    public RSAPrivateKey(byte[] encoded)
                  throws java.io.IOException

  Makes a new RSA private key from a specified encoding.
Parameters:
  `encoded` - a BER encoding of an RSA private key

Method Detail

### initialize

    public void initialize(AlgorithmIdentifier algID,
                           ASN1Object contents)
                    throws AlgorithmIdentifierException,
                           InvalidInputException

  Description copied from interface: `PrivateKey`
  Initializes this instance from the given algorithm paramters and key contents.
  Specified by:
    `initialize` in interface `PrivateKey`
  Throws:
    `AlgorithmIdentifierException`
    `InvalidInputException`

### setModulusExponent

    public void setModulusExponent(java.math.BigInteger modulus,
                                   java.math.BigInteger exponent)

  Sets the modulus and (private) exponent.
  Overrides:
    `setModulusExponent` in class `RSAKey`

### isPublic

    public boolean isPublic()

  Indicates whether this is a public key.
  Specified by:
    `isPublic` in class `RSAKey`
  Returns:
    always returns `false`

### getPublicKey

    public RSAPublicKey getPublicKey()

  Get the public key from this private key.

### getPublicExponent

    public java.math.BigInteger getPublicExponent()

### getPrimeP

    public java.math.BigInteger getPrimeP()

### getPrimeQ

    public java.math.BigInteger getPrimeQ()

### getPrimeExponentP

    public java.math.BigInteger getPrimeExponentP()

### getPrimeExponentQ

    public java.math.BigInteger getPrimeExponentQ()

### getCrtCoefficient

    public java.math.BigInteger getCrtCoefficient()

### getFormat

    public java.lang.String getFormat()

  Returns a string which indicates the format of this object's encoding.
  Specified by:
    `getFormat` in interface `Key`
  Returns:
    "PKCS#8"

### getContents

    public ASN1Object getContents()

  Returns this `RSAPrivateKey`'s contents in PKCS #1 privateKey format (as opposed to PKCS #8 privateKeyInfo format).

  To output the key in this format in DER encoding, use code like the following:

                      RSAPrivateKey key = ... ;
                      OutputStream os = ... ;
                      key.getContents().output(os);

  Specified by:
    `getContents` in interface `PrivateKey`
  See Also:
    `for PKCS #8 privateKeyInfo format.`

### getAlgID

    public AlgorithmIdentifier getAlgID()

  Description copied from interface: `PrivateKey`
  Returns the algorithm identifier for this key.
  Specified by:
    `getAlgID` in interface `PrivateKey`

### erase

    public void erase()

  Erases the key material making the key un-usable.

  Keys can be erased multiple times with no consequence.

  Specified by:
    `erase` in interface `Key`
  Overrides:
    `erase` in class `RSAKey`

### finalize

    public void finalize()

  Erases this object prior to being reclaimed by the garbage collector.

  Note: There is no guarantee of when, if ever, `finalize` will be invoked by the Java runtime.

### clone

    public java.lang.Object clone()

  Creates a deep copy of this `RSAPrivateKey` instance.
  Specified by:
    `clone` in interface `Key`
  Specified by:
    `clone` in class `RSAKey`

### input

    public void input(java.io.InputStream is)
               throws java.io.IOException

  Reads an RSA private key from the specified input stream.
  Specified by:
    `input` in interface `Streamable`
  Throws:
    `java.io.IOException`

### output

    public void output(java.io.OutputStream os)
                throws java.io.IOException

  Writes the DER encoding of this key in PKCS #8 privateKeyInfo format (as opposed to PKCS #1 privateKey format) to the given output stream.
  Specified by:
    `output` in interface `Streamable`
  Throws:
    `java.io.IOException`
  See Also:
    `for PKCS #1 privateKey format.`

### length

    public int length()

  Description copied from interface: `Streamable`
  Length of this object's encoding.
  Specified by:
    `length` in interface `Streamable`

### toString

    public java.lang.String toString()

### writeExternal

    public void writeExternal(java.io.ObjectOutput os)
                       throws java.io.IOException

  Specified by:
    `writeExternal` in interface `java.io.Externalizable`
  Throws:
    `java.io.IOException`

### readExternal

    public void readExternal(java.io.ObjectInput is)
                      throws java.io.IOException,
                             java.lang.ClassNotFoundException

  Specified by:
    `readExternal` in interface `java.io.Externalizable`
  Throws:
    `java.io.IOException`
    `java.lang.ClassNotFoundException`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Oracle Security Developer Tools Crypto Java API Reference 10g Release 3 (10.1.3) B25378-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2005, 2006 , Oracle. All rights reserved.