Class AbstractSshCipher

java.lang.Object
com.sshtools.common.ssh.components.AbstractSshCipher
All Implemented Interfaces:
Component, SshCipher, SshComponent, SecureComponent
Direct Known Subclasses:
AbstractJCECipher, ChaCha20Poly1305, NoneCipher

public abstract class AbstractSshCipher extends Object implements SshCipher

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
  • Constructor Details

    • AbstractSshCipher

      public AbstractSshCipher(String algorithm, SecurityLevel securityLevel, int priority)
  • Method Details

    • getSecurityLevel

      public SecurityLevel getSecurityLevel()
      Specified by:
      getSecurityLevel in interface SecureComponent
      Specified by:
      getSecurityLevel in interface SshCipher
    • getPriority

      public int getPriority()
      Specified by:
      getPriority in interface SecureComponent
      Specified by:
      getPriority in interface SshCipher
    • getAlgorithm

      public String getAlgorithm()
      Specified by:
      getAlgorithm in interface SecureComponent
      Specified by:
      getAlgorithm in interface SshCipher
      Specified by:
      getAlgorithm in interface SshComponent
    • getBlockSize

      public abstract int getBlockSize()
      Get the cipher block size.
      Specified by:
      getBlockSize in interface SshCipher
      Returns:
      the block size in bytes.
    • getKeyLength

      public abstract int getKeyLength()
      Return the key length required
      Specified by:
      getKeyLength in interface SshCipher
      Returns:
    • init

      public abstract void init(int mode, byte[] iv, byte[] keydata) throws 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.
      Specified by:
      init in interface SshCipher
      Parameters:
      mode - the mode to operate
      iv - the initiaization vector
      keydata - the key data
      Throws:
      IOException
    • transform

      public void transform(byte[] data) throws IOException
      Transform the byte array according to the cipher mode.
      Specified by:
      transform in interface SshCipher
      Parameters:
      data -
      Throws:
      IOException
    • transform

      public abstract void transform(byte[] src, int start, byte[] dest, int offset, int len) throws 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.
      Specified by:
      transform in interface SshCipher
      Parameters:
      src -
      start -
      dest -
      offset -
      len -
      Throws:
      IOException
    • isMAC

      public boolean isMAC()
      Specified by:
      isMAC in interface SshCipher
    • getMacLength

      public int getMacLength()
      Specified by:
      getMacLength in interface SshCipher
    • getProviderName

      public abstract String getProviderName()
      Specified by:
      getProviderName in interface SshCipher