Package com.jcraft.jsch
Class KeyPair
java.lang.Object
com.jcraft.jsch.KeyPair
- Direct Known Subclasses:
KeyPairDSA
,KeyPairECDSA
,KeyPairPKCS8
,KeyPairRSA
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) class
(package private) class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Cipher
private static final byte[]
protected byte[]
static final int
static final int
protected boolean
static final int
private HASH
(package private) static byte[][]
private static final String[]
private static final String[]
private static final String[]
private byte[]
(package private) JSch
private byte[]
private byte[]
protected String
private Random
static final int
private static byte[]
static final int
(package private) int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static byte
a2b
(byte c) private static byte
b2a
(byte c) (package private) void
(package private) int
countLength
(int len) boolean
decrypt
(byte[] _passphrase) private byte[]
decrypt
(byte[] data, byte[] passphrase, byte[] iv) boolean
void
dispose()
private byte[]
encrypt
(byte[] plain, byte[][] _iv, byte[] passphrase) void
finalize()
abstract byte[]
private Cipher
(package private) abstract void
generate
(int key_size) private HASH
genHash()
(package private) byte[]
genKey
(byte[] passphrase, byte[] iv) static KeyPair
genKeyPair
(JSch jsch, int type) static KeyPair
genKeyPair
(JSch jsch, int type, int key_size) private Random
(package private) abstract byte[]
getBegin()
(package private) abstract byte[]
getEnd()
Returns the finger-print of the public key.(package private) abstract int
abstract int
(package private) abstract byte[]
(package private) abstract byte[]
byte[]
Returns the blob of the public key.abstract byte[]
getSignature
(byte[] data) abstract Signature
boolean
static KeyPair
static KeyPair
static KeyPair
(package private) static KeyPair
(package private) abstract boolean
parse
(byte[] data) private static boolean
parseHeader
(Buffer buffer, Hashtable v) private static byte[]
parseLines
(Buffer buffer, int lines) 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) (package private) int
writeDATA
(byte[] buf, byte n, int index, byte[] data) (package private) int
writeINTEGER
(byte[] buf, int index, byte[] data) (package private) int
writeLength
(byte[] data, int index, int len) (package private) int
writeOCTETSTRING
(byte[] buf, int index, byte[] data) 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(package private) int
writeSEQUENCE
(byte[] buf, int index, int len)
-
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:
-
VENDOR_OPENSSH
static final int VENDOR_OPENSSH- See Also:
-
VENDOR_FSECURE
static final int VENDOR_FSECURE- See Also:
-
VENDOR_PUTTY
static final int VENDOR_PUTTY- See Also:
-
VENDOR_PKCS8
static final int VENDOR_PKCS8- See Also:
-
vendor
int vendor -
cr
private static final byte[] cr -
publicKeyComment
-
jsch
JSch jsch -
cipher
-
hash
-
random
-
passphrase
private byte[] passphrase -
header
static byte[][] header -
space
private static byte[] space -
encrypted
protected boolean encrypted -
data
protected byte[] data -
iv
private byte[] iv -
publickeyblob
private byte[] publickeyblob -
header1
-
header2
-
header3
-
-
Constructor Details
-
KeyPair
-
-
Method Details
-
genKeyPair
- Throws:
JSchException
-
genKeyPair
- Throws:
JSchException
-
generate
- Throws:
JSchException
-
getBegin
abstract byte[] getBegin() -
getEnd
abstract byte[] getEnd() -
getKeySize
abstract int getKeySize() -
getSignature
public abstract byte[] getSignature(byte[] data) -
getVerifier
-
forSSHAgent
- Throws:
JSchException
-
getPublicKeyComment
-
setPublicKeyComment
-
getPrivateKey
abstract byte[] getPrivateKey() -
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
-
getKeyTypeName
abstract byte[] getKeyTypeName() -
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
-
encrypt
private byte[] encrypt(byte[] plain, byte[][] _iv, byte[] passphrase) -
parse
abstract boolean parse(byte[] data) -
decrypt
private byte[] decrypt(byte[] data, byte[] passphrase, byte[] iv) -
writeSEQUENCE
int writeSEQUENCE(byte[] buf, int index, int len) -
writeINTEGER
int writeINTEGER(byte[] buf, int index, byte[] data) -
writeOCTETSTRING
int writeOCTETSTRING(byte[] buf, int index, byte[] data) -
writeDATA
int writeDATA(byte[] buf, byte n, int index, byte[] data) -
countLength
int countLength(int len) -
writeLength
int writeLength(byte[] data, int index, int len) -
genRandom
-
genHash
-
genCipher
-
genKey
byte[] genKey(byte[] passphrase, byte[] iv) -
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
-
a2b
private static byte a2b(byte c) -
b2a
private static byte b2a(byte c) -
dispose
public void dispose() -
finalize
public void finalize() -
loadPPK
- Throws:
JSchException
-
parseLines
-
parseHeader
-
copy
-