增加init/update/digest/finish长数据操作
This commit is contained in:
@@ -272,7 +272,7 @@ public interface SydApi {
|
||||
);
|
||||
|
||||
|
||||
public SydApiSM4 initSydApiSM4(SydApi sydApi,int iFlag,int ende, int key);
|
||||
public SydApiSM4 initSydApiSM4(SydApi sydApi,int iKeyIndex,int iFlag,int ende, int key);
|
||||
|
||||
public SydApiSM3 initSydApiSM3(SydApi sydApi,int ende, int key);
|
||||
|
||||
|
||||
@@ -768,9 +768,9 @@ public class SydApi4Database implements SydApi {
|
||||
|
||||
|
||||
@Override
|
||||
public SydApiSM4 initSydApiSM4(SydApi sydApi,int iFlag,int ende, int key) {
|
||||
public SydApiSM4 initSydApiSM4(SydApi sydApi,int iKeyIndex,int iFlag,int ende, int key) {
|
||||
|
||||
return new SydApiSM4(sydApi,iFlag,ende,key);
|
||||
return new SydApiSM4(sydApi,iKeyIndex,iFlag,ende,key);
|
||||
}
|
||||
public SydApiSM3 initSydApiSM3(SydApi sydApi,int ende, int key) {
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
public class SydApiSM4 {
|
||||
|
||||
private SydApi api;
|
||||
private int iKeyIndex=1;
|
||||
private int iKeyIndex;
|
||||
private byte[] pcdataResult = new byte[0];
|
||||
private int iPkgNum = 1;
|
||||
private int iFlag;
|
||||
@@ -22,11 +22,12 @@ public class SydApiSM4 {
|
||||
|
||||
|
||||
|
||||
public SydApiSM4(SydApi api, int key, int endeFlag,int iFlag) {
|
||||
public SydApiSM4(SydApi api,int iKeyIndex, int key, int endeFlag,int iFlag) {
|
||||
this.api = api;
|
||||
this.key = key;
|
||||
this.endeFlag = endeFlag;
|
||||
this.iFlag = iFlag;
|
||||
this.iKeyIndex = iKeyIndex;
|
||||
}
|
||||
|
||||
public void update(byte[] pcData) {
|
||||
@@ -65,7 +66,7 @@ public class SydApiSM4 {
|
||||
bufferResult.put(bytes1);
|
||||
sourceWrap = bufferResult;
|
||||
}
|
||||
byte[] bytes = api.SYD_SM4_LongData(iKeyIndex, pcData, iPkgNum, iFlag);
|
||||
byte[] bytes = api.SYD_SM4_LongData(iKeyIndex, pcdataResult, iPkgNum, iFlag);
|
||||
iKeyIndex = 2;
|
||||
} else {
|
||||
if (16 > pcData.length + sourceWrap.array().length) {
|
||||
|
||||
@@ -27,6 +27,9 @@ public class SydSM4Mac {
|
||||
}
|
||||
|
||||
public SydSM4Mac update(byte[] pcData) {
|
||||
if (null==pcData||0 == pcData.length) {
|
||||
return this;
|
||||
}
|
||||
int length = pcData.length;
|
||||
this.pcdataResult = pcData;
|
||||
if (is_finished) {
|
||||
@@ -35,9 +38,7 @@ public class SydSM4Mac {
|
||||
if (length > 4064) {
|
||||
throw new SydApiException(0);
|
||||
}
|
||||
if (0 == length) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (length < 16) {
|
||||
ByteBuffer bufferResult = ByteBuffer.allocate(sourceWrap.array().length + length);
|
||||
bufferResult.put(sourceWrap);
|
||||
|
||||
Reference in New Issue
Block a user