Class ChachaPolyCipher
- java.lang.Object
-
- net.schmizz.sshj.transport.cipher.BaseCipher
-
- com.hierynomus.sshj.transport.cipher.ChachaPolyCipher
-
- All Implemented Interfaces:
Cipher
public class ChachaPolyCipher extends BaseCipher
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.schmizz.sshj.transport.cipher.Cipher
Cipher.Mode
-
-
Field Summary
Fields Modifier and Type Field Description private static int
AAD_LENGTH
protected javax.crypto.Cipher
aadCipher
protected java.security.Key
aadCipherKey
private int
authSize
private static int
CHACHA_KEY_SIZE
private static java.lang.String
CIPHER_CHACHA
protected java.security.Key
cipherKey
private byte[]
encryptedAad
protected javax.crypto.Mac
mac
private static java.lang.String
MAC_POLY1305
protected Cipher.Mode
mode
private static byte[]
POLY_KEY_INPUT
private static int
POLY_TAG_LENGTH
-
Fields inherited from class net.schmizz.sshj.transport.cipher.BaseCipher
cipher
-
-
Constructor Summary
Constructors Constructor Description ChachaPolyCipher(int authSize, int bsize, java.lang.String algorithm)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getAuthenticationTagSize()
protected void
initCipher(javax.crypto.Cipher cipher, Cipher.Mode mode, byte[] key, byte[] iv)
private byte[]
longToBytes(long lng)
void
setSequenceNumber(long seq)
void
update(byte[] input, int inputOffset, int inputLen)
Performs in-place encryption or decryption on the given data.void
updateAAD(byte[] data)
Adds the provided input data as additional authenticated data during encryption or decryption.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 net.schmizz.sshj.transport.cipher.BaseCipher
getBlockSize, getIVSize, getKeySpec, getMode, init, updateWithAAD
-
-
-
-
Field Detail
-
CHACHA_KEY_SIZE
private static final int CHACHA_KEY_SIZE
- See Also:
- Constant Field Values
-
AAD_LENGTH
private static final int AAD_LENGTH
- See Also:
- Constant Field Values
-
POLY_TAG_LENGTH
private static final int POLY_TAG_LENGTH
- See Also:
- Constant Field Values
-
CIPHER_CHACHA
private static final java.lang.String CIPHER_CHACHA
- See Also:
- Constant Field Values
-
MAC_POLY1305
private static final java.lang.String MAC_POLY1305
- See Also:
- Constant Field Values
-
POLY_KEY_INPUT
private static final byte[] POLY_KEY_INPUT
-
authSize
private final int authSize
-
encryptedAad
private byte[] encryptedAad
-
mode
protected Cipher.Mode mode
-
aadCipher
protected javax.crypto.Cipher aadCipher
-
mac
protected javax.crypto.Mac mac
-
cipherKey
protected java.security.Key cipherKey
-
aadCipherKey
protected java.security.Key aadCipherKey
-
-
Method Detail
-
getAuthenticationTagSize
public int getAuthenticationTagSize()
- Specified by:
getAuthenticationTagSize
in interfaceCipher
- Overrides:
getAuthenticationTagSize
in classBaseCipher
- Returns:
- Size of the authentication tag (AT) in bytes or 0 if this cipher does not support authentication
-
setSequenceNumber
public void setSequenceNumber(long seq)
- Specified by:
setSequenceNumber
in interfaceCipher
- Overrides:
setSequenceNumber
in classBaseCipher
-
initCipher
protected void initCipher(javax.crypto.Cipher cipher, Cipher.Mode mode, byte[] key, byte[] iv)
- Specified by:
initCipher
in classBaseCipher
-
updateAAD
public void updateAAD(byte[] data, int offset, int length)
Description copied from interface:Cipher
Adds the provided input data as additional authenticated data during encryption or decryption.- Specified by:
updateAAD
in interfaceCipher
- Overrides:
updateAAD
in classBaseCipher
- Parameters:
data
- The additional data to authenticateoffset
- The offset of the additional data in the bufferlength
- The number of bytes in the buffer to use for authentication
-
updateAAD
public void updateAAD(byte[] data)
Description copied from interface:Cipher
Adds the provided input data as additional authenticated data during encryption or decryption.- Specified by:
updateAAD
in interfaceCipher
- Overrides:
updateAAD
in classBaseCipher
- Parameters:
data
- The data to authenticate
-
update
public void update(byte[] input, int inputOffset, int inputLen)
Description copied from interface:Cipher
Performs in-place encryption or decryption on the given data.- Specified by:
update
in interfaceCipher
- Overrides:
update
in classBaseCipher
- Parameters:
input
- the subjectinputOffset
- offset at which to startinputLen
- number of bytes starting atinputOffset
-
longToBytes
private byte[] longToBytes(long lng)
-
-