public class OpenSSHPrivateKeySpec
extends java.security.spec.EncodedKeySpec
Constructor and Description |
---|
OpenSSHPrivateKeySpec(byte[] encodedKey)
Accept an encoded key and determine the format.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getFormat()
Return the format, either OpenSSH for the OpenSSH propriety format or ASN.1.
|
public OpenSSHPrivateKeySpec(byte[] encodedKey)
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);
encodedKey
- The encoded key.