Skip to main content
Glama

CipherHUB Cryptography Toolkit

sm2_sign

Read-only

[sm2] SM2 私钥签名。 【参数】

  • sm2_private_key_in_pem:PEM 格式私钥

  • data_in_hex:待签数据 Hex。 · RAW 模式(sign_raw_data_mode=True):消息原文 Hex,服务端走标准 SM2 流程,内部计算 e = SM3(ZA || M) 后签名。 · DIGEST 模式(sign_raw_data_mode=False):必须传 32 字节 SM3 摘要 e 的 Hex(64 个 hex 字符),服务端不再做任何隐式 SM3,直接对 e 做裸 SM2 签名,与 KMS / ECC / RSA 的 DIGEST 模式语义一致。

  • sign_raw_data_mode:True=RAW(原文),False=DIGEST(32 字节摘要)

  • sm2_private_key_password:若私钥加密则传入 【输出】signature_in_hex_with_format 字典:

  • RS:r||s 原始拼接(各 32 字节,共 64 字节)

  • RS_ASN1:ASN.1 DER 编码(推荐用于验签) 【验签时需使用 RS_ASN1 格式的签名,且 sign_raw_data_mode 必须与签名时一致】

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "sm2_sign"
  }
}

Input Schema

NameRequiredDescriptionDefault
data_in_hexNo数据的十六进制字符串。RAW 模式为消息原文 Hex,DIGEST 模式为哈希摘要 Hex
sign_raw_data_modeNoTrue=对原文签名(服务端内部先哈希),False=data_in_hex 已是哈希摘要的 Hex
sm2_private_key_in_pemNoSM2 加密私钥的 PEM 文本(含 BEGIN/END ENCRYPTED PRIVATE KEY 头尾)
sm2_private_key_passwordNoSM2 私钥的加密密码(原始字符串,非编码格式)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changed
    • addedInput schema / properties / data_in_hex / description
      Added value: +"数据的十六进制字符串。RAW 模式为消息原文 Hex,DIGEST 模式为哈希摘要 Hex"
    • addedInput schema / properties / sign_raw_data_mode / description
      Added value: +"True=对原文签名(服务端内部先哈希),False=data_in_hex 已是哈希摘要的 Hex"
    • addedInput schema / properties / sm2_private_key_in_pem / description
      Added value: +"SM2 加密私钥的 PEM 文本(含 BEGIN/END ENCRYPTED PRIVATE KEY 头尾)"
    • addedInput schema / properties / sm2_private_key_password / description
      Added value: +"SM2 私钥的加密密码(原始字符串,非编码格式)"
  2. First observed

TDQS

A4.6/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The annotations only declare readOnlyHint=true and openWorldHint=false; the description goes further by explaining the mode-dependent internal behavior (implicit SM3 in RAW, no implicit hashing in DIGEST) and the 64-hex-character requirement. It does not cover error cases or whether a blank sm2_private_key_password is tolerated, so a 4 is fair.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The 【参数】/【输出】 structure is front-loaded and readable, with the operational caveat (RS_ASN1 + matching mode) placed last as a trailing note where it belongs. A small amount of text restates schema defaults (True=RAW, False=DIGEST), but overall it is well sized for a four-parameter cryptographic tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, and the description compensates by defining the return dictionary keys (RS as r||s 64 bytes, RS_ASN1 as DER) and recommending which is used for verification. For a sign tool whose annotations cover the safety profile, nothing an agent needs in order to call it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all four parameters; however, the description adds real meaning beyond it, notably the exact 64-hex-character constraint for DIGEST mode and the e = SM3(ZA || M) construction in RAW mode, plus the KMS/ECC/RSA semantic alignment. The password's encryption precondition is also clarified.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The first line states a specific verb and resource ('SM2 私钥签名') and the [sm2] prefix distinguishes it from the other signing siblings (rsa_sign, ecc_key_sign, sm9_sign) and from sm2_verify. An agent can identify the operation without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It explicitly states when each mode applies: RAW mode for a message Hex where the server computes e = SM3(ZA || M) internally, DIGEST mode where data_in_hex must already be the 32-byte SM3 digest. It also states a downstream constraint — verification must use the RS_ASN1 format and the same sign_raw_data_mode — which routes the agent to sm2_verify correctly.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.