cipherkey is now guaranteed to be 32 characters strong
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ded1968f26
commit
63733a317f
@ -2,6 +2,7 @@
|
|||||||
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 PKCS1_OAEP
|
from Crypto.Cipher import PKCS1_OAEP
|
||||||
from Crypto.Cipher import ChaCha20
|
from Crypto.Cipher import ChaCha20
|
||||||
from Crypto.PublicKey.RSA import RsaKey
|
from Crypto.PublicKey.RSA import RsaKey
|
||||||
@ -62,7 +63,10 @@ class NetWrapper:
|
|||||||
decodedmsg = json.loads(msg.decode('UTF-8'))
|
decodedmsg = json.loads(msg.decode('UTF-8'))
|
||||||
cipher_rsa = PKCS1_OAEP.new(self.serverPrivateKey)
|
cipher_rsa = PKCS1_OAEP.new(self.serverPrivateKey)
|
||||||
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 login(self) -> bool:
|
def login(self) -> bool:
|
||||||
|
Loading…
Reference in New Issue
Block a user