Package org.apache.sshd.common.cipher
Class BaseCipher
- java.lang.Object
-
- org.apache.sshd.common.cipher.BaseCipher
-
- All Implemented Interfaces:
AlgorithmNameProvider
,Cipher
,CipherInformation
,KeySizeIndicator
- Direct Known Subclasses:
BaseRC4Cipher
public class BaseCipher extends java.lang.Object implements Cipher
Base class for all Cipher implementations delegating to the JCE provider.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.sshd.common.cipher.Cipher
Cipher.Mode
-
-
Constructor Summary
Constructors Constructor Description BaseCipher(int ivsize, int kdfSize, java.lang.String algorithm, int keySize, java.lang.String transformation, int blkSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.crypto.Cipher
createCipherInstance(Cipher.Mode mode, byte[] key, byte[] iv)
java.lang.String
getAlgorithm()
int
getCipherBlockSize()
protected javax.crypto.Cipher
getCipherInstance()
int
getIVSize()
int
getKdfSize()
int
getKeySize()
java.lang.String
getTransformation()
void
init(Cipher.Mode mode, byte[] key, byte[] iv)
Initialize the cipher for encryption or decryption with the given key and initialization vectorprotected byte[]
initializeIVData(Cipher.Mode mode, byte[] iv, int reqLen)
protected byte[]
initializeKeyData(Cipher.Mode mode, byte[] key, int reqLen)
protected static byte[]
resize(byte[] data, int size)
java.lang.String
toString()
void
update(byte[] input, int inputOffset, int inputLen)
Performs in-place encryption or decryption on the given data.
-
-
-
Field Detail
-
cipher
private javax.crypto.Cipher cipher
-
ivsize
private final int ivsize
-
kdfSize
private final int kdfSize
-
algorithm
private final java.lang.String algorithm
-
keySize
private final int keySize
-
blkSize
private final int blkSize
-
transformation
private final java.lang.String transformation
-
s
private java.lang.String s
-
-
Method Detail
-
getAlgorithm
public java.lang.String getAlgorithm()
- Specified by:
getAlgorithm
in interfaceAlgorithmNameProvider
-
getKeySize
public int getKeySize()
- Specified by:
getKeySize
in interfaceKeySizeIndicator
- Returns:
- The number of bits used in the key
-
getTransformation
public java.lang.String getTransformation()
- Specified by:
getTransformation
in interfaceCipherInformation
- Returns:
- The actual transformation used - e.g., AES/CBC/NoPadding
-
getIVSize
public int getIVSize()
- Specified by:
getIVSize
in interfaceCipherInformation
- Returns:
- Size of the initialization vector (in bytes)
-
getKdfSize
public int getKdfSize()
- Specified by:
getKdfSize
in interfaceCipherInformation
- Returns:
- The block size (in bytes) used to derive the secret key for this cipher
-
getCipherBlockSize
public int getCipherBlockSize()
- Specified by:
getCipherBlockSize
in interfaceCipherInformation
- Returns:
- Size of block data used by the cipher (in bytes). For stream ciphers this value is (currently) used to indicate some average work buffer size to be used for the automatic re-keying mechanism described in RFC 4253 - Section 9
-
init
public void init(Cipher.Mode mode, byte[] key, byte[] iv) throws java.lang.Exception
Description copied from interface:Cipher
Initialize the cipher for encryption or decryption with the given key and initialization vector
-
getCipherInstance
protected javax.crypto.Cipher getCipherInstance()
-
createCipherInstance
protected javax.crypto.Cipher createCipherInstance(Cipher.Mode mode, byte[] key, byte[] iv) throws java.lang.Exception
- Throws:
java.lang.Exception
-
initializeKeyData
protected byte[] initializeKeyData(Cipher.Mode mode, byte[] key, int reqLen)
-
initializeIVData
protected byte[] initializeIVData(Cipher.Mode mode, byte[] iv, int reqLen)
-
update
public void update(byte[] input, int inputOffset, int inputLen) throws java.lang.Exception
Description copied from interface:Cipher
Performs in-place encryption or decryption on the given data.
-
resize
protected static byte[] resize(byte[] data, int size)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-