Skip to main content
Glama

CipherHUB Cryptography Toolkit

sm2_sign

[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 必须与签名时一致】

Input Schema

TableJSON 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 私钥的加密密码(原始字符串,非编码格式)

TDQS

A4.7/5.0
Behavior5/5

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

With no annotations, the description carries full responsibility for behavioral disclosure. It fully explains that RAW mode performs an internal SM3 hash (e = SM3(ZA||M)) while DIGEST mode does not, describes output formats (RS and RS_ASN1), and warns that verification must use RS_ASN1 and the same mode. No annotation contradictions exist.

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 description is well-structured with a parameter list and output section, using bold and bullets for readability. However, it repeats parameter names and schema descriptions, adding some redundancy. Still, it is compact enough and each section carries meaningful detail, hence a 4.

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?

For a cryptographic signing tool with no output schema, the description is remarkably complete: it covers all input parameters, both operation modes, the exact output structure (RS and RS_ASN1), and a verification caveat. There is no missing behavioral context that an agent would need to invoke this tool correctly.

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

Parameters5/5

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

Although schema coverage is 100%, the description adds critical meaning beyond the schema: it specifies that data_in_hex must be exactly 64 hex characters in DIGEST mode, clarifies that sm2_private_key_password is only needed if the key is encrypted, and explains how sign_raw_data_mode changes the interpretation of data_in_hex. This is substantial added value.

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 description begins with 'SM2 私钥签名' (SM2 private key signing), clearly stating the operation and algorithm. It distinguishes from sibling tools like ECC/RSA signing by specifying SM2 and detailing the signing modes, leaving no ambiguity about scope.

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

Usage Guidelines4/5

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

The description provides clear guidance on when to use RAW vs DIGEST modes, explicitly explaining the behavior of sign_raw_data_mode and the semantics of data_in_hex in each. It references that DIGEST mode aligns with other tools' DIGEST mode, but does not explicitly name alternative tools or state when NOT to use this tool, so it is not a full 5.

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.

TDQS

A3.9/5.0
Disambiguation4/5

Most tools target a distinct algorithm+operation pair (e.g., rsa_sign vs sm2_sign vs ml_dsa_sign), and descriptions are detailed. However, block_cipher and stream_cipher both perform symmetric encryption, and ecc_key_exchange and hybrid_kex overlap as key exchange, requiring careful reading to distinguish.

Naming Consistency3/5

Naming is inconsistent across algorithm families: key generation mixes generate_ecc/generate_rsa with ml_dsa_keygen/ml_kem_keygen, and encryption mixes rsa_encryption/sm2_encryption with block_cipher/stream_cipher. Within each family (e.g., rsa_sign/rsa_verify, ml_dsa_sign/ml_dsa_verify), names are predictable, but the overall pattern is not uniform.

Tool Count2/5

32 tools is far above the typical 3-15 range for a well-scoped server. While every tool has a distinct function, the large surface makes the set heavy and harder to navigate, especially with multiple algorithm families and niche utilities.

Completeness5/5

The toolkit gives comprehensive coverage: key generation, encryption/decryption, signing/verification for RSA, ECC, SM2, ML-DSA, ML-KEM, plus symmetric ciphers, hashing, and key exchange. Full workflows are supported with no dead ends, and even helper tools for debugging are included.