初始化项目
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Java 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '17'
|
||||
cache: maven
|
||||
|
||||
- name: Compile
|
||||
run: mvn -q -DskipTests compile
|
||||
|
||||
- name: Test
|
||||
run: mvn -q test
|
||||
@@ -0,0 +1,7 @@
|
||||
target/
|
||||
.idea/
|
||||
.vscode/
|
||||
*.iml
|
||||
.m2repo/
|
||||
.DS_Store
|
||||
logs/
|
||||
@@ -1,2 +1,206 @@
|
||||
# cisd.service
|
||||
|
||||
# TMS Framework
|
||||
|
||||
Single-process TMS monolith scaffold built with:
|
||||
- JDK 17
|
||||
- Spring Boot 3.5.x
|
||||
- MyBatis-Plus
|
||||
- TiDB (MySQL driver)
|
||||
- Swagger (springdoc-openapi)
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
cd tms-framework
|
||||
mvn spring-boot:run
|
||||
```
|
||||
|
||||
Runtime recommendation:
|
||||
- Use JDK 17 for local build/test to match project and CI runtime.
|
||||
|
||||
Open:
|
||||
- Swagger UI: http://localhost:8080/swagger-ui.html
|
||||
- Internal health API: `GET /api/v1/device/status`
|
||||
- Internal sign preview API: `POST /api/v1/sign/preview`
|
||||
- External sign API: `POST /openapi/v1/sign/signature`
|
||||
- Init template API: `GET /api/v1/init/template`
|
||||
- Init preview API: `POST /api/v1/init/preview`
|
||||
- Auth login API: `POST /api/v1/auth/login`
|
||||
- Device info API: `GET /api/v1/device/info`
|
||||
- PCIe crypto count API: `GET /api/v1/device/crypto/device-count`
|
||||
- PCIe crypto HMAC API: `POST /api/v1/device/crypto/hmac`
|
||||
|
||||
## Architecture (Monolith + Modular)
|
||||
|
||||
- One deployable Spring Boot application.
|
||||
- Module-first packaging under `modules/*`.
|
||||
- Default module layout: `controller/internal + service + repository + entity + dto`.
|
||||
- `sign` module has extra `controller/openapi`, `dto/openapi`, and `support`.
|
||||
- Cross-cutting concerns moved to top-level `security` and `integration`.
|
||||
|
||||
## Project Structure
|
||||
|
||||
```text
|
||||
src/main/java/com/cisd/tms
|
||||
├── TmsApplication.java
|
||||
├── common
|
||||
│ ├── api
|
||||
│ ├── config
|
||||
│ │ └── properties
|
||||
│ ├── constant
|
||||
│ ├── enums
|
||||
│ ├── exception
|
||||
│ └── util
|
||||
├── infrastructure
|
||||
│ └── persistence
|
||||
│ ├── entity
|
||||
│ ├── mapper
|
||||
│ └── mybatis
|
||||
├── integration
|
||||
│ ├── cips
|
||||
│ ├── mq
|
||||
│ ├── crypto
|
||||
│ └── file
|
||||
├── security
|
||||
│ ├── internal
|
||||
│ └── openapi
|
||||
└── modules
|
||||
├── system
|
||||
│ ├── controller/internal
|
||||
│ ├── service
|
||||
│ └── dto
|
||||
├── sign
|
||||
│ ├── controller/internal
|
||||
│ ├── controller/openapi
|
||||
│ ├── service
|
||||
│ ├── dto/internal
|
||||
│ ├── dto/openapi
|
||||
│ ├── support
|
||||
│ ├── repository
|
||||
│ └── entity
|
||||
├── init
|
||||
├── auth
|
||||
├── device
|
||||
├── upgrade
|
||||
├── cert
|
||||
├── key
|
||||
├── audit
|
||||
├── backup
|
||||
└── activation
|
||||
```
|
||||
|
||||
```text
|
||||
src/main/resources
|
||||
├── application.yml
|
||||
├── application-dev.yml
|
||||
├── application-prod.yml
|
||||
├── mapper
|
||||
│ ├── init/InitTaskMapper.xml
|
||||
│ ├── auth/AuthUserMapper.xml
|
||||
│ └── device/DeviceNodeMapper.xml
|
||||
└── db/migration
|
||||
└── V1__init_auth_device_tables.sql
|
||||
```
|
||||
|
||||
## API Boundary Rules
|
||||
|
||||
- Internal API controllers only in `*/controller/internal`, path prefix `/api/**`.
|
||||
- External API controllers only in `*/controller/openapi`, path prefix `/openapi/**`.
|
||||
- Internal and external DTOs are separated.
|
||||
- Cross-module calls must go through `service`, not `repository`.
|
||||
- Internal token interceptor exclusions: `/api/v1/device/status`, `/api/v1/auth/login`.
|
||||
|
||||
## Auth Configuration
|
||||
|
||||
```yaml
|
||||
tms:
|
||||
security:
|
||||
internal-token: ${TMS_INTERNAL_TOKEN:change-me-internal-token}
|
||||
openapi:
|
||||
timestamp-skew-seconds: 300
|
||||
clients:
|
||||
demo-app: ${TMS_OPENAPI_DEMO_SECRET:change-me-openapi-secret}
|
||||
```
|
||||
|
||||
## Crypto Card Configuration
|
||||
|
||||
```yaml
|
||||
tms:
|
||||
crypto-card:
|
||||
enabled: ${TMS_CRYPTO_CARD_ENABLED:false}
|
||||
mode: ${TMS_CRYPTO_CARD_MODE:MOCK} # MOCK / JNA
|
||||
vendor-lib-path: ${TMS_CRYPTO_VENDOR_LIB_PATH:}
|
||||
vendor-lib-name: ${TMS_CRYPTO_VENDOR_LIB_NAME:swsdsdf}
|
||||
```
|
||||
|
||||
- Internal PCIe debug APIs (strong-typed service):
|
||||
- `GET /api/v1/device/crypto/device-count`
|
||||
- `GET /api/v1/device/crypto/device-conf`
|
||||
- `GET /api/v1/device/crypto/device-info`
|
||||
- `GET /api/v1/device/crypto/random?length=16`
|
||||
- `POST /api/v1/device/crypto/self-test`
|
||||
- `POST /api/v1/device/crypto/hmac`
|
||||
- `POST /api/v1/device/crypto/digest`
|
||||
- `POST /api/v1/device/crypto/encrypt/plain`
|
||||
- `POST /api/v1/device/crypto/decrypt/plain`
|
||||
- `POST /api/v1/device/crypto/encrypt/kek`
|
||||
- `POST /api/v1/device/crypto/decrypt/kek`
|
||||
- `POST /api/v1/device/crypto/mac/plain`
|
||||
- `POST /api/v1/device/crypto/file/create`
|
||||
- `POST /api/v1/device/crypto/file/write`
|
||||
- `POST /api/v1/device/crypto/file/read`
|
||||
- `POST /api/v1/device/crypto/file/delete`
|
||||
- `POST /api/v1/device/crypto/kek/generate`
|
||||
- `GET /api/v1/device/crypto/kek/status?keyIndex=1`
|
||||
- `GET /api/v1/device/crypto/lmk/seed-mac`
|
||||
- `POST /api/v1/device/crypto/std/keypair/rsa`
|
||||
- `POST /api/v1/device/crypto/std/keypair/ecc`
|
||||
- `POST /api/v1/device/crypto/envelope/exchange/rsa`
|
||||
- `POST /api/v1/device/crypto/envelope/exchange/ecc`
|
||||
- `POST /api/v1/device/crypto/agreement/data-key/ecc`
|
||||
- `POST /api/v1/device/crypto/agreement/session-key/ecc`
|
||||
|
||||
## PCIe Crypto Unified Wrapper (JNA)
|
||||
|
||||
The project keeps JNA native mappings for PCIe card `SDF/SDFE` interfaces from
|
||||
`PCIE密码卡应用接口说明书 V1.02`, and provides strong-typed service APIs via
|
||||
`com.cisd.tms.integration.crypto.pcie.service.PcieCryptoService`.
|
||||
|
||||
```yaml
|
||||
tms:
|
||||
crypto-card:
|
||||
enabled: ${TMS_CRYPTO_CARD_ENABLED:false}
|
||||
mode: ${TMS_CRYPTO_CARD_MODE:JNA} # MOCK / JNA
|
||||
vendor-lib-path: ${TMS_CRYPTO_VENDOR_LIB_PATH:}
|
||||
vendor-lib-name: ${TMS_CRYPTO_VENDOR_LIB_NAME:swsdsdf}
|
||||
```
|
||||
|
||||
- JNA native mapping: `com.cisd.tms.integration.crypto.pcie.jna.PcieNativeLibrary`
|
||||
- JNA implementation: `com.cisd.tms.integration.crypto.pcie.service.JnaPcieCryptoService`
|
||||
- Mock fallback: `com.cisd.tms.integration.crypto.pcie.service.MockPcieCryptoService`
|
||||
|
||||
### OpenAPI Signature Rules
|
||||
|
||||
- Headers: `X-App-Id`, `X-Timestamp`, `X-Nonce`, `X-Signature`
|
||||
- Canonical string: `appId + "\\n" + timestamp + "\\n" + nonce`
|
||||
- Signature algorithm: `HMAC-SHA256` with app secret, lowercase hex
|
||||
- Replay protection: nonce one-time in time window
|
||||
|
||||
## Build And Test
|
||||
|
||||
```bash
|
||||
mvn -q -DskipTests compile
|
||||
mvn -q test
|
||||
```
|
||||
|
||||
- CI is pinned to JDK 17 via `.github/workflows/ci.yml`.
|
||||
- Maven Surefire preloads Mockito javaagent to avoid dynamic self-attach failures on newer JDKs.
|
||||
|
||||
## Current Status
|
||||
|
||||
- Structure refactored to lightweight monolith modules.
|
||||
- Internal and external API entry points separated.
|
||||
- Basic auth interceptors for internal/openapi are in place.
|
||||
- `init/auth/device/sign/system` modules have runnable skeleton controllers and services.
|
||||
- `init/auth/device` modules include mapper+xml+repository-impl+DDL skeleton for TiDB.
|
||||
>>>>>>> aeb6a4d (初始化项目)
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
# JDK17 + Mockito + CI Stability Implementation Plan
|
||||
|
||||
> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
|
||||
|
||||
**Goal:** Stabilize local/CI test execution by fixing Mockito agent startup behavior and pinning CI to JDK 17.
|
||||
|
||||
**Architecture:** Configure Maven Surefire to preload Mockito as a javaagent and set required JVM flags to avoid runtime self-attach failures. Add a CI workflow that always uses JDK 17 and runs compile/test checks. Update README for explicit developer/CI runtime expectations.
|
||||
|
||||
**Tech Stack:** Maven Surefire, Mockito, GitHub Actions, JDK 17, Spring Boot 3.5
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Build/Test runtime hardening
|
||||
|
||||
**Files:**
|
||||
- Modify: `pom.xml`
|
||||
|
||||
1. Add explicit `mockito.version` property.
|
||||
2. Add `maven-surefire-plugin` with `argLine` including:
|
||||
- `-Djdk.attach.allowAttachSelf=true`
|
||||
- `-XX:+EnableDynamicAgentLoading`
|
||||
- `-javaagent:${settings.localRepository}/org/mockito/mockito-core/${mockito.version}/mockito-core-${mockito.version}.jar`
|
||||
|
||||
### Task 2: CI JDK pinning
|
||||
|
||||
**Files:**
|
||||
- Create: `.github/workflows/ci.yml`
|
||||
|
||||
1. Add workflow on `push` + `pull_request`.
|
||||
2. Use `actions/setup-java` with Temurin `17`.
|
||||
3. Run `mvn -q -DskipTests compile` then `mvn -q test`.
|
||||
|
||||
### Task 3: Documentation sync
|
||||
|
||||
**Files:**
|
||||
- Modify: `README.md`
|
||||
|
||||
1. Add explicit local recommended JDK 17 note.
|
||||
2. Add CI note: workflow runs JDK 17 and compile+test.
|
||||
3. Add troubleshooting note for Mockito agent behavior on newer JDKs.
|
||||
|
||||
### Task 4: Verification
|
||||
|
||||
**Commands:**
|
||||
1. `mvn -q -DskipTests compile`
|
||||
2. `mvn -q test` (sandbox)
|
||||
3. `mvn -q test` (escalated fallback if sandbox attach restrictions block)
|
||||
4. Key checks with `rg` for workflow and surefire config.
|
||||
@@ -0,0 +1,168 @@
|
||||
# PCIe密码卡强类型封装设计(第一期)
|
||||
|
||||
- 日期:2026-02-28
|
||||
- 范围:基于 `0018接口.pdf`(国密标准SDF)与 `PCIE密码卡应用接口说明书.docx`(SDFE扩展)
|
||||
- 目标:为上层提供强类型业务方法,屏蔽底层JNA细节
|
||||
|
||||
## 1. 设计目标与约束
|
||||
|
||||
### 1.1 目标
|
||||
|
||||
1. 提供强类型业务方法,不要求上层使用 `execute(command, params)`。
|
||||
2. 采用短连接会话模型:每个业务方法内部完成 `openDevice/openSession/call/closeSession/closeDevice`。
|
||||
3. 第一期开通核心子集接口,覆盖设备管理、会话、HMAC、LMK与常用密钥管理。
|
||||
4. 统一错误模型与错误码映射,便于上层处理与运维排障。
|
||||
|
||||
### 1.2 非目标
|
||||
|
||||
1. 不在第一期覆盖文档所有SDF/SDFE接口。
|
||||
2. 不在第一期做多设备负载均衡与高并发优化。
|
||||
3. 不在第一期实现JNI桥代码生成。
|
||||
|
||||
## 2. 方案选型
|
||||
|
||||
### 2.1 备选方案
|
||||
|
||||
1. 动态命令入口(`execute(command, params)`)+ 强类型外观。
|
||||
2. 纯强类型服务(推荐)。
|
||||
3. 从头文件自动生成绑定与服务代码。
|
||||
|
||||
### 2.2 选型结论
|
||||
|
||||
采用方案2:新增 `PcieCryptoService` 及其 `JnaPcieCryptoService` 实现,
|
||||
强类型方法直接调用JNA映射,统一通过短连接模板管理句柄生命周期。
|
||||
|
||||
## 3. 总体架构
|
||||
|
||||
### 3.1 分层
|
||||
|
||||
1. `PcieCryptoService`:面向上层的强类型业务接口。
|
||||
2. `JnaPcieCryptoService`:服务实现,调用 `PcieNativeLibrary`。
|
||||
3. `PcieSessionTemplate`:统一短连接模板。
|
||||
4. `PcieNativeLibrary`:JNA native函数映射。
|
||||
5. `PcieErrorMapper`:错误码映射(`retCode -> 业务可读信息`)。
|
||||
|
||||
### 3.2 调用路径
|
||||
|
||||
上层业务 -> `PcieCryptoService` 强类型方法 -> `PcieSessionTemplate` -> `PcieNativeLibrary` -> 厂商 `.so`
|
||||
|
||||
## 4. 第一期开通接口(核心子集)
|
||||
|
||||
### 4.1 设备与会话
|
||||
|
||||
1. `getDeviceNumber()` -> `SDFE_GetDeviceNumber`
|
||||
2. `getNormalDeviceNumber()` -> `SDFE_GetNormalDeviceNumber`
|
||||
3. `deviceSelfTest()` -> `SDFE_DeviceSelfTest`
|
||||
4. `deviceConfGet()` -> `SDFE_DeviceConfGet`
|
||||
5. `initIdentify(oldPin, newPin)` -> `SDFE_InitIdentify`
|
||||
|
||||
> 注:`open/close` 作为模板内部行为,不暴露给上层业务接口。
|
||||
|
||||
### 4.2 常用密钥管理(用户确认的8组)
|
||||
|
||||
1. `generateKeyPairEcc` / `generateKeyPairRsa`
|
||||
2. `generateKek`
|
||||
3. `backupUserKey` / `recoverUserKey`
|
||||
4. `backupKek` / `recoverKek`
|
||||
5. `deleteUserKey` / `deleteKek`
|
||||
6. `statusUserKeyEcc` / `statusUserKeyRsa`
|
||||
7. `statusKek`
|
||||
8. `changePrivateKeyAccessPassword`
|
||||
|
||||
### 4.3 HMAC
|
||||
|
||||
1. `hmac(algId, key, data)`
|
||||
2. 内部流程:`SDFE_HmacInit` -> `SDFE_HmacUpdate` -> `SDFE_HmacFinal`
|
||||
|
||||
### 4.4 LMK(核心)
|
||||
|
||||
1. `generateLmk` / `loadLmk` / `backupLmk` / `recoverLmk` / `destroyLmk`
|
||||
2. `checkLmk` / `exportLmkSeedMac`
|
||||
|
||||
## 5. 强类型模型
|
||||
|
||||
### 5.1 请求对象
|
||||
|
||||
1. `GenerateKeyRequest`:`keyIndex`, `keyBits`, `keyType`
|
||||
2. `RecoverUserKeyRequest`:`keyIndex`, `keyType`, `cipherKeyData`, `storeFlag`
|
||||
3. `RecoverKekRequest`:`keyIndex`, `cipherKeyData`
|
||||
4. `ChangePrivateKeyPasswordRequest`:`keyIndex`, `oldPassword`, `newPassword`
|
||||
5. `HmacRequest`:`algId`, `key`, `data`
|
||||
|
||||
### 5.2 响应对象
|
||||
|
||||
1. `OperationResult`:`success`, `retCode`, `message`
|
||||
2. `DeviceCountResult`:`deviceNumber`, `normalDeviceNumber`
|
||||
3. `DeviceConfResult`:映射 `SDFE_DeviceConf`
|
||||
4. `BackupUserKeyResult` / `BackupKekResult`:`data`, `length`
|
||||
5. `KeyStatusResult`:`keyState`
|
||||
6. `HmacResult`:`hmac`, `hmacLength`
|
||||
|
||||
## 6. 会话模板(短连接)
|
||||
|
||||
定义统一模板方法:
|
||||
|
||||
```text
|
||||
executeWithSession(apiName, callback):
|
||||
SDF_OpenDevice
|
||||
SDF_OpenSession
|
||||
callback(session)
|
||||
SDF_CloseSession
|
||||
SDF_CloseDevice
|
||||
```
|
||||
|
||||
约束:
|
||||
|
||||
1. 所有强类型方法必须通过模板执行。
|
||||
2. 关闭失败仅记录日志,不覆盖主调用错误。
|
||||
3. 模板保证异常场景也能回收句柄。
|
||||
|
||||
## 7. 错误处理
|
||||
|
||||
1. `retCode == 0`:成功。
|
||||
2. `retCode != 0`:抛 `PcieCryptoException(apiName, retCode, mappedMessage)`。
|
||||
3. 映射文档补充错误码:
|
||||
- `SDR_UKEYERR`
|
||||
- `SDR_GENKEYERR`
|
||||
- `SDR_STATEERR`
|
||||
- `SDR_RETRYERR`
|
||||
- `SDR_DEVICE_BUSY`
|
||||
- `SDR_RET_ERR_STATUS`
|
||||
- `SDR_RET_INIT_STATUS`
|
||||
- `SDR_RET_LOGINED`
|
||||
- `SDR_RET_GD32_TIMEOUT`
|
||||
4. 参数校验失败在服务层抛 `IllegalArgumentException`,不下发至设备。
|
||||
|
||||
## 8. 并发与安全
|
||||
|
||||
1. 第一期开启串行访问(单设备锁)避免状态错乱。
|
||||
2. PIN/口令参数不打印明文日志。
|
||||
3. 密钥备份字节在服务层保持二进制,不做文本日志输出。
|
||||
|
||||
## 9. 对上层的使用方式
|
||||
|
||||
示例:
|
||||
|
||||
1. `pcieCryptoService.generateLmk()`
|
||||
2. `pcieCryptoService.backupKek(keyIndex, outBufferSize)`
|
||||
3. `pcieCryptoService.hmac(request)`
|
||||
|
||||
上层仅依赖强类型接口与DTO,不直接依赖JNA类型和指针。
|
||||
|
||||
## 10. 验收标准
|
||||
|
||||
1. 强类型接口可完成第一期核心子集调用。
|
||||
2. 每个方法均使用短连接模板。
|
||||
3. 统一异常中包含 `apiName + retCode + mappedMessage`。
|
||||
4. `mvn -DskipTests compile` 通过。
|
||||
5. 关键路径联调用例可跑通:
|
||||
- `getDeviceNumber`
|
||||
- `deviceConfGet`
|
||||
- `hmac`
|
||||
- `generateKek + statusKek`
|
||||
|
||||
## 11. 后续扩展
|
||||
|
||||
1. 第二期覆盖U盾与内部密钥管理。
|
||||
2. 第三期覆盖全量SDF/SDFE并补充结构体严格对齐校验。
|
||||
3. 加入真实设备集成测试与回放测试。
|
||||
@@ -0,0 +1,140 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<groupId>com.cisd</groupId>
|
||||
<artifactId>tms-framework</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>tms-framework</name>
|
||||
<description>CISD TMS base framework</description>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<mybatis-plus.version>3.5.10.1</mybatis-plus.version>
|
||||
<springdoc.version>2.8.5</springdoc.version>
|
||||
<mockito.version>5.17.0</mockito.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
<version>${springdoc.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna</artifactId>
|
||||
<version>5.14.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<parameters>true</parameters>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<argLine>-Djdk.attach.allowAttachSelf=true -XX:+EnableDynamicAgentLoading -javaagent:${settings.localRepository}/org/mockito/mockito-core/${mockito.version}/mockito-core-${mockito.version}.jar</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>ci</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env.CI</name>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enforce-java-17-in-ci</id>
|
||||
<goals>
|
||||
<goal>enforce</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<requireJavaVersion>
|
||||
<version>[17,18)</version>
|
||||
</requireJavaVersion>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
@@ -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> {
|
||||
}
|
||||
+21
@@ -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;
|
||||
}
|
||||
}
|
||||
+35
@@ -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;
|
||||
+50
@@ -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;
|
||||
}
|
||||
}
|
||||
+32
@@ -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;
|
||||
}
|
||||
}
|
||||
+86
@@ -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;
|
||||
}
|
||||
}
|
||||
+68
@@ -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;
|
||||
}
|
||||
}
|
||||
+41
@@ -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;
|
||||
}
|
||||
}
|
||||
+41
@@ -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;
|
||||
}
|
||||
}
|
||||
+41
@@ -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;
|
||||
}
|
||||
}
|
||||
+32
@@ -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;
|
||||
}
|
||||
}
|
||||
+50
@@ -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;
|
||||
}
|
||||
}
|
||||
+41
@@ -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;
|
||||
}
|
||||
}
|
||||
+32
@@ -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;
|
||||
}
|
||||
}
|
||||
+77
@@ -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;
|
||||
}
|
||||
}
|
||||
+41
@@ -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;
|
||||
}
|
||||
}
|
||||
+32
@@ -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;
|
||||
}
|
||||
}
|
||||
+32
@@ -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;
|
||||
}
|
||||
}
|
||||
+32
@@ -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;
|
||||
}
|
||||
}
|
||||
+41
@@ -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;
|
||||
}
|
||||
}
|
||||
+41
@@ -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;
|
||||
}
|
||||
}
|
||||
+32
@@ -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;
|
||||
}
|
||||
}
|
||||
+23
@@ -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;
|
||||
}
|
||||
}
|
||||
+41
@@ -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;
|
||||
}
|
||||
}
|
||||
+23
@@ -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;
|
||||
}
|
||||
}
|
||||
+23
@@ -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;
|
||||
}
|
||||
}
|
||||
+32
@@ -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;
|
||||
}
|
||||
}
|
||||
+32
@@ -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;
|
||||
}
|
||||
}
|
||||
+59
@@ -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;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user