public abstract class KeyPair
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) class |
KeyPair.ASN1 |
(package private) class |
KeyPair.ASN1Exception |
Modifier and Type | Field and Description |
---|---|
private Cipher |
cipher |
private static byte[] |
cr |
protected byte[] |
data |
static int |
DSA |
static int |
ECDSA |
protected boolean |
encrypted |
static int |
ERROR |
private HASH |
hash |
(package private) static byte[][] |
header |
private static java.lang.String[] |
header1 |
private static java.lang.String[] |
header2 |
private static java.lang.String[] |
header3 |
private byte[] |
iv |
(package private) JSch |
jsch |
private byte[] |
passphrase |
private byte[] |
publickeyblob |
protected java.lang.String |
publicKeyComment |
private Random |
random |
static int |
RSA |
private static byte[] |
space |
static int |
UNKNOWN |
(package private) int |
vendor |
(package private) static int |
VENDOR_FSECURE |
(package private) static int |
VENDOR_OPENSSH |
(package private) static int |
VENDOR_PKCS8 |
(package private) static int |
VENDOR_PUTTY |
Modifier and Type | Method and Description |
---|---|
private static byte |
a2b(byte c) |
private static byte |
b2a(byte c) |
(package private) void |
copy(KeyPair kpair) |
(package private) int |
countLength(int len) |
boolean |
decrypt(byte[] _passphrase) |
private byte[] |
decrypt(byte[] data,
byte[] passphrase,
byte[] iv) |
boolean |
decrypt(java.lang.String _passphrase) |
void |
dispose() |
private byte[] |
encrypt(byte[] plain,
byte[][] _iv,
byte[] passphrase) |
void |
finalize() |
abstract byte[] |
forSSHAgent() |
private Cipher |
genCipher() |
(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 |
genRandom() |
(package private) abstract byte[] |
getBegin() |
(package private) abstract byte[] |
getEnd() |
java.lang.String |
getFingerPrint()
Returns the finger-print of the public key.
|
(package private) abstract int |
getKeySize() |
abstract int |
getKeyType() |
(package private) abstract byte[] |
getKeyTypeName() |
(package private) abstract byte[] |
getPrivateKey() |
byte[] |
getPublicKeyBlob()
Returns the blob of the public key.
|
java.lang.String |
getPublicKeyComment() |
abstract byte[] |
getSignature(byte[] data) |
abstract Signature |
getVerifier() |
boolean |
isEncrypted() |
static KeyPair |
load(JSch jsch,
byte[] prvkey,
byte[] pubkey) |
static KeyPair |
load(JSch jsch,
java.lang.String prvkey) |
static KeyPair |
load(JSch jsch,
java.lang.String prvfile,
java.lang.String pubfile) |
(package private) static KeyPair |
loadPPK(JSch jsch,
byte[] buf) |
(package private) abstract boolean |
parse(byte[] data) |
private static boolean |
parseHeader(Buffer buffer,
java.util.Hashtable v) |
private static byte[] |
parseLines(Buffer buffer,
int lines) |
void |
setPassphrase(byte[] passphrase)
Deprecated.
use #writePrivateKey(String name, byte[] passphrase)
|
void |
setPassphrase(java.lang.String passphrase)
Deprecated.
use #writePrivateKey(java.io.OutputStream out, byte[] passphrase)
|
void |
setPublicKeyComment(java.lang.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 |
writePrivateKey(java.io.OutputStream out)
Writes the plain private key to the given output stream.
|
void |
writePrivateKey(java.io.OutputStream out,
byte[] passphrase)
Writes the cyphered private key to the given output stream.
|
void |
writePrivateKey(java.lang.String name)
Writes the plain private key to the file.
|
void |
writePrivateKey(java.lang.String name,
byte[] passphrase)
Writes the cyphered private key to the file.
|
void |
writePublicKey(java.io.OutputStream out,
java.lang.String comment)
Writes the public key with the specified comment to the output stream.
|
void |
writePublicKey(java.lang.String name,
java.lang.String comment)
Writes the public key with the specified comment to the file.
|
void |
writeSECSHPublicKey(java.io.OutputStream out,
java.lang.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
|
void |
writeSECSHPublicKey(java.lang.String name,
java.lang.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) |
public static final int ERROR
public static final int DSA
public static final int RSA
public static final int ECDSA
public static final int UNKNOWN
static final int VENDOR_OPENSSH
static final int VENDOR_FSECURE
static final int VENDOR_PUTTY
static final int VENDOR_PKCS8
int vendor
private static final byte[] cr
protected java.lang.String publicKeyComment
JSch jsch
private Cipher cipher
private HASH hash
private Random random
private byte[] passphrase
static byte[][] header
private static byte[] space
protected boolean encrypted
protected byte[] data
private byte[] iv
private byte[] publickeyblob
private static final java.lang.String[] header1
private static final java.lang.String[] header2
private static final java.lang.String[] header3
public KeyPair(JSch jsch)
public static KeyPair genKeyPair(JSch jsch, int type) throws JSchException
JSchException
public static KeyPair genKeyPair(JSch jsch, int type, int key_size) throws JSchException
JSchException
abstract void generate(int key_size) throws JSchException
JSchException
abstract byte[] getBegin()
abstract byte[] getEnd()
abstract int getKeySize()
public abstract byte[] getSignature(byte[] data)
public abstract Signature getVerifier()
public abstract byte[] forSSHAgent() throws JSchException
JSchException
public java.lang.String getPublicKeyComment()
public void setPublicKeyComment(java.lang.String publicKeyComment)
abstract byte[] getPrivateKey()
public void writePrivateKey(java.io.OutputStream out)
out
- output streamwritePrivateKey(java.io.OutputStream out, byte[] passphrase)
public void writePrivateKey(java.io.OutputStream out, byte[] passphrase)
out
- output streampassphrase
- a passphrase to encrypt the private keyabstract byte[] getKeyTypeName()
public abstract int getKeyType()
public byte[] getPublicKeyBlob()
public void writePublicKey(java.io.OutputStream out, java.lang.String comment)
out
- output streamcomment
- commentpublic void writePublicKey(java.lang.String name, java.lang.String comment) throws java.io.FileNotFoundException, java.io.IOException
name
- file namecomment
- commentjava.io.FileNotFoundException
java.io.IOException
writePublicKey(java.io.OutputStream out, String comment)
public void writeSECSHPublicKey(java.io.OutputStream out, java.lang.String comment)
out
- output streamcomment
- commentpublic void writeSECSHPublicKey(java.lang.String name, java.lang.String comment) throws java.io.FileNotFoundException, java.io.IOException
name
- file namecomment
- commentjava.io.FileNotFoundException
java.io.IOException
writeSECSHPublicKey(java.io.OutputStream out, String comment)
public void writePrivateKey(java.lang.String name) throws java.io.FileNotFoundException, java.io.IOException
name
- file namejava.io.FileNotFoundException
java.io.IOException
writePrivateKey(String name, byte[] passphrase)
public void writePrivateKey(java.lang.String name, byte[] passphrase) throws java.io.FileNotFoundException, java.io.IOException
name
- file namepassphrase
- a passphrase to encrypt the private keyjava.io.FileNotFoundException
java.io.IOException
writePrivateKey(java.io.OutputStream out, byte[] passphrase)
public java.lang.String getFingerPrint()
private byte[] encrypt(byte[] plain, byte[][] _iv, byte[] passphrase)
abstract boolean parse(byte[] data)
private byte[] decrypt(byte[] data, byte[] passphrase, byte[] iv)
int writeSEQUENCE(byte[] buf, int index, int len)
int writeINTEGER(byte[] buf, int index, byte[] data)
int writeOCTETSTRING(byte[] buf, int index, byte[] data)
int writeDATA(byte[] buf, byte n, int index, byte[] data)
int countLength(int len)
int writeLength(byte[] data, int index, int len)
private Random genRandom()
private HASH genHash()
private Cipher genCipher()
byte[] genKey(byte[] passphrase, byte[] iv)
public void setPassphrase(java.lang.String passphrase)
public void setPassphrase(byte[] passphrase)
public boolean isEncrypted()
public boolean decrypt(java.lang.String _passphrase)
public boolean decrypt(byte[] _passphrase)
public static KeyPair load(JSch jsch, java.lang.String prvkey) throws JSchException
JSchException
public static KeyPair load(JSch jsch, java.lang.String prvfile, java.lang.String pubfile) throws JSchException
JSchException
public static KeyPair load(JSch jsch, byte[] prvkey, byte[] pubkey) throws JSchException
JSchException
private static byte a2b(byte c)
private static byte b2a(byte c)
public void dispose()
public void finalize()
finalize
in class java.lang.Object
static KeyPair loadPPK(JSch jsch, byte[] buf) throws JSchException
JSchException
private static byte[] parseLines(Buffer buffer, int lines)
private static boolean parseHeader(Buffer buffer, java.util.Hashtable v)
void copy(KeyPair kpair)