Top Description Inners Fields Constructors Methods
org.apache.sshd.common.cipher

public Class BaseCipher

extends Object
implements Cipher
Class Inheritance
All Implemented Interfaces
org.apache.sshd.common.cipher.Cipher, org.apache.sshd.common.cipher.CipherInformation, org.apache.sshd.common.keyprovider.KeySizeIndicator, org.apache.sshd.common.AlgorithmNameProvider
Known Direct Subclasses
org.apache.sshd.common.cipher.BaseCTRCipher, org.apache.sshd.common.cipher.BaseGCMCipher, org.apache.sshd.common.cipher.BaseRC4Cipher, org.apache.sshd.common.cipher.BaseCBCCipher
Imports
java.security.GeneralSecurityException, .InvalidAlgorithmParameterException, .InvalidKeyException, java.security.spec.AlgorithmParameterSpec, javax.crypto.SecretKey, javax.crypto.spec.IvParameterSpec, .SecretKeySpec, org.apache.sshd.common.util.ValidateUtils, org.apache.sshd.common.util.security.SecurityUtils

Base class for all Cipher implementations delegating to the JCE provider.
Author
Apache MINA SSHD Project

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static interface

Field Summary

Modifier and TypeField and Description
private final String
pack-priv static boolean
private final int
private final int
private Cipher
pack-priv static BaseCipher.CipherFactory
private final int
private final int
private final int
protected Cipher.Mode
private String
s

private SecretKey
private final String

Constructor Summary

AccessConstructor and Description
public
BaseCipher(int ivsize, int authSize, int kdfSize, String algorithm, int keySize, String transformation, int blkSize)

Method Summary

Modifier and TypeMethod and Description
protected Cipher
createCipherInstance(Cipher.Mode mode, byte[] key, byte[] iv)

protected AlgorithmParameterSpec
determineNewParameters(byte[] processed, int offset, int length)

public String
public int
public int
protected Cipher
public int
public int
public int
public String
public void
init(Cipher.Mode
Encrypt/Decrypt initialization
mode
,
byte[]
Key bytes
key
,
byte[]
Initialization vector bytes
iv
)

Implements org.apache.sshd.common.cipher.Cipher.init.

Initialize the cipher for encryption or decryption with the given key and initialization vector

protected 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)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
update(byte[]
The input/output bytes
input
,
int
The offset of the data in the data buffer
inputOffset
,
int
The number of bytes to update, starting at the given offset; must be a multiple of the cipher's block size
inputLen
)

Implements org.apache.sshd.common.cipher.Cipher.update.

Performs in-place encryption or decryption on the given data.

public void
updateAAD(byte[]
The additional data to authenticate
data
,
int
The offset of the additional data in the buffer
offset
,
int
The number of bytes in the buffer to use for authentication
length
)

Implements org.apache.sshd.common.cipher.Cipher.updateAAD.

Adds the provided input data as additional authenticated data during encryption or decryption.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

algorithmback to summary
private final String algorithm
alwaysReInitback to summary
pack-priv static boolean alwaysReInit
authSizeback to summary
private final int authSize
blkSizeback to summary
private final int blkSize
cipherback to summary
private Cipher cipher
factoryback to summary
pack-priv static BaseCipher.CipherFactory factory
ivsizeback to summary
private final int ivsize
kdfSizeback to summary
private final int kdfSize
keySizeback to summary
private final int keySize
modeback to summary
protected Cipher.Mode mode
sback to summary
private String s
secretKeyback to summary
private SecretKey secretKey
transformationback to summary
private final String transformation

Constructor Detail

BaseCipherback to summary
public BaseCipher(int ivsize, int authSize, int kdfSize, String algorithm, int keySize, String transformation, int blkSize)

Method Detail

createCipherInstanceback to summary
protected Cipher createCipherInstance(Cipher.Mode mode, byte[] key, byte[] iv) throws Exception
determineNewParametersback to summary
protected AlgorithmParameterSpec determineNewParameters(byte[] processed, int offset, int length)
getAlgorithmback to summary
public String getAlgorithm()

Implements org.apache.sshd.common.AlgorithmNameProvider.getAlgorithm.

Annotations
@Override
getAuthenticationTagSizeback to summary
public int getAuthenticationTagSize()

