GmLLC v1.0.0
基于 GmSSL 3.2.0 DLL 的国密算法低层 Python 接口库,通过 ctypes 直接封装 DLL 导出函数,适用于密码学分析、高效计算、CTF 解题等场景。
安装
pip install gmllc
或直接使用:
import sys
sys.path.insert(0, "gmllc")
import gmllc
设计原则
- 直接封装 DLL 导出函数,不做高层抽象
- 按模块分类:
sm2,sm2_z256,sm3,sm4,sm9,sm9_z256,zuc - 低级接口直接暴露,允许调用者自由组合
快速开始
from gmllc import gmssl, rand_bytes, version_str, __version__
from gmllc import sm2, sm3, sm4
# 查看版本
print(__version__) # 1.0.0
print(version_str()) # GmSSL 3.2.0
# 生成随机数
key = rand_bytes(16)
# SM3 哈希
ctx = sm3.sm3_init()
sm3.sm3_update(ctx, b"Hello, GmLLC!")
digest = sm3.sm3_finish(ctx)
print(digest.hex())
模块功能
| 模块 | 算法 | 功能 |
|---|---|---|
sm2 |
SM2 椭圆曲线公钥密码 | 密钥生成、签名/验签、加密/解密、ECDH 密钥交换 |
sm2_z256 |
SM2 低层数学 | 大整数运算、Fp/Fn 模运算、椭圆曲线点运算 |
sm3 |
SM3 密码杂凑 | 哈希、HMAC、KDF、PBKDF2 |
sm4 |
SM4 分组密码 | ECB、CBC、CTR、CTR32、GCM 模式 |
sm9 |
SM9 标识密码 | 签名/验签、加密/解密、KEM、密钥交换 |
sm9_z256 |
SM9 低层数学 | Fp/Fp2/Fp4/Fp12 扩域、配对运算、G1/G2 群 |
zuc |
ZUC 祖冲之序列密码 | ZUC-128/256 流密码、MAC、EEA/EIA |
示例
参考 examples/ 目录下的完整示例:
example_sm2.py— SM2 密钥生成、签名验签、加解密、ECDHexample_sm3.py— SM3 哈希、HMAC、KDF、PBKDF2example_sm4.py— SM4 ECB/CBC/CTR/GCM 各模式example_sm9.py— SM9 签名验签、加解密、KEM、密钥交换example_zuc.py— ZUC-128/256 流密码、MAC、EEA/EIA
运行示例:
cd gmllc
python examples/example_sm3.py
测试
cd gmllc
python test_all.py
依赖
- Python 3.11+
gmssl.dll(GmSSL 3.2.0,已包含在项目中)
许可证
Copyright 2026 The GmLLC Project. All Rights Reserved.
Metadata
Release files for gmllc 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gmllc-1.0.0.tar.gz | 917.5 kB | Without provenance | Details for gmllc-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gmllc-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for gmllc-1.0.0-py3-none-any.whl |
Total release size: 1.8 MB
Release files / gmllc-1.0.0.tar.gz
| Download URL | gmllc-1.0.0.tar.gz |
|---|---|
| Size | 917.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f2b9546c6279e5d769aef8a4382b5b27ea9bb49c003403bfd8dcef7457c3ec9
|
|
BLAKE2b-256 checksum How to use checksums |
93f872ece6b4ccf21200e98bcbb6de9ff05d5fd4c4794e8dc21203d1c221d05c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.5
|
Release files / gmllc-1.0.0-py3-none-any.whl
| Download URL | gmllc-1.0.0-py3-none-any.whl |
|---|---|
| Size | 923.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c3ecce04be51f3c385976e91b46947f0fa1558eb3d4c1773e548a6e376cdf97
|
|
BLAKE2b-256 checksum How to use checksums |
9d106cdfa943e9894d78160e668474d7429d92ece22f95214daea6bb63154915
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.5
|
Security for gmllc 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.