public class GCMParameterSpec
extends java.lang.Object
implements java.security.spec.AlgorithmParameterSpec
This class holds the necessary inputs (additional data, nonce, MAC length or MAC block) for the encryption and decryption with the GCM mode.
If no parameters are passed to the constructor the IV is generated and the
macLength is set to 12. If only macLength shall be specified, nonce and
additional data have to be null
.
AlgorithmParameterSpec
Constructor and Description |
---|
GCMParameterSpec()
Creates a GCM Parameter specification with default values.
|
GCMParameterSpec(byte[] aaData,
byte[] nonce)
Creates a GCM Parameter specification with the given additional data and
nonce.
|
GCMParameterSpec(byte[] aaData,
byte[] nonce,
byte[] macBlock)
Creates a GCM Parameter specification with the given additional data, nonce
and MAC block.
|
GCMParameterSpec(byte[] aaData,
byte[] nonce,
int macLen)
Creates a GCM Parameter specification with the given additional data, nonce
and MAC length.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getAAD()
Returns the associated data used for authentication.
|
byte[] |
getMac()
Returns the authentication block used to authenticate the plaintext and
additional data.
|
int |
getMacLength()
Returns the number of bytes used for the MAC block.
|
byte[] |
getNonce()
Returns the used bytes to generate the IV.
|
void |
setMacLength(int macLength)
Set number of bytes that should be used as MAC.
|
public GCMParameterSpec(byte[] aaData, byte[] nonce, int macLen) throws java.security.InvalidAlgorithmParameterException
aaData
- the additional data that is authenticatednonce
- bytes used to generate the IVmacLen
- number of bytes used as MACjava.security.InvalidAlgorithmParameterException
public GCMParameterSpec(byte[] aaData, byte[] nonce, byte[] macBlock) throws java.security.InvalidAlgorithmParameterException
aaData
- the additional data that is authenticatednonce
- bytes used to generate the IVmacBlock
- the MAC block used to verify authenticityjava.security.InvalidAlgorithmParameterException
public GCMParameterSpec(byte[] aaData, byte[] nonce) throws java.security.InvalidAlgorithmParameterException
aaData
- the additional data that is authenticatednonce
- bytes used to generate the IVjava.security.InvalidAlgorithmParameterException
public GCMParameterSpec() throws java.security.InvalidAlgorithmParameterException
java.security.InvalidAlgorithmParameterException
public void setMacLength(int macLength) throws java.security.InvalidAlgorithmParameterException
java.security.InvalidAlgorithmParameterException
- if the specified MAC length is not validpublic byte[] getAAD()
public int getMacLength()
public byte[] getNonce()
public byte[] getMac()