public class SM4Util extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
private int |
BLOCK_SIZE |
private static int[] |
CK |
private static int[] |
FK |
private static byte[] |
S_BOX |
| 构造器和说明 |
|---|
SM4Util() |
| 限定符和类型 | 方法和说明 |
|---|---|
private int |
_l(int input)
L' change
|
private int |
_t(int input)
T' change
|
int |
bigEndianToInt(byte[] bytes,
int start)
convert 4 bytes to int
|
static void |
copyArray(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
copy the input from inputOffset into the output
|
byte[] |
decrypt(int[] rk,
byte[] cipherText)
SM4 decrypt
|
byte[] |
decrypt(int[] rk,
byte[] input,
int inputOffset)
SM4 decrypt
|
void |
decrypt(int[] rk,
byte[] input,
int inputOffset,
byte[] output,
int outputOffset)
SM4 decrypt
|
byte[] |
encrypt(int[] rk,
byte[] input)
SM4 encrypt
|
byte[] |
encrypt(int[] rk,
byte[] input,
int inputOffset)
SM4 encrypt
|
void |
encrypt(int[] rk,
byte[] input,
int inputOffset,
byte[] output,
int outputOffset)
SM4 encrypt
|
int[] |
expandKey(byte[] key)
calculate rk
|
private int |
f(int x0,
int x1,
int x2,
int x3,
int rk0)
F function
|
void |
intToBigEndian(byte[] output,
int x,
int start)
convert int to 4 bytes
|
private int |
l(int input)
L change
|
private byte[] |
reverse(int x32,
int x33,
int x34,
int x35)
reverse
|
private void |
reverse(int x32,
int x33,
int x34,
int x35,
byte[] output,
int outputOffset)
reverse
|
private int |
t(int input)
T change
|
private int |
tau(int input)
τtrsform
|
byte[] |
xor(byte[] b1,
byte[] b2)
xor operation
|
byte[] |
xor(byte[] b1,
int from1,
int len1,
byte[] b2,
int from2,
int len2)
xor operation
|
byte[] |
xor16Byte(byte[] b1,
byte[] b2)
xor operation
|
private static final byte[] S_BOX
private static final int[] CK
private static final int[] FK
private final int BLOCK_SIZE
private int tau(int input)
input - input(a0,a1,a2,a3)private int l(int input)
input - private int _l(int input)
input - private int t(int input)
input - private int _t(int input)
input - private int f(int x0,
int x1,
int x2,
int x3,
int rk0)
x0 - x1 - x2 - x3 - rk0 - private byte[] reverse(int x32,
int x33,
int x34,
int x35)
x32 - x33 - x34 - x35 - private void reverse(int x32,
int x33,
int x34,
int x35,
byte[] output,
int outputOffset)
x32 - x33 - x34 - x35 - output - outputOffset - public void intToBigEndian(byte[] output,
int x,
int start)
output - x - start - public int bigEndianToInt(byte[] bytes,
int start)
bytes - start - public int[] expandKey(byte[] key)
key - public byte[] encrypt(int[] rk,
byte[] input)
rk - input - public byte[] encrypt(int[] rk,
byte[] input,
int inputOffset)
rk - input - inputOffset - public void encrypt(int[] rk,
byte[] input,
int inputOffset,
byte[] output,
int outputOffset)
rk - input - inputOffset - output - outputOffset - public byte[] decrypt(int[] rk,
byte[] cipherText)
rk - cipherText - public byte[] decrypt(int[] rk,
byte[] input,
int inputOffset)
rk - input - inputOffset - public void decrypt(int[] rk,
byte[] input,
int inputOffset,
byte[] output,
int outputOffset)
rk - input - inputOffset - output - outputOffset - public byte[] xor(byte[] b1,
byte[] b2)
b1 - b2 - public byte[] xor(byte[] b1,
int from1,
int len1,
byte[] b2,
int from2,
int len2)
b1 - from1 - b1's start indexlen1 - b2 - from2 - b2's start indexlen2 - public byte[] xor16Byte(byte[] b1,
byte[] b2)
b1 - b2 - public static void copyArray(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
input - inputOffset - inputLen - output - outputOffset - Copyright © 2024. All rights reserved.