Class GCMBlockCipherBCFips
java.lang.Object
com.itextpdf.bouncycastlefips.crypto.modes.GCMBlockCipherBCFips
- All Implemented Interfaces:
-
IGCMBlockCipher
This class provides the functionality of a cryptographic cipher of aes-gcm for encryption and decryption via wrapping and correctly populating
Cipher
class.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
doFinal
(byte[] plainText, int i) Finishes a multiple-part encryption or decryption operation, depending on how this cipher was initialized.boolean
Gets actual aes-gcm cipher being wrapped.int
getOutputSize
(int len) Returns the length in bytes that an output buffer would need to be in order to hold the result of the next doFinal operation, given the input length (in bytes).int
getUpdateOutputSize
(int len) Returns the length in bytes that an output buffer would need to be in order to hold the result of the next update operation, given the input length (in bytes).int
hashCode()
void
init
(boolean forEncryption, byte[] key, int macSizeBits, byte[] iv) Initialize this cipher with a key and a set of algorithm parameters.void
processBytes
(byte[] input, int inputOffset, int len, byte[] output, int outOffset) Perform a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part.toString()
-
Constructor Details
-
GCMBlockCipherBCFips
Creates new aes-gcm block cipher class.- Parameters:
-
cipher
- crypto instance to populate for aes-gcm encryption
-
-
Method Details
-
getCipher
Gets actual aes-gcm cipher being wrapped.- Returns:
-
wrapped
Cipher
-
init
public void init(boolean forEncryption, byte[] key, int macSizeBits, byte[] iv) throws GeneralSecurityException Initialize this cipher with a key and a set of algorithm parameters.- Specified by:
-
init
in interfaceIGCMBlockCipher
- Parameters:
-
forEncryption
- true to use encrypt mode, false to use decrypt mode -
key
- the encryption key -
macSizeBits
- MAC size, MAC sizes from 32 bits to 128 bits (must be a multiple of 8) -
iv
- the IV source buffer - Throws:
-
GeneralSecurityException
- in case any error during encryption or decryption
-
getUpdateOutputSize
public int getUpdateOutputSize(int len) Returns the length in bytes that an output buffer would need to be in order to hold the result of the next update operation, given the input length (in bytes).- Specified by:
-
getUpdateOutputSize
in interfaceIGCMBlockCipher
- Parameters:
-
len
- input length (in bytes) - Returns:
- output length in bytes
-
processBytes
public void processBytes(byte[] input, int inputOffset, int len, byte[] output, int outOffset) throws GeneralSecurityException Perform a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part.- Specified by:
-
processBytes
in interfaceIGCMBlockCipher
- Parameters:
-
input
- the input buffer -
inputOffset
- the offset in input where the input starts -
len
- the input length -
output
- the buffer for the result -
outOffset
- the offset in output where the result is stored - Throws:
-
GeneralSecurityException
- in case any error during encryption or decryption
-
getOutputSize
public int getOutputSize(int len) Returns the length in bytes that an output buffer would need to be in order to hold the result of the next doFinal operation, given the input length (in bytes).- Specified by:
-
getOutputSize
in interfaceIGCMBlockCipher
- Parameters:
-
len
- input length (in bytes) - Returns:
- output length in bytes
-
doFinal
Finishes a multiple-part encryption or decryption operation, depending on how this cipher was initialized. Input data that may have been buffered during a previous update operation is processed, also the authentication tag is appended in the case of encryption, or verified in the case of decryption.- Specified by:
-
doFinal
in interfaceIGCMBlockCipher
- Parameters:
-
plainText
- the buffer for the result -
i
- the offset in output where the result is stored - Throws:
-
GeneralSecurityException
- in case any error during encryption or decryption
-
equals
-
hashCode
public int hashCode() -
toString
-