Package com.jcraft.jsch
Class KeyPair
java.lang.Object
com.jcraft.jsch.KeyPair
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleandecrypt(byte[] _passphrase) booleanvoiddispose()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) 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
-
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:
-
getFingerPrint
Returns the finger-print of the public key.- Returns:
- finger print
-
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
public void finalize()
-