Class AbstractSshCipher
java.lang.Object
com.sshtools.common.ssh.components.AbstractSshCipher
- All Implemented Interfaces:
Component,SshCipher,SshComponent,SecureComponent
- Direct Known Subclasses:
AbstractJCECipher,ChaCha20Poly1305,NoneCipher
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
Fields inherited from interface com.sshtools.common.ssh.components.SshCipher
DECRYPT_MODE, ENCRYPT_MODE -
Constructor Summary
ConstructorsConstructorDescriptionAbstractSshCipher(String algorithm, SecurityLevel securityLevel, int priority) -
Method Summary
Modifier and TypeMethodDescriptionabstract intGet the cipher block size.abstract intReturn the key length requiredintintabstract Stringabstract voidinit(int mode, byte[] iv, byte[] keydata) Initialize the cipher with up to 40 bytes of iv and key data.booleanisMAC()voidtransform(byte[] data) Transform the byte array according to the cipher mode.abstract voidtransform(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.
-
Constructor Details
-
AbstractSshCipher
-
-
Method Details
-
getSecurityLevel
- Specified by:
getSecurityLevelin interfaceSecureComponent- Specified by:
getSecurityLevelin interfaceSshCipher
-
getPriority
public int getPriority()- Specified by:
getPriorityin interfaceSecureComponent- Specified by:
getPriorityin interfaceSshCipher
-
getAlgorithm
- Specified by:
getAlgorithmin interfaceSecureComponent- Specified by:
getAlgorithmin interfaceSshCipher- Specified by:
getAlgorithmin interfaceSshComponent
-
getBlockSize
public abstract int getBlockSize()Get the cipher block size.- Specified by:
getBlockSizein interfaceSshCipher- Returns:
- the block size in bytes.
-
getKeyLength
public abstract int getKeyLength()Return the key length required- Specified by:
getKeyLengthin interfaceSshCipher- Returns:
-
init
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:
initin interfaceSshCipher- Parameters:
mode- the mode to operateiv- the initiaization vectorkeydata- the key data- Throws:
IOException
-
transform
Transform the byte array according to the cipher mode.- Specified by:
transformin interfaceSshCipher- 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:
transformin interfaceSshCipher- Parameters:
src-start-dest-offset-len-- Throws:
IOException
-
isMAC
public boolean isMAC() -
getMacLength
public int getMacLength()- Specified by:
getMacLengthin interfaceSshCipher
-
getProviderName
- Specified by:
getProviderNamein interfaceSshCipher
-