Top Description Fields Constructors Methods
org.bouncycastle.jcajce.spec

public Class OpenSSHPrivateKeySpec

extends EncodedKeySpec
Class Inheritance
Imports
java.security.spec.EncodedKeySpec

OpenSSHPrivateKeySpec holds and encoded OpenSSH private key. The format of the key can be either ASN.1 or OpenSSH.

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
public
OpenSSHPrivateKeySpec(byte[]
The encoded key.
encodedKey
)

Accept an encoded key and determine the format.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the format OpenSSH or ASN.1
getFormat
()

Implements abstract java.security.spec.EncodedKeySpec.getFormat.

Return the format, either OpenSSH for the OpenSSH propriety format or ASN.1.
Inherited from java.security.spec.EncodedKeySpec:
getAlgorithmgetEncoded

Field Detail

formatback to summary
private final String format

Constructor Detail

OpenSSHPrivateKeySpecback to summary
public OpenSSHPrivateKeySpec(byte[] encodedKey)

Accept an encoded key and determine the format.

The encoded key should be the Base64 decoded blob between the "---BEGIN and ---END" markers. This constructor will endeavour to find the OpenSSH format magic value. If it can not then it will default to ASN.1. It does not attempt to validate the ASN.1

Example: OpenSSHPrivateKeySpec privSpec = new OpenSSHPrivateKeySpec(rawPriv);

KeyFactory kpf = KeyFactory.getInstance("RSA", "BC"); PrivateKey prk = kpf.generatePrivate(privSpec);

OpenSSHPrivateKeySpec rcPrivateSpec = kpf.getKeySpec(prk, OpenSSHPrivateKeySpec.class);

Parameters
encodedKey:byte[]

The encoded key.

Method Detail

getFormatback to summary
public String getFormat()

Implements abstract java.security.spec.EncodedKeySpec.getFormat.

Return the format, either OpenSSH for the OpenSSH propriety format or ASN.1.

Returns:String

the format OpenSSH or ASN.1