Compare commits
2 Commits
206b7ed2f3
...
e37fbd929b
Author | SHA1 | Date | |
---|---|---|---|
e37fbd929b | |||
2fc4a1f752 |
@ -4,6 +4,7 @@ import string
|
|||||||
import json
|
import json
|
||||||
from base64 import b64encode, b64decode
|
from base64 import b64encode, b64decode
|
||||||
import pyDH
|
import pyDH
|
||||||
|
from Crypto.Hash import SHA512
|
||||||
from Crypto.Cipher import ChaCha20, PKCS1_OAEP
|
from Crypto.Cipher import ChaCha20, PKCS1_OAEP
|
||||||
from Crypto.PublicKey.RSA import RsaKey
|
from Crypto.PublicKey.RSA import RsaKey
|
||||||
from Crypto.Random import get_random_bytes
|
from Crypto.Random import get_random_bytes
|
||||||
@ -61,7 +62,10 @@ class NetWrapper:
|
|||||||
decodedmsg = json.loads(msg.decode('UTF-8'))
|
decodedmsg = json.loads(msg.decode('UTF-8'))
|
||||||
cipher_rsa = PKCS1_OAEP.new(self.privateKey)
|
cipher_rsa = PKCS1_OAEP.new(self.privateKey)
|
||||||
serverpubkey = int(cipher_rsa.decrypt(b64decode(decodedmsg['message'])).decode('UTF-8'))
|
serverpubkey = int(cipher_rsa.decrypt(b64decode(decodedmsg['message'])).decode('UTF-8'))
|
||||||
self.cipherkey = dh.gen_shared_key(serverpubkey).encode('UTF-8')
|
cipherkey = dh.gen_shared_key(serverpubkey).encode('UTF-8')
|
||||||
|
hasher = SHA512.new()
|
||||||
|
hasher.update(cipherkey)
|
||||||
|
self.cipherkey = hasher.hexdigest()[:32]
|
||||||
|
|
||||||
|
|
||||||
def authenticate(self, password: str):
|
def authenticate(self, password: str):
|
||||||
|
Loading…
Reference in New Issue
Block a user