This commit is contained in:
liulu
2024-11-14 17:23:38 +08:00
parent 5ce75ed4ce
commit 84aaa824c5
5 changed files with 14 additions and 15 deletions
@@ -31,7 +31,7 @@ public abstract class JnaSdfAdaptor implements SdfApiAdapter {
protected final SdfLibrary sdfLibrary;
protected abstract int getAlgId(String alg);
protected abstract int getAlgId(AlgId alg);
@Override
public String openDevice() {
@@ -2,6 +2,7 @@ package com.sunyard.chsm.sdf.adapter;
import com.sun.jna.Native;
import com.sun.jna.ptr.PointerByReference;
import com.sunyard.chsm.sdf.context.AlgId;
import com.sunyard.chsm.sdf.context.SunyardAlgId;
import com.sunyard.chsm.sdf.lib.SunyardSdfLibrary;
@@ -50,8 +51,8 @@ public class SunyardJnaSdfAdaptor extends JnaSdfAdaptor {
}
@Override
protected int getAlgId(String alg) {
return SunyardAlgId.valueOf(alg).getValue();
protected int getAlgId(AlgId alg) {
return SunyardAlgId.valueOf(alg.name()).getValue();
}
public static byte[] safeStringBytes(String str) {
@@ -4,15 +4,15 @@ package com.sunyard.chsm.sdf.context;
* @author liulu
* @since 2024/11/5
*/
public interface AlgId {
public enum AlgId {
SGD_SM3,
String SGD_SM3 = "SGD_SM3";
SGD_SM4_CBC,
SGD_SM4_ECB,
SGD_SM4_MAC,
String SGD_SM4_CBC = "SGD_SMS4_CBC";
String SGD_SM4_ECB = "SGD_SMS4_ECB";
String SGD_SM4_MAC = "SGD_SMS4_MAC";
String SGD_SM2_1 = "SGD_SM2_1"; // 签名验签
String SGD_SM2_2 = "SGD_SM2_2";
String SGD_SM2_3 = "SGD_SM2_3"; // 加密解密
SGD_SM2_1,// 签名验签
SGD_SM2_2,
SGD_SM2_3,// 加密解密
;
}