Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Tongsuo-Python-SDK基于Tongsuo密码库, 为Python应用提供密码学原语和安全传输协议的支持,目前以支持中国商用密码算法和安全协议为主。
SM2签名和验签,详见sm2_sign_verify.py
from tongsuopy.crypto import hashes, serialization
from tongsuopy.crypto.asymciphers import ec
msg = b"hello"
key = ec.generate_private_key(ec.SM2())
pem = key.public_key().public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.SubjectPublicKeyInfo,
)
pubkey = serialization.load_pem_public_key(pem)
signature = key.sign(msg, ec.ECDSA(hashes.SM3()))
pubkey.verify(signature, msg, ec.ECDSA(hashes.SM3()))
SM2加密和解密,详见sm2_encrypt_decrypt_from_pem.py
from tongsuopy.crypto import serialization
from tongsuopy.crypto.asymciphers import ec
msg = b"hello"
key = ec.generate_private_key(ec.SM2())
pem = key.public_key().public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.SubjectPublicKeyInfo,
)
pubkey = serialization.load_pem_public_key(pem)
ciphertext = pubkey.encrypt(msg)
decrypt_text = key.decrypt(ciphertext)
assert decrypt_text == msg
SM3杂凑,详见sm3.py
from tongsuopy.crypto import hashes
h = hashes.Hash(hashes.SM3())
h.update(b"abc")
res = h.finalize()
SM4-CBC加密,详见sm4_cbc.py
from tongsuopy.crypto.ciphers import Cipher, algorithms, modes
c = Cipher(algorithms.SM4(key), modes.CBC(iv))
enc = c.encryptor()
ciphertext = enc.update(plaintext)
ciphertext += enc.finalize()
SM4-GCM加密,详见sm4_gcm.py
from tongsuopy.crypto.ciphers import Cipher, algorithms, modes
c = Cipher(algorithms.SM4(key), modes.GCM(iv))
enc = c.encryptor()
enc.authenticate_additional_data(aad)
ciphertext = enc.update(plaintext)
ciphertext += enc.finalize()
pip install tongsuopy
要求Python >= 3.6。
欢迎加入铜锁社区交流群,使用钉钉扫描二维码或者钉钉内搜索群号44810299。
FAQs
Tongsuo Python SDK
We found that tongsuopy-crayon demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.