Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javacard.security
Interface RSAPrivateKey

All Superinterfaces:
  Key, PrivateKey

All Known Implementing Classes:
  RSAKeyImpl, RSAPrivateCrtKeyImpl

    public interface RSAPrivateKey

extends PrivateKey

The `RSAPrivateKey` class is used to sign data using the RSA algorithm in its modulus/exponent form. It may also be used by the `javacardx.crypto.Cipher` class to encrypt/decrypt messages.

When both the modulus and exponent of the key are set, the key is initialized and ready for use.

See Also:
  `RSAPublicKey`, `RSAPrivateCrtKey`, `KeyBuilder`, `Signature`, `Cipher`, `KeyEncryption`

Method Summary
`short` | `getExponent(byte[] buffer, short offset)` Returns the private exponent value of the key in plain text.
`short` | `getModulus(byte[] buffer, short offset)` Returns the modulus value of the key in plain text.
`void` | `setExponent(byte[] buffer, short offset, short length)` Sets the private exponent value of the key.
`void` | `setModulus(byte[] buffer, short offset, short length)` Sets the modulus value of the key.

Methods inherited from interface javacard.security.Key
`clearKey, getSize, getType, isInitialized`

Method Detail

### getExponent

    short getExponent(byte[] buffer,
                      short offset)
                      throws CryptoException

  Returns the private exponent value of the key in plain text. The data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte).

  Parameters:
    `buffer` - the output buffer
    `offset` - the offset into the output buffer at which the modulus value starts
  Returns:
    with the following reason code:
    - `CryptoException.UNINITIALIZED_KEY` if the private exponent value of the key has not been successfully initialized since the time the initialized state of the key was set to false.
  Throws:
    `CryptoException` - with the following reason code:
    - `CryptoException.UNINITIALIZED_KEY` if the private exponent value of the key has not been successfully initialized since the time the initialized state of the key was set to false.

### getModulus

    short getModulus(byte[] buffer,
                     short offset)
                     throws CryptoException

  Returns the modulus value of the key in plain text. The data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte).

  Parameters:
    `buffer` - the output buffer
    `offset` - the offset into the output buffer at which the modulus value starts
  Returns:
    the byte length of the modulus value returned
  Throws:
    `CryptoException` - with the following reason code:
    - `CryptoException.UNINITIALIZED_KEY` if the modulus value of the key has not been successfully initialized since the time the initialized state of the key was set to false.

### setExponent

    void setExponent(byte[] buffer,
                     short offset,
                     short length)
                     throws CryptoException

  Sets the private exponent value of the key. The plain text data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte). Input exponent data is copied into the internal representation.

  Note:

  - If the key object implements the `javacardx.crypto.KeyEncryption` interface and the `Cipher` object specified via `setKeyCipher()` is not `null`, the exponent value is decrypted using the `Cipher` object.

  Parameters:
    `buffer` - the input buffer
    `offset` - the offset into the input buffer at which the modulus value begins
    `length` - the length of the modulus
  Throws:
    `CryptoException` - with the following reason code:
    - `CryptoException.ILLEGAL_VALUE` if the input exponent data length is inconsistent with the implementation or if input data decryption is required and fails.

### setModulus

    void setModulus(byte[] buffer,
                    short offset,
                    short length)
                    throws CryptoException

  Sets the modulus value of the key. The plain text data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte). Input modulus data is copied into the internal representation.

  Note:

  - If the key object implements the `javacardx.crypto.KeyEncryption` interface and the `Cipher` object specified via `setKeyCipher()` is not `null`, the modulus value is decrypted using the `Cipher` object.

  Parameters:
    `buffer` - the input buffer
    `offset` - the offset into the input buffer at which the modulus value begins
    `length` - the length of the modulus
  Throws:
    `CryptoException` - with the following reason code:
    - `CryptoException.ILLEGAL_VALUE` if the input modulus data length is inconsistent with the implementation or if input data decryption is required and fails.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD