Python package implementing GM algorithms in C.
Project description
gmalglib
Python extension library for GM (GuoMi) cryptographic algorithms, providing a set of fundamental cryptographic algorithms.
Implemented in C language, encapsulated based on the native CPython interface, without dependencies on any third-party libraries.
Installation
Windows
For python3.8
and higher versions, you can directly install using pip
.
pip install gmalglib
Alternatively, refer to the source code installation for other platforms.
Other Platforms
Visit the PyPI project file list Download files page to download the source distribution package gmalglib-x.y.z.tar.gz
, then proceed with the source code installation.
pip install gmalglib-x.y.z.tar.gz
Core Algorithms Implemented
- SM2 Public Key Cryptograhpic Algorithm Based on Elliptic Curves
- Sign/Verify
- Encrypt/Decrypt
- SM3 Cryptogrpahic Hash Algorithm
- SM4 Block Cipher Algorithm
- ZUC Stream Cipher Algorithm
Usage
For submodules under gmalglib, different algorithm encapsulations are respectively exported, and can be utilized in an object-oriented manner.
from gmalglib.sm3 import SM3
obj = SM3()
obj.update(b"message")
obj.update(b"digest")
print(obj.digest().hex())
Under gmalglib.wrapped, member methods of all algorithm objects are encapsulated, providing a procedural call method. Furthermore, the gmalglib namespace is imported, enabling direct usage.
import gmalglib
print(gmalglib.sm3_digest(b"messagedigest").hex())
About Random Number Generators
For all sections involving random number generators, custom parameters for random number generation are provided, implemented in the form of callback functions. The function type is Callable[[int], bytes]
, meaning it generates a byte string of a specified length.
def rnd_fn(n: int) -> bytes: ...
If no random number generator is passed, the default system-related random number generator is used. On Windows, it utilizes BCryptGenRandom
, while other systems use /dev/urandom
for implementation, which is similar to the Python standard library function os.urandom
.
For specific implementation details, refer to random.c under the OsRandomProc
function.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file gmalglib-0.5.2.tar.gz
.
File metadata
- Download URL: gmalglib-0.5.2.tar.gz
- Upload date:
- Size: 29.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76e983f6b4eef5451228272e9b2c1d70cba1158d16be84d23ae0f98d24cfdf90 |
|
MD5 | 4860df79e47c3634c42be99d2879dcb0 |
|
BLAKE2b-256 | d1ef1d05aa2ab1509a269abf8ef905293076666fd19509931cb21d6137adaa59 |
File details
Details for the file gmalglib-0.5.2-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: gmalglib-0.5.2-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 40.6 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c53f149437dc2f7e1e9e7f1165e2377752430343548a28666a1a1d172c233299 |
|
MD5 | a09d9a8008025ee32913337df9f13656 |
|
BLAKE2b-256 | f0f05b6f177f9335a48321c84b653ded9264d25138973a94bc0c9e82585b2f41 |
File details
Details for the file gmalglib-0.5.2-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: gmalglib-0.5.2-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 40.5 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bce231afe34364df51bac12d01bf4387e35c63bd2953445eaa972b3499ba44c |
|
MD5 | 3851cdcc2af9bd06e40c95ce1c59a089 |
|
BLAKE2b-256 | c3b0716a82cddcd619506461948ed8a28b5fe9c2fb2d8041e3e1deb39054f253 |
File details
Details for the file gmalglib-0.5.2-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: gmalglib-0.5.2-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 40.5 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af497ec4f41eaafcaba960854acaacaac030d4dd370114788399f5302ae5610b |
|
MD5 | 8a3382e33ddff4007e9d99c1ef30955c |
|
BLAKE2b-256 | 187c559fcfcfc7bb3d945bc3445dda33bc6563229935f8d9413e083239f5b0bb |
File details
Details for the file gmalglib-0.5.2-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: gmalglib-0.5.2-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 40.6 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 077ce4189c10d3d7f6de297acb3bf4153bf1360c35994392473bd34fcaa1a365 |
|
MD5 | 1f8e95ce536bcd34358daaf20df51e68 |
|
BLAKE2b-256 | f64b258c948c81026414056461b7e08d23a23024e6b2f707c682a6a2ac8a5aaa |
File details
Details for the file gmalglib-0.5.2-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: gmalglib-0.5.2-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 40.6 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4092089c8174441092a4bea985a28fb4a7c0aac443d13e8afb08a65c3fcfb88 |
|
MD5 | 782ab73042d973ff8622d05c0d00ef67 |
|
BLAKE2b-256 | ea316677a6aa55c453db4d961283e1ba499db46ecb43d43a79988f9712ba2dc5 |