Commit 8fa7ffd8 authored by Administrator's avatar Administrator
Browse files

增加DUPKT AES模式

parent 425ce253
......@@ -225,7 +225,7 @@ public class RandomRunnable implements Runnable{
} else if (cmd.cmd.equals("0007")) {
handleDownloadClient(cmd);
}
/* else if (cmd.cmd.equals("0008")) {
/*else if (cmd.cmd.equals("0008")) {
handleDownloadTerminal(cmd);
} else if (cmd.cmd.equals("0009")) {
handleDownloadClient(cmd);
......@@ -614,19 +614,7 @@ public class RandomRunnable implements Runnable{
msg = "pinpad open error ";
} else {
if (type == 1) {
/*if(HexDump.toHexString(key).startsWith("42")){//下载des密钥
ret = pinPad.updateMasterKey(0, index, key, null, PinPad.Mode.MODE_3DES);
msg = "update master key " + ((ret == 0) ? "succ" : "error:" + ret);
}else if(HexDump.toHexString(key).startsWith("44")){//下载aes密钥
*//*int mIndex = CrcUtils.bytes2int(cmd.list.get(3).value);
SzztDebug.e(TAG, "mIndex:" + mIndex);
ret = pinPad.updateUserKey(mIndex, PinPad.KeyType.PIN, index, key, null, 0x4003);
msg = "update aes key " + ((ret == 0) ? "succ" : "error:" + ret);*//*
ret = pinPad.updateMasterKey(0, index, key, null, PinPad.Mode.MODE_AES);
msg = "update master key " + ((ret == 0) ? "succ" : "error:" + ret);
}else{
msg = "update key error";
}*/
ret = pinPad.updateMasterKey(0, index, key, null, PinPad.Mode.MODE_3DES);
msg = "update master key " + ((ret == 0) ? "succ" : "error:" + ret);
// ret = pinPad.updateMasterKey(0, key, null);
......@@ -657,9 +645,9 @@ public class RandomRunnable implements Runnable{
SzztDebug.e(TAG, "mIndex:" + mIndex);
byte[] ipekbuffer = new byte[16];
byte[] ksnbuffer = new byte[10];
System.arraycopy(key, 0, ipekbuffer, 0, 16);
System.arraycopy(key, 0, ipekbuffer, 0, 16);//参数1 原数组数据 参数2 从原数据起始未置开始 参数3 目标数组 参数4 目标数组的起始位置 参数5 要copy的长度
System.arraycopy(key, 16, ksnbuffer, 0, 10);
ret = pinPad.downloadBDK(0, mIndex, ipekbuffer, null, PinPad.Mode.MODE_3DES);
ret = pinPad.downloadBDK( mIndex,0, ipekbuffer, null, PinPad.Mode.MODE_3DES);//
SzztDebug.e(TAG, "update IPEK ret = " + ret);
if(ret == 0){
ret = pinPad.ksnCtl(1,ksnbuffer,new byte[10]);
......@@ -669,6 +657,24 @@ public class RandomRunnable implements Runnable{
}else{
msg = "update IPEK,KSN " + ((ret == 0) ? "succ" : "error:" + ret);
}
}else if (type == 11) {
if(key != null && key.length >= 28) {
int mIndex = CrcUtils.bytes2int(cmd.list.get(3).value);
SzztDebug.e(TAG, "AES mIndex:" + mIndex);
byte[] ipekbuffer = new byte[key.length - 12];//ipek数据
byte[] ksnbuffer = new byte[12];//KSN数据
System.arraycopy(key, 0, ipekbuffer, 0, key.length - 12);//参数1 原数组数据 参数2 从原数据起始未置开始 参数3 目标数组 参数4 目标数组的起始位置 参数5 要copy的长度
System.arraycopy(key, key.length - 12, ksnbuffer, 0, 12);
ret = pinPad.downloadBDK( mIndex,1, ipekbuffer, null, PinPad.Mode.MODE_AES);
SzztDebug.e(TAG, "update AES IPEK ret = " + ret);
if(ret == 0){
ret = pinPad.ksnCtl(1,ksnbuffer,new byte[12]);
SzztDebug.e(TAG, "update AES KSN ret = " + ret);
}
msg = "update AES IPEK,KSN " + ((ret == 0) ? "succ" : "error:" + ret);
}else{
msg = "update AES IPEK,KSN " + ((ret == 0) ? "succ" : "error:" + ret);
}
} else {
SzztDebug.e(TAG, "download type error");
msg = "download type errror";
......
......@@ -141,7 +141,7 @@ public class MainActivity extends AppCompatActivity {
break;
}
try {
Thread.sleep(10000);
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment