Merge branch 'master' of https://git.kmlabz.com/BiztProtoBois/server
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Attila Szigeti 2021-04-25 18:19:18 +02:00
commit f345d4b961
4 changed files with 12 additions and 8 deletions

View File

@ -13,7 +13,7 @@ from Crypto.PublicKey import RSA
from Crypto.PublicKey.RSA import RsaKey from Crypto.PublicKey.RSA import RsaKey
auth_logger = logging.getLogger('AUTH APPLICATION ') auth_logger = logging.getLogger('AUTH APPLICATION ')
auth_logger.root.setLevel(logging.INFO) auth_logger.setLevel(logging.INFO)
class Authetication: class Authetication:
ABSOLUTE_PATH = os.path.abspath(os.path.dirname(sys.argv[0])) ABSOLUTE_PATH = os.path.abspath(os.path.dirname(sys.argv[0]))
@ -47,7 +47,6 @@ class Authetication:
for user in data['user']: for user in data['user']:
if username == user['username']: if username == user['username']:
b64pwd = b64encode(SHA256.new(password.encode('utf-8')).digest())
try: try:
b64pwd = b64encode(SHA256.new(password.encode('utf-8')).digest()) b64pwd = b64encode(SHA256.new(password.encode('utf-8')).digest())
bcrypt_check(b64pwd, user['password'].encode('utf-8')) bcrypt_check(b64pwd, user['password'].encode('utf-8'))
@ -121,7 +120,7 @@ class Authetication:
with open(self.CONFIG_FILE_LOCATION) as json_file: with open(self.CONFIG_FILE_LOCATION) as json_file:
data = json.load(json_file) data = json.load(json_file)
dictionary: dict dictionary = dict()
for user in data['user']: for user in data['user']:
key = data['publicKey'] key = data['publicKey']

View File

@ -14,7 +14,7 @@ def generatePrivateKeyForUser(auth: Authetication,username: str, user_passphrase
private_key = RSA.generate(2048) private_key = RSA.generate(2048)
public_key = private_key.publickey() public_key = private_key.publickey()
private_key_value = bytes.hex(private_key.exportKey('DER', passphrase=user_passphrase, pkcs=8, protection="scryptAndAES128-CBC")) private_key_value = bytes.hex(private_key.exportKey('DER', passphrase=user_passphrase, pkcs=8))
public_key_value = bytes.hex(public_key.exportKey('DER', pkcs=8)) public_key_value = bytes.hex(public_key.exportKey('DER', pkcs=8))
##Save private key in separate file ##Save private key in separate file

View File

@ -64,7 +64,7 @@ class Executor:
strdirectory = strdirectory[:-1] strdirectory = strdirectory[:-1]
return strdirectory return strdirectory
def putFileInCurrentDirectory(self, filename: str, content) -> str: def putFileInCurrentDirectory(self, filename: str, content: bytes) -> str:
filename = self.sanitizeFile(filename) filename = self.sanitizeFile(filename)
currenctfile = os.path.join(self.currentDirectory, filename) currenctfile = os.path.join(self.currentDirectory, filename)
f = open(currenctfile, "wb") f = open(currenctfile, "wb")

View File

@ -36,8 +36,8 @@ class NetWrapper:
cipher = PKCS1_OAEP.new(self.currentClientPublicKey) cipher = PKCS1_OAEP.new(self.currentClientPublicKey)
identMsg = json.dumps( identMsg = json.dumps(
{'type': 'IDY', 'source': self.network.own_addr, {'type': 'IDY', 'source': self.network.own_addr,
'message': b64encode(cipher.encrypt(retmsg.encode('UTF-8')))}).decode( 'message': b64encode(cipher.encrypt(retmsg.encode('UTF-8'))).decode('ASCII')}).encode(
'ASCII') 'UTF-8')
self.network.send_msg(self.clientAddr, identMsg) self.network.send_msg(self.clientAddr, identMsg)
def sendMessage(self, message: bytes) -> None: def sendMessage(self, message: bytes) -> None:
@ -127,7 +127,12 @@ class NetWrapper:
def recieveEncryptedMessage(self, msg: bytes) -> bytes: def recieveEncryptedMessage(self, msg: bytes) -> bytes:
try: try:
b64 = json.loads(msg) b64 = json.loads(msg.decode('UTF-8'))
while not (b64['source'] == self.clientAddr and b64['type'] == 'CMD'):
status, msg = self.network.receive_msg(blocking=True)
if not status:
raise Exception('Network error during connection.')
b64 = json.loads(msg.decode('UTF-8'))
retnonce = b64decode(b64['nonce']) retnonce = b64decode(b64['nonce'])
retciphertext = b64decode(b64['message']) retciphertext = b64decode(b64['message'])
retcipher = ChaCha20.new(self.cipherkey, nonce=retnonce) retcipher = ChaCha20.new(self.cipherkey, nonce=retnonce)