public class OCB extends StreamModeBaseCipher
| 限定符和类型 | 字段和说明 |
|---|---|
private byte[] |
aad |
private byte |
bottom |
private byte[] |
checkSum |
private int |
defaultIvLen |
private byte[] |
H |
private byte[] |
ktop |
private byte[][] |
L |
private byte[] |
L_$ |
private byte[] |
L_0 |
private byte[] |
nonce |
private byte[] |
offset |
private byte[] |
stretch |
private byte[] |
tag |
private int |
tLen |
counter, ivBLOCKSIZE, inputLenUpdate, inputOffsetUpdate, inputUpdate, isInitialized, len, opmode, padding, rk, sm4| 构造器和说明 |
|---|
OCB() |
| 限定符和类型 | 方法和说明 |
|---|---|
private void |
checkMac(byte[] T,
byte[] _T)
determine whether the authentication tag is consistent
|
private void |
checkTagLen(GCMParameterSpec gcmParam)
check if the mac size is valid
|
private void |
decrypt(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
decrypt and check the authentication tag
|
private byte[] |
double_(byte[] h)
refer to RFC7253 double
|
private void |
encrypt(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
OCB 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 int |
getI(byte[] arr,
int i)
get i-th bit of arr
|
private byte[] |
hash()
hash function
|
private void |
init()
init
|
private void |
initL(int m)
init L
|
private byte[] |
moveLeftOneBit(byte[] input)
move to left one bit
|
private int |
ntz(int num)
The number of trailing zero bits in the base-2
representation of the positive integer n.
|
private void |
processOCB(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
encrypt(decrypt) entire blocks of data
|
void |
reset()
reset some parameters after encryption
|
private void |
setI(byte[] arr,
int i,
int target)
set arr i-th bit to target
|
engineGetIVengineGetBlockSize, engineSetMode, initengineDoFinal, engineGetKeySize, engineUnwrap, engineUpdate, engineUpdateAAD, engineWrapprivate byte[] aad
private int defaultIvLen
private int tLen
private byte[] H
private byte[] L_$
private byte[][] L
private byte[] L_0
private byte[] nonce
private byte[] checkSum
private byte[] offset
private byte[] ktop
private byte bottom
private byte[] stretch
private byte[] tag
public void engineInit(int opmode,
Key key,
AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidKeyException,
InvalidAlgorithmParameterException
public void engineInit(int opmode,
Key key,
SecureRandom random)
throws InvalidKeyException
engineInit 在类中 StreamModeBaseCipherInvalidKeyExceptionpublic void engineInit(int opmode,
Key key,
AlgorithmParameters params,
SecureRandom random)
throws InvalidKeyException,
InvalidAlgorithmParameterException
protected void engineUpdateAAD(byte[] src,
int offset,
int len)
engineUpdateAAD 在类中 SM4BaseCipherpublic int engineGetOutputSize(int inputLen)
engineGetOutputSize 在类中 SM4BaseCipherpublic void engineSetPadding(String padding) throws NoSuchPaddingException
engineSetPadding 在类中 SM4BaseCipherNoSuchPaddingExceptionpublic AlgorithmParameters engineGetParameters()
public 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 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 processOCB(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
input - inputOffset - inputLen - output - outputOffset - private byte[] hash()
private byte[] double_(byte[] h)
h - :inputprivate byte[] moveLeftOneBit(byte[] input)
input - to be moved byte array.private int ntz(int num)
private void init()
private void initL(int m)
m - private void encrypt(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
input - inputOffset - inputLen - output - outputOffset - private void decrypt(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
input - inputOffset - inputLen - output - outputOffset - private int getI(byte[] arr,
int i)
arr - private void setI(byte[] arr,
int i,
int target)
i - target - 0 or 1private void checkTagLen(GCMParameterSpec gcmParam) throws InvalidAlgorithmParameterException
gcmParam - InvalidAlgorithmParameterExceptionprivate void checkMac(byte[] T,
byte[] _T)
T - _T - public void reset()
SM4BaseCipherreset 在类中 StreamModeBaseCipherCopyright © 2024. All rights reserved.