1、添加SJJ1418相关的一些结构体。2、添加SJJ1418指令相关的部分xml文件。3、添加SJJ1418接口的实现类。
This commit is contained in:
@@ -0,0 +1,228 @@
|
||||
package com.sunyard.entity;
|
||||
|
||||
import com.sunyard.proto.Util;
|
||||
import com.sunyard.util.DataUtil;
|
||||
|
||||
/**
|
||||
* 设备信息定义
|
||||
*/
|
||||
public class DeviceInfo {
|
||||
|
||||
/**
|
||||
* 设备生产厂商名称
|
||||
*/
|
||||
private String IssuerName;
|
||||
|
||||
/**
|
||||
* 设备型号
|
||||
*/
|
||||
private String DeviceName;
|
||||
|
||||
/**
|
||||
* 设备编号,机具号
|
||||
*/
|
||||
private String DeviceSerial;
|
||||
|
||||
/**
|
||||
* 密码设备内部软件的版本号
|
||||
*/
|
||||
private String DeviceVersion;
|
||||
|
||||
/**
|
||||
* 密码设备支持的接口规范版本号
|
||||
*/
|
||||
private String StandardVersion;
|
||||
|
||||
/**
|
||||
* 支持的算法
|
||||
*/
|
||||
private int AsymAlgAbility;
|
||||
|
||||
/**
|
||||
* RSA算法的最大模长
|
||||
*/
|
||||
private int RSAMoldHeight;
|
||||
|
||||
/**
|
||||
* SM2算法的最大模长
|
||||
*/
|
||||
private int SM2MoldHeight;
|
||||
|
||||
/**
|
||||
* 所有支持的对称算法
|
||||
*/
|
||||
private int SymAlgAbility;
|
||||
|
||||
/**
|
||||
* 支持的杂凑算法
|
||||
*/
|
||||
private int HashAlgAbility;
|
||||
|
||||
/**
|
||||
* 支持的最大文件存储空间(单位字节)
|
||||
*/
|
||||
private int BufferSize;
|
||||
|
||||
public DeviceInfo() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证是否有传入的算法
|
||||
* @param alg
|
||||
* @return
|
||||
*/
|
||||
public boolean isAlg(int alg){
|
||||
return alg == (alg & AsymAlgAbility ) ||
|
||||
alg == (alg & SymAlgAbility ) ||
|
||||
alg == (alg & HashAlgAbility);
|
||||
}
|
||||
|
||||
/**
|
||||
* 53554E59415244000000000000000000000000000000000000000000000000000000000000000000 SUNYARD
|
||||
* 53594431313138000000000000000000 SYD1118
|
||||
* 71420200000630313030303030303031
|
||||
* 322E3031 2.01
|
||||
* 00182012 00182012
|
||||
* 00000300 00030000
|
||||
* 00010008 08000100
|
||||
* 007F0000 00007F00
|
||||
* 01000000 00000001
|
||||
* 68020000 00000268
|
||||
* 将传进来的byte[]数组解析成字段的值
|
||||
* @param data
|
||||
*/
|
||||
public DeviceInfo(byte[] data) {
|
||||
|
||||
this.IssuerName = new String(DataUtil.catFromArr(data, 0, DataUtil.getIndex(data, 0, 40)));
|
||||
|
||||
int index = DataUtil.getIndex(data, 40, 56);
|
||||
this.DeviceName = new String(DataUtil.catFromArr(data, 40, index - 40));
|
||||
|
||||
this.DeviceSerial = Util.bytes2HexString(DataUtil.catFromArr(data, 56, 6));
|
||||
|
||||
this.DeviceVersion = new String(DataUtil.catFromArr(data, 72, 4));
|
||||
|
||||
this.StandardVersion = Util.bytes2HexString(DataUtil.catFromArr(data, 76, 4));
|
||||
|
||||
this.AsymAlgAbility = DataUtil.byteToInt4(data, 80);
|
||||
|
||||
this.SM2MoldHeight = (data[84] & 0xff) + ((data[85] & 0xff) << 8);
|
||||
|
||||
this.RSAMoldHeight = (data[86] & 0xff) + ((data[87] & 0xff) << 8);
|
||||
|
||||
this.SymAlgAbility = DataUtil.byteToInt4(data, 88);
|
||||
this.HashAlgAbility = DataUtil.byteToInt4(data, 92);
|
||||
|
||||
byte[] bs = new byte[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
bs[3 - i] = data[96 + i];
|
||||
}
|
||||
this.BufferSize = DataUtil.byteToInt4(bs, 0);
|
||||
}
|
||||
|
||||
|
||||
public String getIssuerName() {
|
||||
return IssuerName;
|
||||
}
|
||||
|
||||
public void setIssuerName(String issuerName) {
|
||||
IssuerName = issuerName;
|
||||
}
|
||||
|
||||
public String getDeviceName() {
|
||||
return DeviceName;
|
||||
}
|
||||
|
||||
public void setDeviceName(String deviceName) {
|
||||
DeviceName = deviceName;
|
||||
}
|
||||
|
||||
public String getDeviceSerial() {
|
||||
return DeviceSerial;
|
||||
}
|
||||
|
||||
public void setDeviceSerial(String deviceSerial) {
|
||||
DeviceSerial = deviceSerial;
|
||||
}
|
||||
|
||||
public String getDeviceVersion() {
|
||||
return DeviceVersion;
|
||||
}
|
||||
|
||||
public void setDeviceVersion(String deviceVersion) {
|
||||
DeviceVersion = deviceVersion;
|
||||
}
|
||||
|
||||
public String getStandardVersion() {
|
||||
return StandardVersion;
|
||||
}
|
||||
|
||||
public void setStandardVersion(String standardVersion) {
|
||||
StandardVersion = standardVersion;
|
||||
}
|
||||
|
||||
public int getAsymAlgAbility() {
|
||||
return AsymAlgAbility;
|
||||
}
|
||||
|
||||
public void setAsymAlgAbility(int asymAlgAbility) {
|
||||
AsymAlgAbility = asymAlgAbility;
|
||||
}
|
||||
|
||||
public int getRSAMoldHeight() {
|
||||
return RSAMoldHeight;
|
||||
}
|
||||
|
||||
public void setRSAMoldHeight(int RSAMoldHeight) {
|
||||
this.RSAMoldHeight = RSAMoldHeight;
|
||||
}
|
||||
|
||||
public int getSM2MoldHeight() {
|
||||
return SM2MoldHeight;
|
||||
}
|
||||
|
||||
public void setSM2MoldHeight(int SM2MoldHeight) {
|
||||
this.SM2MoldHeight = SM2MoldHeight;
|
||||
}
|
||||
|
||||
public int getSymAlgAbility() {
|
||||
return SymAlgAbility;
|
||||
}
|
||||
|
||||
public void setSymAlgAbility(int symAlgAbility) {
|
||||
SymAlgAbility = symAlgAbility;
|
||||
}
|
||||
|
||||
public int getHashAlgAbility() {
|
||||
return HashAlgAbility;
|
||||
}
|
||||
|
||||
public void setHashAlgAbility(int hashAlgAbility) {
|
||||
HashAlgAbility = hashAlgAbility;
|
||||
}
|
||||
|
||||
public int getBufferSize() {
|
||||
return BufferSize;
|
||||
}
|
||||
|
||||
public void setBufferSize(int bufferSize) {
|
||||
BufferSize = bufferSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeviceInfo{" +
|
||||
"IssuerName='" + IssuerName + '\'' +
|
||||
", DeviceName='" + DeviceName + '\'' +
|
||||
", DeviceSerial='" + DeviceSerial + '\'' +
|
||||
", DeviceVersion='" + DeviceVersion + '\'' +
|
||||
", StandardVersion='" + StandardVersion + '\'' +
|
||||
", AsymAlgAbility=" + AsymAlgAbility +
|
||||
", RSAMoldHeight=" + RSAMoldHeight +
|
||||
", SM2MoldHeight=" + SM2MoldHeight +
|
||||
", SymAlgAbility=" + SymAlgAbility +
|
||||
", HashAlgAbility=" + HashAlgAbility +
|
||||
", BufferSize=" + BufferSize +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.sunyard.entity;
|
||||
|
||||
import com.sunyard.constant.SDFConstant;
|
||||
|
||||
public class ECCCipher_st {
|
||||
|
||||
private byte[] x = new byte[ SDFConstant._ECCref_MAX_LEN ];
|
||||
private byte[] y = new byte[ SDFConstant._ECCref_MAX_LEN ];
|
||||
private byte[] M = new byte[ 32 ];
|
||||
private int L;
|
||||
private byte[] C = new byte[ SDFConstant._ECCref_MAX_DATALEN ]; // C不能大于5120字节
|
||||
|
||||
public ECCCipher_st() {
|
||||
}
|
||||
|
||||
public byte[] getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(byte[] x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public byte[] getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(byte[] y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public byte[] getM() {
|
||||
return M;
|
||||
}
|
||||
|
||||
public void setM(byte[] m) {
|
||||
M = m;
|
||||
}
|
||||
|
||||
public int getL() {
|
||||
return L;
|
||||
}
|
||||
|
||||
public void setL(int l) {
|
||||
L = l;
|
||||
}
|
||||
|
||||
public byte[] getC() {
|
||||
return C;
|
||||
}
|
||||
|
||||
public void setC(byte[] c) {
|
||||
C = c;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.sunyard.entity;
|
||||
|
||||
import com.sunyard.constant.SDFConstant;
|
||||
|
||||
public class ECCSignnature_st {
|
||||
|
||||
private byte[] r = new byte[ SDFConstant._ECCref_MAX_LEN ];
|
||||
private byte[] s = new byte[ SDFConstant._ECCref_MAX_LEN ];
|
||||
|
||||
public ECCSignnature_st() {
|
||||
}
|
||||
|
||||
public byte[] getR() {
|
||||
return r;
|
||||
}
|
||||
|
||||
public void setR(byte[] r) {
|
||||
this.r = r;
|
||||
}
|
||||
|
||||
public byte[] getS() {
|
||||
return s;
|
||||
}
|
||||
|
||||
public void setS(byte[] s) {
|
||||
this.s = s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sunyard.entity;
|
||||
|
||||
import com.sunyard.constant.SDFConstant;
|
||||
|
||||
public class ECCrefPrivateKey_st {
|
||||
|
||||
private int bits;
|
||||
|
||||
private byte[] K = new byte[ SDFConstant._ECCref_MAX_LEN ];
|
||||
|
||||
public ECCrefPrivateKey_st() {
|
||||
}
|
||||
|
||||
public int getBits() {
|
||||
return bits;
|
||||
}
|
||||
|
||||
public void setBits(int bits) {
|
||||
this.bits = bits;
|
||||
}
|
||||
|
||||
public byte[] getK() {
|
||||
return K;
|
||||
}
|
||||
|
||||
public void setK(byte[] k) {
|
||||
K = k;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.sunyard.entity;
|
||||
|
||||
import com.sunyard.constant.SDFConstant;
|
||||
|
||||
public class ECCrefPublicKey_st {
|
||||
|
||||
private int bits;
|
||||
|
||||
private byte[] x = new byte[ SDFConstant._ECCref_MAX_LEN ];
|
||||
|
||||
private byte[] y = new byte[ SDFConstant._ECCref_MAX_LEN ];
|
||||
|
||||
public ECCrefPublicKey_st() {
|
||||
}
|
||||
|
||||
public int getBits() {
|
||||
return bits;
|
||||
}
|
||||
|
||||
public void setBits(int bits) {
|
||||
this.bits = bits;
|
||||
}
|
||||
|
||||
public byte[] getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(byte[] x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public byte[] getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(byte[] y) {
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.sunyard.entity;
|
||||
|
||||
import com.sunyard.constant.SDFConstant;
|
||||
|
||||
public class RSArefPriKey_st {
|
||||
|
||||
private int bits;
|
||||
private byte[] m = new byte[SDFConstant._RSAref_MAX_LEN];
|
||||
private byte[] e = new byte[SDFConstant._RSAref_MAX_LEN];
|
||||
private byte[] d = new byte[SDFConstant._RSAref_MAX_LEN];
|
||||
private byte[][] prime = new byte[2][SDFConstant._RSAref_MAX_PLEN];
|
||||
private byte[][] pexp = new byte[2][SDFConstant._RSAref_MAX_PLEN];
|
||||
private byte[] coef = new byte[SDFConstant._RSAref_MAX_PLEN];
|
||||
|
||||
public RSArefPriKey_st() {
|
||||
}
|
||||
|
||||
public int getBits() {
|
||||
return bits;
|
||||
}
|
||||
|
||||
public void setBits(int bits) {
|
||||
this.bits = bits;
|
||||
}
|
||||
|
||||
public byte[] getM() {
|
||||
return m;
|
||||
}
|
||||
|
||||
public void setM(byte[] m) {
|
||||
this.m = m;
|
||||
}
|
||||
|
||||
public byte[] getE() {
|
||||
return e;
|
||||
}
|
||||
|
||||
public void setE(byte[] e) {
|
||||
this.e = e;
|
||||
}
|
||||
|
||||
public byte[] getD() {
|
||||
return d;
|
||||
}
|
||||
|
||||
public void setD(byte[] d) {
|
||||
this.d = d;
|
||||
}
|
||||
|
||||
public byte[][] getPrime() {
|
||||
return prime;
|
||||
}
|
||||
|
||||
public void setPrime(byte[][] prime) {
|
||||
this.prime = prime;
|
||||
}
|
||||
|
||||
public byte[][] getPexp() {
|
||||
return pexp;
|
||||
}
|
||||
|
||||
public void setPexp(byte[][] pexp) {
|
||||
this.pexp = pexp;
|
||||
}
|
||||
|
||||
public byte[] getCoef() {
|
||||
return coef;
|
||||
}
|
||||
|
||||
public void setCoef(byte[] coef) {
|
||||
this.coef = coef;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.sunyard.entity;
|
||||
|
||||
import com.sunyard.constant.SDFConstant;
|
||||
|
||||
public class RSArefPubKey_st {
|
||||
|
||||
private int bits;
|
||||
|
||||
private byte[] m = new byte[SDFConstant._RSAref_MAX_LEN];
|
||||
private byte[] e = new byte[SDFConstant._RSAref_MAX_LEN];
|
||||
|
||||
public RSArefPubKey_st() {
|
||||
}
|
||||
|
||||
public int getBits() {
|
||||
return bits;
|
||||
}
|
||||
|
||||
public void setBits(int bits) {
|
||||
this.bits = bits;
|
||||
}
|
||||
|
||||
public byte[] getM() {
|
||||
return m;
|
||||
}
|
||||
|
||||
public void setM(byte[] m) {
|
||||
this.m = m;
|
||||
}
|
||||
|
||||
public byte[] getE() {
|
||||
return e;
|
||||
}
|
||||
|
||||
public void setE(byte[] e) {
|
||||
this.e = e;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.sunyard.entity;
|
||||
|
||||
import com.sunyard.constant.SDFConstant;
|
||||
|
||||
public class SYD_AgreementHandle_st {
|
||||
|
||||
private int index; //发起方公私钥索引
|
||||
private int idlength; //发起方ID长度
|
||||
private byte[] id = new byte[SDFConstant.SYD_PARA_SPONSORID_MAX]; //发起方ID
|
||||
private ECCrefPublicKey_st pucPublicKey_sm2; //发起方临时公钥
|
||||
private ECCrefPrivateKey_st pucPrivateKey_sm2; //发起方临时私钥
|
||||
private int Key_len; //协商生成的密钥长度
|
||||
|
||||
public SYD_AgreementHandle_st() {
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public int getIdlength() {
|
||||
return idlength;
|
||||
}
|
||||
|
||||
public void setIdlength(int idlength) {
|
||||
this.idlength = idlength;
|
||||
}
|
||||
|
||||
public byte[] getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(byte[] id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public ECCrefPublicKey_st getPucPublicKey_sm2() {
|
||||
return pucPublicKey_sm2;
|
||||
}
|
||||
|
||||
public void setPucPublicKey_sm2(ECCrefPublicKey_st pucPublicKey_sm2) {
|
||||
this.pucPublicKey_sm2 = pucPublicKey_sm2;
|
||||
}
|
||||
|
||||
public ECCrefPrivateKey_st getPucPrivateKey_sm2() {
|
||||
return pucPrivateKey_sm2;
|
||||
}
|
||||
|
||||
public void setPucPrivateKey_sm2(ECCrefPrivateKey_st pucPrivateKey_sm2) {
|
||||
this.pucPrivateKey_sm2 = pucPrivateKey_sm2;
|
||||
}
|
||||
|
||||
public int getKey_len() {
|
||||
return Key_len;
|
||||
}
|
||||
|
||||
public void setKey_len(int key_len) {
|
||||
Key_len = key_len;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.sunyard.entity;
|
||||
|
||||
public class SYD_HashCtx_st {
|
||||
|
||||
private byte[] hashContext = new byte[2048];
|
||||
private int hashContextLen;
|
||||
private byte[] hashMessage = new byte[2048];
|
||||
private int hashMessageLen;
|
||||
private int hashmode;
|
||||
|
||||
public SYD_HashCtx_st() {
|
||||
}
|
||||
|
||||
public byte[] getHashContext() {
|
||||
return hashContext;
|
||||
}
|
||||
|
||||
public void setHashContext(byte[] hashContext) {
|
||||
this.hashContext = hashContext;
|
||||
}
|
||||
|
||||
public int getHashContextLen() {
|
||||
return hashContextLen;
|
||||
}
|
||||
|
||||
public void setHashContextLen(int hashContextLen) {
|
||||
this.hashContextLen = hashContextLen;
|
||||
}
|
||||
|
||||
public byte[] getHashMessage() {
|
||||
return hashMessage;
|
||||
}
|
||||
|
||||
public void setHashMessage(byte[] hashMessage) {
|
||||
this.hashMessage = hashMessage;
|
||||
}
|
||||
|
||||
public int getHashMessageLen() {
|
||||
return hashMessageLen;
|
||||
}
|
||||
|
||||
public void setHashMessageLen(int hashMessageLen) {
|
||||
this.hashMessageLen = hashMessageLen;
|
||||
}
|
||||
|
||||
public int getHashmode() {
|
||||
return hashmode;
|
||||
}
|
||||
|
||||
public void setHashmode(int hashmode) {
|
||||
this.hashmode = hashmode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.sunyard.entity;
|
||||
|
||||
public class SYD_KeyHandle_st {
|
||||
|
||||
private int iKeylen;
|
||||
private byte[] cKeyData = new byte[128];
|
||||
|
||||
public SYD_KeyHandle_st() {
|
||||
}
|
||||
|
||||
public int getiKeylen() {
|
||||
return iKeylen;
|
||||
}
|
||||
|
||||
public void setiKeylen(int iKeylen) {
|
||||
this.iKeylen = iKeylen;
|
||||
}
|
||||
|
||||
public byte[] getcKeyData() {
|
||||
return cKeyData;
|
||||
}
|
||||
|
||||
public void setcKeyData(byte[] cKeyData) {
|
||||
this.cKeyData = cKeyData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.sunyard.entity;
|
||||
|
||||
public class SYD_SessionKey_st {
|
||||
|
||||
private int iStatus;
|
||||
private SYD_KeyHandle_st hKeyHandle;
|
||||
|
||||
public SYD_SessionKey_st() {
|
||||
}
|
||||
|
||||
public int getiStatus() {
|
||||
return iStatus;
|
||||
}
|
||||
|
||||
public void setiStatus(int iStatus) {
|
||||
this.iStatus = iStatus;
|
||||
}
|
||||
|
||||
public SYD_KeyHandle_st gethKeyHandle() {
|
||||
return hKeyHandle;
|
||||
}
|
||||
|
||||
public void sethKeyHandle(SYD_KeyHandle_st hKeyHandle) {
|
||||
this.hKeyHandle = hKeyHandle;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user