Implements org.apache.sshd.common.cipher.CipherInformation.getAuthenticationTagSize.

Returns:int

Doc from org.apache.sshd.common.cipher.CipherInformation.getAuthenticationTagSize.

Size of the authentication tag (AT) in bytes or 0 if this cipher does not support authentication

Annotations
@Override
getCipherBlockSizeback to summary
public int getCipherBlockSize()

Implements org.apache.sshd.common.cipher.CipherInformation.getCipherBlockSize.

Returns:int

Doc from org.apache.sshd.common.cipher.CipherInformation.getCipherBlockSize.

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

Annotations
@Override
getCipherInstanceback to summary
protected Cipher getCipherInstance()
getIVSizeback to summary
public int getIVSize()

Implements org.apache.sshd.common.cipher.CipherInformation.getIVSize.

Returns:int

Doc from org.apache.sshd.common.cipher.CipherInformation.getIVSize.

Size of the initialization vector (in bytes)

Annotations
@Override
getKdfSizeback to summary
public int getKdfSize()

Implements org.apache.sshd.common.cipher.CipherInformation.getKdfSize.

Returns:int

Doc from org.apache.sshd.common.cipher.CipherInformation.getKdfSize.

The block size (in bytes) used to derive the secret key for this cipher

Annotations
@Override
getKeySizeback to summary
public int getKeySize()

Implements org.apache.sshd.common.keyprovider.KeySizeIndicator.getKeySize.

Returns:int

Doc from org.apache.sshd.common.keyprovider.KeySizeIndicator.getKeySize.

The number of bits used in the key

Annotations
@Override
getTransformationback to summary
public String getTransformation()

Implements org.apache.sshd.common.cipher.CipherInformation.getTransformation.

Returns:String

Doc from org.apache.sshd.common.cipher.CipherInformation.getTransformation.

The actual transformation used - e.g., AES/CBC/NoPadding

Annotations
@Override
initback to summary
public void init(Cipher.Mode mode, byte[] key, byte[] iv) throws Exception

Implements org.apache.sshd.common.cipher.Cipher.init.

Doc from org.apache.sshd.common.cipher.Cipher.init.

Initialize the cipher for encryption or decryption with the given key and initialization vector

Parameters
mode:Cipher.Mode

Encrypt/Decrypt initialization

key:byte[]

Key bytes

iv:byte[]

Initialization vector bytes

Annotations
@Override
Exceptions
Exception:
If failed to initialize
initializeIVDataback to summary
protected byte[] initializeIVData(Cipher.Mode mode, byte[] iv, int reqLen)
initializeKeyDataback to summary
protected byte[] initializeKeyData(Cipher.Mode mode, byte[] key, int reqLen)
reInitback to summary
protected void reInit(byte[] processed, int offset, int length) throws InvalidKeyException, InvalidAlgorithmParameterException
resizeback to summary
protected static byte[] resize(byte[] data, int size)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
updateback to summary
public void update(byte[] input, int inputOffset, int inputLen) throws Exception

Implements org.apache.sshd.common.cipher.Cipher.update.

Doc from org.apache.sshd.common.cipher.Cipher.update.

Performs in-place encryption or decryption on the given data.

Parameters
input:byte[]

The input/output bytes

inputOffset:int

The offset of the data in the data buffer

inputLen:int

The number of bytes to update, starting at the given offset; must be a multiple of the cipher's block size

Annotations
@Override
Exceptions
Exception:
If failed to execute
updateAADback to summary
public void updateAAD(byte[] data, int offset, int length) throws Exception

Implements org.apache.sshd.common.cipher.Cipher.updateAAD.

Doc from org.apache.sshd.common.cipher.Cipher.updateAAD.

Adds the provided input data as additional authenticated data during encryption or decryption.

Parameters
data:byte[]

The additional data to authenticate

offset:int

The offset of the additional data in the buffer

length:int

The number of bytes in the buffer to use for authentication

Annotations
@Override
Exceptions
Exception:
If failed to execute
org.apache.sshd.common.cipher back to summary

pack-priv Interface BaseCipher.CipherFactory


Method Summary

Modifier and TypeMethod and Description
public Cipher
getCipher(String transformation)

Method Detail

getCipherback to summary
public Cipher getCipher(String transformation) throws GeneralSecurityException