Class GcmCipher
- java.lang.Object
-
- net.schmizz.sshj.transport.cipher.BaseCipher
-
- com.hierynomus.sshj.transport.cipher.GcmCipher
-
- All Implemented Interfaces:
Cipher
public class GcmCipher extends BaseCipher
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
GcmCipher.CounterGCMParameterSpec
Algorithm parameters for AES/GCM that assumes the IV uses an 8-byte counter field as its most significant bytes.-
Nested classes/interfaces inherited from interface net.schmizz.sshj.transport.cipher.Cipher
Cipher.Mode
-
-
Field Summary
Fields Modifier and Type Field Description protected int
authSize
protected boolean
initialized
protected Cipher.Mode
mode
protected GcmCipher.CounterGCMParameterSpec
parameters
protected javax.crypto.SecretKey
secretKey
-
Fields inherited from class net.schmizz.sshj.transport.cipher.BaseCipher
cipher
-
-
Constructor Summary
Constructors Constructor Description GcmCipher(int ivsize, int authSize, int bsize, java.lang.String algorithm, java.lang.String transformation)
-
Method Summary
Modifier and Type Method Description int
getAuthenticationTagSize()
protected javax.crypto.Cipher
getInitializedCipherInstance()
protected void
initCipher(javax.crypto.Cipher cipher, Cipher.Mode mode, byte[] key, byte[] iv)
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 net.schmizz.sshj.transport.cipher.BaseCipher
getBlockSize, getIVSize, getKeySpec, getMode, init, setSequenceNumber, updateAAD, updateWithAAD
-
-
-
-
Field Detail
-
authSize
protected int authSize
-
mode
protected Cipher.Mode mode
-
initialized
protected boolean initialized
-
parameters
protected GcmCipher.CounterGCMParameterSpec parameters
-
secretKey
protected javax.crypto.SecretKey secretKey
-
-
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
-
getInitializedCipherInstance
protected javax.crypto.Cipher getInitializedCipherInstance() throws java.security.GeneralSecurityException
- Throws:
java.security.GeneralSecurityException
-
initCipher
protected void initCipher(javax.crypto.Cipher cipher, Cipher.Mode mode, byte[] key, byte[] iv) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
- Specified by:
initCipher
in classBaseCipher
- Throws:
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
-
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
-
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
-
-