public class CCM extends StreamModeBaseCipher
| 限定符和类型 | 字段和说明 |
|---|---|
private byte[] |
aad |
private byte[] |
B |
private byte[] |
counter0 |
private int |
defaultIvLen |
private int |
L |
private byte[] |
lenA |
private int |
M |
counter, ivBLOCKSIZE, inputLenUpdate, inputOffsetUpdate, inputUpdate, isInitialized, len, opmode, padding, rk, sm4| 构造器和说明 |
|---|
CCM() |
| 限定符和类型 | 方法和说明 |
|---|---|
private void |
checkMac(byte[] T,
byte[] _T)
determine whether the authentication tag is consistent
|
private byte[] |
decrypt(byte[] input,
int inputOffset,
int inputLen)
CCM decrypt
|
private void |
encrypt(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
CCM encrypt
|
byte[] |
engineDoFinal(byte[] input,
int inputOffset,
int inputLen) |
int |
engineDoFinal(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset) |
int |
engineGetOutputSize(int inputLen) |
void |
engineInit(int opmode,
Key key,
AlgorithmParameterSpec params,
SecureRandom random) |
void |
engineInit(int opmode,
Key key,
AlgorithmParameters params,
SecureRandom random) |
void |
engineInit(int opmode,
Key key,
SecureRandom random) |
void |
engineSetPadding(String padding) |
byte[] |
engineUpdate(byte[] input,
int inputOffset,
int inputLen) |
int |
engineUpdate(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset) |
protected void |
engineUpdateAAD(byte[] src,
int offset,
int len) |
private void |
getCountero()
get the CTR0 according to iv
|
private byte[] |
getTag(byte[] plainText)
generate authentication tag
|
private void |
incr()
CCM counter increment
|
private byte |
increment(int index)
determines whether the binary bit of counter[index] contains zeros
if it contains zero, it changes the rightmost zero to 1 and all binary positions to its right to 0
if it does not contain 0, it throws an exception
|
private void |
readInt(byte[] arr,
int x,
int start)
convert x into byte array
|
void |
reset()
reset some parameters after encryption
|
engineGetIV, engineGetParametersengineGetBlockSize, engineSetMode, initengineDoFinal, engineGetKeySize, engineUnwrap, engineUpdate, engineUpdateAAD, engineWrapprivate final int M
private int L
private final int defaultIvLen
private byte[] B
private byte[] counter0
private byte[] aad
private byte[] lenA
public void engineInit(int opmode,
Key key,
SecureRandom random)
throws InvalidKeyException
engineInit 在类中 StreamModeBaseCipherInvalidKeyExceptionpublic void engineInit(int opmode,
Key key,
AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidKeyException,
InvalidAlgorithmParameterException
public void engineInit(int opmode,
Key key,
AlgorithmParameters params,
SecureRandom random)
throws InvalidKeyException,
InvalidAlgorithmParameterException
public int engineGetOutputSize(int inputLen)
engineGetOutputSize 在类中 SM4BaseCipherprotected void engineUpdateAAD(byte[] src,
int offset,
int len)
engineUpdateAAD 在类中 SM4BaseCipherpublic int engineUpdate(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
throws ShortBufferException
engineUpdate 在类中 SM4BaseCipherShortBufferExceptionpublic byte[] engineUpdate(byte[] input,
int inputOffset,
int inputLen)
engineUpdate 在类中 SM4BaseCipherpublic void engineSetPadding(String padding) throws NoSuchPaddingException
engineSetPadding 在类中 SM4BaseCipherNoSuchPaddingExceptionpublic byte[] engineDoFinal(byte[] input,
int inputOffset,
int inputLen)
throws IllegalBlockSizeException,
BadPaddingException
public int engineDoFinal(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
throws ShortBufferException,
IllegalBlockSizeException,
BadPaddingException
private void getCountero()
private void incr()
private byte increment(int index)
throws Exception
index - Exceptionprivate void encrypt(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
input - inputOffset - inputLen - output - outputOffset - private byte[] decrypt(byte[] input,
int inputOffset,
int inputLen)
input - inputOffset - inputLen - public void reset()
SM4BaseCipherreset 在类中 StreamModeBaseCipherprivate byte[] getTag(byte[] plainText)
plainText - private void readInt(byte[] arr,
int x,
int start)
arr - store the convert resultx - to be converted datastart - offset of arrprivate void checkMac(byte[] T,
byte[] _T)
T - the calculated tag_T - tag in cipherTextCopyright © 2024. All rights reserved.