写基础Applet,试图测试加解密正确性
This commit is contained in:
@@ -18,8 +18,8 @@ public final class Zuc256Util {
|
||||
// }
|
||||
/** 辅助方法:从字节数组取出 32 位整数,存放到 short[2] (lo, hi) */
|
||||
public static void getU32(byte[] p, short offset, short[] out32 /* len=2 */) {
|
||||
out32[0] = (short) (((p[offset + 2] & 0xFF) << 8) | (p[offset + 3] & 0xFF)); //低16位
|
||||
out32[1] = (short) (((p[offset] & 0xFF) << 8) | (p[offset + 1] & 0xFF)); //高16位
|
||||
out32[0] = (short) (((p[(short)(offset + 2)] & 0xFF) << 8) | (p[(short)(offset + 3)] & 0xFF)); //低16位
|
||||
out32[1] = (short) (((p[offset] & 0xFF) << 8) | (p[(short)(offset + 1)] & 0xFF)); //高16位
|
||||
}
|
||||
|
||||
|
||||
@@ -34,11 +34,11 @@ public final class Zuc256Util {
|
||||
public static void putU32(byte[] p, short offset, short vlo, short vhi) {
|
||||
// 写高16位
|
||||
p[offset] = (byte) ((vhi >> 8) & 0xFF);
|
||||
p[offset + 1] = (byte) (vhi & 0xFF);
|
||||
p[(short)(offset + 1)] = (byte) (vhi & 0xFF);
|
||||
|
||||
// 写低16位
|
||||
p[offset + 2] = (byte) ((vlo >> 8) & 0xFF);
|
||||
p[offset + 3] = (byte) (vlo & 0xFF);
|
||||
p[(short)(offset + 2)] = (byte) ((vlo >> 8) & 0xFF);
|
||||
p[(short)(offset + 3)] = (byte) (vlo & 0xFF);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ public final class Zuc256Util {
|
||||
bits[i] = (short)((a_lo >>> i) & 1);
|
||||
}
|
||||
for (short i = 0; i < 15; i++) {
|
||||
bits[16 + i] = (short)((a_hi >>> i) & 1);
|
||||
bits[(short)(16 + i)] = (short)((a_hi >>> i) & 1);
|
||||
}
|
||||
|
||||
// 旋转
|
||||
@@ -118,7 +118,7 @@ public final class Zuc256Util {
|
||||
}
|
||||
short hi = 0;
|
||||
for (short i = 0; i < 15; i++) {
|
||||
hi = (short)(hi | (resBits[16 + i] << i));
|
||||
hi = (short)(hi | (resBits[(short)(16 + i)] << i));
|
||||
}
|
||||
|
||||
out[0] = lo;
|
||||
@@ -310,7 +310,7 @@ public final class Zuc256Util {
|
||||
// 处理剩余8字节
|
||||
byte[] src = new byte[8];
|
||||
for (short i = 0; i < 8; i++) {
|
||||
src[i] = (byte) (input25Byte[17 + i] & 0x3F);
|
||||
src[i] = (byte) (input25Byte[(short)(17 + i)] & 0x3F);
|
||||
}
|
||||
|
||||
output23Byte[17] = (byte) ((src[0] << 2) | (src[1] >>> 4));
|
||||
|
||||
Reference in New Issue
Block a user