添加 SM3 接口变种
This commit is contained in:
parent
899b0cc1ca
commit
dbc5530853
@ -37,6 +37,14 @@ interface SydHashApi {
|
|||||||
*/
|
*/
|
||||||
byte[] SM3Hash(String publicKey, byte[] msg, int block, byte[] mac);
|
byte[] SM3Hash(String publicKey, byte[] msg, int block, byte[] mac);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算SM3散列值
|
||||||
|
* @param publicKey 公钥的 DER 编码 (03420004 开头)
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param msg 原始数据,二进制的消息块
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
byte[] SM3Hash(String publicKey, String userId, byte[] msg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 输入对指定的原始数据和公钥,通过 SM3 算法计算数据的散列值。
|
* 输入对指定的原始数据和公钥,通过 SM3 算法计算数据的散列值。
|
||||||
|
|||||||
31
src/test/java/com/sunyard/sydapi/test/TestSM3PK.java
Normal file
31
src/test/java/com/sunyard/sydapi/test/TestSM3PK.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package com.sunyard.sydapi.test;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sunyard.proto.Util;
|
||||||
|
import racal.sunyard.main.SydApi4j;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
|
public class TestSM3PK {
|
||||||
|
public static void main(String[] args) throws UnsupportedEncodingException {
|
||||||
|
System.setProperty("com.sunyard.sydapi4j.debug", "true");
|
||||||
|
|
||||||
|
SydApi4j.SYD_Set_Parameter_HA("unkown", "192.168.0.200", 8889, 1000);
|
||||||
|
|
||||||
|
SydApi4j api = (SydApi4j) new SydApi4j();//.connect("wuyong.fullstack.club" , 8889, null,1000);
|
||||||
|
String certId = "4008258105";
|
||||||
|
try {
|
||||||
|
// "03420004" +
|
||||||
|
String pk = "034200043c59ccb2c52e034337fad49eca0095587eb40e24ffc642d07e0c911ea4a3b0e94f11b92b51047f6f75badf5ab2fc2e15ba4dfddf95869d4fa8d8852dea811d4b";
|
||||||
|
|
||||||
|
byte[] ret = api.SM3Hash(pk, certId, Util.hexString2Bytes("636572745F69643D3430303832353831303526636F64653D3430303034266D73673DE7BCBAE5B091E5BF85E98089E58F82E695B0267369676E5F747970653D534D32267375625F636F64653D75702E6D697373696E672D6F72672D706964267375625F6D73673DE7BCBAE5B0916F72675F706964205B5550303231303031325D"));
|
||||||
|
|
||||||
|
System.out.println( Util.bytes2HexString( ret ) );
|
||||||
|
} finally {
|
||||||
|
api.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user