gmssl icon indicating copy to clipboard operation
gmssl copied to clipboard

a python crypto for sm2/sm3/sm4

Results 43 gmssl issues
Sort by recently updated
recently updated
newest added

https://github.com/duanhongyi/gmssl/blob/master/gmssl/sm2.py#L25 ```python self.public_key = public_key.lstrip("04") if public_key.startswith("04") else public_key ``` should be ```python self.public_key = public_key[2:] if public_key.startswith("04") else public_key ```

sm3功能模块中sm3_kdf该怎么使用,后续迭代是否考虑HMAC-SM3的加入

在python3.10环境使用“pip3.10 install gmssl-3.2.2-py3-none-any.whl --no-index”安装gmssl时提示报错。但我环境上已经安装了pycrytodomex-3.19.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl并且能使用(from Cryptodome.Cipher import ARC4)。 INFO: pip is looking at multiple versions of gmssl to determine which version is compatible with other requirements. This could take a while....

国密sm2是非对称加密算法,需要对加密后的密文做一次asn1编码

![image](https://user-images.githubusercontent.com/55662947/211700924-96b5f270-2e6e-4842-977f-705499468d03.png) ![image](https://user-images.githubusercontent.com/55662947/211701106-92140d51-0528-479b-a3bb-174a5320b46a.png)

readme里面介绍说 # 对接java 时验签失败可以使用 sm2_crypt = sm2.CryptSM2( public_key=public_key, private_key=private_key, asn1=True) 然而根本没用,不知作者是否已自测 已设置参数asn1=True,但是验签java、go等签名出来的签名数据依然是通不过,java、go是可以互通的 看了go的实现源码,里面有经过za函数,但是这个库找不到跟za有关的函数,是不是因为这个原因导致不能和java互通? https://github.com/duanhongyi/gmssl/issues/33 另外关于sign_with_sm3和verify_with_sm3这个两个函数,自己和自己都不能通过 经过sign_with_sm3后的签名 用verify_with_sm3验签是通不过的

实际使用的时候,如果用其他加密工具产生的sm2加密密文会带着“04”头,如果直接拿过来用会导致解密失败,建议在解密时判断下是否有“04”头

# 报错密钥 # prvKeyHex = 'd26929ec5626686a2fae8e3b3ca3fe9899041ce7999aed48f80263f0277f2ab6' # pubKeyHex = '0440f13559863508ad419e34ab2499c9c777edfff6128e54a4ce044fee232cf0b70d3c55dd7d4e2b7319800ee6b57c33eec28617a542cb7ea3a898b730e330b741' # 报错密钥2 prvKeyHex = 'bcfac492fde0edcb646fb6f50e4f3ef390d2f766a4b1bc64f35516ba1c6cde77' pubKeyHex = '0404d09f362fa4464c6ff541da6ba621a161ca46ea4148d1eb66cd7cba794dd36d5e1137cadf03530a86cd8330877fd9cb1d2430e138920a30681e180f2050aada' 用公钥加密的时候会报错 TypeError: object of type 'NoneType' has no len() TypeError: 'NoneType' object...