Package com.jcraft.jsch
Class KeyPair
java.lang.Object
com.jcraft.jsch.KeyPair
- Direct Known Subclasses:
KeyPairDSA
,KeyPairECDSA
,KeyPairPKCS8
,KeyPairRSA
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
decrypt
(byte[] _passphrase) boolean
void
dispose()
void
finalize()
abstract byte[]
static KeyPair
genKeyPair
(JSch jsch, int type) static KeyPair
genKeyPair
(JSch jsch, int type, int key_size) Returns the finger-print of the public key.abstract int
byte[]
Returns the blob of the public key.abstract byte[]
getSignature
(byte[] data) abstract Signature
boolean
static KeyPair
static KeyPair
static KeyPair
void
setPassphrase
(byte[] passphrase) Deprecated.use #writePrivateKey(String name, byte[] passphrase)void
setPassphrase
(String passphrase) Deprecated.use #writePrivateKey(java.io.OutputStream out, byte[] passphrase)void
setPublicKeyComment
(String publicKeyComment) void
Writes the plain private key to the given output stream.void
writePrivateKey
(OutputStream out, byte[] passphrase) Writes the cyphered private key to the given output stream.void
writePrivateKey
(String name) Writes the plain private key to the file.void
writePrivateKey
(String name, byte[] passphrase) Writes the cyphered private key to the file.void
writePublicKey
(OutputStream out, String comment) Writes the public key with the specified comment to the output stream.void
writePublicKey
(String name, String comment) Writes the public key with the specified comment to the file.void
writeSECSHPublicKey
(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.txtvoid
writeSECSHPublicKey
(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
-
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:
-
publicKeyComment
-
encrypted
protected boolean encrypted -
data
protected byte[] data
-
-
Constructor Details
-
KeyPair
-
-
Method Details
-
genKeyPair
- Throws:
JSchException
-
genKeyPair
- Throws:
JSchException
-
getSignature
public abstract byte[] getSignature(byte[] data) -
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() -
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:
FileNotFoundException
IOException
- 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:
FileNotFoundException
IOException
- See Also:
-
writePrivateKey
Writes the plain private key to the file.- Parameters:
name
- file name- Throws:
FileNotFoundException
IOException
- 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:
FileNotFoundException
IOException
- See Also:
-
getFingerPrint
Returns the finger-print of the public key.- Returns:
- finger print
-
setPassphrase
Deprecated.use #writePrivateKey(java.io.OutputStream out, byte[] passphrase) -
setPassphrase
public void setPassphrase(byte[] passphrase) 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()
-