public class CCMParameterSpec
extends java.lang.Object
implements java.security.spec.AlgorithmParameterSpec
This class holds the necessary inputs (associated data, nonce, MAC length and input length) for the encryption and decryption with the CCM mode.
If no parameters are passed to the constructor the nonce is generated and the macLength
is set to 12.
If only macLength and/or inputLength shall be specified,
set nonce and associatedData to null
.
Note that associated data may be supplied to the CCM Cipher only either by means of a
CCMParameterSpec or by calling ccmCipher.updateAAD()
. Supplying associated
data by both CCMParameterSpec and calling ccmCipher.updateAAD()
is not
allowed.
If associated data is specified by a CCMParameterSpec the associated data is also
included in the parameters got from a CCM Cipher when calling
ccmCipher.getParameters()
. However, associated data that
has been supplied by calling ccmCipher.updateAAD()
is not included in the parameters got from a CCM Cipher when calling
ccmCipher.getParameters()
.
AlgorithmParameterSpec
Constructor and Description |
---|
CCMParameterSpec()
Creates a CCM Parameter specification with default values.
|
CCMParameterSpec(byte[] associatedData,
byte[] nonce)
Creates a CCM Parameter specification with the given associated data and nonce.
|
CCMParameterSpec(byte[] associatedData,
byte[] nonce,
int macLength)
Creates a CCM Parameter specification with the given associated data,
nonce and MAC length.
|
CCMParameterSpec(long inputLength,
byte[] associatedData,
byte[] nonce)
Creates a CCM Parameter specification with the given input length,
associated data and nonce.
|
CCMParameterSpec(long inputLen,
byte[] assocData,
byte[] non,
int macLen)
Creates a CCM Parameter specification with the given input length,
associated data, nonce and MAC length.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getAssociatedData()
Returns the associated data used for authentication.
|
long |
getInputLength()
Returns the length of the input data that shall be encrypted and authenticated.
|
int |
getMacLength()
Returns the number of bytes used from the calculated CBC-MAC-block.
|
byte[] |
getNonce()
Returns the nonce used with the IV and the CBC-MAC-calculation.
|
void |
setInputLength(long inputLength)
Set byte length of input data, needed at the beginning of the MAC-calculation.
|
void |
setMacLength(int macLength)
Set number of bytes that should be used as MAC.
|
public CCMParameterSpec(long inputLen, byte[] assocData, byte[] non, int macLen) throws java.security.InvalidAlgorithmParameterException
inputLen
- length of the input data that is authenticated and encryptedassocData
- the associated data that is authenticatednon
- the unique noncemacLen
- number of bytes used as MACjava.security.InvalidAlgorithmParameterException
public CCMParameterSpec(long inputLength, byte[] associatedData, byte[] nonce) throws java.lang.Exception
inputLength
- length of the input data that is authenticated and encryptedassociatedData
- the associated data that is authenticatednonce
- the unique noncejava.lang.Exception
public CCMParameterSpec(byte[] associatedData, byte[] nonce, int macLength) throws java.lang.Exception
associatedData
- the associated data that is authenticatednonce
- the unique noncemacLength
- number of bytes used as authentication blockjava.lang.Exception
public CCMParameterSpec(byte[] associatedData, byte[] nonce) throws java.lang.Exception
associatedData
- the associated data that is authenticatednonce
- the unique noncejava.lang.Exception
public CCMParameterSpec() throws java.lang.Exception
java.lang.Exception
public void setInputLength(long inputLength) throws java.security.InvalidAlgorithmParameterException
java.security.InvalidAlgorithmParameterException
- if the specified input length is not validpublic void setMacLength(int macLength) throws java.security.InvalidAlgorithmParameterException
java.security.InvalidAlgorithmParameterException
- if the specified MAC length is not validpublic byte[] getAssociatedData()
public int getMacLength()
public byte[] getNonce()
public long getInputLength()