GithubHelp home page GithubHelp logo

gmssl / gmssl-python Goto Github PK

View Code? Open in Web Editor NEW
64.0 4.0 11.0 82 KB

Python binding to the GmSSL library

Home Page: https://gmssl.github.io/GmSSL-Python/

License: Apache License 2.0

Python 100.00%
sm2 sm3 sm4 sm9 certificate gmssl zuc

gmssl-python's People

Contributors

guanzhi avatar zxm256 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gmssl-python's Issues

Support SM9

Is there any plan to support sm9? if not, Can I contribute Pull requests?

SM2相关example例程运行报错

开发者您好,我电脑win11 64位系统,python版本是3.12.0
已经正确安装gmssl和gmssl-python如下:

>>> import gmssl
>>> gmssl.GMSSL_PYTHON_VERSION
'2.2.2'
>>> gmssl.GMSSL_LIBRARY_VERSION
'GmSSL 3.1.1 Dev'

我在测试example文件夹下的例程时,sm3.py和sm4.py运行正常,sm2_key.py运行时报错如下:

File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\gmssl.py", line 436, in export_encrypted_private_key_info_pem
    if gmssl.sm2_private_key_info_encrypt_to_pem(byref(self), c_char_p(passwd), c_void_p(fp)) != 1:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: exception: access violation writing 0x0000000000000024

在网上搜索该错误一直没找到解决办法,特在此提问,烦请进行解答,感谢

sm3 pbkdf2 运行报错

Traceback (most recent call last):
File "/home/bc/sm3_pbkdf2_demo.py", line 18, in
key = sm3_pbkdf2(passwd, salt, iterator, keylen)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bc/Public/anaconda3/lib/python3.11/site-packages/gmssl.py", line 136, in sm3_pbkdf2
if gmssl.pbkdf2_hmac_sm3_genkey(c_char_p(passwd), c_size_t(len(passwd)),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bc/Public/anaconda3/lib/python3.11/ctypes/init.py", line 389, in getattr
func = self.getitem(name)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/bc/Public/anaconda3/lib/python3.11/ctypes/init.py", line 394, in getitem
func = self._FuncPtr((name_or_ordinal, self))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: /usr/local/lib/libgmssl.so.3: undefined symbol: pbkdf2_hmac_sm3_genkey

==========================================================================

系统信息:
❯ python3 --version
Python 3.11.5
❯ uname -a
Linux Ubuntu-2404-LTS 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 02:32:42 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux
❯ gcc --version
gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0
❯ g++ --version
g++ (Ubuntu 13.2.0-23ubuntu4) 13.2.0

PS: 在 MAC M2上运行也有这样的问题
image

安装后运行报错

Traceback (most recent call last):
File "C:\Users\sunqi\Desktop\GmSSL-Python-main\demo.py", line 2, in
from gmssl import *
File "C:\Users\sunqi\Desktop\GmSSL-Python-main\gmssl.py", line 18, in
gmssl = cdll.LoadLibrary(libgmssl)
File "C:\Users\sunqi\anaconda3\envs\win32py36sm9\lib\ctypes_init_.py", line 426, in LoadLibrary
return self.dlltype(name)
File "C:\Users\sunqi\anaconda3\envs\win32py36sm9\lib\ctypes_init
.py", line 348, in init
self._handle = _dlopen(self._name, mode)
TypeError: LoadLibrary() argument 1 must be str, not None

sm2样例运行报错

运行时报下面的错误:FileNotFoundError: Could not find module 'C:\Program Files\GmSSL 3.1.1\bin\gmssl.dll' (or one of its dependencies). Try using the full path with constructor syntax.

在控制台能够正常import:
image

安装后在进行test时,和import时报错

import gmssl
Traceback (most recent call last):
File "", line 1, in
File "E:\crypto_lesson_java\PyQt_progress\GmSSL-Python-main\gmssl.py", line 18, in
gmssl = cdll.LoadLibrary(find_library("gmssl"))
File "E:\python3\lib\ctypes_init_.py", line 452, in LoadLibrary
return self.dlltype(name)
File "E:\python3\lib\ctypes_init
.py", line 374, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 不是有效的 Win32 应用程序。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.