增加init/update/digest/finish长数据操作
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.sunyard.sge.database;
|
||||
|
||||
import com.sunyard.SydApiException;
|
||||
import com.sunyard.proto.Util;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@@ -102,16 +103,48 @@ public class SydApiSM4 {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (pcData.length/16<2){
|
||||
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 length=(pcData.length/16)-1;
|
||||
byte[] bytes = new byte[16];
|
||||
dataResult = bytes;
|
||||
byte[] bytes1 = new byte[pcData.length-16];
|
||||
System.arraycopy(pcData,length*16,bytes,0,16);
|
||||
System.arraycopy(pcData,0,bytes1,0,pcData.length-16);
|
||||
byte[] bytes2 = api.SYD_SM4_LongData(iKeyIndex, bytes1, iPkgNum, iFlag);
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -129,9 +162,9 @@ public class SydApiSM4 {
|
||||
this.iPkgNum = 3;
|
||||
}
|
||||
|
||||
|
||||
if (iFlag == 0){
|
||||
byte[] bytes = api.SYD_SM4_LongData(iKeyIndex,dataResult, iPkgNum, iFlag);
|
||||
byte[] d = sourceWrap.array();
|
||||
byte[] bytes = api.SYD_SM4_LongData(iKeyIndex,d, iPkgNum, iFlag);
|
||||
sourceWrap = null;
|
||||
return bytes;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user