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

public Interface Cipher

extends CipherInformation
Known Direct Implementers
org.apache.sshd.common.cipher.CipherNone, org.apache.sshd.common.cipher.BaseCipher, org.apache.sshd.common.cipher.ChaCha20Cipher
Imports
org.apache.sshd.common.util.NumberUtils, .ValidateUtils

Wrapper for a cryptographic cipher, used either for encryption or decryption.
Author
Apache MINA SSHD Project

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

true if the cipher transformation and required key length are supported
checkSupported
(String
The full cipher transformation - e.g., AES/CBC/NoPadding - never null/empty
xform
,
int
The required key length in bits - always positive
keyLength
)

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

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

public default void
update(byte[]
The input/output bytes
input
)

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

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
)

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

public default void
updateAAD(byte[]
The data to authenticate
data
)

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

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
)

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

public default void
updateWithAAD(byte[]
The input/output bytes
input
,
int
The offset of the data in the input buffer
offset
,
int
The number of bytes to use as additional authenticated data - starting at offset
aadLen
,
int
The number of bytes to update, starting at offset + aadLen; must be a multiple of the cipher's block size
inputLen
)

Performs in-place authenticated encryption or decryption with additional data (AEAD).

Inherited from org.apache.sshd.common.cipher.CipherInformation:
getAuthenticationTagSizegetCipherBlockSizegetIVSizegetKdfSizegetTransformation

Method Detail

checkSupportedback to summary
public static boolean checkSupported(String xform, int keyLength)
Parameters
xform:String

The full cipher transformation - e.g., AES/CBC/NoPadding - never null/empty

keyLength:int

The required key length in bits - always positive

Returns:boolean

true if the cipher transformation and required key length are supported

See Also
javax.crypto.Cipher#getMaxAllowedKeyLength(String)
initback to summary
public void init(Cipher.Mode mode, byte[] key, byte[] iv) throws Exception

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

Exceptions
Exception:
If failed to initialize
updateback to summary
public default void update(byte[] input) throws Exception

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

Note

input.length must be a multiple of the cipher's block size.

Parameters
input:byte[]

The input/output bytes

Exceptions
Exception:
If failed to execute
See Also
update(byte[], int, int)
updateback to summary
public void update(byte[] input, int inputOffset, int inputLen) throws Exception

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

Exceptions
Exception:
If failed to execute
updateAADback to summary
public default void updateAAD(byte[] data) throws Exception

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

Parameters
data:byte[]

The data to authenticate

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

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

Exceptions
Exception:
If failed to execute
updateWithAADback to summary
public default void updateWithAAD(byte[] input, int offset, int aadLen, int inputLen) throws Exception

Performs in-place authenticated encryption or decryption with additional data (AEAD). Authentication tags are implicitly appended after the output ciphertext or implicitly verified after the input ciphertext. Header data indicated by the aadLen parameter are authenticated but not encrypted/decrypted, while payload data indicated by the inputLen parameter are authenticated and encrypted/decrypted.

Note

on encryption the input must have enough space after offset + aadLen + inputLength to store the authentication tag. On decryption, the authentication tag is assumed to be in the input at that offset (i.e., after the payload data).

Parameters
input:byte[]

The input/output bytes

offset:int

The offset of the data in the input buffer

aadLen:int

The number of bytes to use as additional authenticated data - starting at offset

inputLen:int

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

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

public final Enum Cipher.Mode

extends Enum<Cipher.Mode>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final Cipher.Mode
public static final Cipher.Mode

Constructor Summary

AccessConstructor and Description
private
Mode()

Method Summary

Modifier and TypeMethod and Description
public static Cipher.Mode
public static Cipher.Mode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

Decryptback to summary
public static final Cipher.Mode Decrypt
Encryptback to summary
public static final Cipher.Mode Encrypt

Constructor Detail

Modeback to summary
private Mode()

Method Detail

valueOfback to summary
public static Cipher.Mode valueOf(String name)
valuesback to summary
public static Cipher.Mode[] values()