Merge branch 'master' of https://git.kmlabz.com/BiztProtoBois/server
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:
commit
f345d4b961
@ -13,7 +13,7 @@ from Crypto.PublicKey import RSA
|
||||
from Crypto.PublicKey.RSA import RsaKey
|
||||
|
||||
auth_logger = logging.getLogger('AUTH APPLICATION ')
|
||||
auth_logger.root.setLevel(logging.INFO)
|
||||
auth_logger.setLevel(logging.INFO)
|
||||
|
||||
class Authetication:
|
||||
ABSOLUTE_PATH = os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||
@ -47,7 +47,6 @@ class Authetication:
|
||||
|
||||
for user in data['user']:
|
||||
if username == user['username']:
|
||||
b64pwd = b64encode(SHA256.new(password.encode('utf-8')).digest())
|
||||
try:
|
||||
b64pwd = b64encode(SHA256.new(password.encode('utf-8')).digest())
|
||||
bcrypt_check(b64pwd, user['password'].encode('utf-8'))
|
||||
@ -121,7 +120,7 @@ class Authetication:
|
||||
with open(self.CONFIG_FILE_LOCATION) as json_file:
|
||||
data = json.load(json_file)
|
||||
|
||||
dictionary: dict
|
||||
dictionary = dict()
|
||||
|
||||
for user in data['user']:
|
||||
key = data['publicKey']
|
||||
|
@ -14,7 +14,7 @@ def generatePrivateKeyForUser(auth: Authetication,username: str, user_passphrase
|
||||
|
||||
private_key = RSA.generate(2048)
|
||||
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))
|
||||
|
||||
##Save private key in separate file
|
||||
|
@ -64,7 +64,7 @@ class Executor:
|
||||
strdirectory = strdirectory[:-1]
|
||||
return strdirectory
|
||||
|
||||
def putFileInCurrentDirectory(self, filename: str, content) -> str:
|
||||
def putFileInCurrentDirectory(self, filename: str, content: bytes) -> str:
|
||||
filename = self.sanitizeFile(filename)
|
||||
currenctfile = os.path.join(self.currentDirectory, filename)
|
||||
f = open(currenctfile, "wb")
|
||||
|
@ -36,8 +36,8 @@ class NetWrapper:
|
||||
cipher = PKCS1_OAEP.new(self.currentClientPublicKey)
|
||||
identMsg = json.dumps(
|
||||
{'type': 'IDY', 'source': self.network.own_addr,
|
||||
'message': b64encode(cipher.encrypt(retmsg.encode('UTF-8')))}).decode(
|
||||
'ASCII')
|
||||
'message': b64encode(cipher.encrypt(retmsg.encode('UTF-8'))).decode('ASCII')}).encode(
|
||||
'UTF-8')
|
||||
self.network.send_msg(self.clientAddr, identMsg)
|
||||
|
||||
def sendMessage(self, message: bytes) -> None:
|
||||
@ -127,7 +127,12 @@ class NetWrapper:
|
||||
|
||||
def recieveEncryptedMessage(self, msg: bytes) -> bytes:
|
||||
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'])
|
||||
retciphertext = b64decode(b64['message'])
|
||||
retcipher = ChaCha20.new(self.cipherkey, nonce=retnonce)
|
||||
|
Loading…
Reference in New Issue
Block a user