写基础Applet,试图测试加解密正确性
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.cscn;
|
||||
|
||||
import javacard.framework.JCSystem;
|
||||
import javacard.framework.Util;
|
||||
|
||||
import static com.cscn.Zuc256Core.zuc256GenerateKeystream;
|
||||
import static com.cscn.Zuc256Core.zuc256GenerateKeyword;
|
||||
@@ -56,7 +57,9 @@ public final class Zuc256EncryptCtx {
|
||||
// int copy = Math.min(inlen, need);
|
||||
short copy = (short)((inlen < need) ? inlen : need);
|
||||
|
||||
System.arraycopy(in, 0, this.buf, this.buflen, copy);
|
||||
// 替代 System.arraycopy(in, 0, this.buf, this.buflen, copy);
|
||||
Util.arrayCopyNonAtomic(in, (short)0, this.buf, this.buflen, copy);
|
||||
|
||||
this.buflen += copy;
|
||||
|
||||
// 调整输入指针和长度
|
||||
@@ -152,7 +155,9 @@ public final class Zuc256EncryptCtx {
|
||||
|
||||
// 缓存剩余不足4字节的数据
|
||||
if (inlen > 0) {
|
||||
System.arraycopy(in, 0, this.buf, 0, inlen);
|
||||
// 等价于 System.arraycopy(in, 0, this.buf, 0, inlen);
|
||||
Util.arrayCopyNonAtomic(in, (short)0, this.buf, (short)0, inlen);
|
||||
|
||||
this.buflen = inlen;
|
||||
}
|
||||
}
|
||||
@@ -186,6 +191,7 @@ public final class Zuc256EncryptCtx {
|
||||
}
|
||||
|
||||
this.buflen = 0;
|
||||
|
||||
// Arrays.fill(this.state.LFSR, 0);
|
||||
// LFSR 全部清零(高低位数组各 16 个元素)
|
||||
for (short i = 0; i < 16; i++) {
|
||||
@@ -193,6 +199,7 @@ public final class Zuc256EncryptCtx {
|
||||
this.state.LFSR_hi[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
// this.state.R1 = 0;
|
||||
// this.state.R2 = 0;
|
||||
// R1、R2 清零
|
||||
|
||||
Reference in New Issue
Block a user