Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc450dcdb5 | ||
|
|
aacd927fbf | ||
|
|
e18cfab77d |
@@ -11,3 +11,4 @@
|
||||
/.DS_Store
|
||||
src/test/java/com/sunyard/sydapi/sample/*.*
|
||||
*.p7
|
||||
/pack/
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
~$*
|
||||
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"vars": {
|
||||
"version": "%project.git_branch_version%",
|
||||
"out_path": "./pack",
|
||||
"target_f1": "./target/sydapi4j-jar-with-dependencies.jar",
|
||||
"target_t1": "%out_path%/sydapi4j-jar-with-dependencies.jar",
|
||||
"target_f2": "./target/sydapi4j.jar",
|
||||
"target_t2": "%out_path%/sydapi4j.jar"
|
||||
},
|
||||
"clear": [
|
||||
{
|
||||
"func": "rmdir",
|
||||
"path": "%out_path%"
|
||||
}
|
||||
],
|
||||
"init": [
|
||||
{
|
||||
"func": "mkdir",
|
||||
"path": "%out_path%"
|
||||
},
|
||||
{
|
||||
"func": "mkdir",
|
||||
"path": "%out_path%/jar"
|
||||
},
|
||||
{
|
||||
"func": "mkdir",
|
||||
"path": "%out_path%/jar/dependences"
|
||||
},
|
||||
{
|
||||
"func": "mkdir",
|
||||
"path": "%out_path%/doc"
|
||||
}
|
||||
],
|
||||
"dependencies": [{
|
||||
"func" : "pom",
|
||||
"xml" : "%out_path%/jar"
|
||||
}, {
|
||||
"shell" : "mvn dependency:copy-dependencies -DincludeScope=runtime -DoutputDirectory=%out_path%/jar/dependences",
|
||||
"check": "BUILD SUCCESS"
|
||||
}],
|
||||
"gen" : [{
|
||||
"shell" : "dproto"
|
||||
}],
|
||||
"build": [
|
||||
{
|
||||
"cmd" : "init"
|
||||
},
|
||||
{
|
||||
"shell": "mvn package -DskipTests",
|
||||
"check": "BUILD SUCCESS"
|
||||
},
|
||||
{
|
||||
"func": "cp",
|
||||
"from": "%target_f1%",
|
||||
"to": "%target_t1%"
|
||||
},
|
||||
{
|
||||
"func": "cp",
|
||||
"from": "%target_f2%",
|
||||
"to": "%target_t2%"
|
||||
},
|
||||
{
|
||||
"func": "zip",
|
||||
"from": "%out_path%",
|
||||
"to": "%out_path%/sydapi-%version%.zip"
|
||||
},
|
||||
{
|
||||
"func": "open",
|
||||
"path": "%out_path%"
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
@@ -38,6 +38,14 @@ interface SydHashApi {
|
||||
*/
|
||||
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 算法计算数据的散列值。
|
||||
|
||||
@@ -4669,6 +4669,11 @@ public class SydApi4j implements SydApi {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public byte[] SM3Hash(String publicKey, String userId, byte[] msg){
|
||||
return SM3Hash(publicKey, null, null, userId, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] SM3Hash(String publicKey, byte[] msg, int block, byte[] mac) {
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user