new对象(short、byte数组)改为调用JCSystem.makeTransientXxxArray放到ram里面;
makeTransientXxxArray类型改为MEMORY_TYPE_TRANSIENT_RESETMEMORY_TYPE_TRANSIENT_RESET
This commit is contained in:
@@ -98,7 +98,7 @@ public final class Zuc256Util {
|
||||
}
|
||||
|
||||
// 拆成 31 位数组 [bit0..bit30]
|
||||
short[] bits = new short[31];
|
||||
short[] bits = JCSystem.makeTransientShortArray((short)31, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);
|
||||
for (short i = 0; i < 16; i++) {
|
||||
bits[i] = (short)((a_lo >>> i) & 1);
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public final class Zuc256Util {
|
||||
}
|
||||
|
||||
// 旋转
|
||||
short[] resBits = new short[31];
|
||||
short[] resBits = JCSystem.makeTransientShortArray((short)31, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);
|
||||
for (short i = 0; i < 31; i++) {
|
||||
short j = (short)((i + k) % 31);
|
||||
resBits[j] = bits[i];
|
||||
@@ -162,8 +162,8 @@ public final class Zuc256Util {
|
||||
* 输出: out[0]=lo, out[1]=hi
|
||||
*/
|
||||
public static void L1(short x_lo, short x_hi, short[] out /*len==2*/) {
|
||||
short[] t = new short[2];
|
||||
short[] acc = new short[2];
|
||||
short[] t = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);
|
||||
short[] acc = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);
|
||||
|
||||
// acc = x
|
||||
acc[0] = x_lo;
|
||||
@@ -206,8 +206,8 @@ public final class Zuc256Util {
|
||||
* 输出: out[0]=lo, out[1]=hi
|
||||
*/
|
||||
public static void L2(short x_lo, short x_hi, short[] out /*len==2*/) {
|
||||
short[] t = new short[2];//todo to ram
|
||||
short[] acc = new short[2];
|
||||
short[] t = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);
|
||||
short[] acc = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);
|
||||
|
||||
// acc = x
|
||||
acc[0] = x_lo;
|
||||
@@ -295,7 +295,7 @@ public final class Zuc256Util {
|
||||
|
||||
|
||||
// 处理剩余8字节
|
||||
byte[] src = new byte[8];
|
||||
byte[] src = JCSystem.makeTransientShortArray((short)8, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);
|
||||
for (short i = 0; i < 8; i++) {
|
||||
src[i] = (byte) (input25Byte[(short)(17 + i)] & 0x3F);
|
||||
}
|
||||
@@ -381,7 +381,7 @@ public final class Zuc256Util {
|
||||
* 输入输出: short[4],低到高 (a[0]=lo16, a[1]=hi16, a[2]=lo16 of high dword, a[3]=hi16 of high dword)
|
||||
*/
|
||||
static void add64(short[] a, short[] b) {
|
||||
short[] tmp = new short[2];
|
||||
short[] tmp = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);
|
||||
|
||||
// 低 32 位
|
||||
short carry = add32_with_carry(a[0], a[1], b[0], b[1], tmp);
|
||||
@@ -475,11 +475,11 @@ public final class Zuc256Util {
|
||||
*/
|
||||
static void shr32u1(short lo, short hi, short[] out) {
|
||||
// >>>1:先处理低16位
|
||||
short newLo = (short)(((((lo & (short)0xFFFF) >>> 1) & (short)0x7FFF)) | ((hi & 0x0001) << 15));
|
||||
short newHi = (short)(((hi & (short)0xFFFF) >>> 1) & (short)0x7FFF);
|
||||
short nwLo = (short)(((((lo & (short)0xFFFF) >>> 1) & (short)0x7FFF)) | ((hi & 0x0001) << 15));
|
||||
short nwHi = (short)(((hi & (short)0xFFFF) >>> 1) & (short)0x7FFF);
|
||||
|
||||
out[0] = newLo;
|
||||
out[1] = newHi;
|
||||
out[0] = nwLo;
|
||||
out[1] = nwHi;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user