Version 0.3.4, Rev656, CryptMessage plugin for AES and ECIES encryption, Added pyelliptic lib for OpenSSSL based encryption methods, Test CryptMessage plugin, Force reload content.json before signing and after write, Escaped Sql IN queries support, Test Sql parameter escaping, ui_websocket Test fixture, Plugin testing support, Always return websocket errors as dict, Wait for file on weboscket fileGet command if its already in bad_files queue, PushState and ReplaceState url manipulation support in wrapper API, Per auth-address localstorage, Longer timeout for udp tracker query
2015-12-10 21:36:20 +01:00
|
|
|
import hashlib
|
2019-03-16 02:23:00 +01:00
|
|
|
import base64
|
2019-12-15 12:46:06 +01:00
|
|
|
import sslcrypto
|
2019-11-25 14:37:55 +01:00
|
|
|
from Crypt import Crypt
|
Version 0.3.4, Rev656, CryptMessage plugin for AES and ECIES encryption, Added pyelliptic lib for OpenSSSL based encryption methods, Test CryptMessage plugin, Force reload content.json before signing and after write, Escaped Sql IN queries support, Test Sql parameter escaping, ui_websocket Test fixture, Plugin testing support, Always return websocket errors as dict, Wait for file on weboscket fileGet command if its already in bad_files queue, PushState and ReplaceState url manipulation support in wrapper API, Per auth-address localstorage, Longer timeout for udp tracker query
2015-12-10 21:36:20 +01:00
|
|
|
|
|
|
|
|
2019-12-15 12:46:06 +01:00
|
|
|
curve = sslcrypto.ecc.get_curve("secp256k1")
|
|
|
|
|
|
|
|
|
|
|
|
def eciesEncrypt(data, pubkey, ciphername="aes-256-cbc"):
|
|
|
|
ciphertext, key_e = curve.encrypt(
|
|
|
|
data,
|
|
|
|
base64.b64decode(pubkey),
|
|
|
|
algo=ciphername,
|
|
|
|
derivation="sha512",
|
|
|
|
return_aes_key=True
|
|
|
|
)
|
|
|
|
return key_e, ciphertext
|
Version 0.3.4, Rev656, CryptMessage plugin for AES and ECIES encryption, Added pyelliptic lib for OpenSSSL based encryption methods, Test CryptMessage plugin, Force reload content.json before signing and after write, Escaped Sql IN queries support, Test Sql parameter escaping, ui_websocket Test fixture, Plugin testing support, Always return websocket errors as dict, Wait for file on weboscket fileGet command if its already in bad_files queue, PushState and ReplaceState url manipulation support in wrapper API, Per auth-address localstorage, Longer timeout for udp tracker query
2015-12-10 21:36:20 +01:00
|
|
|
|
2019-11-25 14:37:55 +01:00
|
|
|
|
|
|
|
@Crypt.thread_pool_crypt.wrap
|
|
|
|
def eciesDecryptMulti(encrypted_datas, privatekey):
|
|
|
|
texts = [] # Decoded texts
|
|
|
|
for encrypted_data in encrypted_datas:
|
|
|
|
try:
|
|
|
|
text = eciesDecrypt(encrypted_data, privatekey).decode("utf8")
|
|
|
|
texts.append(text)
|
|
|
|
except:
|
|
|
|
texts.append(None)
|
|
|
|
return texts
|
|
|
|
|
|
|
|
|
2019-12-15 12:46:06 +01:00
|
|
|
def eciesDecrypt(ciphertext, privatekey):
|
|
|
|
return curve.decrypt(
|
|
|
|
base64.b64decode(ciphertext),
|
|
|
|
curve.wif_to_private(privatekey),
|
|
|
|
derivation="sha512"
|
|
|
|
)
|
Version 0.3.4, Rev656, CryptMessage plugin for AES and ECIES encryption, Added pyelliptic lib for OpenSSSL based encryption methods, Test CryptMessage plugin, Force reload content.json before signing and after write, Escaped Sql IN queries support, Test Sql parameter escaping, ui_websocket Test fixture, Plugin testing support, Always return websocket errors as dict, Wait for file on weboscket fileGet command if its already in bad_files queue, PushState and ReplaceState url manipulation support in wrapper API, Per auth-address localstorage, Longer timeout for udp tracker query
2015-12-10 21:36:20 +01:00
|
|
|
|
2019-12-15 12:46:06 +01:00
|
|
|
def split(ciphertext):
|
|
|
|
return ciphertext[:16], ciphertext[86:-32]
|