36 lines
1.5 KiB
Java
36 lines
1.5 KiB
Java
package sega.a7;
|
|
|
|
import javacard.framework.Util;
|
|
import javacard.security.MessageDigest;
|
|
|
|
public class EepInit extends AuthCommand {
|
|
private static final short RECV_PACKET_SIZE = 46;
|
|
private static final byte AUTH_LEVEL = 2;
|
|
private static final short PARAM_SIZE = 46;
|
|
|
|
public EepInit(short cmd, AppData data, MakePacket packet, MessageDigest sha1, HmacSha1 hmacSha1, Crypt crypt) {
|
|
super(cmd, RECV_PACKET_SIZE, PARAM_SIZE, AUTH_LEVEL, data, packet, sha1, hmacSha1, crypt);
|
|
}
|
|
|
|
public short core(byte[] data, short dataOffset, short dataLength) {
|
|
if (this.m_ee_data.getSflag_ee())
|
|
return AppConfig.A7_EEPWRITE_DISABLE;
|
|
|
|
this.m_ee_data.reset();
|
|
byte[] modulus = this.m_ee_data.getRsaDefaultPriModulus_ee();
|
|
byte[] exponent = this.m_ee_data.getRsaDefaultPriExponent_ee();
|
|
byte[] tmp = this.m_ee_data.getCryptBuffer_ramD();
|
|
Util.arrayFillNonAtomic(tmp, (short) 0, (short) tmp.length, (byte) -1);
|
|
|
|
if (!this.m_ee_data.setRsaPriKeyExponent_ee(exponent, (short) 0, AppConfig.RSA_PRI_EXPONENT_SIZE))
|
|
return AppConfig.A7_EEP_WRITEFAIL;
|
|
|
|
if (!this.m_ee_data.setRsaPriKeyModulus_ee(modulus, (short) 0, AppConfig.RSA_PRI_MODULUS_SIZE))
|
|
return AppConfig.A7_EEP_WRITEFAIL;
|
|
|
|
changeRsaKey_ee(modulus, (short) 0, AppConfig.RSA_PRI_MODULUS_SIZE, exponent, (short) 0, AppConfig.RSA_PRI_EXPONENT_SIZE);
|
|
changeGKey_ee(tmp, (short) 0, (short) tmp.length, tmp, (short) 0, (short) tmp.length);
|
|
return AppConfig.A7_SUCCESS;
|
|
}
|
|
}
|