确认参数
This commit is contained in:
parent
3cd9e78990
commit
080c705d72
@ -2561,10 +2561,12 @@ public class SydApi4j implements SydApi {
|
||||
|
||||
// 生成会话密钥
|
||||
ret = SM2GenSessionKey(pk);
|
||||
String ciperKey = new String( (byte[]) ret.get(SydApi.RET_CIPHER_KEY));
|
||||
String sessionKeyByLMK = new String( (byte[]) ret.get(SydApi.RET_SESSION_KEY ));
|
||||
String ciperKey = ret.get(SydApi.RET_CIPHER_KEY).toString();
|
||||
String sessionKeyByLMK = (String) ret.get(SydApi.RET_SESSION_KEY );
|
||||
ret.put(SydApi.RET_SESSION_KEY , sessionKeyByLMK.getBytes() );
|
||||
|
||||
println("ciperKey=" + ciperKey);
|
||||
println("sessionKeyByLMK=" + sessionKeyByLMK);
|
||||
|
||||
// 加密数据
|
||||
byte[] iv = new byte[32];
|
||||
@ -2573,7 +2575,7 @@ public class SydApi4j implements SydApi {
|
||||
byte[] enData = (byte[]) retWrap.get("msg_all");
|
||||
|
||||
// 组织格式
|
||||
ContentInfo cms = genCMSEnvelopedData(Util.hexString2Bytes(ciperKey), enData,
|
||||
ContentInfo cms = genCMSEnvelopedData( Util.hexString2Bytes(ciperKey), enData,
|
||||
x509.getSerialNumber().toString(16) ,
|
||||
dnToMap(issuser.getName() )
|
||||
);
|
||||
@ -5142,14 +5144,14 @@ public class SydApi4j implements SydApi {
|
||||
}
|
||||
RetWrap rw = new RetWrap();
|
||||
rw.put(SydApi.RET_CIPHER_KEY,
|
||||
((PacketSection) ret.get("key")).getBytes()
|
||||
Util.bytes2HexString( ((PacketSection) ret.get("key")).getBytes() )
|
||||
);
|
||||
|
||||
rw.put(SydApi.RET_SESSION_KEY, (((PacketSection) ret.get("lmkHead")).getString() +
|
||||
((PacketSection) ret.get("lmk")).getString()).getBytes()
|
||||
((PacketSection) ret.get("lmk")).getString())
|
||||
);
|
||||
|
||||
rw.put(SydApi.RET_KCV, ((PacketSection) ret.get("keyCheck")).getBytes());
|
||||
rw.put(SydApi.RET_KCV, ((PacketSection) ret.get("keyCheck")).getString());
|
||||
|
||||
return rw;
|
||||
}
|
||||
|
||||
@ -193,6 +193,20 @@ public class TestHT {
|
||||
printRetWrap(retWrap1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecryptDE58k() throws UnsupportedEncodingException {
|
||||
String dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";
|
||||
byte[] oData = new byte[ 8 * 1024 ];
|
||||
|
||||
RetWrap retWrap = api.generateDEByDn(dn, oData);
|
||||
byte[] CipherKey = (byte[]) retWrap.get(SydApi.RET_CIPHER_KEY);
|
||||
byte[] sessionKey = (byte[]) retWrap.get(SydApi.RET_SESSION_KEY);
|
||||
printRetWrap(retWrap);
|
||||
|
||||
RetWrap retWrap1 = api.decryptDEByDN(dn, CipherKey);
|
||||
printRetWrap(retWrap1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecryptDE5() throws UnsupportedEncodingException {
|
||||
String dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user