com.mindbright.ssh2
Class SSH2Preferences

java.lang.Object
  extended bycom.mindbright.ssh2.SSH2Preferences

public class SSH2Preferences
extends java.lang.Object

This class is a container for all protocol preferences and the packet version used in the class SSH2Transport. It can be created using a hard-coded list of preferences or it can be created from a java.util.Properties instance. All preferences for algorithms are comma separated lists in order of preference (as defined in the trasport protocol spec.).

This class contains the negotiation logic to select preferences from lists of client and server preferences. It also contains the functionality to select a key exchange algorithm given the available algorithms and host key types. These functions are used from the SSH2Transport class.

!!! TODO COMPLETE THIS LIST !!! The preferences that can be set are the following:

Property nameDescription
kex-algorithmsKey exchange algorithms
server-host-key-algorithmsHost key algorithms
enc-algorithms-cli2srv Encryption algorithms client to server
enc-algorithms-srv2cli Encryption algorithms server to client
mac-algorithms-cli2srvMac algorithms client to server
mac-algorithms-srv2cliMac algorithms server to client
comp-algorithms-cli2srv Compression algorithms client to server
comp-algorithms-srv2cli Compression algorithms server to client
languages-cli2srvLanguage tags client to server
languages-srv2cliLanguage tags server to client
compressionOutgoing compression level 0-9 (default 6)
package-versionPackage version for protocol version string
aliveSeconds between keepalive packets (default 0 = no keepalive packets sent)
rx-init-win-szInitial receive window size
rx-max-pkt-szMaximum size of packets we accept
tx-max-pkt-szMaximum size of packets we send
x11-displaytX11 display MindTerm tries to connect to
queued-rx-chanEnable queuing on the receive channel
default-pkt-szDefault packet size
pkt-pool-szSize of PDU pool
term-min-latUse no-latency mode when writing to terminal
int-in-buf-szSize of internal IO buffers
queue-depthDefault depth of queues
queue-hiwaterHighwater mark for queues
log-levelDebug level 0-7
log-fileFile to write debug messages to
log-appendIf "false" then the log-file is truncated

The available algorithms are the following (provided their classes are included):

TypeAlgorithms
Key exchange diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1
Host key ssh-dss,ssh-rsa
Ciphers 3des-cbc, 3des-ecb, 3des-cfb, 3des-ofb, 3des-ctr, blowfish-cbc, blowfish-ecb, blowfish-cfb, blowfish-ofb, blowfish-ctr, aes128-cbc, aes192-cbc, aes256-cbc, aes128-ctr, aes192-ctr, aes256-ctr, twofish128-cbc, twofish128-ctr, twofish192-cbc, twofish256-cbc, cast128-cbc, cast128-ecb, cast128-cfb, cast128-ofb, idea-cbc, idea-ecb, idea-cfb, idea-ofb, arcfour
Macs hmac-sha1,hmac-md5,hmac-ripemd160,hmac-sha1-96,hmac-md5-96,hmac-ripemd160-96

See Also:
SSH2Transport, SSH2Connection

Field Summary
static java.lang.String ALIVE
           
static java.lang.String CIPHERS_C2S
           
static java.lang.String CIPHERS_S2C
           
static java.lang.String COMP_C2S
           
static java.lang.String COMP_LEVEL
           
static java.lang.String COMP_S2C
           
static java.lang.String DEFAULT_PKT_SZ
          Misc internal preferences
static java.lang.String HOST_KEY_ALG
           
static java.lang.String INT_IO_BUF_SZ
           
static java.lang.String KEX_ALGORITHMS
          Transport layer preferences
static java.lang.String LANG_C2S
           
static java.lang.String LANG_S2C
           
static java.lang.String LOG_APPEND
           
static java.lang.String LOG_FILE
           
static java.lang.String LOG_LEVEL
           
static java.lang.String MACS_C2S
           
static java.lang.String MACS_S2C
           
static java.lang.String PKG_VERSION
           
static java.lang.String PKT_POOL_SZ
           
static java.lang.String QUEUE_DEPTH
           
static java.lang.String QUEUE_HIWATER
           
static java.lang.String QUEUED_RX_CHAN
           
static java.lang.String RX_INIT_WIN_SZ
          Connection layer preferences
