END_LEN = 4 AES_SET_MSG = 'AES Key Set' class CommunicationLink(object): def __init__(self, comm): pass def send(self, msg): pass def process(self, data): pass def recieve(self): pass auth_msg_check = create_existance_check_dec('auth_msg') pub_key_check = create_existance_check_dec('pub_key') pri_key_check = create_existance_check_dec('pri_key') aes_key_check = create_existance_check_dec('aes_key') partner_secret_hash_check = create_existance_check_dec('partner_secret_hash') authenticated_exist_check = create_existance_check_dec('authenticated') authenticated_true_check = create_value_check_dec('authenticated', True) key_agreement_true_check = create_value_check_dec('key_agreement', True) class PillowTalkLink(CommunicationLink): def __init__(self, comm, keyfile): self.comm = comm self.keyfile = keyfile if keyfile.has_key('user'): if keyfile['user'].has_key('secret'): self.secret = qcrypt.denormalize(keyfile['user']['secret']) else: self.secret = None if keyfile['user'].has_key('salt'): self.salt = keyfile['user']['salt'] else: self.salt = None else: if keyfile.has_key('secret'): self.secret = qcrypt.denormalize( keyfile['secret'])
def __init__(self): def defualt_proc(data): pass self.proc_syscommand = defualt_proc self.proc_command = defualt_proc def connect(self): pass def send(self, msg): pass def recieve(self): pass def listen(self): pass def accept(self): pass def close(self): pass def set_proc_syscommand(self, proc_func): self.proc_syscommand = proc_func def set_proc_command(self, proc_func): self.proc_command = proc_func closed_false_check = create_value_check_dec('closed', False) connected_true_check = create_value_check_dec('connected', True) connected_false_check = create_value_check_dec('connected', False) listening_true_check = create_value_check_dec('listening', True) listening_false_check = create_value_check_dec('listening', False) class SocketGeneric(CommGenericBase): END_MARK = '<<STOP>>' END_LEN = 8 def __init__(self, host, port, bufsize=1024): super(SocketGeneric, self).__init__() self.sock = None self.HOST = host self.PORT = port