Skip to content

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

@ZhuoZhuoCrayon

Description

@ZhuoZhuoCrayon

版本: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>])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions