Class GCMBlockCipherBC
- java.lang.Object
-
- com.itextpdf.bouncycastle.crypto.modes.GCMBlockCipherBC
-
- All Implemented Interfaces:
IGCMBlockCipher
public class GCMBlockCipherBC extends java.lang.Object implements IGCMBlockCipher
This class provides the functionality of a cryptographic cipher of aes-gcm for encryption and decryption via wrapping the correspondingGCMBlockCipher
class from bouncy-castle.
-
-
Field Summary
Fields Modifier and Type Field Description private org.bouncycastle.crypto.modes.GCMBlockCipher
cipher
-
Constructor Summary
Constructors Constructor Description GCMBlockCipherBC(org.bouncycastle.crypto.modes.GCMBlockCipher cipher)
Creates new wrapper forGCMBlockCipher
aes-gcm block cipher class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doFinal(byte[] plainText, int i)
Finishes a multiple-part encryption or decryption operation, depending on how this cipher was initialized.boolean
equals(java.lang.Object o)
org.bouncycastle.crypto.modes.GCMBlockCipher
getCipher()
Gets actual org.bouncycastle object 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.java.lang.String
toString()
-
-
-
Method Detail
-
getCipher
public org.bouncycastle.crypto.modes.GCMBlockCipher getCipher()
Gets actual org.bouncycastle object being wrapped.- Returns:
- wrapped
GCMBlockCipher
-
init
public void init(boolean forEncryption, byte[] key, int macSizeBits, byte[] iv)
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 modekey
- the encryption keymacSizeBits
- MAC size, MAC sizes from 32 bits to 128 bits (must be a multiple of 8)iv
- the IV source buffer
-
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)
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 bufferinputOffset
- the offset in input where the input startslen
- the input lengthoutput
- the buffer for the resultoutOffset
- the offset in output where the result is stored
-
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
public void doFinal(byte[] plainText, int i)
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 resulti
- the offset in output where the result is stored
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-