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 intAAD_LENGTHprotected javax.crypto.CipheraadCipherprotected java.security.KeyaadCipherKeyprivate intauthSizeprivate static intCHACHA_KEY_SIZEprivate static java.lang.StringCIPHER_CHACHAprotected java.security.KeycipherKeyprivate byte[]encryptedAadprotected javax.crypto.Macmacprivate static java.lang.StringMAC_POLY1305protected Cipher.Modemodeprivate static byte[]POLY_KEY_INPUTprivate static intPOLY_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 intgetAuthenticationTagSize()protected voidinitCipher(javax.crypto.Cipher cipher, Cipher.Mode mode, byte[] key, byte[] iv)private byte[]longToBytes(long lng)voidsetSequenceNumber(long seq)voidupdate(byte[] input, int inputOffset, int inputLen)Performs in-place encryption or decryption on the given data.voidupdateAAD(byte[] data)Adds the provided input data as additional authenticated data during encryption or decryption.voidupdateAAD(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:
getAuthenticationTagSizein interfaceCipher- Overrides:
getAuthenticationTagSizein 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:
setSequenceNumberin interfaceCipher- Overrides:
setSequenceNumberin classBaseCipher
-
initCipher
protected void initCipher(javax.crypto.Cipher cipher, Cipher.Mode mode, byte[] key, byte[] iv)- Specified by:
initCipherin classBaseCipher
-
updateAAD
public void updateAAD(byte[] data, int offset, int length)Description copied from interface:CipherAdds the provided input data as additional authenticated data during encryption or decryption.- Specified by:
updateAADin interfaceCipher- Overrides:
updateAADin 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:CipherAdds the provided input data as additional authenticated data during encryption or decryption.- Specified by:
updateAADin interfaceCipher- Overrides:
updateAADin classBaseCipher- Parameters:
data- The data to authenticate
-
update
public void update(byte[] input, int inputOffset, int inputLen)Description copied from interface:CipherPerforms in-place encryption or decryption on the given data.- Specified by:
updatein interfaceCipher- Overrides:
updatein classBaseCipher- Parameters:
input- the subjectinputOffset- offset at which to startinputLen- number of bytes starting atinputOffset
-
longToBytes
private byte[] longToBytes(long lng)
-
-