🔐 哈希与消息认证
计算摘要与 HMAC/CMAC。algorithm 传 all 可一次返回 MD5、SHA-1、SHA-256、SHA-512、SM3 五种结果。
POST
/api/hash
计算摘要
对文本 / HEX / Base64 数据计算摘要,支持大写输出与文件名标记(便于批量结果标注)。
| 参数 | 类型 | 必填 | 说明 |
data |
string |
是 |
待计算的数据 |
algorithm |
string |
否 |
md5 / sha1 / sha256 / sha512 / sm3 / all,默认 sha256 |
data_format |
string |
否 |
text / hex / base64,默认 text |
uppercase |
bool |
否 |
是否输出大写 HEX,默认 false |
filename |
string |
否 |
仅回显,用于批量计算时标注结果 |
请求示例
curl -s -X POST https://gm.okpki.com/api/hash \
-H 'Content-Type: application/json' \
-d '{"data":"abc","algorithm":"sm3"}'
响应示例
{
"success": true,
"algorithm": "sm3",
"hash": "66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0",
"length": 256,
"input_bytes": 3,
"filename": "",
"data_format": "text"
}
POST
/api/hash/identify
识别摘要算法
根据摘要长度猜测候选算法;同时传入原文时逐个计算并标记匹配项(matched 为 true / false / null)。
| 参数 | 类型 | 必填 | 说明 |
digest |
string |
是 |
摘要值(HEX 或 Base64) |
digest_format |
string |
否 |
auto / hex / base64,默认 auto |
data |
string |
否 |
原文,传入后可精确匹配 |
data_format |
string |
否 |
原文格式,默认 text |
请求示例
curl -s -X POST https://gm.okpki.com/api/hash/identify \
-H 'Content-Type: application/json' \
-d '{"digest":"66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0","data":"abc"}'
响应示例
{
"success": true,
"summary": "摘要长度 32 字节(256 位)",
"digest_format": "hex",
"candidates": [
{"name": "SHA-256", "matched": false, "supported": true},
{"name": "SM3", "matched": true, "supported": true}
]
}
POST
/api/mac/hmac
HMAC 计算
支持 HMAC-SM3、HMAC-SHA-256/1/512、HMAC-MD5,密钥与消息均可指定 text / hex / base64。
| 参数 | 类型 | 必填 | 说明 |
data |
string |
是 |
待认证消息 |
key |
string |
是 |
密钥 |
algorithm |
string |
否 |
sm3 / sha256 / sha1 / sha512 / md5,默认 sha256 |
data_format |
string |
否 |
text / hex / base64 |
key_format |
string |
否 |
text / hex / base64 |
请求示例
curl -s -X POST https://gm.okpki.com/api/mac/hmac \
-H 'Content-Type: application/json' \
-d '{"data":"hello","key":"secret","algorithm":"sm3"}'
响应示例
{
"success": true,
"mac": "1973512596c912af99f686bcf632151e721cb32ac8bb8d44f0ae5af7570abd49",
"mac_base64": "GXNRJZbJEq+Z9oa89jIVHnIcsyrIu41E8K5a91cKvUk=",
"length": 256,
"algorithm": "HMAC-SM3",
"key_bits": 48
}
POST
/api/mac/cmac
CMAC 计算
基于分组密码的消息认证码,支持 CMAC-SM4 与 CMAC-AES。
| 参数 | 类型 | 必填 | 说明 |
data |
string |
是 |
待认证消息 |
key |
string |
是 |
密钥(默认按 HEX 解析) |
algorithm |
string |
否 |
sm4 / aes,默认 sm4 |
data_format |
string |
否 |
text / hex / base64 |
key_format |
string |
否 |
text / hex / base64,默认 hex |
请求示例
curl -s -X POST https://gm.okpki.com/api/mac/cmac \
-H 'Content-Type: application/json' \
-d '{"data":"hello","key":"0123456789abcdeffedcba9876543210","algorithm":"sm4"}'
响应示例
{
"success": true,
"mac": "89d7cffc580750b96f8a9ad96d55a453",
"mac_base64": "idfP/FgHULlviprZbVWkUw==",
"length": 128,
"algorithm": "CMAC-SM4",
"key_bits": 128
}
🔒 对称加密
AES 与 SM4 加解密,支持 CBC / ECB / CFB / OFB / CTR / XTS 六种模式。密文统一 Base64,IV 用 Base64 传递;密钥可用 key_format 指定按文本或 HEX 解析,padding 可指定 PKCS#7 / 零填充 / 不填充。
POST
/api/encrypt/aes
AES 加密
按密钥长度自动选择 AES-128/192/256;CBC 模式返回随机 IV。
| 参数 | 类型 | 必填 | 说明 |
data |
string |
是 |
明文 |
key |
string |
是 |
16 / 24 / 32 字节密钥 |
mode |
string |
否 |
cbc / ecb / cfb / ofb / ctr / xts,默认 cbc |
padding |
string |
否 |
pkcs7 / zero / none,仅 CBC/ECB 生效,默认 pkcs7 |
key_format |
string |
否 |
auto / text / hex,默认 auto |
请求示例
curl -s -X POST https://gm.okpki.com/api/encrypt/aes \
-H 'Content-Type: application/json' \
-d '{"data":"hello","key":"0123456789abcdef","mode":"cbc"}'
响应示例
{
"success": true,
"ciphertext": "ZyxoNxEqPSLhEFMxZEEbQg==",
"iv": "LHuTtvMHaKiv+rv+0xzJHw==",
"algorithm": "AES-128-CBC"
}
POST
/api/decrypt/aes
AES 解密
CBC 模式必须提供加密时返回的 IV(Base64)。
| 参数 | 类型 | 必填 | 说明 |
data |
string |
是 |
密文(Base64) |
key |
string |
是 |
与加密一致的密钥 |
mode |
string |
否 |
cbc / ecb |
iv |
string |
否 |
CBC 时为必填,Base64 |
请求示例
curl -s -X POST https://gm.okpki.com/api/decrypt/aes \
-H 'Content-Type: application/json' \
-d '{"data":"ZyxoNxEqPSLhEFMxZEEbQg==","key":"0123456789abcdef","mode":"cbc","iv":"LHuTtvMHaKiv+rv+0xzJHw=="}'
响应示例
{
"success": true,
"plaintext": "hello"
}
POST
/api/encrypt/sm4
SM4 加密
国密 SM4 分组密码,密钥固定 16 字节,CBC 模式使用随机 IV。
| 参数 | 类型 | 必填 | 说明 |
data |
string |
是 |
明文 |
key |
string |
是 |
16 字节密钥 |
mode |
string |
否 |
cbc / ecb / cfb / ofb / ctr / xts,默认 cbc |
padding |
string |
否 |
pkcs7 / zero / none,仅 CBC/ECB 生效,默认 pkcs7 |
key_format |
string |
否 |
auto / text / hex,默认 auto |
请求示例
curl -s -X POST https://gm.okpki.com/api/encrypt/sm4 \
-H 'Content-Type: application/json' \
-d '{"data":"hello","key":"0123456789abcdef","mode":"cbc"}'
响应示例
{
"success": true,
"ciphertext": "<Base64>",
"iv": "<Base64>",
"algorithm": "SM4-CBC"
}
POST
/api/decrypt/sm4
SM4 解密
与 /api/encrypt/sm4 配对使用。
| 参数 | 类型 | 必填 | 说明 |
data |
string |
是 |
密文(Base64) |
key |
string |
是 |
16 字节密钥 |
mode |
string |
否 |
cbc / ecb |
iv |
string |
否 |
CBC 时为必填,Base64 |
请求示例
curl -s -X POST https://gm.okpki.com/api/decrypt/sm4 \
-H 'Content-Type: application/json' \
-d '{"data":"<Base64 密文>","key":"0123456789abcdef","mode":"cbc","iv":"<Base64 IV>"}'
响应示例
{
"success": true,
"plaintext": "hello"
}
POST
/api/zuc
ZUC-128 加解密 / 密钥流
GM/T 0001.1 保密算法。action=encrypt/decrypt 时加解密同源;action=keystream 只生成密钥流。密钥与 IV 均为 16 字节。
| 参数 | 类型 | 必填 | 说明 |
key |
string |
是 |
16 字节密钥 |
iv |
string |
否 |
16 字节 IV,留空则随机生成并在响应中返回 |
data |
string |
否 |
待处理数据(keystream 模式忽略) |
action |
string |
否 |
encrypt / decrypt / keystream,默认 encrypt |
key_format |
string |
否 |
hex(默认)/ text |
data_format |
string |
否 |
text(默认)/ hex / base64 |
output_format |
string |
否 |
hex(默认)/ base64 / text |
length |
int |
否 |
keystream 输出字节数,默认 32,上限 4096 |
请求示例
curl -s -X POST https://gm.okpki.com/api/zuc \
-H 'Content-Type: application/json' \
-d '{"key":"00112233445566778899aabbccddeeff","iv":"ffeeddccbbaa99887766554433221100","data":"hello","action":"encrypt","key_format":"hex"}'
响应示例
{
"success": true,
"output": "<HEX 密文>",
"hex": "<同上>",
"base64": "<Base64 密文>",
"iv": "<Base64 IV>",
"iv_hex": "<HEX IV>",
"algorithm": "ZUC-128"
}
🔑 非对称与 SM2
RSA / EC 密钥生成、RSA 签名验签,以及完整的 SM2 密钥生成、签名验签、加解密。密钥统一用 PEM 或 128 位 HEX 表示。
POST
/api/keypair/generate
生成密钥对
algorithm=rsa 时生成 RSA 密钥;algorithm=ec 时按 curve 生成 EC 密钥。
| 参数 | 类型 | 必填 | 说明 |
algorithm |
string |
否 |
rsa / ec,默认 rsa |
key_size |
int |
否 |
RSA 位数,默认 2048 |
curve |
string |
否 |
secp256r1 / secp384r1 / secp521r1 |
请求示例
curl -s -X POST https://gm.okpki.com/api/keypair/generate \
-H 'Content-Type: application/json' \
-d '{"algorithm":"ec","curve":"secp256r1"}'
响应示例
{
"success": true,
"public_key": "-----BEGIN PUBLIC KEY-----\n...",
"private_key": "-----BEGIN PRIVATE KEY-----\n..."
}
POST
/api/sm2/keypair/generate
生成 SM2 密钥对
返回 64 位十六进制私钥与 128 位公钥(不含 04 前缀),可直接传给签名 / 验签接口。
无请求参数
请求示例
curl -s -X POST https://gm.okpki.com/api/sm2/keypair/generate \
-H 'Content-Type: application/json' \
-d '{}'
响应示例
{
"success": true,
"private_key": "d90a55327d78bd9b76446187027c78c0f0cede9f146ec00b9b92e27797c9c92f",
"public_key": "63eef3fbc174a37634592a3a0342d53b5f2a428cf0f679af609a905ce7ede621370f9e93a3be38537f05827a9dce35d962abf11cc965d59ad0d9fe64a60a63c7",
"algorithm": "SM2"
}
POST
/api/sm2/sign
SM2 签名
对数据做 SM2-with-SM3 签名,返回 r‖s 拼接的 128 位十六进制签名值。
| 参数 | 类型 | 必填 | 说明 |
data |
string |
是 |
待签名数据 |
private_key |
string |
是 |
64 位十六进制私钥 |
请求示例
curl -s -X POST https://gm.okpki.com/api/sm2/sign \
-H 'Content-Type: application/json' \
-d '{"data":"hello","private_key":"<64 位十六进制私钥>"}'
响应示例
{
"success": true,
"signature": "7208cbba104e3b28d438706a8d625956888623df2eba17d77c0bb1146b2718a6e0fb3e9a3d46d270fecda9d6395c0b041377257c12d02b74ff600c2a6f14167c",
"algorithm": "SM2-with-SM3"
}
POST
/api/sm2/verify
SM2 验签
验签失败返回 valid=false 并附带原因,不抛 5xx,便于前端直接展示。
| 参数 | 类型 | 必填 | 说明 |
data |
string |
是 |
原始数据 |
signature |
string |
是 |
签名值(128 位十六进制) |
public_key |
string |
是 |
公钥(128 位十六进制) |
请求示例
curl -s -X POST https://gm.okpki.com/api/sm2/verify \
-H 'Content-Type: application/json' \
-d '{"data":"hello","signature":"<签名值>","public_key":"<128 位十六进制公钥>"}'
响应示例
{
"success": true,
"valid": true
}
POST
/api/sm2/encrypt
SM2 加密
使用公钥加密,返回 Base64 编码的 C1C3C2 密文。
| 参数 | 类型 | 必填 | 说明 |
data |
string |
是 |
明文 |
public_key |
string |
是 |
公钥(hex 字符串) |
请求示例
curl -s -X POST https://gm.okpki.com/api/sm2/encrypt \
-H 'Content-Type: application/json' \
-d '{"data":"hello","public_key":"<128 位十六进制公钥>"}'
响应示例
{
"success": true,
"ciphertext": "<Base64,C1C3C2>"
}
GET
/api/ec/curves
支持的椭圆曲线清单
返回 SM2 / secp256r1 / secp256k1 的 p、n 与基点坐标,便于现场自检参数是否一致。
无请求参数
请求示例
curl -s https://gm.okpki.com/api/ec/curves
响应示例
{
"success": true,
"curves": [{"key": "sm2", "name": "SM2 (sm2p256v1)", "oid": "1.2.156.10197.1.301", "bits": 256, "p": "0x...", "n": "0x...", "gx": "0x...", "gy": "0x..."}]
}
POST
/api/ec/point
曲线点运算
点加 / 点减 / 点乘 / 曲线校验。输入点支持 04 未压缩、02/03 压缩、128 位 X‖Y;结果同时给出未压缩与压缩两种编码。
| 参数 | 类型 | 必填 | 说明 |
curve |
string |
否 |
sm2(默认)/ secp256r1 / secp256k1 |
op |
string |
否 |
check / add / sub / mul,默认 check |
p1 |
string |
是 |
第一个点 |
p2 |
string |
否 |
mul 时为标量 k(HEX 或十进制),其余为第二个点 |
请求示例
curl -s -X POST https://gm.okpki.com/api/ec/point \
-H 'Content-Type: application/json' \
-d '{"curve":"sm2","op":"mul","p1":"04<128 位 HEX 基点>","p2":"2"}'
响应示例
{
"success": true,
"curve": "SM2 (sm2p256v1)",
"op": "mul",
"is_infinity": false,
"point": "04<128 位 HEX>",
"compressed": "03<64 位 HEX>",
"x": "0x...",
"y": "0x..."
}
POST
/api/ec/compress
公钥压缩 / 解压
compress 输出 33 字节压缩公钥;decompress 用模平方根还原 Y。输入点不在曲线上会直接报错而不是算出错误结果。
| 参数 | 类型 | 必填 | 说明 |
curve |
string |
否 |
同上 |
p1 |
string |
是 |
待转换的点(压缩或未压缩均可) |
请求示例
curl -s -X POST https://gm.okpki.com/api/ec/decompress \
-H 'Content-Type: application/json' \
-d '{"curve":"sm2","p1":"03<64 位 HEX>"}'
响应示例
{
"success": true,
"curve": "SM2 (sm2p256v1)",
"uncompressed": "04<128 位 HEX>",
"compressed": "03<64 位 HEX>",
"y_parity": "奇(03)"
}
POST
/api/sm2/attack
SM2 签名攻击推导
mode=recover_d(共用 k 恢复私钥)/ recover_k(由私钥反推 k)/ recover_d2(求第二组私钥)/ split(拆分 R‖S 与 DER)。结果附带反算公钥便于交叉验证。
| 参数 | 类型 | 必填 | 说明 |
mode |
string |
是 |
recover_d / recover_k / recover_d2 / split |
r1 |
string |
否 |
第一组签名的 r(recover_d / recover_d2) |
s1 |
string |
否 |
第一组签名的 s |
r2 |
string |
否 |
第二组签名的 r |
s2 |
string |
否 |
第二组签名的 s |
r |
string |
否 |
单组签名的 r(recover_k) |
s |
string |
否 |
单组签名的 s(recover_k) |
d |
string |
否 |
私钥(recover_k 必需) |
d1 |
string |
否 |
第一组私钥(recover_d2 必需) |
signature |
string |
否 |
签名值(split 模式,HEX 或 Base64) |
请求示例
curl -s -X POST https://gm.okpki.com/api/sm2/attack \
-H 'Content-Type: application/json' \
-d '{"mode":"recover_k","r":"<64 位 HEX>","s":"<64 位 HEX>","d":"<64 位 HEX 私钥>"}'
响应示例
{
"success": true,
"private_key": "<64 位 HEX>",
"k": "<64 位 HEX>",
"derived_public_key": "<128 位 HEX>",
"steps": {"(1 + d)": "0x..."}
}
📜 证书工具
解析、生成、转换与校验 X.509 证书。PEM 直接传字符串,DER / P12 / P7 统一用 Base64。
POST
/api/cert/parse
解析证书
返回主题、颁发者、有效期、SAN、密钥用法、指纹等字段,并识别是否国密算法。
| 参数 | 类型 | 必填 | 说明 |
cert_pem |
string |
是 |
PEM 格式证书 |
请求示例
curl -s -X POST https://gm.okpki.com/api/cert/parse \
-H 'Content-Type: application/json' \
-d '{"cert_pem":"-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----"}'
响应示例
{
"success": true,
"subject": {"countryName": "CN", "commonName": "example.com"},
"issuer": {"countryName": "CN", "commonName": "Example CA"},
"serial_number": "645425037953468266791195573448180121837620318826",
"not_before": "2026-11-14T04:39:57+00:00",
"not_after": "2027-11-14T04:39:57+00:00",
"is_expired": false,
"days_left": 364,
"san": ["example.com"],
"key_usage": ["digitalSignature", "keyEncipherment"],
"is_ca": false,
"key_type": "RSA",
"key_size": 2048,
"fingerprint_sha256": "AB:CD:...",
"version": "v3"
}
POST
/api/cert/parse-batch
批量解析证书
一次解析多张证书(如证书链),返回逐张结果与失败原因。
| 参数 | 类型 | 必填 | 说明 |
cert_pems |
array |
是 |
PEM 字符串数组 |
请求示例
curl -s -X POST https://gm.okpki.com/api/cert/parse-batch \
-H 'Content-Type: application/json' \
-d '{"cert_pems":["-----BEGIN CERTIFICATE-----\n..."]}'
响应示例
{
"success": true,
"results": [{"index": 1, "success": true, "subject": {"commonName": "example.com"}}],
"summary": {"total": 1, "success": 1, "failed": 0}
}
POST
/api/cert/generate-csr
生成 CSR
生成私钥与 CSR,支持 RSA / EC / SM2,可带 SAN 与密钥用法扩展。SM2 的 CSR 按 PKCS#10 自实现签名,openssl req -verify 可验。
| 参数 | 类型 | 必填 | 说明 |
cn |
string |
否 |
通用名 |
key_type |
string |
否 |
rsa / ec / sm2 |
key_size |
int |
否 |
RSA 位数,默认 2048 |
san_dns |
array |
否 |
SAN 域名列表 |
key_usage |
array |
否 |
密钥用法 |
sm2_id |
string |
否 |
仅 SM2:standard(默认)/ empty(OpenSSL 3.5+) |
请求示例
curl -s -X POST https://gm.okpki.com/api/cert/generate-csr \
-H 'Content-Type: application/json' \
-d '{"cn":"example.com","key_type":"rsa","san_dns":["example.com","www.example.com"]}'
响应示例
{
"success": true,
"csr": "-----BEGIN CERTIFICATE REQUEST-----\n...",
"private_key": "-----BEGIN PRIVATE KEY-----\n...",
"key_type": "rsa"
}
POST
/api/cert/parse-csr-sm2
解析 SM2 CSR
解析 PKCS#10 请求并验证签名,返回主体、公钥、SAN/KeyUsage/EKU 与匹配到的用户标识。非国密 CSR 会明确报错。
| 参数 | 类型 | 必填 | 说明 |
csr_pem |
string |
是 |
CSR(PEM 或 HEX) |
sm2_id |
string |
否 |
指定用户标识;留空则国标默认值与空标识都试 |
请求示例
curl -s -X POST https://gm.okpki.com/api/cert/parse-csr-sm2 \
-H 'Content-Type: application/json' \
-d '{"csr_pem":"-----BEGIN CERTIFICATE REQUEST-----\n..."}'
响应示例
{
"success": true,
"valid": true,
"subject": "C=CN, O=OKPKI, CN=csr.example.com",
"public_key_hex": "a1b2...",
"san_dns": ["csr.example.com"],
"key_usage": ["digital_signature"],
"matched_user_id": "空标识(OpenSSL 3.5+ 默认)"
}
POST
/api/cert/issue-from-csr-sm2
签发 SM2 CSR
用 CA 私钥给 SM2 CSR 签发证书:公钥与主体沿用 CSR,SKI/AKI/BasicConstraints 由签发方决定,返回叶子证书与完整链。CSR 签名无效一律拒绝签发。
| 参数 | 类型 | 必填 | 说明 |
csr_pem |
string |
是 |
CSR(PEM 或 HEX) |
ca_cert_pem |
string |
是 |
CA 证书 |
ca_key |
string |
是 |
CA 私钥(PEM 或裸 HEX) |
validity_days |
int |
否 |
有效期天数,默认 365 |
sm2_id |
string |
否 |
签发用的用户标识,需与对端一致 |
is_ca |
bool |
否 |
true 则签发 CA 证书 |
请求示例
curl -s -X POST https://gm.okpki.com/api/cert/issue-from-csr-sm2 \
-H 'Content-Type: application/json' \
-d '{"csr_pem":"...","ca_cert_pem":"...","ca_key":"...","sm2_id":"empty"}'
响应示例
{
"success": true,
"subject": "C=CN, O=OKPKI, CN=csr.example.com",
"csr_user_id": "空标识(OpenSSL 3.5+ 默认)",
"chain_pem": "-----BEGIN CERTIFICATE-----\n...",
"self_check": {"valid": true}
}
POST
/api/cert/generate-self-signed
生成自签名证书
用于测试环境快速构造证书,支持 SAN、有效期与扩展项。
| 参数 | 类型 | 必填 | 说明 |
cn |
string |
否 |
通用名,默认 localhost |
validity_days |
int |
否 |
有效期天数,默认 365 |
san_dns |
array |
否 |
SAN 域名 |
san_ip |
array |
否 |
SAN IP |
请求示例
curl -s -X POST https://gm.okpki.com/api/cert/generate-self-signed \
-H 'Content-Type: application/json' \
-d '{"cn":"localhost","validity_days":365,"san_dns":["localhost"]}'
响应示例
{
"success": true,
"certificate": "-----BEGIN CERTIFICATE-----\n...",
"private_key": "-----BEGIN PRIVATE KEY-----\n..."
}
POST
/api/cert/generate-sm2-self-signed
签发 SM2 国密证书
手写 DER + 自实现的 GM/T 0003.2 签名,签出真正的 SM2 证书(SM2-with-SM3 + sm2p256v1),openssl verify 可真正验过。传 ca_cert_pem + ca_key 即由该 CA 签发叶子并返回完整链;sm2_id 控制用户标识:standard(国密网关/GMSSL)或 empty(OpenSSL 3.5+ 默认),两者互不认。
| 参数 | 类型 | 必填 | 说明 |
cn |
string |
是 |
通用名(CN) |
validity_days |
int |
否 |
有效期天数,1-3650,默认 365 |
o |
string |
否 |
组织名 O |
ou |
string |
否 |
部门 OU |
c |
string |
否 |
国家,两字母,默认 CN |
san_dns |
array |
否 |
SAN 域名列表 |
san_ip |
array |
否 |
SAN IP 列表 |
key_usage |
array |
否 |
digital_signature / non_repudiation / key_encipherment 等 |
extended_key_usage |
array |
否 |
server_auth / client_auth / code_signing 等 |
is_ca |
bool |
否 |
true 则签 CA 证书(basicConstraints CA:TRUE) |
ca_cert_pem |
string |
否 |
CA 证书;给出则签成证书链 |
ca_key |
string |
否 |
CA 私钥(PEM 或裸 HEX),与 ca_cert_pem 配对使用 |
sm2_id |
string |
否 |
standard(默认,1234567812345678)/ empty(OpenSSL 3.5+)/ 自定义 |
请求示例
curl -s -X POST https://gm.okpki.com/api/cert/generate-sm2-self-signed \
-H 'Content-Type: application/json' \
-d '{"cn":"sm2.example.com","validity_days":365,"san_dns":["sm2.example.com"]}'
响应示例
{
"success": true,
"algorithm": "SM2",
"signature_algorithm": "SM2-with-SM3",
"curve": "sm2p256v1",
"sm2_id": "GM/T 0009 默认(1234567812345678)",
"issued_by_ca": false,
"chain_pem": "-----BEGIN CERTIFICATE-----\n...",
"certificate": "-----BEGIN CERTIFICATE-----\n...",
"private_key": "-----BEGIN PRIVATE KEY-----\n...",
"self_check": {"valid": true, "detail": "签名自校验通过"}
}
POST
/api/cert/sm2-verify
校验 SM2 证书自签名
从证书中取出 TBS 与签名值,用 SM2 公钥验签。不给 sm2_id 时依次尝试国标默认值与空标识,返回 matched_user_id 说明是哪个通过——国密网关与 OpenSSL 3.5 的用户标识默认值不同,这是验签结论相反的常见原因。
| 参数 | 类型 | 必填 | 说明 |
cert_pem |
string |
是 |
PEM 或 HEX(DER) 格式证书 |
issuer_cert_pem |
string |
否 |
签发者证书;给出则验证链,否则按自签验证 |
sm2_id |
string |
否 |
指定用户标识;留空则依次尝试国标默认值与空标识并回报结果 |
请求示例
curl -s -X POST https://gm.okpki.com/api/cert/sm2-verify \
-H 'Content-Type: application/json' \
-d '{"cert_pem":"-----BEGIN CERTIFICATE-----\n..."}'
响应示例
{
"success": true,
"valid": true,
"chain_mode": "issued",
"matched_user_id": "空标识(OpenSSL 3.5+ 默认)",
"issuer_name_matched": true,
"is_sm2_algorithm": true,
"detail": "签名验证通过(签发者公钥)"
}
POST
/api/cert/verify-chain
验证证书链
校验有效期、链完整性、签名、KeyUsage 与 BasicConstraints,逐项返回 pass/fail/warn。
| 参数 | 类型 | 必填 | 说明 |
cert_pem |
string |
是 |
待验证的叶子证书 |
ca_certs |
array |
是 |
CA 证书数组,中间 CA 在前、根 CA 在后 |
请求示例
curl -s -X POST https://gm.okpki.com/api/cert/verify-chain \
-H 'Content-Type: application/json' \
-d '{"cert_pem":"-----BEGIN CERTIFICATE-----\n...","ca_certs":["-----BEGIN CERTIFICATE-----\n..."]}'
响应示例
{
"success": true,
"valid": true,
"chain_complete": true,
"checks": [{"check": "有效期", "status": "pass", "detail": "有效期内(剩余 364 天)"}]
}
POST
/api/cert/dual-check
双证书配套校验
校验证书与加密证书的配套关系:主体一致、同一 CA 签发、密钥对独立、KeyUsage/EKU 分离、有效期匹配。提供 ca_cert 时用 CA 公钥做真实验签(SM2 走国标用户标识)。逐条返回 pass/warn/fail 与得分。
| 参数 | 类型 | 必填 | 说明 |
sign_cert |
string |
是 |
签名证书 PEM |
enc_cert |
string |
是 |
加密证书 PEM |
ca_cert |
string |
否 |
签发这两张证书的 CA 证书;给出则做真实验签 |
请求示例
curl -s -X POST https://gm.okpki.com/api/cert/dual-check \
-H 'Content-Type: application/json' \
-d '{"sign_cert":"-----BEGIN CERTIFICATE-----\n...","enc_cert":"-----BEGIN CERTIFICATE-----\n..."}'
响应示例
{
"success": true,
"verdict": "pass",
"score": 100,
"counts": {"pass": 12, "warn": 0, "fail": 0},
"findings": [{"level": "pass", "item": "密钥独立性", "detail": "两张证书公钥不同,密钥对相互独立", "suggestion": ""}],
"ca_checked": true
}
POST
/api/cert/dual-sample
生成双证书示例
现场签发一套符合 TLCP 要求的示例:Demo CA + 签名证书(digitalSignature)+ 加密证书(keyEncipherment),两张证书同主体、密钥对独立,可直接用于校验功能演示。
无请求参数
请求示例
curl -s -X POST https://gm.okpki.com/api/cert/dual-sample \
-H 'Content-Type: application/json' \
-d ''
响应示例
{
"success": true,
"sign_cert": "-----BEGIN CERTIFICATE-----\n...",
"enc_cert": "-----BEGIN CERTIFICATE-----\n...",
"ca_cert": "-----BEGIN CERTIFICATE-----\n..."
}
POST
/api/cert/convert/pem-to-der
PEM → DER
证书格式互转,同类接口还有 der-to-pem、key-pem-to-der、key-der-to-pem、cert-to-pkcs7、pkcs7-to-pem。
| 参数 | 类型 | 必填 | 说明 |
cert_pem |
string |
是 |
PEM 格式证书 |
请求示例
curl -s -X POST https://gm.okpki.com/api/cert/convert/pem-to-der \
-H 'Content-Type: application/json' \
-d '{"cert_pem":"-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----"}'
响应示例
{
"success": true,
"der_base64": "MIIC..."
}
POST
/api/cert/convert/parse-pkcs12
解析 PFX / PKCS#12
解包 PFX,返回证书、私钥、CA 链与友好名称。**支持国密 SM2**——cryptography 遇到 SM2 会抛 UnsupportedAlgorithm,这里是自实现的 ASN.1 解析。支持传统 PBE(3DES/RC2)与 PBES2(PBKDF2 + AES/SM4-CBC),并校验 MAC 完整性。口令错误时直接报错,不会返回半成品。
| 参数 | 类型 | 必填 | 说明 |
p12_base64 |
string |
是 |
PFX 的 Base64、HEX 或 data URL |
password |
string |
否 |
解封口令;无口令 PFX 留空 |
请求示例
curl -s -X POST https://gm.okpki.com/api/cert/convert/parse-pkcs12 \
-H 'Content-Type: application/json' \
-d '{"p12_base64":"MIIEBwIBAzCCA80...","password":"123456"}'
响应示例
{
"success": true,
"version": 3,
"is_sm2": true,
"mac": {"present": true, "status": "ok", "algorithm": "SHA-1"},
"encryption_algorithms": ["pbeWithSHAAnd3-KeyTripleDES-CBC"],
"counts": {"certificate": 1, "private_key": 1, "crl": 0},
"private_key": "-----BEGIN PRIVATE KEY-----\n...",
"private_key_info": {"algorithm": "SM2", "curve": "sm2p256v1", "private_key_hex": "7e15..."},
"certificate": "-----BEGIN CERTIFICATE-----\n..."
}
POST
/api/cert/convert/create-pkcs12
生成 PFX / PKCS#12
把证书与私钥打包成 PFX。给了口令就用 PBES2 包住私钥并写入 MAC;口令留空则私钥以 keyBag 明文存放。algorithm 选 sm4(国密)或 aes(通用),生成的包可直接被 OpenSSL 读取。会先校验证书与私钥是否配对。
| 参数 | 类型 | 必填 | 说明 |
cert_pem |
string |
是 |
叶证书 PEM |
key_pem |
string |
是 |
私钥 PEM、SEC1 格式或 64 位 HEX 的 SM2 私钥 |
password |
string |
否 |
导出密码;留空则不加密 |
ca_certs |
array |
否 |
随包携带的 CA 证书 |
friendly_name |
string |
否 |
写入 bagAttributes 的显示名 |
algorithm |
string |
否 |
sm4(默认)或 aes |
请求示例
curl -s -X POST https://gm.okpki.com/api/cert/convert/create-pkcs12 \
-H 'Content-Type: application/json' \
-d '{"cert_pem":"-----BEGIN CERTIFICATE-----\n...","key_pem":"-----BEGIN PRIVATE KEY-----\n...","password":"123456","algorithm":"sm4"}'
响应示例
{
"success": true,
"p12_base64": "MIIEBwIBAzCC...",
"size": 1154,
"encrypted": true,
"algorithm": "PBES2 / SM4-CBC / PBKDF2-HMAC-SHA256",
"is_sm2": true
}
POST
/api/cert/crl/create
签发 CRL
用 CA 私钥签发证书吊销列表,支持国密 SM2-with-SM3 与 RSA/ECDSA。自动写入 AuthorityKeyIdentifier 与 CRLNumber,签发后立即做一次签名自校验并在 self_check 里返回。issuer 直接取 CA 证书 subject 的原始 DER,避免重编码后对不上。
| 参数 | 类型 | 必填 | 说明 |
ca_cert_pem |
string |
是 |
CA 证书 PEM |
ca_key_pem |
string |
是 |
CA 私钥,仅本次请求使用,不落库 |
revoked |
array |
否 |
序列号数组,或 [{"serial":"1A2B","date":"2026-11-20","reason":"keyCompromise"}] |
days |
int |
否 |
有效期天数,1~3650,默认 7 |
crl_number |
string |
否 |
CRL 号;留空按签发时间生成 |
digest |
string |
否 |
auto(默认)/ sha256 / sha384 / sha512;SM2 固定 SM3 |
sm2_id |
string |
否 |
SM2 用户标识,默认国密 1234567812345678;填 empty 用空标识 |
请求示例
curl -s -X POST https://gm.okpki.com/api/cert/crl/create \
-H 'Content-Type: application/json' \
-d '{"ca_cert_pem":"-----BEGIN CERTIFICATE-----\n...","ca_key_pem":"-----BEGIN PRIVATE KEY-----\n...","revoked":["1A2B3C"],"days":7}'
响应示例
{
"success": true,
"crl_pem": "-----BEGIN X509 CRL-----\n...",
"issuer": "CN=sm2.example.cn,O=Test,C=CN",
"crl_number": 202611200556,
"entry_count": 1,
"signature_algorithm": "SM2-with-SM3",
"self_check": {"verified": true, "message": "签名自校验通过"}
}
POST
/api/cert/crl/parse
解析 CRL
读取 CRL 的签发者、本次/下次更新时间与吊销条目(含序列号、时间、原因),供状态检查使用。
| 参数 | 类型 | 必填 | 说明 |
crl_pem |
string |
是 |
CRL(PEM 或 Base64 DER) |
请求示例
curl -s -X POST https://gm.okpki.com/api/cert/crl/parse \
-H 'Content-Type: application/json' \
-d '{"crl_pem":"-----BEGIN X509 CRL-----\n...\n-----END X509 CRL-----"}'
响应示例
{
"success": true,
"issuer": {"CN": "Example CA"},
"last_update": "2026-11-20T05:56:26+00:00",
"total_revoked": 1,
"revoked_certificates": [{"serial_number": "1715004", "reason": "key_compromise"}]
}
🧰 辅助与站点数据
口令强度、字符集转换、大数运算,以及站点自身的统计数据。
POST
/api/password/strength
口令强度检测
返回 0~7 分评分、等级、字符类型覆盖与改进建议。
| 参数 | 类型 | 必填 | 说明 |
password |
string |
是 |
待检测口令 |
请求示例
curl -s -X POST https://gm.okpki.com/api/password/strength \
-H 'Content-Type: application/json' \
-d '{"password":"Abc12345!"}'
响应示例
{
"success": true,
"score": 4,
"max_score": 7,
"level": "中",
"length": 9,
"has_lower": true,
"has_upper": true,
"has_digit": true,
"has_special": true,
"feedback": []
}
POST
/api/encode/charset
字符集转换
在 UTF-8 / GBK / GB18030 等字符集间转换,同时返回 HEX 与 Base64。
| 参数 | 类型 | 必填 | 说明 |
text |
string |
是 |
待转换文本 |
mode |
string |
否 |
encode / decode |
from_charset |
string |
否 |
默认 utf-8 |
to_charset |
string |
否 |
默认 gbk |
请求示例
curl -s -X POST https://gm.okpki.com/api/encode/charset \
-H 'Content-Type: application/json' \
-d '{"text":"你好","mode":"encode","to_charset":"gbk"}'
响应示例
{
"success": true,
"mode": "encode",
"result": "你好",
"hex": "c4e3bac3",
"base64": "xOO6ww==",
"byte_length": 4
}
POST
/api/aux/bignum
大数运算
支持 add / sub / mul / div / mod / pow 以及 add_mod / mul_mod / pow_mod,输入输出格式可选 hex / dec / bin。
| 参数 | 类型 | 必填 | 说明 |
a |
string |
是 |
操作数 A |
b |
string |
否 |
操作数 B |
p |
string |
否 |
模数(带 _mod 的运算必填) |
op |
string |
否 |
add / sub / mul / div / mod / pow / add_mod / mul_mod / pow_mod |
input_format |
string |
否 |
hex / dec / bin |
output_format |
string |
否 |
hex / dec / bin |
请求示例
curl -s -X POST https://gm.okpki.com/api/aux/bignum \
-H 'Content-Type: application/json' \
-d '{"a":"ff","b":"01","op":"add"}'
响应示例
{
"success": true,
"result": "100",
"operation": "add",
"bit_length": 9,
"output_format": "hex"
}
GET
/api/tools/stats
站点使用统计
返回总调用量、成功率、按工具与按日期的聚合数据。
无请求参数
请求示例
curl -s https://gm.okpki.com/api/tools/stats
响应示例
{
"total": 1234,
"success_rate": 96.5,
"by_tool": [{"tool": "hash", "count": 500}],
"by_date": [{"date": "2026-11-14", "count": 42}]
}
🎲 随机性检测
依据 GM/T 0005-2012 的核心统计检测项(频数、块内频数、扑克、游程、自相关、矩阵秩、累积和等),返回每项 P-value 与判定。
GET
/api/randomness/tests
检测项列表
列出支持的检测项、默认显著性水平与输入上限。
无请求参数
请求示例
curl -s https://gm.okpki.com/api/randomness/tests
响应示例
{
"success": true,
"tests": [{"key": "frequency", "name": "单比特频数检测"}],
"alpha_default": 0.01,
"max_bits": 100000
}
POST
/api/randomness/detect
执行随机性检测
按 GM/T 0005-2012 的 15 项方法做统计检测,P-value >= alpha 判定为通过。多参数方法(重叠子序列 m=2/5 的双 p 值、二元推导 k=3/7、近似熵 m=2/5、累积和前向/后向)拆成多条独立判定;序列过短的项标为 skipped 而不是判失败。
| 参数 | 类型 | 必填 | 说明 |
data |
string |
是 |
待检测数据 |
data_format |
string |
否 |
text / hex / base64 / binary,默认 text |
alpha |
number |
否 |
显著性水平,默认 0.01 |
tests |
array |
否 |
指定检测项 key 列表,留空则全部 |
请求示例
curl -s -X POST https://gm.okpki.com/api/randomness/detect \
-H 'Content-Type: application/json' \
-d '{"data":"a5c3...","data_format":"hex"}'
响应示例
{
"success": true,
"total_bits": 38400,
"standard_items": 15,
"tests_run": 21,
"skipped": 0,
"passed": 21,
"failed": 0,
"all_pass": true,
"results": [{"name": "重叠子序列检测(m=5, p1)", "p_value": 0.324, "pass": true}]
}
POST
/api/randomness/batch
样本集判定(二级检测)
对多条样本做整体判定:每项检测的通过率不得低于 p̂−3√(p̂(1−p̂)/m),且 P 值需均匀落在 10 个区间(卡方,显著性 1e-4)。单条序列只看 P 值时误报率就是 α,只有样本集判定才能说明随机源是否合格。判据参考 NIST SP 800-22 §4.2.2。样本过短(如 < 38912 比特)时矩阵秩等项会整体跳过,不参与判定。
| 参数 | 类型 | 必填 | 说明 |
samples |
array |
是 |
样本数组,每项一条序列;单次最多 50 条 |
data_format |
string |
否 |
text / hex / base64 / binary,默认 hex |
alpha |
number |
否 |
单条判定显著性水平,默认 0.01 |
请求示例
curl -s -X POST https://gm.okpki.com/api/randomness/batch \
-H 'Content-Type: application/json' \
-d '{"samples":["a5c3...","7f19..."],"data_format":"hex"}'
响应示例
{
"success": true,
"samples": 20,
"samples_all_pass": 18,
"items_checked": 18,
"failed_items": [],
"all_pass": true,
"items": [{"name": "单比特频数检测", "samples": 20, "pass_rate": 0.95, "pass_rate_lower": 0.9233, "uniformity_p": 0.35, "verdict": "pass"}],
"criteria": {"pass_rate_lower": 0.9233, "uniformity_bins": 10, "uniformity_alpha": 0.0001}
}
🔐 SM9 标识密码
基于标识的公钥密码(GM/T 0044 系列)。需安装可选依赖 gmalg;未安装时接口返回明确提示。密钥均为 Base64 编码。
POST
/api/sm9/master-key
生成主密钥对
生成签名或加密主密钥对(msk 秘密、mpk 公开)。
| 参数 | 类型 | 必填 | 说明 |
purpose |
string |
否 |
sign / encrypt,默认 sign |
请求示例
curl -s -X POST https://gm.okpki.com/api/sm9/master-key \
-H 'Content-Type: application/json' \
-d '{"purpose":"sign"}'
响应示例
{
"success": true,
"purpose": "sign",
"master_secret_key": "<Base64 msk>",
"master_public_key": "<Base64 mpk>",
"hid": "01"
}
POST
/api/sm9/derive-key
派生用户私钥
KGC 用主私钥按标识(uid)派生用户私钥。
| 参数 | 类型 | 必填 | 说明 |
master_secret_key |
string |
是 |
主私钥(Base64) |
uid |
string |
是 |
用户标识,如邮箱 |
purpose |
string |
否 |
sign / encrypt |
请求示例
curl -s -X POST https://gm.okpki.com/api/sm9/derive-key \
-H 'Content-Type: application/json' \
-d '{"master_secret_key":"<msk>","uid":"alice@example.com","purpose":"sign"}'
响应示例
{
"success": true,
"uid": "alice@example.com",
"user_secret_key": "<Base64 sk>"
}
POST
/api/sm9/sign
SM9 签名
用签名主公钥 + 用户签名私钥对消息签名,返回 h 与 S。
| 参数 | 类型 | 必填 | 说明 |
data |
string |
是 |
待签名消息 |
master_public_key |
string |
是 |
签名主公钥(Base64) |
user_secret_key |
string |
是 |
用户签名私钥(Base64) |
请求示例
curl -s -X POST https://gm.okpki.com/api/sm9/sign \
-H 'Content-Type: application/json' \
-d '{"data":"hello","master_public_key":"<mpk>","user_secret_key":"<sk>"}'
响应示例
{
"success": true,
"h": "<Base64>",
"S": "<Base64>",
"algorithm": "SM9-with-SM3"
}
POST
/api/sm9/verify
SM9 验签
用签名主公钥 + uid 验签。
| 参数 | 类型 | 必填 | 说明 |
h |
string |
是 |
签名 h(Base64) |
s |
string |
是 |
签名 S(Base64) |
master_public_key |
string |
是 |
签名主公钥 |
uid |
string |
是 |
用户标识 |
请求示例
curl -s -X POST https://gm.okpki.com/api/sm9/verify \
-H 'Content-Type: application/json' \
-d '{"data":"hello","h":"<h>","s":"<S>","master_public_key":"<mpk>","uid":"alice@example.com"}'
响应示例
{
"success": true,
"valid": true
}
POST
/api/sm9/encrypt
SM9 加密
用加密主公钥 + 接收方 uid 加密。
| 参数 | 类型 | 必填 | 说明 |
plaintext |
string |
是 |
明文 |
master_public_key |
string |
是 |
加密主公钥 |
uid |
string |
是 |
接收方标识 |
请求示例
curl -s -X POST https://gm.okpki.com/api/sm9/encrypt \
-H 'Content-Type: application/json' \
-d '{"plaintext":"secret","master_public_key":"<mpk>","uid":"alice@example.com"}'
响应示例
{
"success": true,
"ciphertext": "<Base64>",
"algorithm": "SM9"
}
POST
/api/sm9/decrypt
SM9 解密
用用户解密私钥 + uid 解密。
| 参数 | 类型 | 必填 | 说明 |
ciphertext |
string |
是 |
密文(Base64) |
user_secret_key |
string |
是 |
用户解密私钥 |
uid |
string |
是 |
接收方标识 |
请求示例
curl -s -X POST https://gm.okpki.com/api/sm9/decrypt \
-H 'Content-Type: application/json' \
-d '{"ciphertext":"<ct>","user_secret_key":"<sk>","uid":"alice@example.com"}'
响应示例
{
"success": true,
"plaintext": "secret",
"plaintext_hex": "736563726574"
}
🧰 协议与结构分析工具
P1 批工具:ECDSA 签名验签、ASN.1 DER 结构解析、AES-GCM 与 SM4-GCM 认证加密(含 AAD)、RFC3161 时间戳解析与 pcap 流量包解析。
POST
/api/ecdsa/keypair
生成 ECDSA 密钥对
支持 secp256r1/secp384r1/secp521r1/secp256k1,返回 PEM 与 X962 公钥。
| 参数 | 类型 | 必填 | 说明 |
curve |
string |
否 |
曲线名,默认 secp256r1 |
请求示例
curl -s -X POST https://gm.okpki.com/api/ecdsa/keypair \
-H 'Content-Type: application/json' \
-d '{"curve":"secp256r1"}'
响应示例
{
"success": true,
"curve": "secp256r1",
"private_key": "<PEM>",
"public_key": "<PEM>"
}
POST
/api/ecdsa/sign
ECDSA 签名
DER(Base64)或 R||S(HEX)格式输出。
| 参数 | 类型 | 必填 | 说明 |
data |
string |
是 |
待签名数据 |
private_key |
string |
是 |
PEM 私钥 |
output_format |
string |
否 |
der / raw |
请求示例
curl -s -X POST https://gm.okpki.com/api/ecdsa/sign \
-H 'Content-Type: application/json' \
-d '{"data":"hello","private_key":"<PEM>","output_format":"der"}'
响应示例
{
"success": true,
"signature": "<Base64 DER>",
"format": "DER"
}
POST
/api/asn1/parse
ASN.1 DER 解析
递归解析 DER TLV 结构树,输出标签、长度与值。
| 参数 | 类型 | 必填 | 说明 |
data |
string |
是 |
DER 数据 |
data_format |
string |
否 |
hex / base64 |
请求示例
curl -s -X POST https://gm.okpki.com/api/asn1/parse \
-H 'Content-Type: application/json' \
-d '{"data":"3082...","data_format":"hex"}'
响应示例
{
"success": true,
"total_bytes": 684,
"tree": [{"tag": "SEQUENCE", "children": [...]}]
}
POST
/api/gcm/encrypt
AES-GCM 加密(含 AAD)
返回 IV||密文||标签 的 Base64;解密时 AAD 不匹配会认证失败。
| 参数 | 类型 | 必填 | 说明 |
plaintext |
string |
是 |
明文 |
key |
string |
是 |
16/24/32 字节 HEX 密钥 |
aad |
string |
否 |
附加认证数据 |
请求示例
curl -s -X POST https://gm.okpki.com/api/gcm/encrypt \
-H 'Content-Type: application/json' \
-d '{"plaintext":"secret","key":"0123456789abcdef0123456789abcdef","aad":"hdr"}'
响应示例
{
"success": true,
"ciphertext": "<Base64>",
"iv": "7b7e...",
"algorithm": "AES-128-GCM"
}
POST
/api/gcm/sm4-encrypt
SM4-GCM 加密(国密,含 AAD)
国密 SM4-GCM AEAD:返回 IV||密文||标签 的 Base64,标签固定 16 字节。核心经 NIST SP 800-38D 向量校验,SM4 分组经 GM/T 0002 校验。
| 参数 | 类型 | 必填 | 说明 |
plaintext |
string |
是 |
明文 |
key |
string |
是 |
16 字节(32 HEX 字符)SM4 密钥 |
aad |
string |
否 |
附加认证数据 |
iv |
string |
否 |
12 字节 HEX;留空随机生成 |
请求示例
curl -s -X POST https://gm.okpki.com/api/gcm/sm4-encrypt \
-H 'Content-Type: application/json' \
-d '{"plaintext":"hello","key":"0123456789abcdeffedcba9876543210","aad":"hdr"}'
响应示例
{
"success": true,
"ciphertext": "AAAAAAAAAAAAAAAA23YAaCGs7ZMNlma1uoAX8eJ1Tp8A",
"iv": "000000000000000000000000",
"tag": "aced930d9666b5ba8017f1e2754e9f00",
"algorithm": "SM4-GCM",
"format": "IV || ciphertext || tag(16)"
}
POST
/api/gcm/sm4-decrypt
SM4-GCM 解密(验证认证)
校验 16 字节标签;AAD/密钥/密文任一不匹配即认证失败,不返回明文。
| 参数 | 类型 | 必填 | 说明 |
ciphertext |
string |
是 |
加密返回的 Base64 |
key |
string |
是 |
16 字节 SM4 密钥 |
aad |
string |
否 |
与加密时一致 |
请求示例
curl -s -X POST https://gm.okpki.com/api/gcm/sm4-decrypt \
-H 'Content-Type: application/json' \
-d '{"ciphertext":"AAAAAAAA...","key":"0123456789abcdeffedcba9876543210","aad":"hdr"}'
响应示例
{
"success": true,
"plaintext": "hello",
"plaintext_hex": "68656c6c6f",
"authenticated": true
}
POST
/api/timestamp/parse
RFC3161 时间戳解析
提取 TSTInfo 的策略 OID、消息摘要、序列号与签发时间。
| 参数 | 类型 | 必填 | 说明 |
data |
string |
是 |
TimeStampToken 令牌 |
data_format |
string |
否 |
base64 / hex |
请求示例
curl -s -X POST https://gm.okpki.com/api/timestamp/parse \
-H 'Content-Type: application/json' \
-d '{"data":"MI...","data_format":"base64"}'
响应示例
{
"success": true,
"fields": {"version": 1, "serial_number": "12345", "gen_time": "2025-01-18T10:00:00+00:00"}
}
POST
/api/timestamp/verify
RFC3161 令牌验签与文档绑定
验证 TSA 对 TSTInfo 的 CMS 签名,并核对令牌内消息摘要是否与原文一致。令牌未内嵌证书时需提供 TSA 证书 PEM。
| 参数 | 类型 | 必填 | 说明 |
data |
string |
是 |
TimeStampToken 令牌 |
data_format |
string |
否 |
base64 / hex |
document |
string |
否 |
待验证原文;留空则只验签名 |
tsa_cert_pem |
string |
否 |
TSA 证书 PEM(令牌未内嵌时必填) |
请求示例
curl -s -X POST https://gm.okpki.com/api/timestamp/verify \
-H 'Content-Type: application/json' \
-d '{"data":"MI...","document":"原文","tsa_cert_pem":"-----BEGIN CERTIFICATE-----..."}'
响应示例
{
"success": true,
"valid": true,
"tsa_signature_valid": true,
"document_digest_bound": true,
"tsa_signer": "CN=Test TSA",
"tst_info": {"message_digest_algorithm": "SHA-256", "gen_time": "2026-11-20T03:54:53+00:00"}
}
POST
/api/pcap/parse
pcap 流量包解析
识别 TLS 握手版本/密码套件(含国密 GM/T 0024)、SSH 版本与 IPSec 特征。
| 参数 | 类型 | 必填 | 说明 |
data |
string |
是 |
pcap 文件 Base64 |
data_format |
string |
否 |
base64 / hex |
请求示例
curl -s -X POST https://gm.okpki.com/api/pcap/parse \
-H 'Content-Type: application/json' \
-d '{"data":"d4c3...","data_format":"base64"}'
响应示例
{
"success": true,
"application_protocols": {"TLS": 12},
"tls_versions": {"TLS 1.2": 8},
"gm_cipher_suites": ["ECDHE_SM4_CBC_SM3 (GM/T 0024)"]
}