/**
* @author SongWei
* @version 1.0.0
* @ClassName spring-cloud.com.boot.cloud.sm.Sm3Tool.java
* @Description TODO
* @createTime 2018年10月28日 14:29:00
*/
public class Sm3Tool {
public static final byte[] iv = {
0x73, (byte) 0x80, 0x16, 0x6f, 0x49,
0x14, (byte) 0xb2, (byte) 0xb9, 0x17, 0x24, 0x42, (byte) 0xd7,
(byte) 0xda, (byte) 0x8a, 0x06, 0x00, (byte) 0xa9, 0x6f, 0x30,
(byte) 0xbc, (byte) 0x16, 0x31, 0x38, (byte) 0xaa, (byte) 0xe3,
(byte) 0x8d, (byte) 0xee, 0x4d, (byte) 0xb0, (byte) 0xfb, 0x0e,
0x4e};
public static int[] Tj = new int[64];
static {
for (int i = 0; i < 16; i++) {
Tj[i] = 0x79cc4519;
}
for (int i = 16; i < 64; i++) {
Tj[i] = 0x7a879d8a;
}
}
public static byte[] CF(byte[] V, byte[] B) {
int[] v, b;
v = convert(V);
b = convert(B);
return convert(CF(v, b));
}
private static int[] convert(byte[] arr) {
int[] out = new int[arr.length / 4];
byte[] tmp = new byte[4];
for (int i = 0; i < arr.length; i += 4) {
System.arraycopy(arr, i, tmp, 0, 4);
out[i / 4] = bigEndianByteToInt(tmp);
}
return out;
}
private static byte[] convert(int[] arr) {
byte[] out = new byte[arr.length * 4]
java实现sm3
于 2023-02-15 09:37:17 首次发布