Skip to content

Commit

Permalink
Merge pull request #15 from Scratchcat1/Simple-Connection
Browse files Browse the repository at this point in the history
Simple connection
  • Loading branch information
Scratchcat1 authored Oct 22, 2017
2 parents a94f8e4 + d7c230d commit cb46844
Show file tree
Hide file tree
Showing 5 changed files with 227 additions and 499 deletions.
27 changes: 15 additions & 12 deletions AATC_Client_Text_UI.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,17 +361,14 @@ def GetMonitorPermissionUser(self):
#################################################

def Call_Exit(self):
Choice = input("Exit? (Y/N) >>").upper()
if Choice == "Y":
print("Exiting..")
try:
Sucess,Message = self.UserInterface.Exit()
self.DisplayResults(Sucess,Message)
except:
print("Unable to close server connection")
self.Exit = True
else:
print("Exit cancelled")
print("Exiting..")
try:
Sucess,Message = self.UserInterface.Exit()
self.DisplayResults(Sucess,Message)
except:
print("Unable to close server connection")
self.Exit = True




Expand All @@ -386,7 +383,13 @@ def Call_Exit(self):

TextUI = UserTextUI(U,MenuOptions)
TextUI.Main_Loop()
Exit = True #When user selects exit

Choice = input("Exit? (Y/N) >>").upper()
if Choice == "Y":
print("Exiting")
Exit = True #When user selects exit
else:
print("Exit cancelled")

except Exception as e:
print("Error occured creating user interface",e)
Expand Down
3 changes: 3 additions & 0 deletions AATC_Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@


DRONE_BATTERY_DRAIN_MULT = 1


NOFLYZONE_THRESHOLD_COST = 50
8 changes: 4 additions & 4 deletions AATC_Crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,15 @@ def ServerGenerateKey(self):

if Command == "ExchangeKey":
publicKey,AES_KeySize = Arguments[0],Arguments[1]

if AES_KeySize not in AATC_Config.ALLOWED_AES_KEYSIZES:
AES_KeySize = AATC_Config.DEFAULT_AES_KEYSIZE #If key size is not valid set size to default of AATC_Config.DEFAULT_AES_KEYSIZE

self.AESKey = binascii.b2a_hex(os.urandom(AES_KeySize//2)) # Here to allow regeneration of AES key while still in loop if required.
self.IV = binascii.b2a_hex(os.urandom(AES_KeySize//2))
self.IV = binascii.b2a_hex(os.urandom(AES_KeySize//2))

RSAPrivateKey = RSA.import_key(publicKey)
PublicKeyObject = PKCS1_OAEP.new(RSAPrivateKey)
RSAPublicKey = RSA.import_key(publicKey)
PublicKeyObject = PKCS1_OAEP.new(RSAPublicKey)

EncryptedAESKey = PublicKeyObject.encrypt(self.AESKey)
EncryptedIV = PublicKeyObject.encrypt(self.IV)
Expand Down Expand Up @@ -136,6 +137,5 @@ def Send(self,data):
def Recv(self):
data = recvall.recvall(self.con)
data = ast.literal_eval(codecs.decode(data))
# (Command,Arguments)
return data

Loading

0 comments on commit cb46844

Please sign in to comment.