tongsuo-python-sdk
Tongsuo-Python-SDK基于Tongsuo密码库, 为Python应用提供密码学原语和安全传输协议的支持,目前以支持中国商用密码算法和安全协议为主。
SM2签名和验签,详见sm2_sign_verify.py
from tongsuopy.crypto import hashes, serialization
from tongsuopy.crypto.asymciphers import ec
msg = b"hello"
key = ec.generate_private_key(ec.SM2())
pem = key.public_key().public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.SubjectPublicKeyInfo,
)
pubkey = serialization.load_pem_public_key(pem)
signature = key.sign(msg, ec.ECDSA(hashes.SM3()))
pubkey.verify(signature, msg, ec.ECDSA(hashes.SM3()))
SM3杂凑,详见sm3.py
from tongsuopy.crypto import hashes
h = hashes.Hash(hashes.SM3())
h.update(b"abc")
res = h.finalize()
SM4-CBC加密,详见sm4_cbc.py
from tongsuopy.crypto.ciphers import Cipher, algorithms, modes
c = Cipher(algorithms.SM4(key), modes.CBC(iv))
enc = c.encryptor()
ciphertext = enc.update(plaintext)
ciphertext += enc.finalize()
SM4-GCM加密,详见sm4_gcm.py
from tongsuopy.crypto.ciphers import Cipher, algorithms, modes
c = Cipher(algorithms.SM4(key), modes.GCM(iv))
enc = c.encryptor()
enc.authenticate_additional_data(aad)
ciphertext = enc.update(plaintext)
ciphertext += enc.finalize()
安装
pip install tongsuopy
要求Python >= 3.6。
功能特性
- 支持SM2签名和验签
- 支持SM3杂凑算法
- 支持SM4加解密,包括ECB、CBC、OFB、CFB、CTR模式
- 支持SM4-GCM和SM4-CCM
- [TODO] TLCP协议支持
交流群
欢迎加入铜锁社区交流群,使用钉钉扫描二维码或者钉钉内搜索群号44810299。
Metadata
Release files for tongsuopy 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 32.9 MB
Release files / tongsuopy-1.0.1-pp39-pypy39_pp73-win_amd64.whl
| Download URL | tongsuopy-1.0.1-pp39-pypy39_pp73-win_amd64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | PyPy 3.9 PyPy 3.9 7.3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
0d7fe8af36922897f7430291424938127f29fc06a97c743728974f2fda6c2df9
|
|
BLAKE2b-256 checksum How to use checksums |
6bd05563e654415c840fd6a0300d3086610231ac5a96be425c93cf3bab628600
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 PyPy/7.3.11
|
Release files / tongsuopy-1.0.1-pp39-pypy39_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | tongsuopy-1.0.1-pp39-pypy39_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 PyPy 3.9 PyPy 3.9 7.3 |
|
SHA-256 checksum How to use checksums |
616302d76e4affb7fb98598dd02944aa4608c41948e87998062a550c4b55d6f3
|
|
BLAKE2b-256 checksum How to use checksums |
9496b7dc518ebafcd755d109a9cf667c263268168e091776942f97c7bd8aba64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.2
|
Release files / tongsuopy-1.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | tongsuopy-1.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.9 PyPy 3.9 7.3 |
|
SHA-256 checksum How to use checksums |
d2663a6e2aea9ebfa8117c7382e52a43a8d03a5707cead430e2b36448cb91ac3
|
|
BLAKE2b-256 checksum How to use checksums |
df516c3b3d5eb703326d66cb184c77df1d521568984baf2a15402d0b47225094
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.2
|
Release files / tongsuopy-1.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
| Download URL | tongsuopy-1.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | Linux glibc 2.17+ x86-64 Linux glibc 2.24+ x86-64 PyPy 3.9 PyPy 3.9 7.3 |
|
SHA-256 checksum How to use checksums |
5c68cd52cd3f21ca7281266b69f8b83615212b4daf6682af52ff1d11da413db8
|
|
BLAKE2b-256 checksum How to use checksums |
c7817f9cb1f780746aad176596a1bfd4470563efdb24e29de65c31dfa0fb8fea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.2
|
Release files / tongsuopy-1.0.1-pp39-pypy39_pp73-macosx_10_12_x86_64.whl
| Download URL | tongsuopy-1.0.1-pp39-pypy39_pp73-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | PyPy 3.9 PyPy 3.9 7.3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
17ad389f9ff655eca001175063f1674b468a4a586a1e635b6124b931b7bf39c6
|
|
BLAKE2b-256 checksum How to use checksums |
773c311fabf03ef864b6f5e56a4c118a9ea19634fd847d4abf21526965e13dc0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 PyPy/7.3.11
|
Release files / tongsuopy-1.0.1-pp38-pypy38_pp73-win_amd64.whl
| Download URL | tongsuopy-1.0.1-pp38-pypy38_pp73-win_amd64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | PyPy 3.8 PyPy 3.8 7.3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5f4b8048e2e9799b46e1848af31ce7a853af0f69a5f0757497f169e6d6a89367
|
|
BLAKE2b-256 checksum How to use checksums |
3cd4ab6e6f15dc9a5ab104c9122c9072a2857cbd5ec64fc7798088974ca2ffac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 PyPy/7.3.11
|
Release files / tongsuopy-1.0.1-pp38-pypy38_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | tongsuopy-1.0.1-pp38-pypy38_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 PyPy 3.8 PyPy 3.8 7.3 |
|
SHA-256 checksum How to use checksums |
73dae334d2cd462f84ec590741d75b4e80349b9cb0415edaffee98044eaea931
|
|
BLAKE2b-256 checksum How to use checksums |
11b3e53a7b4275082593fa983eefd4900457a4eb113afa503335ac50db1bf0ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.2
|
Release files / tongsuopy-1.0.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | tongsuopy-1.0.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.8 PyPy 3.8 7.3 |
|
SHA-256 checksum How to use checksums |
039e411cb245e4b737ca441c38b8b5e9be76b8b3b3843863495706c5d1f907dc
|
|
BLAKE2b-256 checksum How to use checksums |
a4eb05d053107e085745a6028cfce83639e0db670d1c4e9367f235a15793a6ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.2
|
Release files / tongsuopy-1.0.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
| Download URL | tongsuopy-1.0.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | Linux glibc 2.17+ x86-64 Linux glibc 2.24+ x86-64 PyPy 3.8 PyPy 3.8 7.3 |
|
SHA-256 checksum How to use checksums |
664811b1ea7f256cceb8bbd7c4fa0f97dcab48142793fbfbe43d3e0de0ed3abc
|
|
BLAKE2b-256 checksum How to use checksums |
a6e512e72f78744467e7cb9fbf7c956d62df97934005b54ca65e9c052890314c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.2
|
Release files / tongsuopy-1.0.1-pp38-pypy38_pp73-macosx_10_12_x86_64.whl
| Download URL | tongsuopy-1.0.1-pp38-pypy38_pp73-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | PyPy 3.8 PyPy 3.8 7.3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
0ea2e8d4e8f3d1bd6944c1cc2de3d22d467e29f74d15c7e54834f5dec81f4237
|
|
BLAKE2b-256 checksum How to use checksums |
ac2e5c4cad46fd8c8b1683a41593b96a5fbbe257573af6ea328024c8ec48efed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 PyPy/7.3.11
|
Release files / tongsuopy-1.0.1-cp36-abi3-win_amd64.whl
| Download URL | tongsuopy-1.0.1-cp36-abi3-win_amd64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.6 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
178c1cefc16a929fe62b8f4cbaa6c8064e8106acaaa8283d895538f529ffa1e0
|
|
BLAKE2b-256 checksum How to use checksums |
3a51cbcdf5b3f920305c24365d3d147b983b259ca3f716cafccdd9237ab21288
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Release files / tongsuopy-1.0.1-cp36-abi3-win32.whl
| Download URL | tongsuopy-1.0.1-cp36-abi3-win32.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.6 Windows x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
565e894878b8e34fd8a96ec27e43253a1a112025209a54de3b0c372f09ca98ae
|
|
BLAKE2b-256 checksum How to use checksums |
7e8e6011b4f9490b3bff7bc0f207f20666867134a5d4655a46d26d16cc3b457c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Release files / tongsuopy-1.0.1-cp36-abi3-musllinux_1_1_x86_64.whl
| Download URL | tongsuopy-1.0.1-cp36-abi3-musllinux_1_1_x86_64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.6 Linux musl 1.1+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
02b9cc2965b90cad208432bce0206579f574dc19e59192520e52515c42f08e95
|
|
BLAKE2b-256 checksum How to use checksums |
97b12aa58706306f6a83c83255ff0c384ff941c023ee3d04d7767049b37e7029
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.2
|
Release files / tongsuopy-1.0.1-cp36-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | tongsuopy-1.0.1-cp36-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.6 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
daabaf13e113af1e1ffca1b5e321da40273b64a0359f9c1b1146f1d9de06ccda
|
|
BLAKE2b-256 checksum How to use checksums |
85411a9ad2277665b0aa185ce0ff08154c38015c95e5381a2e30b9b9d03ecbd2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.2
|
Release files / tongsuopy-1.0.1-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | tongsuopy-1.0.1-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.6 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
9cab6dd24cdeab69ac13e2a2559eac074af800c9eab71e6ee34d23d9596b42c2
|
|
BLAKE2b-256 checksum How to use checksums |
6800264191fe172170aa1a70777aebfba24bc7c3aa764222ab38ad4555bd15d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.2
|
Release files / tongsuopy-1.0.1-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
| Download URL | tongsuopy-1.0.1-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl |
|---|---|
| Size | 2.5 MB |
| Tags | CPython 3.6 Linux glibc 2.17+ x86-64 Linux glibc 2.24+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1c497d65cba4d1a34afacd84a134325beffcd422190eb2f508001578f7ca5945
|
|
BLAKE2b-256 checksum How to use checksums |
01458c158965111617ad3b02da12c0f2f0fd05e976a70ed5fd857cce1a8b0c5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.2
|
Release files / tongsuopy-1.0.1-cp36-abi3-macosx_10_12_x86_64.whl
| Download URL | tongsuopy-1.0.1-cp36-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.6 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
8c660bd64011eca32a796a77dc52a80ad17d246f1a413ac4a8763643be2fdf69
|
|
BLAKE2b-256 checksum How to use checksums |
0d5bf7177dfd6c65957f34e345b94113a9a5ac30c389352d3ab405d23705587d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.0
|
Release files / tongsuopy-1.0.1-cp36-abi3-macosx_10_12_universal2.whl
| Download URL | tongsuopy-1.0.1-cp36-abi3-macosx_10_12_universal2.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.6 abi3 macOS 10.12+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
30efce7c20c4e3d243202412ef732109c427aad0b1502adf330ec38f48783c68
|
|
BLAKE2b-256 checksum How to use checksums |
83a4948ba60b4bedb9060dd264e3354c34929178b1352bca387e64eb8627c3d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.0
|