Merge remote-tracking branch 'origin/dev-1.0' into dev-1.0

This commit is contained in:
cheney 2022-09-01 18:02:33 +08:00
commit 52378b75f1

View File

@ -14,7 +14,7 @@ public class SydApiSM4 {
private boolean is_finished = false;
private byte[] dataResult = new byte[0];
ByteBuffer sourceWrap = ByteBuffer.wrap(new byte[1]);
ByteBuffer sourceWrap = ByteBuffer.wrap(new byte[0]);
public SydApiSM4(SydApi api, int iKeyIndex, int endeFlag) {
@ -59,9 +59,9 @@ public class SydApiSM4 {
bufferResult.put(bytes1);
sourceWrap = bufferResult;
}
byte[] bytes = api.SYD_SM4_LongData(iKeyIndex, pcdataResult, iPkgNum, iFlag);
iPkgNum = 2;
return api.SYD_SM4_LongData(iKeyIndex, pcdataResult, iPkgNum, iFlag);
return bytes;
} else {
if (16 > pcData.length + sourceWrap.array().length) {
@ -75,7 +75,9 @@ public class SydApiSM4 {
bufferResult.put(sourceWrap.array());
bufferResult.put(pcData);
byte[] bytes = SydSM4Mac.bytebuffer2ByteArray(bufferResult);
return api.SYD_SM4_LongData(iKeyIndex, bytes, iPkgNum, iFlag);
byte[] bytes1 = api.SYD_SM4_LongData(iKeyIndex, bytes, iPkgNum, iFlag);
iPkgNum = 2;
return bytes1;
} else {
ByteBuffer bufferResult = ByteBuffer.allocate(sourceWrap.array().length + plength);
bufferResult.put(sourceWrap.array());
@ -92,8 +94,10 @@ public class SydApiSM4 {
ByteBuffer bufferResults = ByteBuffer.allocate(remainder);
bufferResults.put(bytes1);
sourceWrap = bufferResults;
byte[] bytes2 = api.SYD_SM4_LongData(iKeyIndex, pcdataResult, iPkgNum, iFlag);
iPkgNum = 2;
return api.SYD_SM4_LongData(iKeyIndex, pcdataResult, iPkgNum, iFlag);
return bytes2;
}
}
}
@ -106,9 +110,10 @@ public class SydApiSM4 {
dataResult = bytes;
byte[] bytes1 = new byte[pcData.length-16];
System.arraycopy(pcData,length*16,bytes,0,16);
System.arraycopy(pcData,1,bytes1,0,pcData.length-16);
System.arraycopy(pcData,0,bytes1,0,pcData.length-16);
byte[] bytes2 = api.SYD_SM4_LongData(iKeyIndex, bytes1, iPkgNum, iFlag);
iPkgNum = 2;
return api.SYD_SM4_LongData(iKeyIndex,bytes1,iPkgNum,iFlag);
return bytes2;
}
}
@ -126,14 +131,11 @@ public class SydApiSM4 {
if (iFlag == 0){
ByteBuffer buffer = ByteBuffer.allocate(dataResult.length+sourceWrap.array().length);
buffer.put(dataResult);
buffer.put(sourceWrap.array());
byte[] bytes = api.SYD_SM4_LongData(iKeyIndex,dataResult, iPkgNum, iFlag);
sourceWrap = null;
return bytes;
}
byte[] bytes = api.SYD_SM4_LongData(iKeyIndex,dataResult, iPkgNum, iFlag);
byte[] bytes = api.SYD_SM4_LongData(iKeyIndex,sourceWrap.array(), iPkgNum, iFlag);
sourceWrap = null;
return bytes;
}