|
Bouncy Castle Cryptography Library 1.85 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.bouncycastle.crypto.util.OpenSSHPrivateKeyUtil
A collection of utility methods for parsing OpenSSH private keys.
| Method Summary | |
static byte[] |
encodePrivateKey(AsymmetricKeyParameter params)
Encode a cipher parameters into an OpenSSH private key. |
static AsymmetricKeyParameter |
parsePrivateKeyBlob(byte[] blob)
Parse a private key. |
static AsymmetricKeyParameter |
parsePrivateKeyBlob(byte[] blob,
byte[] passphrase)
Parse a private key, decrypting it with the supplied passphrase if it is a passphrase-protected key. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static byte[] encodePrivateKey(AsymmetricKeyParameter params)
throws java.io.IOException
params - the cipher parameters.
java.io.IOExceptionpublic static AsymmetricKeyParameter parsePrivateKeyBlob(byte[] blob)
This method accepts the body of the OpenSSH private key. The easiest way to extract the body is to use PemReader, for example:
byte[] blob = new PemReader([reader]).readPemObject().getContent(); CipherParameters params = parsePrivateKeyBlob(blob);
blob - The key.
public static AsymmetricKeyParameter parsePrivateKeyBlob(byte[] blob,
byte[] passphrase)
This method accepts the body of the OpenSSH private key (see
parsePrivateKeyBlob(byte[]) for how to extract it from PEM). For an
unencrypted key is ignored and may be ; for an
encrypted key it must carry the passphrase bytes (the OpenSSH client uses the raw
UTF-8 bytes). The KDF and the OpenSSH cipher suite
(aes128/192/256-ctr, aes128/192/256-cbc, 3des-cbc, aes128/256-gcm@openssh.com and
chacha20-poly1305@openssh.com) are supported.
blob - The key.passphrase - The passphrase bytes, or for an unencrypted key. The
array is not modified; the caller is responsible for clearing it.
|
Bouncy Castle Cryptography Library 1.85 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||