Files
se-algo/src/com/zuc/zuc256/Zuc256MacCtx.java

35 lines
1.1 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.zuc.zuc256;
import javacard.framework.JCSystem;
/**
* MAC上下文类Java Card兼容版本
*/
public final class Zuc256MacCtx {
// 所有32位int类型改为16位short类型适应Java Card 16位处理能力
short[] LFSR;
short R1;
short R2;
byte[] buf;
short buflen; // 长度变量使用short类型
short[] T;
short[] K0;
short macbits; // MAC位数使用short类型
// 构造函数初始化瞬态数组符合Java Card内存管理规范
public Zuc256MacCtx() {
// 使用瞬态内存存储敏感数据,提高安全性
// CLEAR_ON_DESELECT卡片复位或选择其他应用时清除数据
LFSR = JCSystem.makeTransientShortArray((short)16, JCSystem.CLEAR_ON_DESELECT);
buf = JCSystem.makeTransientByteArray((short)4, JCSystem.CLEAR_ON_DESELECT);
T = JCSystem.makeTransientShortArray((short)4, JCSystem.CLEAR_ON_DESELECT);
K0 = JCSystem.makeTransientShortArray((short)4, JCSystem.CLEAR_ON_DESELECT);
// 初始化变量
R1 = 0;
R2 = 0;
buflen = 0;
macbits = 0;
}
}