public class GCM extends StreamModeBaseCipher
| 限定符和类型 | 字段和说明 |
|---|---|
private byte[] |
aad |
private int |
aLen |
private int |
cLen |
private byte[] |
counter0 |
private int |
defaultIvLen |
private byte[] |
g |
private byte[] |
H |
private byte[] |
lastEncIv |
private byte[] |
lastEncKey |
private boolean |
requireReinit |
private byte[] |
T |
private int |
tLen |
private byte[] |
updateData |
counter, ivBLOCKSIZE, inputLenUpdate, inputOffsetUpdate, inputUpdate, isInitialized, len, opmode, padding, rk, sm4| 构造器和说明 |
|---|
GCM() |
| 限定符和类型 | 方法和说明 |
|---|---|
private boolean |
checkMac(byte[] T,
byte[] _T)
determine whether the authentication tag is consistent
|
private void |
checkReinit() |
private boolean |
checkTagLen(GCMParameterSpec spec)
check if the mac size is valid
|
private void |
decrypt(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset,
boolean first)
decrypt and check the authentication tag
|
private void |
encrypt(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset,
boolean first)
encrypt and generate authentication tag
|
byte[] |
engineDoFinal(byte[] input,
int inputOffset,
int inputLen) |
int |
engineDoFinal(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset) |
int |
engineGetOutputSize(int inputLen) |
AlgorithmParameters |
engineGetParameters() |
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 |
inc32()
GCM incrementing function
|
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 |
processG(byte[] cipherText,
boolean first)
process intermediate authentication parameters
|
private void |
processGCM(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
encrypt(decrypt) entire blocks of data
|
void |
reset()
reset some parameters after encryption
|
engineGetIVengineGetBlockSize, engineSetMode, initengineDoFinal, engineGetKeySize, engineUnwrap, engineUpdate, engineUpdateAAD, engineWrapprivate byte[] T
private byte[] aad
private byte[] H
private byte[] g
private final int defaultIvLen
private int tLen
private byte[] counter0
private int aLen
private int cLen
private byte[] updateData
private boolean requireReinit
private byte[] lastEncIv
private byte[] lastEncKey
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 在类中 SM4BaseCipherpublic AlgorithmParameters engineGetParameters()
public void engineSetPadding(String padding) throws NoSuchPaddingException
engineSetPadding 在类中 SM4BaseCipherNoSuchPaddingExceptionpublic byte[] engineUpdate(byte[] input,
int inputOffset,
int inputLen)
engineUpdate 在类中 SM4BaseCipherpublic int engineUpdate(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
throws ShortBufferException
engineUpdate 在类中 SM4BaseCipherShortBufferExceptionpublic int engineDoFinal(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
throws ShortBufferException,
IllegalBlockSizeException,
BadPaddingException
public byte[] engineDoFinal(byte[] input,
int inputOffset,
int inputLen)
throws IllegalBlockSizeException,
BadPaddingException
protected void engineUpdateAAD(byte[] src,
int offset,
int len)
engineUpdateAAD 在类中 SM4BaseCipherprivate boolean checkTagLen(GCMParameterSpec spec) throws InvalidAlgorithmParameterException
spec - InvalidAlgorithmParameterExceptionprivate boolean checkMac(byte[] T,
byte[] _T)
T - the calculated tag_T - tag in cipherTextprivate void processGCM(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
input - inputOffset - inputLen - output - outputOffset - private void encrypt(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset,
boolean first)
input - inputOffset - inputLen - output - outputOffset - first - private void decrypt(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset,
boolean first)
input - inputOffset - inputLen - output - outputOffset - first - private void inc32()
private byte increment(int index)
throws Exception
index - Exceptionprivate void processG(byte[] cipherText,
boolean first)
cipherText - aad or cipherTextfirst - indicates if this is the first time the function has been calledpublic void reset()
SM4BaseCipherreset 在类中 StreamModeBaseCipherprivate void checkReinit()
Copyright © 2024. All rights reserved.