static java.lang.String RX_MAX_PKT_SZ
           
static java.lang.String SO_TCP_NODELAY
           
static java.lang.String SOCK_OPT
          Socket option preferences Examples: Enable TCP_NODELAY for the socket connected to the server: socketoption.transport.tcp-nodelay = true Enable TCP_NODELAY for all sockets to local forward '127.0.0.1:4711': socketoption.local.127.0.0.1.4711.tcp-nodelay = true
static java.lang.String SOCK_OPT_LOCAL
           
static java.lang.String SOCK_OPT_REMOTE
           
static java.lang.String SOCK_OPT_TRANSPORT
           
static java.lang.String TERM_MIN_LAT
           
static java.lang.String TX_MAX_PKT_SZ
           
static java.lang.String X11_DISPLAY
           
 
Constructor Summary
SSH2Preferences()
           
SSH2Preferences(java.util.Properties props)
           
 
Method Summary
 boolean canAgree(SSH2Preferences peerPrefs, boolean weAreAServer)
           
 java.lang.String getAgreedCipher(boolean transmitter, boolean weAreAServer)
           
 java.lang.String getAgreedCompression(boolean transmitter, boolean weAreAServer)
           
 java.lang.String getAgreedHostKeyAlgorithm()
           
 java.lang.String getAgreedKEXAlgorithm()
           
 java.lang.String getAgreedMac(boolean transmitter, boolean weAreAServer)
           
static int getCipherKeyLen(java.lang.String cipherName)
           
static java.util.Properties getDefaultProperties()
           
 java.lang.String getDisagreeType()
           
 int getIntPreference(java.lang.String type)
           
static int getMacKeyLen(java.lang.String macName)
           
 java.lang.String getPreference(java.lang.String type)
           
 boolean isSupported(java.lang.String type, java.lang.String item)
           
 void readFrom(SSH2TransportPDU pdu)
           
 boolean sameKEXGuess()
           
 SSH2KeyExchanger selectKEXAlgorithm(SSH2Preferences peerPrefs, boolean weAreAServer)
           
 void setPreference(java.lang.String type, java.lang.String value)
           
static java.lang.String ssh2ToJCECipher(java.lang.String prefCipher)
           
static java.lang.String ssh2ToJCEMac(java.lang.String prefMac)
           
 void writeTo(SSH2TransportPDU pdu)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PKG_VERSION

public static final java.lang.String PKG_VERSION
See Also:
Constant Field Values

KEX_ALGORITHMS

public static final java.lang.String KEX_ALGORITHMS
Transport layer preferences

See Also:
Constant Field Values

HOST_KEY_ALG

public static final java.lang.String HOST_KEY_ALG
See Also:
Constant Field Values

CIPHERS_C2S

public static final java.lang.String CIPHERS_C2S
See Also:
Constant Field Values

CIPHERS_S2C

public static final java.lang.String CIPHERS_S2C
See Also:
Constant Field Values

MACS_C2S

public static final java.lang.String MACS_C2S
See Also:
Constant Field Values

MACS_S2C

public static final java.lang.String MACS_S2C
See Also:
Constant Field Values

COMP_C2S

public static final java.lang.String COMP_C2S
See Also:
Constant Field Values

COMP_S2C

public static final java.lang.String COMP_S2C
See Also:
Constant Field Values

LANG_C2S

public static final java.lang.String LANG_C2S
See Also:
Constant Field Values

LANG_S2C

public static final java.lang.String LANG_S2C
See Also:
Constant Field Values

COMP_LEVEL

public static final java.lang.String COMP_LEVEL
See Also:
Constant Field Values

ALIVE

public static final java.lang.String ALIVE
See Also:
Constant Field Values

RX_INIT_WIN_SZ

public static final java.lang.String RX_INIT_WIN_SZ
Connection layer preferences

See Also:
Constant Field Values

RX_MAX_PKT_SZ

public static final java.lang.String RX_MAX_PKT_SZ
See Also:
Constant Field Values

TX_MAX_PKT_SZ

public static final java.lang.String TX_MAX_PKT_SZ
See Also:
Constant Field Values

X11_DISPLAY

