Пример #1
0
from cryptography.hazmat.primitives.asymmetric import padding as signature_padder
import chat_library as util
import ast
import traceback
import select 
import Queue
import random 
from socket import error as socket_err


SERVER_CONFIG = 'server_config.txt'
progress = {}
shared_key = 0
SERVER_KEY = 'server_public_key.pem'
#PUBLIC_KEY = util.get_public_key('server_public_key.pem')
CLIENT_PRIVATE_KEY = util.get_private_key('client_private_key.pem')
CLIENT_PRIVATE_KEY_STR = util.get_public_key_string('client_private_key.pem')
CLIENT_PUBLIC_KEY_STR = util.get_public_key_string('client_public_key.pem')
NONCE_SENT = 0
IV = os.urandom(16)
GENERATED_IV = IV
USERNAME_TO_PORT = {}
EXIT_IN_ERROR = False
ACTION_NONCE = 0
CHAT_NONCE = 0
g = 5 #627
p = 23 #941
a = 0
df_keys = {}
message_tracker = {}
IV_tracker = {}
Пример #2
0
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
import os 
from cryptography import exceptions
from cryptography.hazmat.primitives import padding as plain_text_padder
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding as signature_padder

logger = logging.getLogger('ChatServer')
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.INFO)
client_store = {}
client_progress = {}
SERVER_PRIVATE_KEY = 'server_private_key.pem'
private_key = util.get_private_key(SERVER_PRIVATE_KEY)
logged_users = {}
action_progress = {}

'''
TODO:
  add key check if the key is legit - sign iv and key 
  password file to be encrypted with salt 
  add check if client wants to chat with unknown user (not registered)
  check if user online while chat 
'''

def parse_data(data):
  values = data.split(":")
  username = values[0].strip()
  A = values[1].strip()