测试文件修改
This commit is contained in:
parent
602781686b
commit
d2aaa8e9ac
@ -272,7 +272,7 @@ public interface SydApi {
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
public SydApiSM423 initSM4(int iKeyIndex, int ende);
|
public SydApiSM4 initSM4(int iKeyIndex, int ende);
|
||||||
|
|
||||||
public SydApiSM3 initSM3();
|
public SydApiSM3 initSM3();
|
||||||
|
|
||||||
|
|||||||
@ -773,9 +773,9 @@ public class SydApi4Database implements SydApi {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SydApiSM423 initSM4(int iKeyIndex, int ende) {
|
public SydApiSM4 initSM4(int iKeyIndex, int ende) {
|
||||||
|
|
||||||
return new SydApiSM423(this,iKeyIndex,ende);
|
return new SydApiSM4(this,iKeyIndex,ende);
|
||||||
}
|
}
|
||||||
public SydApiSM3 initSM3() {
|
public SydApiSM3 initSM3() {
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,8 @@
|
|||||||
package com.sunyard.sge.database;
|
package com.sunyard.sge.database;
|
||||||
|
|
||||||
import com.sunyard.SydApiException;
|
import com.sunyard.SydApiException;
|
||||||
import com.sunyard.proto.Util;
|
|
||||||
import com.sunyard.sge.bytes.BytesQueue;
|
import com.sunyard.sge.bytes.BytesQueue;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
|
|
||||||
public class SydApiSM4 {
|
public class SydApiSM4 {
|
||||||
|
|
||||||
@ -66,12 +64,12 @@ public class SydApiSM4 {
|
|||||||
iPkgNum = 2;
|
iPkgNum = 2;
|
||||||
return bytes2;
|
return bytes2;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if (null==queue||null==pcData){
|
else {
|
||||||
|
if (null == queue || null == pcData) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
queue.push(pcData);
|
queue.push(pcData);
|
||||||
// int totalLen = queue.getLength() + pcData.length;
|
|
||||||
if ((queue.getLength()) / 16 < 2) {
|
if ((queue.getLength()) / 16 < 2) {
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
}
|
}
|
||||||
@ -81,50 +79,6 @@ public class SydApiSM4 {
|
|||||||
iPkgNum = 2;
|
iPkgNum = 2;
|
||||||
return bytes2;
|
return bytes2;
|
||||||
|
|
||||||
// ByteBuffer nSourceWrap = ByteBuffer.allocate( sourceWrap.array().length + pcData.length );
|
|
||||||
// byte[] waitData = sourceWrap.array();
|
|
||||||
// nSourceWrap.put( waitData );
|
|
||||||
// nSourceWrap.put( pcData );
|
|
||||||
// sourceWrap = nSourceWrap;
|
|
||||||
//
|
|
||||||
// System.out.println("new sourceWrap=" + Util.bytes2HexString(sourceWrap.array()));
|
|
||||||
//
|
|
||||||
// int totalLen = sourceWrap.array().length;
|
|
||||||
// if ( totalLen / 16 < 2){
|
|
||||||
// return new byte[0];
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// int com = totalLen % 16;
|
|
||||||
// int sendBuffLen = totalLen - com -16;
|
|
||||||
// byte[] sendBuff = new byte[sendBuffLen];
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// sourceWrap.position(0);
|
|
||||||
// sourceWrap.get( sendBuff , 0, sendBuff.length );
|
|
||||||
// byte[] waitBuff = new byte[ totalLen - sendBuffLen ];
|
|
||||||
// sourceWrap.get( waitBuff , 0, waitBuff.length );
|
|
||||||
//
|
|
||||||
// System.out.println( String.format("debug inDataLen=%d totalDataLen=%d sendDataLen=%d 16=%d iPkgNum=%d",
|
|
||||||
// pcData.length,
|
|
||||||
// totalLen,
|
|
||||||
// sendBuff.length,
|
|
||||||
// sendBuff.length % 16,
|
|
||||||
// iPkgNum)
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// System.out.println( "waitBuff=" + Util.bytes2HexString( waitBuff ) );
|
|
||||||
//
|
|
||||||
// if( 0x00 == waitBuff[0] ) {
|
|
||||||
// System.out.println("eee");
|
|
||||||
// }
|
|
||||||
// sourceWrap = ByteBuffer.wrap( waitBuff );
|
|
||||||
// System.out.println("sourceWrap=" + Util.bytes2HexString(sourceWrap.array()));
|
|
||||||
// byte[] bytes2 = api.SYD_SM4_LongData(iKeyIndex, sendBuff, iPkgNum, iFlag);
|
|
||||||
//
|
|
||||||
// iPkgNum = 2;
|
|
||||||
// return bytes2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -143,21 +97,11 @@ public class SydApiSM4 {
|
|||||||
|
|
||||||
byte[] pop = queue.pop();
|
byte[] pop = queue.pop();
|
||||||
byte[] bytes = api.SYD_SM4_LongData(iKeyIndex, pop, iPkgNum, iFlag);
|
byte[] bytes = api.SYD_SM4_LongData(iKeyIndex, pop, iPkgNum, iFlag);
|
||||||
|
queue = null;
|
||||||
return bytes;
|
return bytes;
|
||||||
|
|
||||||
// byte[] bytes = api.SYD_SM4_LongData(iKeyIndex, , iPkgNum, iFlag);
|
|
||||||
// sourceWrap = null;
|
|
||||||
// return bytes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public ByteBuffer bufferResult(int plength, byte[] pcData) {
|
|
||||||
// ByteBuffer bufferResult = ByteBuffer.allocate(sourceWrap.array().length + plength);
|
|
||||||
// bufferResult.put(sourceWrap);
|
|
||||||
// bufferResult.put(pcData);
|
|
||||||
// return bufferResult;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import com.sunyard.proto.Util;
|
|||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
public class SydApiSM423 {
|
public class SydApiSM4Backup {
|
||||||
|
|
||||||
private SydApi api;
|
private SydApi api;
|
||||||
private int iKeyIndex;
|
private int iKeyIndex;
|
||||||
@ -18,7 +18,7 @@ public class SydApiSM423 {
|
|||||||
ByteBuffer sourceWrap = ByteBuffer.wrap(new byte[0]);
|
ByteBuffer sourceWrap = ByteBuffer.wrap(new byte[0]);
|
||||||
|
|
||||||
|
|
||||||
public SydApiSM423(SydApi api, int iKeyIndex, int endeFlag) {
|
public SydApiSM4Backup(SydApi api, int iKeyIndex, int endeFlag) {
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.iFlag = endeFlag;
|
this.iFlag = endeFlag;
|
||||||
this.iKeyIndex = iKeyIndex;
|
this.iKeyIndex = iKeyIndex;
|
||||||
@ -23,7 +23,7 @@ public class Sample
|
|||||||
|
|
||||||
// 通常单例就够了
|
// 通常单例就够了
|
||||||
SydApiBuilder builder = new SydApiBuilder(
|
SydApiBuilder builder = new SydApiBuilder(
|
||||||
new String[]{ "192.168.0.200" },
|
new String[]{ "192.168.1.128" },
|
||||||
new int[]{ 8889 },
|
new int[]{ 8889 },
|
||||||
10,
|
10,
|
||||||
15
|
15
|
||||||
|
|||||||
@ -115,7 +115,7 @@ public class LongDataTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void case5() {
|
public void case5() {
|
||||||
SydApiSM423 sydApiSM4 = api.initSM4(1, 1);
|
SydApiSM4 sydApiSM4 = api.initSM4(1, 1);
|
||||||
byte[] enData = sydApiSM4.finish();
|
byte[] enData = sydApiSM4.finish();
|
||||||
System.out.println(Util.bytes2HexString(enData));
|
System.out.println(Util.bytes2HexString(enData));
|
||||||
Assert.assertArrayEquals(Util.hexString2Bytes("FF49F76AD3A71651FE1A8A9F0D2A689E"), enData);
|
Assert.assertArrayEquals(Util.hexString2Bytes("FF49F76AD3A71651FE1A8A9F0D2A689E"), enData);
|
||||||
@ -123,7 +123,7 @@ public class LongDataTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void case6() {
|
public void case6() {
|
||||||
SydApiSM423 sydApiSM4 = api.initSM4(1, 1);
|
SydApiSM4 sydApiSM4 = api.initSM4(1, 1);
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
int lucky = new Random().nextInt(4065);
|
int lucky = new Random().nextInt(4065);
|
||||||
@ -144,8 +144,8 @@ public class LongDataTest {
|
|||||||
|
|
||||||
int max = 1000;
|
int max = 1000;
|
||||||
int size = 4065;
|
int size = 4065;
|
||||||
SydApiSM423 en = api.initSM4(1, 1);
|
SydApiSM4 en = api.initSM4(1, 1);
|
||||||
SydApiSM423 de = api.initSM4(1, 0);
|
SydApiSM4 de = api.initSM4(1, 0);
|
||||||
|
|
||||||
ByteBuffer inData = ByteBuffer.allocate(max * size);
|
ByteBuffer inData = ByteBuffer.allocate(max * size);
|
||||||
ByteBuffer enData = ByteBuffer.allocate(max * size + 16);
|
ByteBuffer enData = ByteBuffer.allocate(max * size + 16);
|
||||||
@ -215,4 +215,5 @@ public class LongDataTest {
|
|||||||
|
|
||||||
Assert.assertArrayEquals(deData.array(), inData.array());
|
Assert.assertArrayEquals(deData.array(), inData.array());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,8 +12,8 @@
|
|||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
|
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
|
||||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.sunyard:sydapi4j:1.0.20220902" level="project" />
|
<orderEntry type="library" name="Maven: com.sunyard:sydapi4j:1.0.20220805" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.sunyard:proto:1.0-20220412" level="project" />
|
<orderEntry type="library" name="Maven: com.sunyard:proto:1.0-20220804" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.codehaus.groovy:groovy-all:2.4.15" level="project" />
|
<orderEntry type="library" name="Maven: org.codehaus.groovy:groovy-all:2.4.15" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.10" level="project" />
|
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.10" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.17.0" level="project" />
|
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.17.0" level="project" />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user