public static final java.lang.String X11_DISPLAY
See Also:
Constant Field Values

QUEUED_RX_CHAN

public static final java.lang.String QUEUED_RX_CHAN
See Also:
Constant Field Values

DEFAULT_PKT_SZ

public static final java.lang.String DEFAULT_PKT_SZ
Misc internal preferences

See Also:
Constant Field Values

PKT_POOL_SZ

public static final java.lang.String PKT_POOL_SZ
See Also:
Constant Field Values

TERM_MIN_LAT

public static final java.lang.String TERM_MIN_LAT
See Also:
Constant Field Values

INT_IO_BUF_SZ

public static final java.lang.String INT_IO_BUF_SZ
See Also:
Constant Field Values

QUEUE_DEPTH

public static final java.lang.String QUEUE_DEPTH
See Also:
Constant Field Values

QUEUE_HIWATER

public static final java.lang.String QUEUE_HIWATER
See Also:
Constant Field Values

LOG_LEVEL

public static final java.lang.String LOG_LEVEL
See Also:
Constant Field Values

LOG_FILE

public static final java.lang.String LOG_FILE
See Also:
Constant Field Values

LOG_APPEND

public static final java.lang.String LOG_APPEND
See Also:
Constant Field Values

SOCK_OPT

public static final java.lang.String SOCK_OPT
Socket option preferences Examples: Enable TCP_NODELAY for the socket connected to the server: socketoption.transport.tcp-nodelay = true Enable TCP_NODELAY for all sockets to local forward '127.0.0.1:4711': socketoption.local.127.0.0.1.4711.tcp-nodelay = true

See Also:
Constant Field Values

SOCK_OPT_TRANSPORT

public static final java.lang.String SOCK_OPT_TRANSPORT
See Also:
Constant Field Values

SOCK_OPT_LOCAL

public static final java.lang.String SOCK_OPT_LOCAL
See Also:
Constant Field Values

SOCK_OPT_REMOTE

public static final java.lang.String SOCK_OPT_REMOTE
See Also:
Constant Field Values

SO_TCP_NODELAY

public static final java.lang.String SO_TCP_NODELAY
See Also:
Constant Field Values
Constructor Detail

SSH2Preferences

public SSH2Preferences()

SSH2Preferences

public SSH2Preferences(java.util.Properties props)
Method Detail

getDefaultProperties

public static java.util.Properties getDefaultProperties()

readFrom

public void readFrom(SSH2TransportPDU pdu)

writeTo

public void writeTo(SSH2TransportPDU pdu)

getPreference

public java.lang.String getPreference(java.lang.String type)

getIntPreference

public int getIntPreference(java.lang.String type)

setPreference

public void setPreference(java.lang.String type,
                          java.lang.String value)

getAgreedKEXAlgorithm

public java.lang.String getAgreedKEXAlgorithm()

getAgreedHostKeyAlgorithm

public java.lang.String getAgreedHostKeyAlgorithm()

getAgreedCipher

public java.lang.String getAgreedCipher(boolean transmitter,
                                        boolean weAreAServer)

getAgreedMac

public java.lang.String getAgreedMac(boolean transmitter,
                                     boolean weAreAServer)

getAgreedCompression

public java.lang.String getAgreedCompression(boolean transmitter,
                                             boolean weAreAServer)

isSupported

public boolean isSupported(java.lang.String type,
                           java.lang.String item)

selectKEXAlgorithm

public SSH2KeyExchanger selectKEXAlgorithm(SSH2Preferences peerPrefs,
                                           boolean weAreAServer)
                                    throws SSH2KEXFailedException
Throws:
SSH2KEXFailedException

sameKEXGuess

public boolean sameKEXGuess()

canAgree

public boolean canAgree(SSH2Preferences peerPrefs,
                        boolean weAreAServer)

getDisagreeType

public java.lang.String getDisagreeType()

ssh2ToJCECipher

public static java.lang.String ssh2ToJCECipher(java.lang.String prefCipher)

ssh2ToJCEMac

public static java.lang.String ssh2ToJCEMac(java.lang.String prefMac)

getCipherKeyLen

public static int getCipherKeyLen(java.lang.String cipherName)

getMacKeyLen

public static int getMacKeyLen(java.lang.String macName)