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:
BaseCBCCipher
,BaseCTRCipher
,BaseGCMCipher
,BaseRC4Cipher
Base class for all Cipher implementations delegating to the JCE provider.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.apache.sshd.common.cipher.Cipher
Cipher.Mode
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
(package private) static boolean
private final int
private final int
private Cipher
(package private) static BaseCipher.CipherFactory
private final int
private final int
private final int
protected Cipher.Mode
private String
private SecretKey
private final String
-
Constructor Summary
ConstructorsConstructorDescriptionBaseCipher
(int ivsize, int authSize, int kdfSize, String algorithm, int keySize, String transformation, int blkSize) -
Method Summary
Modifier and TypeMethodDescriptionprotected Cipher
createCipherInstance
(Cipher.Mode mode, byte[] key, byte[] iv) protected AlgorithmParameterSpec
determineNewParameters
(byte[] processed, int offset, int length) int
int
protected Cipher
int
int
int
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 void
reInit
(byte[] processed, int offset, int length) protected static byte[]
resize
(byte[] data, int size) toString()
void
update
(byte[] input, int inputOffset, int inputLen) Performs in-place encryption or decryption on the given data.void
updateAAD
(byte[] data, int offset, int length) Adds the provided input data as additional authenticated data during encryption or decryption.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.sshd.common.cipher.Cipher
update, updateAAD, updateWithAAD
-
Field Details
-
factory
-
alwaysReInit
static boolean alwaysReInit -
mode
-
cipher
-
ivsize
private final int ivsize -
authSize
private final int authSize -
kdfSize
private final int kdfSize -
algorithm
-
keySize
private final int keySize -
blkSize
private final int blkSize -
transformation
-
s
-
secretKey
-
-
Constructor Details
-
BaseCipher
-
-
Method Details
-
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
- 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)
-
getAuthenticationTagSize
public int getAuthenticationTagSize()- Specified by:
getAuthenticationTagSize
in interfaceCipherInformation
- Returns:
- Size of the authentication tag (AT) in bytes or 0 if this cipher does not support authentication
-
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
Description copied from interface:Cipher
Initialize the cipher for encryption or decryption with the given key and initialization vector -
getCipherInstance
-
createCipherInstance
- Throws:
Exception
-
initializeKeyData
-
initializeIVData
-
update
Description copied from interface:Cipher
Performs in-place encryption or decryption on the given data. -
reInit
protected void reInit(byte[] processed, int offset, int length) throws InvalidKeyException, InvalidAlgorithmParameterException -
determineNewParameters
-
updateAAD
Description copied from interface:Cipher
Adds the provided input data as additional authenticated data during encryption or decryption. -
resize
protected static byte[] resize(byte[] data, int size) -
toString
-