com.maverick.ssh.components
Class SshCipher

java.lang.Object
  extended by com.maverick.ssh.components.SshCipher
Direct Known Subclasses:
AbstractJCECipher, AES128Cbc, AES128Ctr, AES192Cbc, AES192Ctr, AES256Cbc, AES256Ctr, BlowfishCbc, CAST128Cbc, NoneCipher, Ssh1Des, Ssh1Des3, Ssh1Des3, TripleDesCbc, Twofish128Cbc, Twofish192Cbc, Twofish256Cbc

public abstract class SshCipher
extends java.lang.Object

Base class for all SSH protocol ciphers. The cipher itself has 2 modes, encryption or decrpytion. The same method is used to transporm the data depending upon the mode.

Author:
Lee David Painter

Field Summary
static int DECRYPT_MODE
          Decryption mode.
static int ENCRYPT_MODE
          Encryption mode.
 
Constructor Summary
SshCipher(java.lang.String algorithm)
           
 
Method Summary
 java.lang.String getAlgorithm()
           
abstract  int getBlockSize()
          Get the cipher block size.
abstract  void init(int mode, byte[] iv, byte[] keydata)
          Initialize the cipher with up to 40 bytes of iv and key data.
 void transform(byte[] data)
          Transform the byte array according to the cipher mode.
abstract  void transform(byte[] src, int start, byte[] dest, int offset, int len)
          Transform the byte array according to the cipher mode; it is legal for the source and destination arrays to reference the same physical array so care should be taken in the transformation process to safeguard this rule.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENCRYPT_MODE

public static final int ENCRYPT_MODE
Encryption mode.

See Also:
Constant Field Values

DECRYPT_MODE

public static final int DECRYPT_MODE
Decryption mode.

See Also:
Constant Field Values
Constructor Detail

SshCipher

public SshCipher(java.lang.String algorithm)
Method Detail

getAlgorithm

public java.lang.String getAlgorithm()

getBlockSize

public abstract int getBlockSize()
Get the cipher block size.

Returns:
the block size in bytes.

init

public abstract void init(int mode,
                          byte[] iv,
                          byte[] keydata)
                   throws java.io.IOException
Initialize the cipher with up to 40 bytes of iv and key data. Each implementation should take as much data from the initialization as it needs ignoring any data that it does not require.

Parameters:
mode - the mode to operate
iv - the initiaization vector
keydata - the key data
Throws:
java.io.IOException

transform

public void transform(byte[] data)
               throws java.io.IOException
Transform the byte array according to the cipher mode.

Parameters:
data -
Throws:
java.io.IOException

transform

public abstract void transform(byte[] src,
                               int start,
                               byte[] dest,
                               int offset,
                               int len)
                        throws java.io.IOException
Transform the byte array according to the cipher mode; it is legal for the source and destination arrays to reference the same physical array so care should be taken in the transformation process to safeguard this rule.

Parameters:
src -
start -
dest -
offset -
len -
Throws:
java.io.IOException


Copyright © 2003-2008 SSHTools LTD. All Rights Reserved.