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 classGcmCipher.CounterGCMParameterSpecAlgorithm 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 intauthSizeprotected booleaninitializedprotected Cipher.Modemodeprotected GcmCipher.CounterGCMParameterSpecparametersprotected javax.crypto.SecretKeysecretKey-
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 intgetAuthenticationTagSize()protected javax.crypto.CiphergetInitializedCipherInstance()protected voidinitCipher(javax.crypto.Cipher cipher, Cipher.Mode mode, byte[] key, byte[] iv)voidupdate(byte[] input, int inputOffset, int inputLen)Performs in-place encryption or decryption on the given data.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, 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:
getAuthenticationTagSizein interfaceCipher- Overrides:
getAuthenticationTagSizein 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:
initCipherin classBaseCipher- Throws:
java.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterException
-
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
-
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
-
-