Package org.globus.gsi.bc

# Class BouncyCastleOpenSSLKey

java.lang.Object
org.globus.gsi.OpenSSLKey
org.globus.gsi.bc.BouncyCastleOpenSSLKey

All Implemented Interfaces:
  `Serializable`

public class BouncyCastleOpenSSLKey extends OpenSSLKey
BouncyCastle-based implementation of OpenSSLKey.

Since:
  1.0
Version:
  ${version}
See Also:
  - Serialized Form

## Constructor Summary

Constructors
Constructor
Description
`BouncyCastleOpenSSLKey(InputStream is)`
Reads a OpenSSL private key from the specified input stream.
`BouncyCastleOpenSSLKey(String file)`
Reads a OpenSSL private key from the specified file.
`BouncyCastleOpenSSLKey(String algorithm, byte[] data)`
Initializes the OpenSSL key from raw byte array.
`BouncyCastleOpenSSLKey(PrivateKey key)`
Converts a RSAPrivateCrtKey into OpenSSL key.

## Method Summary

Modifier and Type
Method
Description
`protected byte[]`
`getEncoded(PrivateKey key)`
`protected PrivateKey`
`getKey(String alg, byte[] data)`
`protected String`
`getProvider()`

### Methods inherited from class org.globus.gsi.OpenSSLKey

`decrypt, decrypt, encrypt, encrypt, equals, getEncoded, getPrivateKey, hashCode, isEncrypted, setEncryptionAlgorithm, writeTo, writeTo, writeTo`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### BouncyCastleOpenSSLKey

public BouncyCastleOpenSSLKey(InputStream is) throws IOException, GeneralSecurityException
Reads a OpenSSL private key from the specified input stream. The private key must be PEM encoded and can be encrypted.

Parameters:
  `is` - input stream with OpenSSL key in PEM format.
Throws:
  `IOException` - if I/O problems.
  `GeneralSecurityException` - if problems with the key

### BouncyCastleOpenSSLKey

public BouncyCastleOpenSSLKey(String file) throws IOException, GeneralSecurityException
Reads a OpenSSL private key from the specified file. The private key must be PEM encoded and can be encrypted.

Parameters:
  `file` - file containing the OpenSSL key in PEM format.
Throws:
  `IOException` - if I/O problems.
  `GeneralSecurityException` - if problems with the key

### BouncyCastleOpenSSLKey

public BouncyCastleOpenSSLKey(PrivateKey key)
Converts a RSAPrivateCrtKey into OpenSSL key.

Parameters:
  `key` - private key - must be a RSAPrivateCrtKey

### BouncyCastleOpenSSLKey

public BouncyCastleOpenSSLKey(String algorithm, byte[] data) throws GeneralSecurityException
Initializes the OpenSSL key from raw byte array.

Parameters:
  `algorithm` - the algorithm of the key. Currently only RSA algorithm is supported.
  `data` - the DER encoded key data. If RSA algorithm, the key must be in PKCS#1 format.
Throws:
  `GeneralSecurityException` - if any security problems.

## Method Details

### getKey

protected PrivateKey getKey(String alg, byte[] data) throws GeneralSecurityException

Specified by:
  `getKey` in class `OpenSSLKey`
Throws:
  `GeneralSecurityException`

### getEncoded

protected byte[] getEncoded(PrivateKey key)

Specified by:
  `getEncoded` in class `OpenSSLKey`

### getProvider

protected String getProvider()

Overrides:
  `getProvider` in class `OpenSSLKey`