初始化项目

This commit is contained in:
waner
2026-02-28 14:41:43 +08:00
parent 8d57e8b3fd
commit 7c16d5d576
178 changed files with 10310 additions and 1 deletions
@@ -0,0 +1,14 @@
package com.cisd.tms;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@ConfigurationPropertiesScan
public class TmsApplication {
public static void main(String[] args) {
SpringApplication.run(TmsApplication.class, args);
}
}
@@ -0,0 +1,128 @@
package com.cisd.tms.common.api;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.time.Instant;
import java.util.Map;
import org.slf4j.MDC;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ApiResponse<T> {
private static final int SUCCESS_CODE = 200;
private static final String DEFAULT_SUCCESS_MSG = "success";
private boolean success;
private int code;
private String msg;
private T data;
private long timestamp;
private String traceId;
private String path;
private Map<String, Object> details;
public ApiResponse() {
}
public ApiResponse(boolean success, int code, String msg, T data) {
this.success = success;
this.code = code;
this.msg = msg;
this.data = data;
this.timestamp = Instant.now().toEpochMilli();
this.traceId = MDC.get("traceId");
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
public String getTraceId() {
return traceId;
}
public void setTraceId(String traceId) {
this.traceId = traceId;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public Map<String, Object> getDetails() {
return details;
}
public void setDetails(Map<String, Object> details) {
this.details = details;
}
public ApiResponse<T> withPath(String path) {
this.path = path;
return this;
}
public ApiResponse<T> withDetails(Map<String, Object> details) {
this.details = details;
return this;
}
public static <T> ApiResponse<T> success(T data) {
return new ApiResponse<>(true, SUCCESS_CODE, DEFAULT_SUCCESS_MSG, data);
}
public static <T> ApiResponse<T> success(String msg, T data) {
return new ApiResponse<>(true, SUCCESS_CODE, msg, data);
}
public static ApiResponse<Void> success() {
return new ApiResponse<>(true, SUCCESS_CODE, DEFAULT_SUCCESS_MSG, null);
}
public static ApiResponse<Void> fail(int code, String msg) {
return new ApiResponse<>(false, code, msg, null);
}
public static <T> ApiResponse<T> fail(int code, String msg, T data) {
return new ApiResponse<>(false, code, msg, data);
}
}
@@ -0,0 +1,14 @@
package com.cisd.tms.common.config;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MybatisPlusConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
return new MybatisPlusInterceptor();
}
}
@@ -0,0 +1,42 @@
package com.cisd.tms.common.config;
import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springdoc.core.models.GroupedOpenApi;
@Configuration
public class OpenApiConfig {
@Bean
public OpenAPI tmsOpenApi() {
return new OpenAPI()
.info(new Info()
.title("CISD TMS API")
.description("CISD Terminal Management System API")
.version("v0.0.1")
.license(new License().name("Internal Use")))
.externalDocs(new ExternalDocumentation()
.description("CISD design docs")
.url("https://example.internal/cisd"));
}
@Bean
public GroupedOpenApi internalApiGroup() {
return GroupedOpenApi.builder()
.group("internal-api")
.pathsToMatch("/api/**")
.build();
}
@Bean
public GroupedOpenApi openApiGroup() {
return GroupedOpenApi.builder()
.group("openapi-sign")
.pathsToMatch("/openapi/**")
.build();
}
}
@@ -0,0 +1,65 @@
package com.cisd.tms.common.config;
import com.cisd.tms.security.internal.InternalApiAuthInterceptor;
import com.cisd.tms.security.openapi.OpenApiSignAuthInterceptor;
import com.cisd.tms.common.util.TraceIdUtil;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import org.slf4j.MDC;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
private final InternalApiAuthInterceptor internalApiAuthInterceptor;
private final OpenApiSignAuthInterceptor openApiSignAuthInterceptor;
public WebMvcConfig(
InternalApiAuthInterceptor internalApiAuthInterceptor,
OpenApiSignAuthInterceptor openApiSignAuthInterceptor
) {
this.internalApiAuthInterceptor = internalApiAuthInterceptor;
this.openApiSignAuthInterceptor = openApiSignAuthInterceptor;
}
@Bean
public OncePerRequestFilter traceIdFilter() {
return new OncePerRequestFilter() {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
String traceId = request.getHeader("X-Trace-Id");
if (traceId == null || traceId.isBlank()) {
traceId = TraceIdUtil.newTraceId();
}
MDC.put("traceId", traceId);
response.setHeader("X-Trace-Id", traceId);
try {
filterChain.doFilter(request, response);
} finally {
MDC.remove("traceId");
}
}
};
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(internalApiAuthInterceptor)
.addPathPatterns("/api/**")
.excludePathPatterns(
"/api/v1/device/status",
"/api/v1/auth/login"
);
registry.addInterceptor(openApiSignAuthInterceptor)
.addPathPatterns("/openapi/**");
}
}
@@ -0,0 +1,45 @@
package com.cisd.tms.common.config.properties;
import java.util.HashMap;
import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "tms.security")
public class TmsSecurityProperties {
private String internalToken = "change-me-internal-token";
private final Openapi openapi = new Openapi();
public String getInternalToken() {
return internalToken;
}
public void setInternalToken(String internalToken) {
this.internalToken = internalToken;
}
public Openapi getOpenapi() {
return openapi;
}
public static class Openapi {
private long timestampSkewSeconds = 300;
private Map<String, String> clients = new HashMap<>();
public long getTimestampSkewSeconds() {
return timestampSkewSeconds;
}
public void setTimestampSkewSeconds(long timestampSkewSeconds) {
this.timestampSkewSeconds = timestampSkewSeconds;
}
public Map<String, String> getClients() {
return clients;
}
public void setClients(Map<String, String> clients) {
this.clients = clients;
}
}
}
@@ -0,0 +1,10 @@
package com.cisd.tms.common.constant;
public final class Profiles {
public static final String DEV = "dev";
public static final String PROD = "prod";
private Profiles() {
}
}
@@ -0,0 +1,26 @@
package com.cisd.tms.common.enums;
public enum ErrorCode {
BAD_REQUEST(400, "bad request"),
UNAUTHORIZED(4010, "unauthorized"),
VALIDATE_FAILED(4001, "parameter validation failed"),
BIZ_ERROR(5001, "business exception"),
CRYPTO_CARD_ERROR(5201, "crypto card adapter error"),
INTERNAL_ERROR(5000, "internal server error");
private final int code;
private final String message;
ErrorCode(int code, String message) {
this.code = code;
this.message = message;
}
public int getCode() {
return code;
}
public String getMessage() {
return message;
}
}
@@ -0,0 +1,15 @@
package com.cisd.tms.common.exception;
public class BizException extends RuntimeException {
private final int code;
public BizException(int code, String message) {
super(message);
this.code = code;
}
public int getCode() {
return code;
}
}
@@ -0,0 +1,60 @@
package com.cisd.tms.common.exception;
import com.cisd.tms.common.api.ApiResponse;
import com.cisd.tms.common.enums.ErrorCode;
import com.cisd.tms.integration.crypto.pcie.PcieCryptoException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.ConstraintViolationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@RestControllerAdvice
public class GlobalExceptionHandler {
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
@ExceptionHandler(MethodArgumentNotValidException.class)
public ApiResponse<Void> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpServletRequest request) {
String msg = ex.getBindingResult().getAllErrors().stream()
.findFirst()
.map(error -> {
if (error instanceof FieldError fieldError) {
return fieldError.getField() + ": " + fieldError.getDefaultMessage();
}
return error.getDefaultMessage();
})
.orElse(ErrorCode.VALIDATE_FAILED.getMessage());
return ApiResponse.fail(ErrorCode.VALIDATE_FAILED.getCode(), msg).withPath(request.getRequestURI());
}
@ExceptionHandler(ConstraintViolationException.class)
public ApiResponse<Void> handleConstraintViolation(ConstraintViolationException ex, HttpServletRequest request) {
return ApiResponse.fail(ErrorCode.VALIDATE_FAILED.getCode(), ex.getMessage()).withPath(request.getRequestURI());
}
@ExceptionHandler(BizException.class)
public ApiResponse<Void> handleBizException(BizException ex, HttpServletRequest request) {
return ApiResponse.fail(ex.getCode(), ex.getMessage()).withPath(request.getRequestURI());
}
@ExceptionHandler(IllegalArgumentException.class)
public ApiResponse<Void> handleIllegalArgument(IllegalArgumentException ex, HttpServletRequest request) {
return ApiResponse.fail(ErrorCode.VALIDATE_FAILED.getCode(), ex.getMessage()).withPath(request.getRequestURI());
}
@ExceptionHandler(PcieCryptoException.class)
public ApiResponse<Void> handleCryptoCardException(PcieCryptoException ex, HttpServletRequest request) {
return ApiResponse.fail(ErrorCode.CRYPTO_CARD_ERROR.getCode(), ex.getMessage())
.withPath(request.getRequestURI());
}
@ExceptionHandler(Exception.class)
public ApiResponse<Void> handleException(Exception ex, HttpServletRequest request) {
log.error("Unhandled exception", ex);
return ApiResponse.fail(ErrorCode.INTERNAL_ERROR.getCode(), ErrorCode.INTERNAL_ERROR.getMessage())
.withPath(request.getRequestURI());
}
}
@@ -0,0 +1,30 @@
package com.cisd.tms.common.util;
import java.nio.charset.StandardCharsets;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
public final class HmacUtil {
private HmacUtil() {
}
public static String hmacSha256Hex(String key, String content) {
try {
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
byte[] digest = mac.doFinal(content.getBytes(StandardCharsets.UTF_8));
return toHex(digest);
} catch (Exception ex) {
throw new IllegalStateException("Cannot calculate hmac", ex);
}
}
private static String toHex(byte[] bytes) {
StringBuilder builder = new StringBuilder(bytes.length * 2);
for (byte b : bytes) {
builder.append(String.format("%02x", b));
}
return builder.toString();
}
}
@@ -0,0 +1,20 @@
package com.cisd.tms.common.util;
import com.cisd.tms.common.api.ApiResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
public final class HttpResponseUtil {
private HttpResponseUtil() {
}
public static void writeJson(HttpServletResponse response, int httpStatus, ApiResponse<?> body, ObjectMapper objectMapper)
throws IOException {
response.setStatus(httpStatus);
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json;charset=UTF-8");
response.getWriter().write(objectMapper.writeValueAsString(body));
}
}
@@ -0,0 +1,13 @@
package com.cisd.tms.common.util;
import java.util.UUID;
public final class TraceIdUtil {
private TraceIdUtil() {
}
public static String newTraceId() {
return UUID.randomUUID().toString().replace("-", "");
}
}
@@ -0,0 +1,43 @@
package com.cisd.tms.infrastructure.persistence.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
public class BaseEntity {
@TableId(type = IdType.ASSIGN_ID)
private Long id;
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createTime;
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public LocalDateTime getCreateTime() {
return createTime;
}
public void setCreateTime(LocalDateTime createTime) {
this.createTime = createTime;
}
public LocalDateTime getUpdateTime() {
return updateTime;
}
public void setUpdateTime(LocalDateTime updateTime) {
this.updateTime = updateTime;
}
}
@@ -0,0 +1,6 @@
package com.cisd.tms.infrastructure.persistence.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
public interface BaseMapperX<T> extends BaseMapper<T> {
}
@@ -0,0 +1,21 @@
package com.cisd.tms.infrastructure.persistence.mybatis;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import java.time.LocalDateTime;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
@Component
public class CommonMetaObjectHandler implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());
this.strictInsertFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
}
@Override
public void updateFill(MetaObject metaObject) {
this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
}
}
@@ -0,0 +1,4 @@
/**
* cips integration adapters.
*/
package com.cisd.tms.integration.cips;
@@ -0,0 +1,49 @@
package com.cisd.tms.integration.crypto.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "tms.crypto-card")
public class CryptoCardProperties {
public enum Mode {
MOCK,
JNA
}
private boolean enabled;
private Mode mode = Mode.MOCK;
private String vendorLibPath;
private String vendorLibName = "swsdsdf";
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public Mode getMode() {
return mode;
}
public void setMode(Mode mode) {
this.mode = mode;
}
public String getVendorLibPath() {
return vendorLibPath;
}
public void setVendorLibPath(String vendorLibPath) {
this.vendorLibPath = vendorLibPath;
}
public String getVendorLibName() {
return vendorLibName;
}
public void setVendorLibName(String vendorLibName) {
this.vendorLibName = vendorLibName;
}
}
@@ -0,0 +1,35 @@
package com.cisd.tms.integration.crypto.config;
import com.cisd.tms.integration.crypto.pcie.PcieSessionTemplate;
import com.cisd.tms.integration.crypto.pcie.service.JnaPcieCryptoService;
import com.cisd.tms.integration.crypto.pcie.service.MockPcieCryptoService;
import com.cisd.tms.integration.crypto.pcie.service.PcieCryptoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class PcieCryptoServiceConfiguration {
private static final Logger log = LoggerFactory.getLogger(PcieCryptoServiceConfiguration.class);
@Bean
public PcieCryptoService pcieCryptoService(
CryptoCardProperties properties,
PcieSessionTemplate sessionTemplate
) {
if (!properties.isEnabled()) {
log.info("PCIe crypto service disabled, fallback to mock service");
return new MockPcieCryptoService();
}
if (properties.getMode() == CryptoCardProperties.Mode.JNA) {
log.info("PCIe crypto service enabled in JNA mode");
return new JnaPcieCryptoService(sessionTemplate);
}
log.info("PCIe crypto service fallback to mock, current mode={}", properties.getMode());
return new MockPcieCryptoService();
}
}
@@ -0,0 +1,4 @@
/**
* Crypto card configuration and properties.
*/
package com.cisd.tms.integration.crypto.config;
@@ -0,0 +1,4 @@
/**
* Crypto integration entry points.
*/
package com.cisd.tms.integration.crypto;
@@ -0,0 +1,27 @@
package com.cisd.tms.integration.crypto.pcie;
public class PcieCryptoException extends RuntimeException {
private final String apiName;
private final int nativeRetCode;
public PcieCryptoException(String apiName, int nativeRetCode, String message) {
super("[" + apiName + "] " + message + " (errorCode=" + nativeRetCode + ")");
this.apiName = apiName;
this.nativeRetCode = nativeRetCode;
}
public PcieCryptoException(String apiName, String message, Throwable cause) {
super("[" + apiName + "] " + message, cause);
this.apiName = apiName;
this.nativeRetCode = -1;
}
public String getApiName() {
return apiName;
}
public int getNativeRetCode() {
return nativeRetCode;
}
}
@@ -0,0 +1,38 @@
package com.cisd.tms.integration.crypto.pcie;
import java.util.HashMap;
import java.util.Map;
import org.springframework.stereotype.Component;
@Component
public class PcieErrorMapper {
private final Map<Integer, String> lowByteErrorMap = new HashMap<>();
public PcieErrorMapper() {
// From PCIe custom document (SDR_BASE + 0x1F ~ 0x27)
lowByteErrorMap.put(0x1F, "ukey error");
lowByteErrorMap.put(0x20, "generate key error");
lowByteErrorMap.put(0x21, "state error");
lowByteErrorMap.put(0x22, "retry exceeded");
lowByteErrorMap.put(0x23, "device busy");
lowByteErrorMap.put(0x24, "error status");
lowByteErrorMap.put(0x25, "init status");
lowByteErrorMap.put(0x26, "already logined");
lowByteErrorMap.put(0x27, "timeout");
}
public String toMessage(int retCode) {
if (retCode == 0) {
return "success";
}
int lowByte = retCode & 0xFF;
String known = lowByteErrorMap.get(lowByte);
if (known != null) {
return known + " (retCode=0x" + Integer.toHexString(retCode) + ")";
}
return "native error (retCode=0x" + Integer.toHexString(retCode) + ")";
}
}
@@ -0,0 +1,27 @@
package com.cisd.tms.integration.crypto.pcie;
public enum PcieKeyState {
NO_VALID(0),
NO_RIGHT(1),
RIGHT(2),
UNKNOWN(-1);
private final int code;
PcieKeyState(int code) {
this.code = code;
}
public int getCode() {
return code;
}
public static PcieKeyState from(int code) {
for (PcieKeyState state : values()) {
if (state.code == code) {
return state;
}
}
return UNKNOWN;
}
}
@@ -0,0 +1,116 @@
package com.cisd.tms.integration.crypto.pcie;
import com.cisd.tms.integration.crypto.config.CryptoCardProperties;
import com.cisd.tms.integration.crypto.pcie.jna.PcieNativeLibrary;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.PointerByReference;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@Component
public class PcieSessionTemplate {
@FunctionalInterface
public interface DeviceCallback<T> {
T apply(PcieNativeLibrary lib, Pointer deviceHandle);
}
@FunctionalInterface
public interface SessionCallback<T> {
T apply(PcieNativeLibrary lib, Pointer deviceHandle, Pointer sessionHandle);
}
private static final Logger log = LoggerFactory.getLogger(PcieSessionTemplate.class);
private final CryptoCardProperties properties;
private final PcieErrorMapper errorMapper;
private final Object lock = new Object();
private volatile PcieNativeLibrary nativeLibrary;
public PcieSessionTemplate(CryptoCardProperties properties, PcieErrorMapper errorMapper) {
this.properties = properties;
this.errorMapper = errorMapper;
}
public <T> T withDevice(String apiName, DeviceCallback<T> callback) {
synchronized (lock) {
PcieNativeLibrary lib = ensureLibraryLoaded();
PointerByReference deviceRef = new PointerByReference();
int openRc = lib.SDF_OpenDevice(deviceRef);
ensureSuccess(apiName + ":SDF_OpenDevice", openRc);
Pointer device = deviceRef.getValue();
try {
return callback.apply(lib, device);
} finally {
int closeRc = lib.SDF_CloseDevice(device);
if (closeRc != 0) {
log.warn("{} close device failed: {}", apiName, errorMapper.toMessage(closeRc));
}
}
}
}
public <T> T withSession(String apiName, SessionCallback<T> callback) {
return withDevice(apiName, (lib, deviceHandle) -> {
PointerByReference sessionRef = new PointerByReference();
int openSessionRc = lib.SDF_OpenSession(deviceHandle, sessionRef);
ensureSuccess(apiName + ":SDF_OpenSession", openSessionRc);
Pointer session = sessionRef.getValue();
try {
return callback.apply(lib, deviceHandle, session);
} finally {
int closeSessionRc = lib.SDF_CloseSession(session);
if (closeSessionRc != 0) {
log.warn("{} close session failed: {}", apiName, errorMapper.toMessage(closeSessionRc));
}
}
});
}
public void ensureSuccess(String apiName, int retCode) {
if (retCode != 0) {
throw new PcieCryptoException(apiName, retCode, errorMapper.toMessage(retCode));
}
}
private PcieNativeLibrary ensureLibraryLoaded() {
PcieNativeLibrary cached = nativeLibrary;
if (cached != null) {
return cached;
}
synchronized (this) {
if (nativeLibrary != null) {
return nativeLibrary;
}
Map<String, Object> options = new HashMap<>();
options.put(Library.OPTION_STRING_ENCODING, "UTF-8");
String libPath = properties.getVendorLibPath();
String libName = properties.getVendorLibName();
try {
if (libPath != null && !libPath.isBlank()) {
nativeLibrary = Native.load(libPath, PcieNativeLibrary.class, options);
log.info("Loaded PCIe native library by path: {}", libPath);
} else {
nativeLibrary = Native.load(libName, PcieNativeLibrary.class, options);
log.info("Loaded PCIe native library by name: {}", libName);
}
} catch (UnsatisfiedLinkError ex) {
throw new PcieCryptoException("Native.load", "load PCIe native library failed", ex);
}
return nativeLibrary;
}
}
}
@@ -0,0 +1,16 @@
package com.cisd.tms.integration.crypto.pcie;
public enum PcieUserKeyType {
SIGN(0),
ENC(1);
private final int code;
PcieUserKeyType(int code) {
this.code = code;
}
public int getCode() {
return code;
}
}
@@ -0,0 +1,22 @@
package com.cisd.tms.integration.crypto.pcie.jna;
import com.sun.jna.Structure;
import java.util.List;
@Structure.FieldOrder({"x", "y", "m", "l", "c"})
public class EccCipher extends Structure {
// GM/T 0018定义为C[1]变长数组;JNA侧采用固定上限承载。
public static final int C_MAX_LEN = 1024;
public byte[] x = new byte[EccRefPublicKey.MAX_LEN];
public byte[] y = new byte[EccRefPublicKey.MAX_LEN];
public byte[] m = new byte[32];
public int l;
public byte[] c = new byte[C_MAX_LEN];
@Override
protected List<String> getFieldOrder() {
return List.of("x", "y", "m", "l", "c");
}
}
@@ -0,0 +1,19 @@
package com.cisd.tms.integration.crypto.pcie.jna;
import com.sun.jna.Structure;
import java.util.List;
@Structure.FieldOrder({"bits", "k"})
public class EccRefPrivateKey extends Structure {
public static final int MAX_BITS = 512;
public static final int MAX_LEN = (MAX_BITS + 7) / 8;
public int bits;
public byte[] k = new byte[MAX_LEN];
@Override
protected List<String> getFieldOrder() {
return List.of("bits", "k");
}
}
@@ -0,0 +1,20 @@
package com.cisd.tms.integration.crypto.pcie.jna;
import com.sun.jna.Structure;
import java.util.List;
@Structure.FieldOrder({"bits", "x", "y"})
public class EccRefPublicKey extends Structure {
public static final int MAX_BITS = 512;
public static final int MAX_LEN = (MAX_BITS + 7) / 8;
public int bits;
public byte[] x = new byte[MAX_LEN];
public byte[] y = new byte[MAX_LEN];
@Override
protected List<String> getFieldOrder() {
return List.of("bits", "x", "y");
}
}
@@ -0,0 +1,16 @@
package com.cisd.tms.integration.crypto.pcie.jna;
import com.sun.jna.Structure;
import java.util.List;
@Structure.FieldOrder({"r", "s"})
public class EccSignature extends Structure {
public byte[] r = new byte[EccRefPublicKey.MAX_LEN];
public byte[] s = new byte[EccRefPublicKey.MAX_LEN];
@Override
protected List<String> getFieldOrder() {
return List.of("r", "s");
}
}
@@ -0,0 +1,21 @@
package com.cisd.tms.integration.crypto.pcie.jna;
import com.sun.jna.NativeLong;
import com.sun.jna.Structure;
import java.util.List;
@Structure.FieldOrder({"version", "symmAlgId", "bits", "encryptedPriKey", "pubKey", "eccCipherBlob"})
public class EnvelopedKeyBlob extends Structure {
public NativeLong version = new NativeLong();
public NativeLong symmAlgId = new NativeLong();
public NativeLong bits = new NativeLong();
public byte[] encryptedPriKey = new byte[64];
public EccRefPublicKey pubKey = new EccRefPublicKey();
public EccCipher eccCipherBlob = new EccCipher();
@Override
protected List<String> getFieldOrder() {
return List.of("version", "symmAlgId", "bits", "encryptedPriKey", "pubKey", "eccCipherBlob");
}
}
@@ -0,0 +1,263 @@
package com.cisd.tms.integration.crypto.pcie.jna;
import com.sun.jna.Library;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
public interface PcieNativeLibrary extends Library {
int SDF_OpenDevice(PointerByReference phDeviceHandle);
int SDF_CloseDevice(Pointer hDeviceHandle);
int SDF_OpenSession(Pointer hDeviceHandle, PointerByReference phSessionHandle);
int SDF_CloseSession(Pointer hSessionHandle);
int SDF_GetPrivateKeyAccessRight(Pointer hSessionHandle, int uiKeyIndex, byte[] pucPassword, int uiPwdLength);
int SDF_ReleasePrivateKeyAccessRight(Pointer hSessionHandle, int uiKeyIndex);
int SDF_GetDeviceInfo(Pointer hSessionHandle, SdfDeviceInfo deviceInfo);
int SDF_GenerateRandom(Pointer hSessionHandle, int uiLength, byte[] pucRandom);
int SDF_ImportKey(Pointer hSessionHandle, byte[] pucKey, int uiKeyLength, PointerByReference phKeyHandle);
int SDF_ImportKeyWithKEK(Pointer hSessionHandle, int uiAlgID, byte[] pucKey, int uiKeyLength,
int uiKEKIndex, PointerByReference phKeyHandle);
int SDF_GenerateKeyWithKEK(Pointer hSessionHandle, int uiKeyBits, int uiAlgID, int uiKEKIndex,
byte[] pucKey, IntByReference puiKeyLength, PointerByReference phKeyHandle);
int SDF_DestroyKey(Pointer hSessionHandle, Pointer hKeyHandle);
int SDF_ExportSignPublicKey_RSA(Pointer hSessionHandle, int uiKeyIndex, RsaRefPublicKey pucPublicKey);
int SDF_ExportEncPublicKey_RSA(Pointer hSessionHandle, int uiKeyIndex, RsaRefPublicKey pucPublicKey);
int SDF_ExportSignPublicKey_ECC(Pointer hSessionHandle, int uiKeyIndex, EccRefPublicKey pucPublicKey);
int SDF_ExportEncPublicKey_ECC(Pointer hSessionHandle, int uiKeyIndex, EccRefPublicKey pucPublicKey);
int SDF_GenerateKeyPair_RSA(Pointer hSessionHandle, int uiKeyBits, RsaRefPublicKey pucPublicKey, RsaRefPrivateKey pucPrivateKey);
int SDF_GenerateKeyPair_ECC(Pointer hSessionHandle, int uiAlgID, int uiKeyBits, EccRefPublicKey pucPublicKey, EccRefPrivateKey pucPrivateKey);
int SDF_ExternalPublicKeyOperation_RSA(Pointer hSessionHandle, RsaRefPublicKey pucPublicKey,
byte[] pucInput, int uiInputLength,
byte[] pucOutput, IntByReference puiOutputLength);
int SDF_ExternalPrivateKeyOperation_RSA(Pointer hSessionHandle, RsaRefPrivateKey pucPrivateKey,
byte[] pucInput, int uiInputLength,
byte[] pucOutput, IntByReference puiOutputLength);
int SDF_InternalPublicKeyOperation_RSA(Pointer hSessionHandle, int uiKeyIndex,
byte[] pucInput, int uiInputLength,
byte[] pucOutput, IntByReference puiOutputLength);
int SDF_InternalPrivateKeyOperation_RSA(Pointer hSessionHandle, int uiKeyIndex,
byte[] pucInput, int uiInputLength,
byte[] pucOutput, IntByReference puiOutputLength);
int SDF_InternalSign_ECC(Pointer hSessionHandle, int uiISKIndex, byte[] pucData, int uiDataLength, EccSignature pucSignature);
int SDF_InternalVerify_ECC(Pointer hSessionHandle, int uiISKIndex, byte[] pucData, int uiDataLength, EccSignature pucSignature);
int SDF_ExternalSign_ECC(Pointer hSessionHandle, int uiAlgID, EccRefPrivateKey pucPrivateKey,
byte[] pucData, int uiDataLength, EccSignature pucSignature);
int SDF_ExternalVerify_ECC(Pointer hSessionHandle, int uiAlgID, EccRefPublicKey pucPublicKey,
byte[] pucData, int uiDataLength, EccSignature pucSignature);
int SDF_ExternalEncrypt_ECC(Pointer hSessionHandle, int uiAlgID, EccRefPublicKey pucPublicKey,
byte[] pucData, int uiDataLength, EccCipher pucEncData);
int SDF_ExternalDecrypt_ECC(Pointer hSessionHandle, int uiAlgID, EccRefPrivateKey pucPrivateKey, EccCipher pucEncData,
byte[] pucData, IntByReference puiDataLength);
int SDF_GenerateKeyWithIPK_RSA(Pointer hSessionHandle, int uiIPKIndex, int uiKeyBits,
byte[] pucKey, IntByReference puiKeyLength, PointerByReference phKeyHandle);
int SDF_GenerateKeyWithEPK_RSA(Pointer hSessionHandle, int uiKeyBits, RsaRefPublicKey pucPublicKey,
byte[] pucKey, IntByReference puiKeyLength, PointerByReference phKeyHandle);
int SDF_ImportKeyWithISK_RSA(Pointer hSessionHandle, int uiISKIndex, byte[] pucKey, int uiKeyLength,
PointerByReference phKeyHandle);
int SDF_GenerateKeyWithIPK_ECC(Pointer hSessionHandle, int uiIPKIndex, int uiKeyBits,
EccCipher pucKey, PointerByReference phKeyHandle);
int SDF_GenerateKeyWithEPK_ECC(Pointer hSessionHandle, int uiKeyBits, int uiAlgID, EccRefPublicKey pucPublicKey,
EccCipher pucKey, PointerByReference phKeyHandle);
int SDF_ImportKeyWithISK_ECC(Pointer hSessionHandle, int uiISKIndex, EccCipher pucKey, PointerByReference phKeyHandle);
int SDF_GenerateAgreementDataAndKeyWithECC(Pointer hSessionHandle, int uiISKIndex, int uiKeyBits,
byte[] pucResponseID, int uiResponseIDLength,
byte[] pucSponsorID, int uiSponsorIDLength,
EccRefPublicKey pucSponsorPublicKey, EccRefPublicKey pucSponsorTmpPublicKey,
EccRefPublicKey pucResponsePublicKey, EccRefPublicKey pucResponseTmpPublicKey,
PointerByReference phKeyHandle);
int SDF_GenerateAgreementDataWithECC(Pointer hSessionHandle, int uiISKIndex, int uiKeyBits,
byte[] pucSponsorID, int uiSponsorIDLength,
EccRefPublicKey pucSponsorPublicKey, EccRefPublicKey pucSponsorTmpPublicKey,
PointerByReference phAgreementHandle);
int SDF_GenerateKeyWithECC(Pointer hSessionHandle, byte[] pucResponseID, int uiResponseIDLength,
EccRefPublicKey pucResponsePublicKey, EccRefPublicKey pucResponseTmpPublicKey,
Pointer hAgreementHandle,
PointerByReference phKeyHandle);
int SDF_ExchangeDigitEnvelopeBaseOnRSA(Pointer hSessionHandle, int uiKeyIndex, RsaRefPublicKey pucPublicKey,
byte[] pucDEInput, int uiDELength, byte[] pucDEOutput, IntByReference puiDELength);
int SDF_ExchangeDigitEnvelopeBaseOnECC(Pointer hSessionHandle, int uiKeyIndex, int uiAlgID,
EccRefPublicKey pucPublicKey, EccCipher pucEncDataIn, EccCipher pucEncDataOut);
int SDF_Encrypt(Pointer hSessionHandle, Pointer hKeyHandle, int uiAlgID, byte[] pucIV,
byte[] pucData, int uiDataLength, byte[] pucEncData, IntByReference puiEncDataLength);
int SDF_Decrypt(Pointer hSessionHandle, Pointer hKeyHandle, int uiAlgID, byte[] pucIV,
byte[] pucEncData, int uiEncDataLength, byte[] pucData, IntByReference puiDataLength);
int SDF_CalculateMAC(Pointer hSessionHandle, Pointer hKeyHandle, int uiAlgID, byte[] pucIV,
byte[] pucData, int uiDataLength, byte[] pucMAC, IntByReference puiMACLength);
int SDF_HashInit(Pointer hSessionHandle, int uiAlgID, EccRefPublicKey publicKey, byte[] pucID, int uiIDLength);
int SDF_HashUpdate(Pointer hSessionHandle, byte[] pucData, int uiDataLength);
int SDF_HashFinal(Pointer hSessionHandle, byte[] pucHash, IntByReference puiHashLength);
int SDF_CreateFile(Pointer hSessionHandle, byte[] pucFileName, int uiNameLen, int uiFileSize);
int SDF_DeleteFile(Pointer hSessionHandle, byte[] pucFileName, int uiNameLen);
int SDF_ReadFile(Pointer hSessionHandle, byte[] pucFileName, int uiNameLen, int uiOffset,
IntByReference puiReadLength, byte[] pucBuffer);
int SDF_WriteFile(Pointer hSessionHandle, byte[] pucFileName, int uiNameLen, int uiOffset,
int uiWriteLength, byte[] pucBuffer);
int SDFE_GetDeviceNumber(IntByReference number);
int SDFE_GetNormalDeviceNumber(Pointer hDeviceHandle, IntByReference number);
int SDFE_ChangePrivateKeyAccessPassword(Pointer hSessionHandle, int uiKeyIndex,
byte[] oldPassword, int oldLength,
byte[] newPassword, int newLength);
int SDFE_DeviceConfGet(Pointer hSessionHandle, SdfeDeviceConf deviceConf);
int SDFE_InitIdentify(Pointer hSessionHandle, byte[] oldPin, int oldPinLen, byte[] newPin, int newPinLen);
int SDFE_DeviceStatusGet(Pointer hSessionHandle, Pointer pDeviceStatus);
int SDFE_DeviceSelfTest(Pointer hSessionHandle);
int SDFE_DeviceFactoryReset(Pointer hSessionHandle);
int SDFE_GenerateKeyPair_ECC(Pointer hSessionHandle, int keyBits, int keyIndex, int keyType);
int SDFE_GenerateKeyPair_RSA(Pointer hSessionHandle, int keyBits, int keyIndex, int keyType);
int SDFE_GenerateKEK(Pointer hSessionHandle, int keyBits, int keyIndex);
int SDFE_ImportKeyPair_ECC(Pointer hSessionHandle, int keyIndex, int keyType, EccRefPublicKey publicKey, EccRefPrivateKey privateKey);
int SDFE_ImportKeyPair_RSA(Pointer hSessionHandle, int keyIndex, int keyType, RsaRefPublicKey publicKey, RsaRefPrivateKey privateKey);
int SDFE_ImportKEK(Pointer hSessionHandle, int keyIndex, byte[] keyData, int keyLen);
int SDFE_ImportKEKComponent(Pointer hSessionHandle, int keyIndex, int componentNum, SdfeKekComponent keyComponent);
int SDFE_ExportKEKComponent(Pointer hSessionHandle, int keyIndex, int componentNum, SdfeKekComponent keyComponent);
int SDFE_BackupUserKey(Pointer hSessionHandle, int keyIndex, int keyType, byte[] userKey, IntByReference userKeyLen);
int SDFE_BackupKEK(Pointer hSessionHandle, int keyIndex, byte[] key, IntByReference keyLen);
int SDFE_RecoverUserKey(Pointer hSessionHandle, int keyIndex, int keyType, byte[] userKey, int userKeyLen, byte storeFlag);
int SDFE_RecoverKEK(Pointer hSessionHandle, int keyIndex, byte[] key, int keyLen);
int SDFE_BackKey(Pointer hSessionHandle, byte[] keyImage, IntByReference keyImageSize);
int SDFE_RestoryKey(Pointer hSessionHandle, byte[] keyImage, int keyImageSize);
int SDFE_DeleteUserKey(Pointer hSessionHandle, int keyIndex);
int SDFE_DeleteKey_KEK(Pointer hSessionHandle, int keyIndex);
int SDFE_StatusUserKey_ECC(Pointer hSessionHandle, int keyIndex, int keyType, IntByReference keyState);
int SDFE_StatusUserKey_RSA(Pointer hSessionHandle, int keyIndex, int keyType, IntByReference keyState);
int SDFE_StatusKey_KEK(Pointer hSessionHandle, int keyIndex, IntByReference keyState);
int SDFE_ImportEncKeyPair_ECC(Pointer hSessionHandle, int keyIndex, EnvelopedKeyBlob envelopedKeyBlob);
int SDFE_ImportEncKeyPair_RSA(Pointer hSessionHandle, int keyIndex, int symAlgId,
byte[] wrappedKey, int wrappedKeyLen,
byte[] encryptedData, int encryptedDataLen);
int SDFE_UpdateBackedKey(Pointer hSessionHandle, byte[] oldData, int oldDataLength,
byte[] newData, IntByReference newDataLength);
int SDFE_GenerateLMK(Pointer hSessionHandle);
int SDFE_LoadLMK(Pointer hSessionHandle);
int SDFE_BackupLMK(Pointer hSessionHandle);
int SDFE_RecoverLMK(Pointer hSessionHandle);
int SDFE_DestroyLMK(Pointer hSessionHandle);
int SDFE_ExportLMKSeedMAC(Pointer hSessionHandle, byte[] mac);
int SDFE_CheckLMK(Pointer hSessionHandle);
int SDFE_BackupLMK_EX(Pointer hSessionHandle, SdfeLmkComponent lmkComponent);
int SDFE_RecoverLMK_EX(Pointer hSessionHandle, SdfeLmkComponent lmkComponent);
int SDFE_GenerateIK(Pointer hSessionHandle, int keyType);
int SDFE_BackupIK(Pointer hSessionHandle, int keyType);
int SDFE_RecoverIK(Pointer hSessionHandle, int keyType);
int SDFE_DestroyIK(Pointer hSessionHandle, int keyType);
int SDFE_StatusIK(Pointer hSessionHandle, int keyType, IntByReference keyState);
int SDFE_GenerateUkey(Pointer hSessionHandle, byte adminIndex,
byte[] ukeyPin, int ukeyPinLen,
byte[] loginPin, int loginPinLen);
int SDFE_LoginUkey(Pointer hSessionHandle, byte[] ukeyPin, int ukeyPinLen, byte[] loginPin, int loginPinLen);
int SDFE_ChangeUkeyPin(Pointer hSessionHandle, int pinType, byte[] oldPin, int oldPinLen, byte[] newPin, int newPinLen);
int SDFE_UnlockUkey(Pointer hSessionHandle, byte[] adminPin, int adminPinLen, byte[] userPin, int userPinLen);
int SDFE_ReadLMKComponent(Pointer hSessionHandle, byte[] ukeyPin, int ukeyPinLen);
int SDFE_ReadUkeyIKComponent(Pointer hSessionHandle, int keyType, byte[] ukeyPin, int ukeyPinLen);
int SDFE_GenerateCertificate(Pointer hSessionHandle, byte[] ukeyPin, int ukeyPinLen);
int SDFE_LoginoutAdmin(Pointer hSessionHandle, byte adminIndex);
int SDFE_LoginStatus(Pointer hSessionHandle, SdfeLoginState loginState);
int SDFE_HmacInit(Pointer hSessionHandle, int algId, byte[] key, int keyLen);
int SDFE_HmacUpdate(Pointer hSessionHandle, byte[] data, int dataLength);
int SDFE_HmacFinal(Pointer hSessionHandle, byte[] hmac, IntByReference hmacLength);
}
@@ -0,0 +1,26 @@
package com.cisd.tms.integration.crypto.pcie.jna;
import com.sun.jna.Structure;
import java.util.List;
@Structure.FieldOrder({"bits", "m", "e", "d", "prime", "pexp", "coef"})
public class RsaRefPrivateKey extends Structure {
public static final int MAX_BITS = 2048;
public static final int MAX_LEN = (MAX_BITS + 7) / 8;
public static final int MAX_PBITS = (MAX_BITS + 1) / 2;
public static final int MAX_PLEN = (MAX_PBITS + 7) / 8;
public int bits;
public byte[] m = new byte[MAX_LEN];
public byte[] e = new byte[MAX_LEN];
public byte[] d = new byte[MAX_LEN];
public byte[] prime = new byte[2 * MAX_PLEN];
public byte[] pexp = new byte[2 * MAX_PLEN];
public byte[] coef = new byte[MAX_PLEN];
@Override
protected List<String> getFieldOrder() {
return List.of("bits", "m", "e", "d", "prime", "pexp", "coef");
}
}
@@ -0,0 +1,20 @@
package com.cisd.tms.integration.crypto.pcie.jna;
import com.sun.jna.Structure;
import java.util.List;
@Structure.FieldOrder({"bits", "m", "e"})
public class RsaRefPublicKey extends Structure {
public static final int MAX_BITS = 2048;
public static final int MAX_LEN = (MAX_BITS + 7) / 8;
public int bits;
public byte[] m = new byte[MAX_LEN];
public byte[] e = new byte[MAX_LEN];
@Override
protected List<String> getFieldOrder() {
return List.of("bits", "m", "e");
}
}
@@ -0,0 +1,31 @@
package com.cisd.tms.integration.crypto.pcie.jna;
import com.sun.jna.Structure;
@Structure.FieldOrder({
"issuerName",
"deviceName",
"deviceSerial",
"deviceVersion",
"standardVersion",
"asymAlgAbility",
"symAlgAbility",
"hashAlgAbility",
"bufferSize"
})
public class SdfDeviceInfo extends Structure {
public byte[] issuerName = new byte[40];
public byte[] deviceName = new byte[16];
public byte[] deviceSerial = new byte[16];
public int deviceVersion;
public int standardVersion;
public int[] asymAlgAbility = new int[2];
public int symAlgAbility;
public int hashAlgAbility;
public int bufferSize;
public SdfDeviceInfo() {
super(ALIGN_NONE);
}
}
@@ -0,0 +1,27 @@
package com.cisd.tms.integration.crypto.pcie.jna;
import com.sun.jna.Structure;
@Structure.FieldOrder({
"level",
"devCount",
"rsaKeyCount",
"sm2KeyCount",
"kekCount",
"sessKeyCount",
"fileSysCapacity"
})
public class SdfeDeviceConf extends Structure {
public int level;
public int devCount;
public int rsaKeyCount;
public int sm2KeyCount;
public int kekCount;
public int sessKeyCount;
public int fileSysCapacity;
public SdfeDeviceConf() {
super(ALIGN_NONE);
}
}
@@ -0,0 +1,19 @@
package com.cisd.tms.integration.crypto.pcie.jna;
import com.sun.jna.Structure;
import java.util.List;
@Structure.FieldOrder({"keyLen", "component", "kekMac"})
public class SdfeKekComponent extends Structure {
public static final int KEK_MAX_LEN = 32;
public byte keyLen;
public byte[] component = new byte[9 * KEK_MAX_LEN];
public byte[] kekMac = new byte[8];
@Override
protected List<String> getFieldOrder() {
return List.of("keyLen", "component", "kekMac");
}
}
@@ -0,0 +1,16 @@
package com.cisd.tms.integration.crypto.pcie.jna;
import com.sun.jna.Structure;
import java.util.List;
@Structure.FieldOrder({"lmkMac", "component"})
public class SdfeLmkComponent extends Structure {
public byte[] lmkMac = new byte[8];
public byte[] component = new byte[3 * 16];
@Override
protected List<String> getFieldOrder() {
return List.of("lmkMac", "component");
}
}
@@ -0,0 +1,11 @@
package com.cisd.tms.integration.crypto.pcie.jna;
import com.sun.jna.Structure;
@Structure.FieldOrder({"admin1", "admin2", "admin3"})
public class SdfeLoginState extends Structure {
public int admin1;
public int admin2;
public int admin3;
}
@@ -0,0 +1,4 @@
/**
* JNA bindings and provider implementation for PCIe crypto card native library.
*/
package com.cisd.tms.integration.crypto.pcie.jna;
@@ -0,0 +1,50 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class AgreementDataAndKeyEccResult {
private byte[] responsePublicKey;
private int responsePublicKeyLength;
private byte[] responseTmpPublicKey;
private int responseTmpPublicKeyLength;
private boolean sessionKeyGenerated;
public byte[] getResponsePublicKey() {
return responsePublicKey;
}
public void setResponsePublicKey(byte[] responsePublicKey) {
this.responsePublicKey = responsePublicKey;
}
public int getResponsePublicKeyLength() {
return responsePublicKeyLength;
}
public void setResponsePublicKeyLength(int responsePublicKeyLength) {
this.responsePublicKeyLength = responsePublicKeyLength;
}
public byte[] getResponseTmpPublicKey() {
return responseTmpPublicKey;
}
public void setResponseTmpPublicKey(byte[] responseTmpPublicKey) {
this.responseTmpPublicKey = responseTmpPublicKey;
}
public int getResponseTmpPublicKeyLength() {
return responseTmpPublicKeyLength;
}
public void setResponseTmpPublicKeyLength(int responseTmpPublicKeyLength) {
this.responseTmpPublicKeyLength = responseTmpPublicKeyLength;
}
public boolean isSessionKeyGenerated() {
return sessionKeyGenerated;
}
public void setSessionKeyGenerated(boolean sessionKeyGenerated) {
this.sessionKeyGenerated = sessionKeyGenerated;
}
}
@@ -0,0 +1,23 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class BackupDataResult {
private byte[] data;
private int length;
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public int getLength() {
return length;
}
public void setLength(int length) {
this.length = length;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class ChangePrivateKeyPasswordRequest {
private int keyIndex;
private byte[] oldPassword;
private byte[] newPassword;
public int getKeyIndex() {
return keyIndex;
}
public void setKeyIndex(int keyIndex) {
this.keyIndex = keyIndex;
}
public byte[] getOldPassword() {
return oldPassword;
}
public void setOldPassword(byte[] oldPassword) {
this.oldPassword = oldPassword;
}
public byte[] getNewPassword() {
return newPassword;
}
public void setNewPassword(byte[] newPassword) {
this.newPassword = newPassword;
}
}
@@ -0,0 +1,68 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class DeviceConfResult {
private int level;
private int devCount;
private int rsaKeyCount;
private int sm2KeyCount;
private int kekCount;
private int sessKeyCount;
private int fileSysCapacity;
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public int getDevCount() {
return devCount;
}
public void setDevCount(int devCount) {
this.devCount = devCount;
}
public int getRsaKeyCount() {
return rsaKeyCount;
}
public void setRsaKeyCount(int rsaKeyCount) {
this.rsaKeyCount = rsaKeyCount;
}
public int getSm2KeyCount() {
return sm2KeyCount;
}
public void setSm2KeyCount(int sm2KeyCount) {
this.sm2KeyCount = sm2KeyCount;
}
public int getKekCount() {
return kekCount;
}
public void setKekCount(int kekCount) {
this.kekCount = kekCount;
}
public int getSessKeyCount() {
return sessKeyCount;
}
public void setSessKeyCount(int sessKeyCount) {
this.sessKeyCount = sessKeyCount;
}
public int getFileSysCapacity() {
return fileSysCapacity;
}
public void setFileSysCapacity(int fileSysCapacity) {
this.fileSysCapacity = fileSysCapacity;
}
}
@@ -0,0 +1,23 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class DeviceCountResult {
private int deviceNumber;
private int normalDeviceNumber;
public int getDeviceNumber() {
return deviceNumber;
}
public void setDeviceNumber(int deviceNumber) {
this.deviceNumber = deviceNumber;
}
public int getNormalDeviceNumber() {
return normalDeviceNumber;
}
public void setNormalDeviceNumber(int normalDeviceNumber) {
this.normalDeviceNumber = normalDeviceNumber;
}
}
@@ -0,0 +1,95 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class DeviceInfoResult {
private String issuerName;
private String deviceName;
private String deviceSerial;
private int deviceVersion;
private int standardVersion;
private int asymAlgAbility0;
private int asymAlgAbility1;
private int symAlgAbility;
private int hashAlgAbility;
private int bufferSize;
public String getIssuerName() {
return issuerName;
}
public void setIssuerName(String issuerName) {
this.issuerName = issuerName;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getDeviceSerial() {
return deviceSerial;
}
public void setDeviceSerial(String deviceSerial) {
this.deviceSerial = deviceSerial;
}
public int getDeviceVersion() {
return deviceVersion;
}
public void setDeviceVersion(int deviceVersion) {
this.deviceVersion = deviceVersion;
}
public int getStandardVersion() {
return standardVersion;
}
public void setStandardVersion(int standardVersion) {
this.standardVersion = standardVersion;
}
public int getAsymAlgAbility0() {
return asymAlgAbility0;
}
public void setAsymAlgAbility0(int asymAlgAbility0) {
this.asymAlgAbility0 = asymAlgAbility0;
}
public int getAsymAlgAbility1() {
return asymAlgAbility1;
}
public void setAsymAlgAbility1(int asymAlgAbility1) {
this.asymAlgAbility1 = asymAlgAbility1;
}
public int getSymAlgAbility() {
return symAlgAbility;
}
public void setSymAlgAbility(int symAlgAbility) {
this.symAlgAbility = symAlgAbility;
}
public int getHashAlgAbility() {
return hashAlgAbility;
}
public void setHashAlgAbility(int hashAlgAbility) {
this.hashAlgAbility = hashAlgAbility;
}
public int getBufferSize() {
return bufferSize;
}
public void setBufferSize(int bufferSize) {
this.bufferSize = bufferSize;
}
}
@@ -0,0 +1,23 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class DeviceStatusResult {
private byte[] statusData;
private int length;
public byte[] getStatusData() {
return statusData;
}
public void setStatusData(byte[] statusData) {
this.statusData = statusData;
}
public int getLength() {
return length;
}
public void setLength(int length) {
this.length = length;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class DigestRequest {
private int algId;
private byte[] data;
private int outBufferSize = 64;
public int getAlgId() {
return algId;
}
public void setAlgId(int algId) {
this.algId = algId;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public int getOutBufferSize() {
return outBufferSize;
}
public void setOutBufferSize(int outBufferSize) {
this.outBufferSize = outBufferSize;
}
}
@@ -0,0 +1,86 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class EccAgreementSessionKeyRequest {
private int iskIndex;
private int keyBits;
private byte[] sponsorId;
private byte[] responseId;
private byte[] responsePublicKeyBlob;
private byte[] responseTmpPublicKeyBlob;
private int sponsorPublicKeyBufferSize;
private int sponsorTmpPublicKeyBufferSize;
private int sessionKeyBufferSize;
public int getIskIndex() {
return iskIndex;
}
public void setIskIndex(int iskIndex) {
this.iskIndex = iskIndex;
}
public int getKeyBits() {
return keyBits;
}
public void setKeyBits(int keyBits) {
this.keyBits = keyBits;
}
public byte[] getSponsorId() {
return sponsorId;
}
public void setSponsorId(byte[] sponsorId) {
this.sponsorId = sponsorId;
}
public byte[] getResponseId() {
return responseId;
}
public void setResponseId(byte[] responseId) {
this.responseId = responseId;
}
public byte[] getResponsePublicKeyBlob() {
return responsePublicKeyBlob;
}
public void setResponsePublicKeyBlob(byte[] responsePublicKeyBlob) {
this.responsePublicKeyBlob = responsePublicKeyBlob;
}
public byte[] getResponseTmpPublicKeyBlob() {
return responseTmpPublicKeyBlob;
}
public void setResponseTmpPublicKeyBlob(byte[] responseTmpPublicKeyBlob) {
this.responseTmpPublicKeyBlob = responseTmpPublicKeyBlob;
}
public int getSponsorPublicKeyBufferSize() {
return sponsorPublicKeyBufferSize;
}
public void setSponsorPublicKeyBufferSize(int sponsorPublicKeyBufferSize) {
this.sponsorPublicKeyBufferSize = sponsorPublicKeyBufferSize;
}
public int getSponsorTmpPublicKeyBufferSize() {
return sponsorTmpPublicKeyBufferSize;
}
public void setSponsorTmpPublicKeyBufferSize(int sponsorTmpPublicKeyBufferSize) {
this.sponsorTmpPublicKeyBufferSize = sponsorTmpPublicKeyBufferSize;
}
public int getSessionKeyBufferSize() {
return sessionKeyBufferSize;
}
public void setSessionKeyBufferSize(int sessionKeyBufferSize) {
this.sessionKeyBufferSize = sessionKeyBufferSize;
}
}
@@ -0,0 +1,68 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class EccAgreementSessionKeyResult {
private byte[] sponsorPublicKey;
private int sponsorPublicKeyLength;
private byte[] sponsorTmpPublicKey;
private int sponsorTmpPublicKeyLength;
private byte[] sessionKey;
private int sessionKeyLength;
private boolean sessionKeyGenerated;
public byte[] getSponsorPublicKey() {
return sponsorPublicKey;
}
public void setSponsorPublicKey(byte[] sponsorPublicKey) {
this.sponsorPublicKey = sponsorPublicKey;
}
public int getSponsorPublicKeyLength() {
return sponsorPublicKeyLength;
}
public void setSponsorPublicKeyLength(int sponsorPublicKeyLength) {
this.sponsorPublicKeyLength = sponsorPublicKeyLength;
}
public byte[] getSponsorTmpPublicKey() {
return sponsorTmpPublicKey;
}
public void setSponsorTmpPublicKey(byte[] sponsorTmpPublicKey) {
this.sponsorTmpPublicKey = sponsorTmpPublicKey;
}
public int getSponsorTmpPublicKeyLength() {
return sponsorTmpPublicKeyLength;
}
public void setSponsorTmpPublicKeyLength(int sponsorTmpPublicKeyLength) {
this.sponsorTmpPublicKeyLength = sponsorTmpPublicKeyLength;
}
public byte[] getSessionKey() {
return sessionKey;
}
public void setSessionKey(byte[] sessionKey) {
this.sessionKey = sessionKey;
}
public int getSessionKeyLength() {
return sessionKeyLength;
}
public void setSessionKeyLength(int sessionKeyLength) {
this.sessionKeyLength = sessionKeyLength;
}
public boolean isSessionKeyGenerated() {
return sessionKeyGenerated;
}
public void setSessionKeyGenerated(boolean sessionKeyGenerated) {
this.sessionKeyGenerated = sessionKeyGenerated;
}
}
@@ -0,0 +1,41 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class EccExternalDecryptRequest {
private int algId;
private byte[] privateKeyBlob;
private byte[] encryptedData;
private int outBufferSize;
public int getAlgId() {
return algId;
}
public void setAlgId(int algId) {
this.algId = algId;
}
public byte[] getPrivateKeyBlob() {
return privateKeyBlob;
}
public void setPrivateKeyBlob(byte[] privateKeyBlob) {
this.privateKeyBlob = privateKeyBlob;
}
public byte[] getEncryptedData() {
return encryptedData;
}
public void setEncryptedData(byte[] encryptedData) {
this.encryptedData = encryptedData;
}
public int getOutBufferSize() {
return outBufferSize;
}
public void setOutBufferSize(int outBufferSize) {
this.outBufferSize = outBufferSize;
}
}
@@ -0,0 +1,41 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class EccExternalEncryptRequest {
private int algId;
private byte[] publicKeyBlob;
private byte[] data;
private int outBufferSize;
public int getAlgId() {
return algId;
}
public void setAlgId(int algId) {
this.algId = algId;
}
public byte[] getPublicKeyBlob() {
return publicKeyBlob;
}
public void setPublicKeyBlob(byte[] publicKeyBlob) {
this.publicKeyBlob = publicKeyBlob;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public int getOutBufferSize() {
return outBufferSize;
}
public void setOutBufferSize(int outBufferSize) {
this.outBufferSize = outBufferSize;
}
}
@@ -0,0 +1,41 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class EccExternalSignRequest {
private int algId;
private byte[] privateKeyBlob;
private byte[] data;
private int signatureBufferSize;
public int getAlgId() {
return algId;
}
public void setAlgId(int algId) {
this.algId = algId;
}
public byte[] getPrivateKeyBlob() {
return privateKeyBlob;
}
public void setPrivateKeyBlob(byte[] privateKeyBlob) {
this.privateKeyBlob = privateKeyBlob;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public int getSignatureBufferSize() {
return signatureBufferSize;
}
public void setSignatureBufferSize(int signatureBufferSize) {
this.signatureBufferSize = signatureBufferSize;
}
}
@@ -0,0 +1,41 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class EccExternalVerifyRequest {
private int algId;
private byte[] publicKeyBlob;
private byte[] data;
private byte[] signature;
public int getAlgId() {
return algId;
}
public void setAlgId(int algId) {
this.algId = algId;
}
public byte[] getPublicKeyBlob() {
return publicKeyBlob;
}
public void setPublicKeyBlob(byte[] publicKeyBlob) {
this.publicKeyBlob = publicKeyBlob;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public byte[] getSignature() {
return signature;
}
public void setSignature(byte[] signature) {
this.signature = signature;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class EccInternalSignRequest {
private int keyIndex;
private byte[] data;
private int signatureBufferSize;
public int getKeyIndex() {
return keyIndex;
}
public void setKeyIndex(int keyIndex) {
this.keyIndex = keyIndex;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public int getSignatureBufferSize() {
return signatureBufferSize;
}
public void setSignatureBufferSize(int signatureBufferSize) {
this.signatureBufferSize = signatureBufferSize;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class EccInternalVerifyRequest {
private int keyIndex;
private byte[] data;
private byte[] signature;
public int getKeyIndex() {
return keyIndex;
}
public void setKeyIndex(int keyIndex) {
this.keyIndex = keyIndex;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public byte[] getSignature() {
return signature;
}
public void setSignature(byte[] signature) {
this.signature = signature;
}
}
@@ -0,0 +1,50 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class ExchangeDigitEnvelopeEccRequest {
private int keyIndex;
private int algId;
private byte[] publicKeyBlob;
private byte[] inputEnvelopeBlob;
private int outBufferSize;
public int getKeyIndex() {
return keyIndex;
}
public void setKeyIndex(int keyIndex) {
this.keyIndex = keyIndex;
}
public int getAlgId() {
return algId;
}
public void setAlgId(int algId) {
this.algId = algId;
}
public byte[] getPublicKeyBlob() {
return publicKeyBlob;
}
public void setPublicKeyBlob(byte[] publicKeyBlob) {
this.publicKeyBlob = publicKeyBlob;
}
public byte[] getInputEnvelopeBlob() {
return inputEnvelopeBlob;
}
public void setInputEnvelopeBlob(byte[] inputEnvelopeBlob) {
this.inputEnvelopeBlob = inputEnvelopeBlob;
}
public int getOutBufferSize() {
return outBufferSize;
}
public void setOutBufferSize(int outBufferSize) {
this.outBufferSize = outBufferSize;
}
}
@@ -0,0 +1,41 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class ExchangeDigitEnvelopeRsaRequest {
private int keyIndex;
private byte[] publicKeyBlob;
private byte[] inputEnvelopeBlob;
private int outBufferSize;
public int getKeyIndex() {
return keyIndex;
}
public void setKeyIndex(int keyIndex) {
this.keyIndex = keyIndex;
}
public byte[] getPublicKeyBlob() {
return publicKeyBlob;
}
public void setPublicKeyBlob(byte[] publicKeyBlob) {
this.publicKeyBlob = publicKeyBlob;
}
public byte[] getInputEnvelopeBlob() {
return inputEnvelopeBlob;
}
public void setInputEnvelopeBlob(byte[] inputEnvelopeBlob) {
this.inputEnvelopeBlob = inputEnvelopeBlob;
}
public int getOutBufferSize() {
return outBufferSize;
}
public void setOutBufferSize(int outBufferSize) {
this.outBufferSize = outBufferSize;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class ExportKekComponentRequest {
private int keyIndex;
private int componentNum;
private int componentSize;
public int getKeyIndex() {
return keyIndex;
}
public void setKeyIndex(int keyIndex) {
this.keyIndex = keyIndex;
}
public int getComponentNum() {
return componentNum;
}
public void setComponentNum(int componentNum) {
this.componentNum = componentNum;
}
public int getComponentSize() {
return componentSize;
}
public void setComponentSize(int componentSize) {
this.componentSize = componentSize;
}
}
@@ -0,0 +1,23 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class FileCreateRequest {
private String fileName;
private int fileSize;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public int getFileSize() {
return fileSize;
}
public void setFileSize(int fileSize) {
this.fileSize = fileSize;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class FileReadRequest {
private String fileName;
private int offset;
private int readLength;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public int getOffset() {
return offset;
}
public void setOffset(int offset) {
this.offset = offset;
}
public int getReadLength() {
return readLength;
}
public void setReadLength(int readLength) {
this.readLength = readLength;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class FileWriteRequest {
private String fileName;
private int offset;
private byte[] data;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public int getOffset() {
return offset;
}
public void setOffset(int offset) {
this.offset = offset;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
}
@@ -0,0 +1,77 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class GenerateAgreementDataAndKeyEccRequest {
private int iskIndex;
private int keyBits;
private byte[] responseId;
private byte[] sponsorId;
private byte[] sponsorPublicKeyBlob;
private byte[] sponsorTmpPublicKeyBlob;
private int responsePublicKeyBufferSize;
private int responseTmpPublicKeyBufferSize;
public int getIskIndex() {
return iskIndex;
}
public void setIskIndex(int iskIndex) {
this.iskIndex = iskIndex;
}
public int getKeyBits() {
return keyBits;
}
public void setKeyBits(int keyBits) {
this.keyBits = keyBits;
}
public byte[] getResponseId() {
return responseId;
}
public void setResponseId(byte[] responseId) {
this.responseId = responseId;
}
public byte[] getSponsorId() {
return sponsorId;
}
public void setSponsorId(byte[] sponsorId) {
this.sponsorId = sponsorId;
}
public byte[] getSponsorPublicKeyBlob() {
return sponsorPublicKeyBlob;
}
public void setSponsorPublicKeyBlob(byte[] sponsorPublicKeyBlob) {
this.sponsorPublicKeyBlob = sponsorPublicKeyBlob;
}
public byte[] getSponsorTmpPublicKeyBlob() {
return sponsorTmpPublicKeyBlob;
}
public void setSponsorTmpPublicKeyBlob(byte[] sponsorTmpPublicKeyBlob) {
this.sponsorTmpPublicKeyBlob = sponsorTmpPublicKeyBlob;
}
public int getResponsePublicKeyBufferSize() {
return responsePublicKeyBufferSize;
}
public void setResponsePublicKeyBufferSize(int responsePublicKeyBufferSize) {
this.responsePublicKeyBufferSize = responsePublicKeyBufferSize;
}
public int getResponseTmpPublicKeyBufferSize() {
return responseTmpPublicKeyBufferSize;
}
public void setResponseTmpPublicKeyBufferSize(int responseTmpPublicKeyBufferSize) {
this.responseTmpPublicKeyBufferSize = responseTmpPublicKeyBufferSize;
}
}
@@ -0,0 +1,23 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class GenerateKekRequest {
private int keyBits;
private int keyIndex;
public int getKeyBits() {
return keyBits;
}
public void setKeyBits(int keyBits) {
this.keyBits = keyBits;
}
public int getKeyIndex() {
return keyIndex;
}
public void setKeyIndex(int keyIndex) {
this.keyIndex = keyIndex;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class GenerateKeyPairRequest {
private int keyBits;
private int keyIndex;
private int keyType;
public int getKeyBits() {
return keyBits;
}
public void setKeyBits(int keyBits) {
this.keyBits = keyBits;
}
public int getKeyIndex() {
return keyIndex;
}
public void setKeyIndex(int keyIndex) {
this.keyIndex = keyIndex;
}
public int getKeyType() {
return keyType;
}
public void setKeyType(int keyType) {
this.keyType = keyType;
}
}
@@ -0,0 +1,41 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class GenerateKeyWithEpkEccRequest {
private int keyBits;
private int algId;
private byte[] publicKeyBlob;
private int outBufferSize;
public int getKeyBits() {
return keyBits;
}
public void setKeyBits(int keyBits) {
this.keyBits = keyBits;
}
public int getAlgId() {
return algId;
}
public void setAlgId(int algId) {
this.algId = algId;
}
public byte[] getPublicKeyBlob() {
return publicKeyBlob;
}
public void setPublicKeyBlob(byte[] publicKeyBlob) {
this.publicKeyBlob = publicKeyBlob;
}
public int getOutBufferSize() {
return outBufferSize;
}
public void setOutBufferSize(int outBufferSize) {
this.outBufferSize = outBufferSize;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class GenerateKeyWithEpkRsaRequest {
private int keyBits;
private byte[] publicKeyBlob;
private int outBufferSize;
public int getKeyBits() {
return keyBits;
}
public void setKeyBits(int keyBits) {
this.keyBits = keyBits;
}
public byte[] getPublicKeyBlob() {
return publicKeyBlob;
}
public void setPublicKeyBlob(byte[] publicKeyBlob) {
this.publicKeyBlob = publicKeyBlob;
}
public int getOutBufferSize() {
return outBufferSize;
}
public void setOutBufferSize(int outBufferSize) {
this.outBufferSize = outBufferSize;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class GenerateKeyWithIpkEccRequest {
private int ipkIndex;
private int keyBits;
private int outBufferSize;
public int getIpkIndex() {
return ipkIndex;
}
public void setIpkIndex(int ipkIndex) {
this.ipkIndex = ipkIndex;
}
public int getKeyBits() {
return keyBits;
}
public void setKeyBits(int keyBits) {
this.keyBits = keyBits;
}
public int getOutBufferSize() {
return outBufferSize;
}
public void setOutBufferSize(int outBufferSize) {
this.outBufferSize = outBufferSize;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class GenerateKeyWithIpkRsaRequest {
private int ipkIndex;
private int keyBits;
private int outBufferSize;
public int getIpkIndex() {
return ipkIndex;
}
public void setIpkIndex(int ipkIndex) {
this.ipkIndex = ipkIndex;
}
public int getKeyBits() {
return keyBits;
}
public void setKeyBits(int keyBits) {
this.keyBits = keyBits;
}
public int getOutBufferSize() {
return outBufferSize;
}
public void setOutBufferSize(int outBufferSize) {
this.outBufferSize = outBufferSize;
}
}
@@ -0,0 +1,41 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class GenerateKeyWithKekRequest {
private int keyBits;
private int algId;
private int kekIndex;
private int outBufferSize;
public int getKeyBits() {
return keyBits;
}
public void setKeyBits(int keyBits) {
this.keyBits = keyBits;
}
public int getAlgId() {
return algId;
}
public void setAlgId(int algId) {
this.algId = algId;
}
public int getKekIndex() {
return kekIndex;
}
public void setKekIndex(int kekIndex) {
this.kekIndex = kekIndex;
}
public int getOutBufferSize() {
return outBufferSize;
}
public void setOutBufferSize(int outBufferSize) {
this.outBufferSize = outBufferSize;
}
}
@@ -0,0 +1,41 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class GenerateStandardEccKeyPairRequest {
private int algId;
private int keyBits;
private int publicKeyBufferSize;
private int privateKeyBufferSize;
public int getAlgId() {
return algId;
}
public void setAlgId(int algId) {
this.algId = algId;
}
public int getKeyBits() {
return keyBits;
}
public void setKeyBits(int keyBits) {
this.keyBits = keyBits;
}
public int getPublicKeyBufferSize() {
return publicKeyBufferSize;
}
public void setPublicKeyBufferSize(int publicKeyBufferSize) {
this.publicKeyBufferSize = publicKeyBufferSize;
}
public int getPrivateKeyBufferSize() {
return privateKeyBufferSize;
}
public void setPrivateKeyBufferSize(int privateKeyBufferSize) {
this.privateKeyBufferSize = privateKeyBufferSize;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class GenerateStandardRsaKeyPairRequest {
private int keyBits;
private int publicKeyBufferSize;
private int privateKeyBufferSize;
public int getKeyBits() {
return keyBits;
}
public void setKeyBits(int keyBits) {
this.keyBits = keyBits;
}
public int getPublicKeyBufferSize() {
return publicKeyBufferSize;
}
public void setPublicKeyBufferSize(int publicKeyBufferSize) {
this.publicKeyBufferSize = publicKeyBufferSize;
}
public int getPrivateKeyBufferSize() {
return privateKeyBufferSize;
}
public void setPrivateKeyBufferSize(int privateKeyBufferSize) {
this.privateKeyBufferSize = privateKeyBufferSize;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class HmacRequest {
private int algId;
private byte[] key;
private byte[] data;
public int getAlgId() {
return algId;
}
public void setAlgId(int algId) {
this.algId = algId;
}
public byte[] getKey() {
return key;
}
public void setKey(byte[] key) {
this.key = key;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
}
@@ -0,0 +1,23 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class HmacResult {
private byte[] hmac;
private int hmacLength;
public byte[] getHmac() {
return hmac;
}
public void setHmac(byte[] hmac) {
this.hmac = hmac;
}
public int getHmacLength() {
return hmacLength;
}
public void setHmacLength(int hmacLength) {
this.hmacLength = hmacLength;
}
}
@@ -0,0 +1,23 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class ImportEncKeyPairEccRequest {
private int keyIndex;
private byte[] envelopedKeyBlob;
public int getKeyIndex() {
return keyIndex;
}
public void setKeyIndex(int keyIndex) {
this.keyIndex = keyIndex;
}
public byte[] getEnvelopedKeyBlob() {
return envelopedKeyBlob;
}
public void setEnvelopedKeyBlob(byte[] envelopedKeyBlob) {
this.envelopedKeyBlob = envelopedKeyBlob;
}
}
@@ -0,0 +1,41 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class ImportEncKeyPairRsaRequest {
private int keyIndex;
private int symAlgId;
private byte[] wrappedKey;
private byte[] encryptedData;
public int getKeyIndex() {
return keyIndex;
}
public void setKeyIndex(int keyIndex) {
this.keyIndex = keyIndex;
}
public int getSymAlgId() {
return symAlgId;
}
public void setSymAlgId(int symAlgId) {
this.symAlgId = symAlgId;
}
public byte[] getWrappedKey() {
return wrappedKey;
}
public void setWrappedKey(byte[] wrappedKey) {
this.wrappedKey = wrappedKey;
}
public byte[] getEncryptedData() {
return encryptedData;
}
public void setEncryptedData(byte[] encryptedData) {
this.encryptedData = encryptedData;
}
}
@@ -0,0 +1,23 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class ImportKekRequest {
private int keyIndex;
private byte[] keyData;
public int getKeyIndex() {
return keyIndex;
}
public void setKeyIndex(int keyIndex) {
this.keyIndex = keyIndex;
}
public byte[] getKeyData() {
return keyData;
}
public void setKeyData(byte[] keyData) {
this.keyData = keyData;
}
}
@@ -0,0 +1,41 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class ImportKeyPairRequest {
private int keyIndex;
private int keyType;
private byte[] publicKey;
private byte[] privateKey;
public int getKeyIndex() {
return keyIndex;
}
public void setKeyIndex(int keyIndex) {
this.keyIndex = keyIndex;
}
public int getKeyType() {
return keyType;
}
public void setKeyType(int keyType) {
this.keyType = keyType;
}
public byte[] getPublicKey() {
return publicKey;
}
public void setPublicKey(byte[] publicKey) {
this.publicKey = publicKey;
}
public byte[] getPrivateKey() {
return privateKey;
}
public void setPrivateKey(byte[] privateKey) {
this.privateKey = privateKey;
}
}
@@ -0,0 +1,23 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class ImportKeyWithIskEccRequest {
private int iskIndex;
private byte[] encryptedKeyBlob;
public int getIskIndex() {
return iskIndex;
}
public void setIskIndex(int iskIndex) {
this.iskIndex = iskIndex;
}
public byte[] getEncryptedKeyBlob() {
return encryptedKeyBlob;
}
public void setEncryptedKeyBlob(byte[] encryptedKeyBlob) {
this.encryptedKeyBlob = encryptedKeyBlob;
}
}
@@ -0,0 +1,23 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class ImportKeyWithIskRsaRequest {
private int iskIndex;
private byte[] wrappedKey;
public int getIskIndex() {
return iskIndex;
}
public void setIskIndex(int iskIndex) {
this.iskIndex = iskIndex;
}
public byte[] getWrappedKey() {
return wrappedKey;
}
public void setWrappedKey(byte[] wrappedKey) {
this.wrappedKey = wrappedKey;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class KekComponentRequest {
private int keyIndex;
private int componentNum;
private byte[] componentData;
public int getKeyIndex() {
return keyIndex;
}
public void setKeyIndex(int keyIndex) {
this.keyIndex = keyIndex;
}
public int getComponentNum() {
return componentNum;
}
public void setComponentNum(int componentNum) {
this.componentNum = componentNum;
}
public byte[] getComponentData() {
return componentData;
}
public void setComponentData(byte[] componentData) {
this.componentData = componentData;
}
}
@@ -0,0 +1,23 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class KeyStatusResult {
private int keyState;
private String keyStateName;
public int getKeyState() {
return keyState;
}
public void setKeyState(int keyState) {
this.keyState = keyState;
}
public String getKeyStateName() {
return keyStateName;
}
public void setKeyStateName(String keyStateName) {
this.keyStateName = keyStateName;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class LoginStatusResult {
private int admin1;
private int admin2;
private int admin3;
public int getAdmin1() {
return admin1;
}
public void setAdmin1(int admin1) {
this.admin1 = admin1;
}
public int getAdmin2() {
return admin2;
}
public void setAdmin2(int admin2) {
this.admin2 = admin2;
}
public int getAdmin3() {
return admin3;
}
public void setAdmin3(int admin3) {
this.admin3 = admin3;
}
}
@@ -0,0 +1,50 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class MacCalcRequest {
private int algId;
private byte[] key;
private byte[] iv;
private byte[] data;
private int outBufferSize = 32;
public int getAlgId() {
return algId;
}
public void setAlgId(int algId) {
this.algId = algId;
}
public byte[] getKey() {
return key;
}
public void setKey(byte[] key) {
this.key = key;
}
public byte[] getIv() {
return iv;
}
public void setIv(byte[] iv) {
this.iv = iv;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public int getOutBufferSize() {
return outBufferSize;
}
public void setOutBufferSize(int outBufferSize) {
this.outBufferSize = outBufferSize;
}
}
@@ -0,0 +1,23 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class PrivateKeyAccessRequest {
private int keyIndex;
private byte[] password;
public int getKeyIndex() {
return keyIndex;
}
public void setKeyIndex(int keyIndex) {
this.keyIndex = keyIndex;
}
public byte[] getPassword() {
return password;
}
public void setPassword(byte[] password) {
this.password = password;
}
}
@@ -0,0 +1,23 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class RecoverKekRequest {
private int keyIndex;
private byte[] encryptedKey;
public int getKeyIndex() {
return keyIndex;
}
public void setKeyIndex(int keyIndex) {
this.keyIndex = keyIndex;
}
public byte[] getEncryptedKey() {
return encryptedKey;
}
public void setEncryptedKey(byte[] encryptedKey) {
this.encryptedKey = encryptedKey;
}
}
@@ -0,0 +1,41 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class RecoverUserKeyRequest {
private int keyIndex;
private int keyType;
private byte[] encryptedKey;
private int storeFlag = 1;
public int getKeyIndex() {
return keyIndex;
}
public void setKeyIndex(int keyIndex) {
this.keyIndex = keyIndex;
}
public int getKeyType() {
return keyType;
}
public void setKeyType(int keyType) {
this.keyType = keyType;
}
public byte[] getEncryptedKey() {
return encryptedKey;
}
public void setEncryptedKey(byte[] encryptedKey) {
this.encryptedKey = encryptedKey;
}
public int getStoreFlag() {
return storeFlag;
}
public void setStoreFlag(int storeFlag) {
this.storeFlag = storeFlag;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class RsaExternalPrivateKeyOpRequest {
private byte[] privateKeyBlob;
private byte[] input;
private int outBufferSize;
public byte[] getPrivateKeyBlob() {
return privateKeyBlob;
}
public void setPrivateKeyBlob(byte[] privateKeyBlob) {
this.privateKeyBlob = privateKeyBlob;
}
public byte[] getInput() {
return input;
}
public void setInput(byte[] input) {
this.input = input;
}
public int getOutBufferSize() {
return outBufferSize;
}
public void setOutBufferSize(int outBufferSize) {
this.outBufferSize = outBufferSize;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class RsaExternalPublicKeyOpRequest {
private byte[] publicKeyBlob;
private byte[] input;
private int outBufferSize;
public byte[] getPublicKeyBlob() {
return publicKeyBlob;
}
public void setPublicKeyBlob(byte[] publicKeyBlob) {
this.publicKeyBlob = publicKeyBlob;
}
public byte[] getInput() {
return input;
}
public void setInput(byte[] input) {
this.input = input;
}
public int getOutBufferSize() {
return outBufferSize;
}
public void setOutBufferSize(int outBufferSize) {
this.outBufferSize = outBufferSize;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class RsaInternalKeyOpRequest {
private int keyIndex;
private byte[] input;
private int outBufferSize;
public int getKeyIndex() {
return keyIndex;
}
public void setKeyIndex(int keyIndex) {
this.keyIndex = keyIndex;
}
public byte[] getInput() {
return input;
}
public void setInput(byte[] input) {
this.input = input;
}
public int getOutBufferSize() {
return outBufferSize;
}
public void setOutBufferSize(int outBufferSize) {
this.outBufferSize = outBufferSize;
}
}
@@ -0,0 +1,41 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class StandardKeyPairResult {
private byte[] publicKey;
private int publicKeyLength;
private byte[] privateKey;
private int privateKeyLength;
public byte[] getPublicKey() {
return publicKey;
}
public void setPublicKey(byte[] publicKey) {
this.publicKey = publicKey;
}
public int getPublicKeyLength() {
return publicKeyLength;
}
public void setPublicKeyLength(int publicKeyLength) {
this.publicKeyLength = publicKeyLength;
}
public byte[] getPrivateKey() {
return privateKey;
}
public void setPrivateKey(byte[] privateKey) {
this.privateKey = privateKey;
}
public int getPrivateKeyLength() {
return privateKeyLength;
}
public void setPrivateKeyLength(int privateKeyLength) {
this.privateKeyLength = privateKeyLength;
}
}
@@ -0,0 +1,50 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class SymmetricCryptoRequest {
private int algId;
private byte[] key;
private byte[] iv;
private byte[] data;
private int outBufferSize;
public int getAlgId() {
return algId;
}
public void setAlgId(int algId) {
this.algId = algId;
}
public byte[] getKey() {
return key;
}
public void setKey(byte[] key) {
this.key = key;
}
public byte[] getIv() {
return iv;
}
public void setIv(byte[] iv) {
this.iv = iv;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public int getOutBufferSize() {
return outBufferSize;
}
public void setOutBufferSize(int outBufferSize) {
this.outBufferSize = outBufferSize;
}
}
@@ -0,0 +1,59 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class SymmetricKekCryptoRequest {
private int algId;
private int kekIndex;
private byte[] wrappedKey;
private byte[] iv;
private byte[] data;
private int outBufferSize;
public int getAlgId() {
return algId;
}
public void setAlgId(int algId) {
this.algId = algId;
}
public int getKekIndex() {
return kekIndex;
}
public void setKekIndex(int kekIndex) {
this.kekIndex = kekIndex;
}
public byte[] getWrappedKey() {
return wrappedKey;
}
public void setWrappedKey(byte[] wrappedKey) {
this.wrappedKey = wrappedKey;
}
public byte[] getIv() {
return iv;
}
public void setIv(byte[] iv) {
this.iv = iv;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public int getOutBufferSize() {
return outBufferSize;
}
public void setOutBufferSize(int outBufferSize) {
this.outBufferSize = outBufferSize;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class UkeyGenerateRequest {
private int adminIndex;
private byte[] ukeyPin;
private byte[] loginPin;
public int getAdminIndex() {
return adminIndex;
}
public void setAdminIndex(int adminIndex) {
this.adminIndex = adminIndex;
}
public byte[] getUkeyPin() {
return ukeyPin;
}
public void setUkeyPin(byte[] ukeyPin) {
this.ukeyPin = ukeyPin;
}
public byte[] getLoginPin() {
return loginPin;
}
public void setLoginPin(byte[] loginPin) {
this.loginPin = loginPin;
}
}
@@ -0,0 +1,23 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class UkeyLoginRequest {
private byte[] ukeyPin;
private byte[] loginPin;
public byte[] getUkeyPin() {
return ukeyPin;
}
public void setUkeyPin(byte[] ukeyPin) {
this.ukeyPin = ukeyPin;
}
public byte[] getLoginPin() {
return loginPin;
}
public void setLoginPin(byte[] loginPin) {
this.loginPin = loginPin;
}
}
@@ -0,0 +1,32 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class UkeyPinChangeRequest {
private int pinType;
private byte[] oldPin;
private byte[] newPin;
public int getPinType() {
return pinType;
}
public void setPinType(int pinType) {
this.pinType = pinType;
}
public byte[] getOldPin() {
return oldPin;
}
public void setOldPin(byte[] oldPin) {
this.oldPin = oldPin;
}
public byte[] getNewPin() {
return newPin;
}
public void setNewPin(byte[] newPin) {
this.newPin = newPin;
}
}
@@ -0,0 +1,23 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class UkeyUnlockRequest {
private byte[] adminPin;
private byte[] userPin;
public byte[] getAdminPin() {
return adminPin;
}
public void setAdminPin(byte[] adminPin) {
this.adminPin = adminPin;
}
public byte[] getUserPin() {
return userPin;
}
public void setUserPin(byte[] userPin) {
this.userPin = userPin;
}
}
@@ -0,0 +1,23 @@
package com.cisd.tms.integration.crypto.pcie.model;
public class UpdateBackedKeyRequest {
private byte[] oldData;
private int newDataBufferSize;
public byte[] getOldData() {
return oldData;
}
public void setOldData(byte[] oldData) {
this.oldData = oldData;
}
public int getNewDataBufferSize() {
return newDataBufferSize;
}
public void setNewDataBufferSize(int newDataBufferSize) {
this.newDataBufferSize = newDataBufferSize;
}
}
@@ -0,0 +1,4 @@
/**
* Unified PCIe crypto card wrapper for SDF/SDFE commands.
*/
package com.cisd.tms.integration.crypto.pcie;

Some files were not shown because too many files have changed in this diff Show More