com.sshtools.jce
Class AbstractJCECipher
java.lang.Object
com.maverick.ssh.cipher.SshCipher
com.sshtools.jce.AbstractJCECipher
- Direct Known Subclasses:
- AES128Cbc, BlowfishCbc, TripleDesCbc
- public class AbstractJCECipher
- extends SshCipher
An abstract base class for defining SSH2 ciphers which use a JCE
provider instead of the internal Maverick Crypto provider. Take a look
at JCEProviderMapping
to learn more about how to configure
which providers are in use for any given algorithm.
Simply create an extended class as follows:
public class BlowfishCbc extends AbstractJCECipher {
public BlowfishCbc() {
super("Blowfish/CBC/NoPadding", "Blowfish", 16);
}
}
Then to install the cipher for use:
SshConnector con = SshConnector.getInstance();
Ssh2Context context = (Ssh2Context)con.getContext(SshConnector.SSH2);
// Add our new implementation
context.supportedCiphers().add("blowfish-cbc", BlowfishCbc.class);
- Author:
- Lee David Painter
Constructor Summary |
AbstractJCECipher(java.lang.String spec,
java.lang.String keyspec,
int keylength,
java.lang.String algorithm)
|
Method Summary |
int |
getBlockSize()
Get the cipher block size. |
void |
init(int mode,
byte[] iv,
byte[] keydata)
Initialize the cipher with up to 40 bytes of iv and key data. |
void |
transform(byte[] buf,
int start,
byte[] output,
int off,
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 |
AbstractJCECipher
public AbstractJCECipher(java.lang.String spec,
java.lang.String keyspec,
int keylength,
java.lang.String algorithm)
- Parameters:
spec
- the value passed into Cipher.getInstance() that specifies the
specification of the cipher; for example "Blowfish/CBC/NoPadding"keyspec
- the value passed into the constructor of SecretKeySpec.keylength
- int the length in bytes of the key
transform
public void transform(byte[] buf,
int start,
byte[] output,
int off,
int len)
throws java.io.IOException
- Description copied from class:
SshCipher
- 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 class SshCipher
- Parameters:
off
- len
-
- Returns:
- the transformed data
- Throws:
java.io.IOException
init
public void init(int mode,
byte[] iv,
byte[] keydata)
throws java.io.IOException
- Description copied from class:
SshCipher
- 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 class SshCipher
- Parameters:
mode
- the mode to operateiv
- the initiaization vectorkeydata
- the key data
- Throws:
java.io.IOException
getBlockSize
public int getBlockSize()
- Description copied from class:
SshCipher
- Get the cipher block size.
- Specified by:
getBlockSize
in class SshCipher
- Returns:
- the block size in bytes.
Copyright © 2003 3SP LTD. All Rights Reserved.