public class CBCCMacParameterSpec
extends javax.crypto.spec.IvParameterSpec
This class holds the necessary inputs (additional data, iv, MAC length or MAC block) for the encryption and decryption.
If no parameters are passed to the constructor a 16-byte all-zero IV is generated and the macLength is set to 16:
CBC-CMAC-Param ::= SEQUENCE { aes-iV OCTET STRING aes-MacLen INTEGER (12 | 13 | 14 | 15 | 16) DEFAULT 16 }
AlgorithmParameterSpec
Constructor and Description |
---|
CBCCMacParameterSpec()
Creates a CBCCMac Parameter specification with default values.
|
CBCCMacParameterSpec(byte[] iv)
Creates a CBCCMac Parameter specification with the given iv.
|
CBCCMacParameterSpec(byte[] iv,
byte[] macBlock)
Creates a CBCCMac Parameter specification with the given additional data, iv
and MAC block.
|
CBCCMacParameterSpec(byte[] iv,
int macLen)
Creates a CBCCMac Parameter specification with the given iv
and MAC length.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
engineToString()
Returns a string describing the AES-CBC-CMAC Parameters.
|
byte[] |
getAAD()
Returns the additional authenticated data.
|
byte[] |
getMac()
Returns the mac block.
|
int |
getMacLength()
Returns the number of bytes used for the MAC block.
|
void |
setAAD(byte[] aad)
Sets the additional authenticated data.
|
void |
setMac(byte[] mac)
Sets the mac value.
|
void |
setMacLength(int macLength)
Set number of bytes that should be used as MAC.
|
public CBCCMacParameterSpec(byte[] iv, int macLen) throws java.security.InvalidAlgorithmParameterException
iv
- the IV (will be not cloned)macLen
- number of bytes used as MACjava.security.InvalidAlgorithmParameterException
public CBCCMacParameterSpec(byte[] iv, byte[] macBlock) throws java.security.InvalidAlgorithmParameterException
iv
- the IV (will be not cloned)macBlock
- the MAC block used to verify authenticityjava.security.InvalidAlgorithmParameterException
public CBCCMacParameterSpec(byte[] iv) throws java.security.InvalidAlgorithmParameterException
iv
- the IV (will be not cloned)java.security.InvalidAlgorithmParameterException
public CBCCMacParameterSpec() 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 void setMac(byte[] mac)
For CMS the mac value is not appended to the cipher data, rather it has to be set/got by/from parameters.
mac
- the mac value (not cloned)public void setAAD(byte[] aad)
aad
- the additional authenticated data (will not be cloned)public byte[] getAAD()
null
if
no additional authenticated data has been setpublic int getMacLength()
public byte[] getMac()
null
if the mac block has not been setprotected java.lang.String engineToString()