整理
This commit is contained in:
@@ -272,9 +272,9 @@ public interface SydApi {
|
||||
);
|
||||
|
||||
|
||||
public SydApiSM4 initSydApiSM4(SydApi sydApi,int iKeyIndex,int iFlag,int ende, int key);
|
||||
public SydApiSM4 initSM4(SydApi sydApi, int iKeyIndex, int ende);
|
||||
|
||||
public SydApiSM3 initSydApiSM3(SydApi sydApi,int ende, int key);
|
||||
public SydApiSM3 initSM3();
|
||||
|
||||
public SydSM4Mac initSydSM4Mac(SydApi sydApi,int iKeyIndex,int ende, int key,String pcMac);
|
||||
public SydSM4Mac initSM4Mac(int iKeyIndex);
|
||||
}
|
||||
|
||||
@@ -768,22 +768,17 @@ public class SydApi4Database implements SydApi {
|
||||
|
||||
|
||||
@Override
|
||||
public SydApiSM4 initSydApiSM4(SydApi sydApi,int iKeyIndex,int iFlag,int ende, int key) {
|
||||
public SydApiSM4 initSM4(SydApi sydApi, int iKeyIndex, int ende) {
|
||||
|
||||
return new SydApiSM4(sydApi,iKeyIndex,iFlag,ende,key);
|
||||
return new SydApiSM4(this,iKeyIndex,ende);
|
||||
}
|
||||
public SydApiSM3 initSydApiSM3(SydApi sydApi,int ende, int key) {
|
||||
public SydApiSM3 initSM3() {
|
||||
|
||||
return new SydApiSM3(sydApi);
|
||||
return new SydApiSM3(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SydSM4Mac initSydSM4Mac(SydApi sydApi, int iKeyIndex,int ende, int key,String pcMac) {
|
||||
return new SydSM4Mac(sydApi,iKeyIndex,1,null,pcMac);
|
||||
}
|
||||
|
||||
public SydSM4Mac initSydSM4Mac(SydApi sydApi){
|
||||
|
||||
return new SydSM4Mac(sydApi);
|
||||
public SydSM4Mac initSM4Mac(int iKeyIndex) {
|
||||
return new SydSM4Mac(this, iKeyIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
package com.sunyard.sge.database;
|
||||
|
||||
import com.sunyard.SydApiException;
|
||||
import com.sunyard.sge.EntityCache;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class SydApiSM4 {
|
||||
|
||||
@@ -15,24 +11,19 @@ public class SydApiSM4 {
|
||||
private byte[] pcdataResult = new byte[0];
|
||||
private int iPkgNum = 1;
|
||||
private int iFlag;
|
||||
private int key;
|
||||
private int endeFlag;
|
||||
private boolean is_finished = false;
|
||||
ByteBuffer sourceWrap = ByteBuffer.wrap(new byte[0]);
|
||||
|
||||
|
||||
|
||||
public SydApiSM4(SydApi api,int iKeyIndex, int key, int endeFlag,int iFlag) {
|
||||
public SydApiSM4(SydApi api, int iKeyIndex, int endeFlag) {
|
||||
this.api = api;
|
||||
this.key = key;
|
||||
this.endeFlag = endeFlag;
|
||||
this.iFlag = iFlag;
|
||||
this.iFlag = endeFlag;
|
||||
this.iKeyIndex = iKeyIndex;
|
||||
}
|
||||
|
||||
public void update(byte[] pcData) {
|
||||
this.pcdataResult = pcData;
|
||||
if (null==pcData||pcData.length==0){
|
||||
if (null == pcData || pcData.length == 0) {
|
||||
return;
|
||||
}
|
||||
int plength = pcData.length;
|
||||
@@ -81,8 +72,7 @@ public class SydApiSM4 {
|
||||
bufferResult.put(pcData);
|
||||
byte[] bytes = SydSM4Mac.bytebuffer2ByteArray(bufferResult);
|
||||
api.SYD_SM4_LongData(iKeyIndex, bytes, iPkgNum, iFlag);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ByteBuffer bufferResult = ByteBuffer.allocate(sourceWrap.array().length + plength);
|
||||
bufferResult.put(sourceWrap);
|
||||
bufferResult.put(pcData);
|
||||
@@ -98,8 +88,8 @@ public class SydApiSM4 {
|
||||
ByteBuffer bufferResults = ByteBuffer.allocate(remainder);
|
||||
bufferResults.put(bytes1);
|
||||
sourceWrap = bufferResults;
|
||||
api.SYD_SM4_LongData(iKeyIndex, pcdataResult, iPkgNum, iFlag);
|
||||
iPkgNum = 2;
|
||||
api.SYD_SM4_LongData(iKeyIndex, pcdataResult, iPkgNum, iFlag);
|
||||
iPkgNum = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +109,8 @@ public class SydApiSM4 {
|
||||
// sourceWrap = null;
|
||||
return bytes;
|
||||
}
|
||||
public ByteBuffer bufferResult(int plength,byte[] pcData){
|
||||
|
||||
public ByteBuffer bufferResult(int plength, byte[] pcData) {
|
||||
ByteBuffer bufferResult = ByteBuffer.allocate(sourceWrap.array().length + plength);
|
||||
bufferResult.put(sourceWrap);
|
||||
bufferResult.put(pcData);
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.sunyard.SydApiException;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
public class SydSM4Mac {
|
||||
private SydApi api;
|
||||
@@ -16,7 +17,7 @@ public class SydSM4Mac {
|
||||
private byte[] pcdataResult = new byte[0];
|
||||
ByteBuffer sourceWrap = ByteBuffer.wrap(new byte[0]);
|
||||
|
||||
public SydSM4Mac(SydApi api, int iKeyIndex, int iPkgNum, String pcProcData,String pcMac) {
|
||||
public SydSM4Mac(SydApi api, int iKeyIndex) {
|
||||
this.api = api;
|
||||
this.iKeyIndex = iKeyIndex;
|
||||
this.pcProcData = pcProcData;
|
||||
@@ -126,7 +127,9 @@ public class SydSM4Mac {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public LongDataReturn disget() {
|
||||
|
||||
if (is_finished) {
|
||||
throw new SydApiException(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user