Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac M1 运行 demos 报错:Unable to sign/verify with this key #3

Open
ZhuoZhuoCrayon opened this issue Feb 14, 2023 · 1 comment

Comments

@ZhuoZhuoCrayon
Copy link
Contributor

版本:1.0.0

运行 demos 代码:

from tongsuopy.crypto import hashes
from tongsuopy.crypto.asymciphers import ec


msg = b"message digest"
d = b"3945208F7B2144B13F36E38AC6D39F95889393692860B51A42FB81EF4DF7C5B8"
Qx = b"09F9DF311E5421A150DD7D161E4BC5C672179FAD1833FC076BB08FF356F35020"
Qy = b"CCEA490CE26775A52DC6EA718CC1AA600AED05FBF35E084A6632F6072DA9AD13"

key = ec.EllipticCurvePrivateNumbers(
    int(d, 16),
    ec.EllipticCurvePublicNumbers(int(Qx, 16), int(Qy, 16), ec.SM2()),
).private_key()
signature = key.sign(msg, ec.ECDSA(hashes.SM3()))

pubkey = key.public_key()
pubkey.verify(signature, msg, ec.ECDSA(hashes.SM3()))

报错:

Traceback (most recent call last):
  File "/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3524, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-ebc580c1d414>", line 14, in <module>
    signature = key.sign(msg, ec.ECDSA(hashes.SM3()))
  File "/lib/python3.7/site-packages/tongsuopy/backends/tongsuo/ec.py", line 264, in sign
    self._backend, signature_algorithm.algorithm, self, data
  File "/lib/python3.7/site-packages/tongsuopy/backends/tongsuo/ec.py", line 104, in _ecdsa_sig_sign
    backend._lib.EVP_DigestSignInit,
  File "/lib/python3.7/site-packages/tongsuopy/backends/tongsuo/ec.py", line 173, in _ecdsa_sig_setup
    raise ValueError("Unable to sign/verify with this key", errors)
ValueError: ('Unable to sign/verify with this key', [<tongsuopy.backends.tongsuo.binding._OpenSSLError object at 0x11680d888>])
@dongbeiouba
Copy link
Member

dongbeiouba commented Feb 15, 2023

目前还不支持MacOS M1架构,可以试试其他平台是否存在该问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants