Class KeyPair
java.lang.Object
com.jcraft.jsch.KeyPair
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleandecrypt(byte[] _passphrase) booleanvoiddispose()static byte[]extractX509SubjectPublicKeyInfo(byte[] x509SubjectPublicKeyInfo, byte[] algorithmIdentifier, int keyLen) voidfinalize()abstract byte[]static KeyPairgenKeyPair(JSch jsch, int type) static KeyPairgenKeyPair(JSch jsch, int type, int key_size) Returns the finger-print of the public key.abstract intabstract intWrapper to provide the String representation of#getKeyTypeName().byte[]Returns the blob of the public key.abstract byte[]getSignature(byte[] data) abstract byte[]getSignature(byte[] data, String alg) abstract Signatureabstract SignaturegetVerifier(String alg) booleanstatic KeyPairstatic KeyPairstatic KeyPairvoidsetPassphrase(byte[] passphrase) Deprecated.use #writePrivateKey(String name, byte[] passphrase)voidsetPassphrase(String passphrase) Deprecated.use #writePrivateKey(OutputStream out, byte[] passphrase)voidsetPublicKeyComment(String publicKeyComment) voidwriteOpenSSHv1PrivateKey(OutputStream out, byte[] passphrase) Writes the cyphered private key to the given output stream.voidwriteOpenSSHv1PrivateKey(OutputStream out, byte[] passphrase, int rounds) Writes the cyphered private key to the given output stream.voidwriteOpenSSHv1PrivateKey(OutputStream out, byte[] passphrase, String cipher) Writes the cyphered private key to the given output stream.voidwriteOpenSSHv1PrivateKey(OutputStream out, byte[] passphrase, String cipher, int rounds) Writes the cyphered private key to the given output stream.voidWrites the plain private key to the file.voidwriteOpenSSHv1PrivateKey(String name, byte[] passphrase) Writes the cyphered private key to the file.voidwriteOpenSSHv1PrivateKey(String name, byte[] passphrase, int rounds) Writes the cyphered private key to the file.voidwriteOpenSSHv1PrivateKey(String name, byte[] passphrase, String cipher) Writes the cyphered private key to the file.voidwriteOpenSSHv1PrivateKey(String name, byte[] passphrase, String cipher, int rounds) Writes the cyphered private key to the file.voidWrites the plain private key to the given output stream.voidwritePrivateKey(OutputStream out, byte[] passphrase) Writes the cyphered private key to the given output stream.voidwritePrivateKey(String name) Writes the plain private key to the file.voidwritePrivateKey(String name, byte[] passphrase) Writes the cyphered private key to the file.voidwritePublicKey(OutputStream out, String comment) Writes the public key with the specified comment to the output stream.voidwritePublicKey(String name, String comment) Writes the public key with the specified comment to the file.voidwriteSECSHPublicKey(OutputStream out, String comment) Writes the public key with the specified comment to the output stream in the format defined in http://www.ietf.org/rfc/rfc4716.txtvoidwriteSECSHPublicKey(String name, String comment) Writes the public key with the specified comment to the output stream in the format defined in http://www.ietf.org/rfc/rfc4716.txt
-
Field Details
-
DEFERRED
public static final int DEFERREDDEFERRED should not be be used.- See Also:
-
ERROR
public static final int ERROR- See Also:
-
DSA
public static final int DSA- See Also:
-
RSA
public static final int RSA- See Also:
-
ECDSA
public static final int ECDSA- See Also:
-
UNKNOWN
public static final int UNKNOWN- See Also:
-
ED25519
public static final int ED25519- See Also:
-
ED448
public static final int ED448- See Also:
-
publicKeyComment
-
cipher
-
encrypted
protected boolean encrypted -
data
protected byte[] data
-
-
Method Details
-
genKeyPair
- Throws:
JSchException
-
genKeyPair
- Throws:
JSchException
-
getKeySize
public abstract int getKeySize() -
getSignature
public abstract byte[] getSignature(byte[] data) -
getSignature
-
getVerifier
-
getVerifier
-
forSSHAgent
- Throws:
JSchException
-
getPublicKeyComment
-
setPublicKeyComment
-
writePrivateKey
Writes the plain private key to the given output stream.- Parameters:
out- output stream- See Also:
-
writePrivateKey
Writes the cyphered private key to the given output stream.- Parameters:
out- output streampassphrase- a passphrase to encrypt the private key
-
writeOpenSSHv1PrivateKey
Writes the cyphered private key to the given output stream.- Parameters:
out- output streampassphrase- a passphrase to encrypt the private key- Throws:
JSchException
-
writeOpenSSHv1PrivateKey
public void writeOpenSSHv1PrivateKey(OutputStream out, byte[] passphrase, String cipher) throws JSchException Writes the cyphered private key to the given output stream.- Parameters:
out- output streampassphrase- a passphrase to encrypt the private keycipher- the cipher to use- Throws:
JSchException
-
writeOpenSSHv1PrivateKey
public void writeOpenSSHv1PrivateKey(OutputStream out, byte[] passphrase, int rounds) throws JSchException Writes the cyphered private key to the given output stream.- Parameters:
out- output streampassphrase- a passphrase to encrypt the private keyrounds- the number of KDF rounds to use- Throws:
JSchException
-
writeOpenSSHv1PrivateKey
public void writeOpenSSHv1PrivateKey(OutputStream out, byte[] passphrase, String cipher, int rounds) throws JSchException Writes the cyphered private key to the given output stream.- Parameters:
out- output streampassphrase- a passphrase to encrypt the private keycipher- the cipher to userounds- the number of KDF rounds to use- Throws:
JSchException
-
getKeyType
public abstract int getKeyType() -
getKeyTypeString
Wrapper to provide the String representation of#getKeyTypeName().- Returns:
- the standard SSH key type string
-
getPublicKeyBlob
public byte[] getPublicKeyBlob()Returns the blob of the public key.- Returns:
- blob of the public key
-
writePublicKey
Writes the public key with the specified comment to the output stream.- Parameters:
out- output streamcomment- comment
-
writePublicKey
Writes the public key with the specified comment to the file.- Parameters:
name- file namecomment- comment- Throws:
FileNotFoundExceptionIOException- See Also:
-
writeSECSHPublicKey
Writes the public key with the specified comment to the output stream in the format defined in http://www.ietf.org/rfc/rfc4716.txt- Parameters:
out- output streamcomment- comment
-
writeSECSHPublicKey
public void writeSECSHPublicKey(String name, String comment) throws FileNotFoundException, IOException Writes the public key with the specified comment to the output stream in the format defined in http://www.ietf.org/rfc/rfc4716.txt- Parameters:
name- file namecomment- comment- Throws:
FileNotFoundExceptionIOException- See Also:
-
writePrivateKey
Writes the plain private key to the file.- Parameters:
name- file name- Throws:
FileNotFoundExceptionIOException- See Also:
-
writePrivateKey
public void writePrivateKey(String name, byte[] passphrase) throws FileNotFoundException, IOException Writes the cyphered private key to the file.- Parameters:
name- file namepassphrase- a passphrase to encrypt the private key- Throws:
FileNotFoundExceptionIOException- See Also:
-
writeOpenSSHv1PrivateKey
public void writeOpenSSHv1PrivateKey(String name) throws FileNotFoundException, IOException, JSchException Writes the plain private key to the file.- Parameters:
name- file name- Throws:
FileNotFoundExceptionIOExceptionJSchException- See Also:
-
writeOpenSSHv1PrivateKey
public void writeOpenSSHv1PrivateKey(String name, byte[] passphrase) throws FileNotFoundException, IOException, JSchException Writes the cyphered private key to the file.- Parameters:
name- file namepassphrase- a passphrase to encrypt the private key- Throws:
FileNotFoundExceptionIOExceptionJSchException- See Also:
-
writeOpenSSHv1PrivateKey
public void writeOpenSSHv1PrivateKey(String name, byte[] passphrase, int rounds) throws FileNotFoundException, IOException, JSchException Writes the cyphered private key to the file.- Parameters:
name- file namepassphrase- a passphrase to encrypt the private keyrounds- the number of KDF rounds to use- Throws:
FileNotFoundExceptionIOExceptionJSchException- See Also:
-
writeOpenSSHv1PrivateKey
public void writeOpenSSHv1PrivateKey(String name, byte[] passphrase, String cipher) throws FileNotFoundException, IOException, JSchException Writes the cyphered private key to the file.- Parameters:
name- file namepassphrase- a passphrase to encrypt the private keycipher- the cipher to use- Throws:
FileNotFoundExceptionIOExceptionJSchException- See Also:
-
writeOpenSSHv1PrivateKey
public void writeOpenSSHv1PrivateKey(String name, byte[] passphrase, String cipher, int rounds) throws FileNotFoundException, IOException, JSchException Writes the cyphered private key to the file.- Parameters:
name- file namepassphrase- a passphrase to encrypt the private keycipher- the cipher to userounds- the number of KDF rounds to use- Throws:
FileNotFoundExceptionIOExceptionJSchException- See Also:
-
getFingerPrint
-
setPassphrase
Deprecated.use #writePrivateKey(OutputStream out, byte[] passphrase) -
setPassphrase
Deprecated.use #writePrivateKey(String name, byte[] passphrase) -
isEncrypted
public boolean isEncrypted() -
decrypt
-
decrypt
public boolean decrypt(byte[] _passphrase) -
load
- Throws:
JSchException
-
load
- Throws:
JSchException
-
load
- Throws:
JSchException
-
dispose
public void dispose() -
finalize
-
extractX509SubjectPublicKeyInfo
public static byte[] extractX509SubjectPublicKeyInfo(byte[] x509SubjectPublicKeyInfo, byte[] algorithmIdentifier, int keyLen) throws JSchException - Throws:
JSchException
-