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 Cipherprivate static final byte[]protected byte[]static final intstatic final intprotected booleanstatic final intprivate HASH(package private) static byte[][]private static final String[]private static final String[]private static final String[]private byte[](package private) JSchprivate byte[]private byte[]protected Stringprivate Randomstatic final intprivate 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 bytea2b(byte c) private static byteb2a(byte c) (package private) void(package private) intcountLength(int len) booleandecrypt(byte[] _passphrase) private byte[]decrypt(byte[] data, byte[] passphrase, byte[] iv) booleanvoiddispose()private byte[]encrypt(byte[] plain, byte[][] _iv, byte[] passphrase) voidfinalize()abstract byte[]private Cipher(package private) abstract voidgenerate(int key_size) private HASHgenHash()(package private) byte[]genKey(byte[] passphrase, byte[] iv) static KeyPairgenKeyPair(JSch jsch, int type) static KeyPairgenKeyPair(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 intabstract int(package private) abstract byte[](package private) abstract byte[]byte[]Returns the blob of the public key.abstract byte[]getSignature(byte[] data) abstract Signaturebooleanstatic KeyPairstatic KeyPairstatic KeyPair(package private) static KeyPair(package private) abstract booleanparse(byte[] data) private static booleanparseHeader(Buffer buffer, Hashtable v) private static byte[]parseLines(Buffer buffer, int lines) voidsetPassphrase(byte[] passphrase) Deprecated.use #writePrivateKey(String name, byte[] passphrase)voidsetPassphrase(String passphrase) Deprecated.use #writePrivateKey(java.io.OutputStream out, byte[] passphrase)voidsetPublicKeyComment(String publicKeyComment) (package private) intwriteDATA(byte[] buf, byte n, int index, byte[] data) (package private) intwriteINTEGER(byte[] buf, int index, byte[] data) (package private) intwriteLength(byte[] data, int index, int len) (package private) intwriteOCTETSTRING(byte[] buf, int index, byte[] data) 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(package private) intwriteSEQUENCE(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:
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
-
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
-